Clearspace API (1.10.16) Core Javadocs

com.jivesoftware.community
Class Permissions

java.lang.Object
  extended by com.jivesoftware.community.Permissions
All Implemented Interfaces:
com.jivesoftware.community.cache.Cacheable, java.io.Serializable

public class Permissions
extends java.lang.Object
implements com.jivesoftware.community.cache.Cacheable

Represents a set of permissions that an entity has for an object in the system. For example, the rights that a user has for a community. Permissions are used by the protection proxy objects defined for each major component of the system to provide access rights.

A Permissions object is internally represented as a long with each bit indicating whether a particular permission is set. The constants defined by extensions of this class define the bit masks that can be used for permission operations. For example, the following code creates permissions:


 // Create a permissions object with only read permissions set to true.
 Permissions perms1 = new Permissions(Permissions.VIEW_COMMUNITY);
 // Create a permissions object with read and system admin permissions set to true.
 Permissions perms2 = new Permissions(Permissions.VIEW_COMMUNITY |
          Permissions.SYSTEM_ADMIN);
If we were to view the bits of each variable, perms1 would be 0000000000000000000000000000000000000000000000000000000000000001 and perms2 would be 0000000000000000000000000000000010000000000000000000000000000001.

See Also:
Serialized Form

Field Summary
static long COMMUNITY_ADMIN
          Permission to administer a community.
static long CREATE_ANNOUNCEMENT
          Permission to create, delete, and schedule announcements.
static long CREATE_BLOG
          Permission to create a blog.
static long CREATE_COMMENT
          Permission to create a comment
static long CREATE_DOC_ATTACHMENT
          Permission to create an attachment
static long CREATE_DOCUMENT
          Permission to create a document
static long CREATE_IMAGE
          Permission to create an image
static long CREATE_MESSAGE
          Permission to create a new message.
static long CREATE_MESSAGE_ATTACHMENT
          Permission to create attachments.
static long CREATE_POLL
          Permission to create polls.
static long CREATE_PRIVATE_MESSAGE_ATTACHMENT
          Permission to create attachments in a private message.
static long CREATE_THREAD
          Permission to create a new thread.
static long EDIT_AVATAR
          Permission to create and delete avatars
static long GROUP_ADMIN
          Permission to administer a particular group.
static long HOSTED_ADMIN
          Permission to perform hosted operations
static long MODERATOR
          Permission to moderate content.
static long NONE
          No permissions.
static long PRIVATE_MESSAGE
          Permission to get and send private messages.
static long RATE_DOCUMENT
          Permission to rate documents in a community
static long RATE_MESSAGE
          Permission to rate messages.
static long READ_BLOG
          Permission to read blog a blog.
static long READ_COMMENT
          Permission to read a comment
static long READ_DOCUMENT
          Permission to read a document
static long SYSTEM_ADMIN
          Permission to administer the entire sytem.
static long USER_ADMIN
          Permission to administer a particular user.
static long VIEW_COMMUNITY
          Permission to read object.
static long VIEW_ONLINE_STATUS
          Permission to see the online status of a particular user.
static long VOTE_IN_POLL
          Permission to vote in polls.
 
Constructor Summary
Permissions(long permissions)
          Create a new permissions object with the specified permissions.
Permissions(Permissions permissions1, Permissions permissions2)
          Creates a new Permission object by combining two permissions objects.
 
Method Summary
 int getCachedSize()
           
 boolean hasPermission(long permissionTypes)
          Returns true if one or more of the permission types is set to true.
 void set(long permissionTypes, boolean value)
          Sets the permissions given by a bit mask to true or false.
 java.lang.String toString()
           
 long value()
          Returns the long value (bitmask) of the permissions that are set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final long NONE
No permissions.

See Also:
Constant Field Values

VIEW_ONLINE_STATUS

public static final long VIEW_ONLINE_STATUS
Permission to see the online status of a particular user.

See Also:
Constant Field Values

USER_ADMIN

public static final long USER_ADMIN
Permission to administer a particular user. Used for LDAP

See Also:
Constant Field Values

GROUP_ADMIN

public static final long GROUP_ADMIN
Permission to administer a particular group. Usec for LDAP

See Also:
Constant Field Values

SYSTEM_ADMIN

public static final long SYSTEM_ADMIN
Permission to administer the entire sytem.

See Also:
Constant Field Values

HOSTED_ADMIN

public static final long HOSTED_ADMIN
Permission to perform hosted operations

