com.atlassian.confluence.security
Class SpacePermission

java.lang.Object
  extended bycom.atlassian.core.bean.EntityObject
      extended bycom.atlassian.confluence.core.ConfluenceEntityObject
          extended bycom.atlassian.confluence.security.SpacePermission
All Implemented Interfaces:
Cloneable, Serializable

public class SpacePermission
extends ConfluenceEntityObject
implements Serializable

A SpacePermission restricts access to different functions on a space. A a SpacePermission is defined for a permissionType then that permissionType is not permitted, otherwise if it's not it's permitted.

Version:
$Revision: 1.41 $
Author:
$Author: sleberrigaud $
See Also:
Serialized Form

Field Summary
static String ADMINISTER_CONFLUENCE_PERMISSION
           
static String ADMINISTER_SPACE_PERMISSION
           
static String COMMENT_PERMISSION
           
static String CREATE_ATTACHMENT_PERMISSION
           
static String CREATE_SPACE_PERMISSION
           
static String CREATEEDIT_PAGE_PERMISSION
           
static String EDITBLOG_PERMISSION
           
static String EXPORT_PAGE_PERMISSION
           
static String EXPORT_SPACE_PERMISSION
           
static String FORM_PARAMETER_PREFIX
           
static String FORM_PARAMETER_SEPARATOR
           
static String FULL_FORM_PARAMETER_PREFIX
           
static Collection GENERIC_SPACE_PERMISSIONS
          represents all permissions which can be used to build SpacePermissions.
static Collection GLOBAL_PERMISSIONS
          A list of all global permissions
static Collection INVALID_ANONYMOUS_PERMISSIONS
          A list of all permissions that can not be assigned to the anonymous user
static Collection PERMISSION_TYPES
          A list of all possible permissions
static String PERSONAL_SPACE_PERMISSION
           
static String PROFILE_ATTACHMENT_PERMISSION
           
static String REMOVE_ATTACHMENT_PERMISSION
           
static String REMOVE_BLOG_PERMISSION
           
static String REMOVE_COMMENT_PERMISSION
           
static String REMOVE_MAIL_PERMISSION
           
static String REMOVE_PAGE_PERMISSION
           
static String SET_PAGE_PERMISSIONS_PERMISSION
           
static String USE_CONFLUENCE_PERMISSION
           
static String VIEWSPACE_PERMISSION
           
 
Constructor Summary
SpacePermission()
           
SpacePermission(String type)
           
SpacePermission(String type, Space space)
           
SpacePermission(String type, Space space, String group)
           
SpacePermission(String type, Space space, String group, String userName)
           
 
Method Summary
 boolean equals(Object obj)
           
static SpacePermission fromFormParameterName(String formParameterName, Space space)
          Convert a form parameter name into a space permission.
static Collection getGenericSpacePermissions()
           
 String getGroup()
           
 Space getSpace()
          The space of this permission.
 long getSpaceId()
           
 String getType()
           
 String getUserName()
           
 int hashCode()
           
 boolean isAdministrativePermission()
          Is this an administrative permission either globally or at a space level?
 boolean isAnonymousPermission()
           
 boolean isDependentOn(SpacePermission otherPermission)
          One permission is dependent on another if the other permission is a guard permission that applies to the same space/global scope, and to the same group or user as this permission.
 boolean isGlobalPermission()
           
 boolean isGroupPermission()
           
 boolean isGuardPermission()
          Is this a guard permission, either globally or at the space level? Guard permissions are required before any more permissions can be added for a particular user/group in a particular scope.
 boolean isInvalidAnonymousPermission()
          Some permissions are not valid as they can not be assigned to the anonymous user.
 boolean isSpacePermission()
           
 boolean isUserPermission()
           
 void setGroup(String group)
           
 void setSpace(Space space)
           
 void setType(String type)
           
 void setUserName(String userName)
           
 String toFormParameterName()
          Convert the space permission into a form parameter name that can be used for form checkboxes.
 String toString()
           
 
Methods inherited from class com.atlassian.confluence.core.ConfluenceEntityObject
getCreatorName, getLastModifierName, isPersistent, setCreatorName, setLastModifierName
 
Methods inherited from class com.atlassian.core.bean.EntityObject
clone, getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FORM_PARAMETER_PREFIX

public static final String FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

FORM_PARAMETER_SEPARATOR

public static final String FORM_PARAMETER_SEPARATOR
See Also:
Constant Field Values

FULL_FORM_PARAMETER_PREFIX

public static final String FULL_FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

USE_CONFLUENCE_PERMISSION

public static final String USE_CONFLUENCE_PERMISSION
See Also:
Constant Field Values

ADMINISTER_CONFLUENCE_PERMISSION

public static final String ADMINISTER_CONFLUENCE_PERMISSION
See Also:
Constant Field Values

PERSONAL_SPACE_PERMISSION

public static final String PERSONAL_SPACE_PERMISSION
See Also:
Constant Field Values

CREATE_SPACE_PERMISSION

public static final String CREATE_SPACE_PERMISSION
See Also:
Constant Field Values

PROFILE_ATTACHMENT_PERMISSION

public static final String PROFILE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

VIEWSPACE_PERMISSION

