diff --git a/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceAction.java b/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceAction.java new file mode 100644 index 0000000..6340548 --- /dev/null +++ b/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceAction.java @@ -0,0 +1,48 @@ +/* + * ConfigurePurgeAttachmentsSpaceAction.java Jul 10 2012, 02:49 + * + * Copyright 2012 Drunken Dev. All rights reserved. + * Use is subject to license terms. + */ + +package com.drunkendev.confluence.plugins.attachments; + +import com.atlassian.confluence.security.Permission; +import com.atlassian.confluence.spaces.actions.AbstractSpaceAction; +import com.atlassian.confluence.spaces.actions.SpaceAware; + + +/** + * Action to configure space attachment purging. + * + * @author Brett Ryan + */ +public class ConfigurePurgeAttachmentsSpaceAction + extends AbstractSpaceAction implements SpaceAware { + + /** + * Creates a new {@code ConfigurePurgeAttachmentsSpaceAction} instance. + */ + public ConfigurePurgeAttachmentsSpaceAction() { + } + + @Override + public boolean isSpaceRequired() { + return true; + } + + @Override + public boolean isViewPermissionRequired() { + return true; + } + + @Override + public boolean isPermitted() { + return getRemoteUser() != null + && getSpace() != null + && permissionManager.hasPermission(getRemoteUser(), + Permission.ADMINISTER, + getSpace()); + } + +} diff --git a/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceCondition.java b/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceCondition.java new file mode 100644 index 0000000..582e187 --- /dev/null +++ b/src/main/java/com/drunkendev/confluence/plugins/attachments/ConfigurePurgeAttachmentsSpaceCondition.java @@ -0,0 +1,44 @@ +/* + * ConfigurePurgeAttachmentsSpaceCondition.java Jul 10 2012, 02:27 + * + * Copyright 2012 Drunken Dev. All rights reserved. + * Use is subject to license terms. + */ + +package com.drunkendev.confluence.plugins.attachments; + +import com.atlassian.confluence.plugin.descriptor.web.WebInterfaceContext; +import com.atlassian.confluence.plugin.descriptor.web.conditions.BaseConfluenceCondition; +import com.atlassian.confluence.security.Permission; +import com.atlassian.confluence.security.PermissionManager; + + +/** + * Condition to show the purging options against a space. + * + * @author Brett Ryan + */ +public class ConfigurePurgeAttachmentsSpaceCondition extends BaseConfluenceCondition { + + private PermissionManager permissionManager; + + /** + * Creates a new {@code ConfigurePurgeAttachmentsSpaceCondition} instance. + */ + public ConfigurePurgeAttachmentsSpaceCondition() { + } + + public void setPermissionManager(PermissionManager permissionManager) { + this.permissionManager = permissionManager; + } + + @Override + protected boolean shouldDisplay(WebInterfaceContext wic) { + return wic.getUser() != null + && wic.getSpace() != null + && permissionManager.hasPermission(wic.getUser(), + Permission.ADMINISTER, + wic.getSpace()); + } + +} diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index c24462e..9e38d96 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -12,6 +12,15 @@ /admin/plugins/attachment-tools/configure.action + + + - + + @@ -44,6 +53,17 @@ /templates/purge-attachments/config/configure-purge-attachments.vm + + + + + /templates/purge-attachments/config/configure-purge-attachments-space.vm + + + diff --git a/src/main/resources/templates/purge-attachments/config/configure-purge-attachments-space.vm b/src/main/resources/templates/purge-attachments/config/configure-purge-attachments-space.vm new file mode 100644 index 0000000..99b63f9 --- /dev/null +++ b/src/main/resources/templates/purge-attachments/config/configure-purge-attachments-space.vm @@ -0,0 +1,36 @@ + + + + + $action.getText("com.drunkendev.confluence.plugins.attachment-tools.config.title") + + +

+ TODO: Implement configuration for handling space + settings. Settigns may include but are not limited to: +

+
    +
  • + Process by age: Prior attachment versions may only be + kept if the attachment's modified date is within a given period. +
  • +
  • + Process by limits: Allows specifying a maximum count + of prior versions for each attachment. +
  • +
  • + Process by total size limit: Allow all versions of an + attachment to not exceede a given size limit. If the size limit is + imposed then prior versions are deleted until the limit is satisfied. +
  • +
  • + Report only: Do not perform any action, just use the + email alerting function which must be present. +
  • +
  • + Email alerting: Email results to a given email address + or user. +
  • +
+ +