See Also:
Constant Field Values

READ_DOCUMENT

public static final long READ_DOCUMENT
Permission to read a document

See Also:
Constant Field Values

READ_COMMENT

public static final long READ_COMMENT
Permission to read a comment

See Also:
Constant Field Values

CREATE_DOCUMENT

public static final long CREATE_DOCUMENT
Permission to create a document

See Also:
Constant Field Values

CREATE_COMMENT

public static final long CREATE_COMMENT
Permission to create a comment

See Also:
Constant Field Values

CREATE_DOC_ATTACHMENT

public static final long CREATE_DOC_ATTACHMENT
Permission to create an attachment

See Also:
Constant Field Values

RATE_DOCUMENT

public static final long RATE_DOCUMENT
Permission to rate documents in a community

See Also:
Constant Field Values

CREATE_IMAGE

public static final long CREATE_IMAGE
Permission to create an image

See Also:
Constant Field Values

VIEW_COMMUNITY

public static final long VIEW_COMMUNITY
Permission to read object.

See Also:
Constant Field Values

CREATE_MESSAGE

public static final long CREATE_MESSAGE
Permission to create a new message.

See Also:
Constant Field Values

CREATE_THREAD

public static final long CREATE_THREAD
Permission to create a new thread.

See Also:
Constant Field Values

CREATE_MESSAGE_ATTACHMENT

public static final long CREATE_MESSAGE_ATTACHMENT
Permission to create attachments.

See Also:
Constant Field Values

CREATE_POLL

public static final long CREATE_POLL
Permission to create polls.

See Also:
Constant Field Values

PRIVATE_MESSAGE

public static final long PRIVATE_MESSAGE
Permission to get and send private messages.

See Also:
Constant Field Values

RATE_MESSAGE

public static final long RATE_MESSAGE
Permission to rate messages.

See Also:
Constant Field Values

MODERATOR

public static final long MODERATOR
Permission to moderate content.

See Also:
Constant Field Values

COMMUNITY_ADMIN

public static final long COMMUNITY_ADMIN
Permission to administer a community.

See Also:
Constant Field Values

VOTE_IN_POLL

public static final long VOTE_IN_POLL
Permission to vote in polls.

See Also:
Constant Field Values

CREATE_PRIVATE_MESSAGE_ATTACHMENT

public static final long CREATE_PRIVATE_MESSAGE_ATTACHMENT
Permission to create attachments in a private message.

See Also:
Constant Field Values

CREATE_ANNOUNCEMENT

public static final long CREATE_ANNOUNCEMENT
Permission to create, delete, and schedule announcements.

See Also:
Constant Field Values

EDIT_AVATAR

public static final long EDIT_AVATAR
Permission to create and delete avatars

See Also:
Constant Field Values

READ_BLOG

public static final long READ_BLOG
Permission to read blog a blog.

See Also:
Constant Field Values

CREATE_BLOG

public static final long CREATE_BLOG
Permission to create a blog.

See Also:
Constant Field Values
Constructor Detail

Permissions

public Permissions(long permissions)
Create a new permissions object with the specified permissions.

Parameters:
permissions - integer bitmask values to for the new Permissions.

Permissions

public Permissions(Permissions permissions1,
                   Permissions permissions2)
Creates a new Permission object by combining two permissions objects. The higher permission of each permission type will be used.

Parameters:
permissions1 - the first permissions to use when creating the new Permissions.
permissions2 - the second permissions to use when creating the new Permissions.
Method Detail

hasPermission

public boolean hasPermission(long permissionTypes)
Returns true if one or more of the permission types is set to true.

Parameters:
permissionTypes -
Returns:
true if one or more of the permission types is set to true, false otherwise.

set

public void set(long permissionTypes,
                boolean value)
Sets the permissions given by a bit mask to true or false. For example, the following would set the VIEW_COMMUNITY and SYSTEM_ADMIN permissions to true:
 permissions.set(Permissions.VIEW_COMMUNITY | Permissions.SYSTEM_ADMIN, true);
 

Parameters:
permissionTypes - the permission types to set.
value - true to enable the permission, false to disable.

value

public long value()
Returns the long value (bitmask) of the permissions that are set.

Returns:
the long value of the object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getCachedSize

public int getCachedSize()
Specified by:
getCachedSize in interface com.jivesoftware.community.cache.Cacheable

Clearspace Project Page

Copyright © 1999-2007 Jive Software.