Skip to content

Commit

Permalink
Basis for space admin screen.
Browse files Browse the repository at this point in the history
- Not sure why the space admin doesn't display inside the space admin section.
  I have opened this question: https://answers.atlassian.com/questions/67965/how-do-i-render-an-xwork-action-inside-a-space-admin-page
  • Loading branch information
brettryan committed Jul 9, 2012
1 parent 5542534 commit 0e1d1ac
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}

}
Original file line number Diff line number Diff line change
@@ -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());
}

}
24 changes: 22 additions & 2 deletions src/main/resources/atlassian-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<param name="configure.url">/admin/plugins/attachment-tools/configure.action</param>
</plugin-info>

<web-item key="configure-purge-attachments-space"
name="Configure Purge Attachments (Space)"
section="system.space.admin/spaceops"
weight="40">
<label key="Attachment Purging" />
<link>/spaces/configure-purge-attachments-space.action?key=$helper.space.key</link>
<condition class="com.drunkendev.confluence.plugins.attachments.ConfigurePurgeAttachmentsSpaceCondition"/>
</web-item>

<resource type="i18n" name="i18n" location="i18n" />

<job key="purge-old-attachments-job"
Expand All @@ -30,8 +39,8 @@
canDisable="true" />
</trigger>

<xwork key="configure-purge-attachments"
name="Configure Purge Attachments">
<xwork key="configure-purge-attachments" name="Configure Purge Attachments">

<package name="purge-attachments"
extends="default"
namespace="/admin/plugins/attachment-tools">
Expand All @@ -44,6 +53,17 @@
<result name="success" type="velocity">/templates/purge-attachments/config/configure-purge-attachments.vm</result>
</action>
</package>

<package name="purge-attachments-space"
extends="default"
namespace="/spaces">
<default-interceptor-ref name="validatingStack" />
<action name="configure-purge-attachments-space"
class="com.drunkendev.confluence.plugins.attachments.ConfigurePurgeAttachmentsSpaceAction">
<result name="success" type="velocity">/templates/purge-attachments/config/configure-purge-attachments-space.vm</result>
</action>
</package>

</xwork>

</atlassian-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>

<html>
<head>
<title>$action.getText("com.drunkendev.confluence.plugins.attachment-tools.config.title")</title>
</head>
<body>
<p>
<strong>TODO</strong>: Implement configuration for handling space
settings. Settigns may include but are not limited to:
</p>
<ul>
<li>
<strong>Process by age</strong>: Prior attachment versions may only be
kept if the attachment's modified date is within a given period.
</li>
<li>
<strong>Process by limits</strong>: Allows specifying a maximum count
of prior versions for each attachment.
</li>
<li>
<strong>Process by total size limit</strong>: 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.
</li>
<li>
<strong>Report only</strong>: Do not perform any action, just use the
email alerting function which must be present.
</li>
<li>
<strong>Email alerting</strong>: Email results to a given email address
or user.
</li>
</ul>
</body>
</html>

0 comments on commit 0e1d1ac

Please sign in to comment.