public static final String VIEWSPACE_PERMISSION
See Also:
Constant Field Values

COMMENT_PERMISSION

public static final String COMMENT_PERMISSION
See Also:
Constant Field Values

CREATEEDIT_PAGE_PERMISSION

public static final String CREATEEDIT_PAGE_PERMISSION
See Also:
Constant Field Values

ADMINISTER_SPACE_PERMISSION

public static final String ADMINISTER_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_PAGE_PERMISSION

public static final String REMOVE_PAGE_PERMISSION
See Also:
Constant Field Values

REMOVE_COMMENT_PERMISSION

public static final String REMOVE_COMMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_BLOG_PERMISSION

public static final String REMOVE_BLOG_PERMISSION
See Also:
Constant Field Values

CREATE_ATTACHMENT_PERMISSION

public static final String CREATE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_ATTACHMENT_PERMISSION

public static final String REMOVE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

EDITBLOG_PERMISSION

public static final String EDITBLOG_PERMISSION
See Also:
Constant Field Values

EXPORT_PAGE_PERMISSION

public static final String EXPORT_PAGE_PERMISSION
See Also:
Constant Field Values

EXPORT_SPACE_PERMISSION

public static final String EXPORT_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_MAIL_PERMISSION

public static final String REMOVE_MAIL_PERMISSION
See Also:
Constant Field Values

SET_PAGE_PERMISSIONS_PERMISSION

public static final String SET_PAGE_PERMISSIONS_PERMISSION
See Also:
Constant Field Values

PERMISSION_TYPES

public static final Collection PERMISSION_TYPES
A list of all possible permissions


GENERIC_SPACE_PERMISSIONS

public static final Collection GENERIC_SPACE_PERMISSIONS
represents all permissions which can be used to build SpacePermissions.


GLOBAL_PERMISSIONS

public static final Collection GLOBAL_PERMISSIONS
A list of all global permissions


INVALID_ANONYMOUS_PERMISSIONS

public static final Collection INVALID_ANONYMOUS_PERMISSIONS
A list of all permissions that can not be assigned to the anonymous user

Constructor Detail

SpacePermission

public SpacePermission()

SpacePermission

public SpacePermission(String type)

SpacePermission

public SpacePermission(String type,
                       Space space)

SpacePermission

public SpacePermission(String type,
                       Space space,
                       String group)

SpacePermission

public SpacePermission(String type,
                       Space space,
                       String group,
                       String userName)
Method Detail

fromFormParameterName

public static SpacePermission fromFormParameterName(String formParameterName,
                                                    Space space)
                                             throws ParseException
Convert a form parameter name into a space permission. The form parameter name should have been generated from toFormParameterName().

Parameters:
formParameterName - the form parameter name to convert to a space permission
space - the space the permission applies to, or null if it is a global permission
Returns:
the relevant SpacePermission
Throws:
ParseException - if the form parameter name can not be converted to a permission type

getSpace

public Space getSpace()
The space of this permission.


setSpace

public void setSpace(Space space)

getSpaceId

public long getSpaceId()

getType

public String getType()

setType

public void setType(String type)

getGroup

public String getGroup()

setGroup

public void setGroup(String group)

getUserName

public String getUserName()

setUserName

public void setUserName(String userName)

isUserPermission

public boolean isUserPermission()

isGroupPermission

public boolean isGroupPermission()

isAnonymousPermission

public boolean isAnonymousPermission()

isGlobalPermission

public boolean isGlobalPermission()

isSpacePermission

public boolean isSpacePermission()

toString

public String toString()

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

getGenericSpacePermissions

public static Collection getGenericSpacePermissions()

toFormParameterName

public String toFormParameterName()
Convert the space permission into a form parameter name that can be used for form checkboxes. The reverse of this method is fromFormParameterName(java.lang.String, com.atlassian.confluence.spaces.Space) The format of the parameter name is:

confluence_[permissionType]_[user/group/anonymous]_[user/group name]

Note: the space is NOT encoded in the form parameter name, and must be kept separately.

Returns:
the space permission as a form parameter.

isAdministrativePermission

public boolean isAdministrativePermission()
Is this an administrative permission either globally or at a space level?

Returns:
true if this is a global or space administrative permission, false otherwise

isGuardPermission

public boolean isGuardPermission()
Is this a guard permission, either globally or at the space level? Guard permissions are required before any more permissions can be added for a particular user/group in a particular scope. Globally, USE_CONFLUENCE is a guard permission, at the space level, VIEWSPACE is theguard.

Returns:
true if this is a guard permission, false otherwise.

isDependentOn

public boolean isDependentOn(SpacePermission otherPermission)
One permission is dependent on another if the other permission is a guard permission that applies to the same space/global scope, and to the same group or user as this permission. It is used when determining which permissions should be removed as the result of removing a guard permission.

Parameters:
otherPermission -
Returns:
true if this permission is dependent on otherPermission, false otherwise.

isInvalidAnonymousPermission

public boolean isInvalidAnonymousPermission()
Some permissions are not valid as they can not be assigned to the anonymous user. Really, we should just refuse to create such permissions from the outset, but for now we've just got this check.

Returns:
true if this permission is invalid due to being anonymous, and of a type not available to anonymous users


Confluence is developed by Atlassian.