com.dotmarketing.business
Class PermissionAPIImpl

java.lang.Object
  extended by com.dotmarketing.business.PermissionAPIImpl
All Implemented Interfaces:
GenericAPI<Permission>, PermissionAPI<Inode>

public class PermissionAPIImpl
extends java.lang.Object
implements PermissionAPI<Inode>

PermissionAPI is an API intended to be a helper class for class to get Permissions. Classes within the dotCMS should use this API for permissions. The PermissionAPI will goto the PermissionCache for you so you can use the PermissionAPI trusting that you will not be continually hitting the database.

Author:
Jason Tesser, Carlos Rivas

Field Summary
 
Fields inherited from interface com.dotmarketing.business.PermissionAPI
PERMISSION_CAN_ADD_CHILDREN, PERMISSION_EDIT, PERMISSION_PUBLISH, PERMISSION_READ, PERMISSION_USE, PERMISSION_WRITE
 
Constructor Summary
PermissionAPIImpl()
           
PermissionAPIImpl(PermissionFactory serviceRef)
          Builds a PermissionAPI initialized with its dependent objects.
 
Method Summary
 void clearCache()
          This method is to clear the permissions cache.
 void copyPermissions(Permissionable from, Permissionable to)
          copies permissions from one permissionable to another
 void delete(Permission permission)
           
 boolean doesRoleHavePermission(Permissionable permissionable, int permissionKey, com.liferay.portal.model.Role role, boolean respectFrontendRoles)
          Return true if the role has permission over the permissionable the specified permission
 boolean doesUserHavePermission(Permissionable permissionable, int permissionKey, com.liferay.portal.model.User user)
          Return true if the user have over the permissionable the specified permission This method is meant to be used by frontend call because assumes that frontend roles should respected
 boolean doesUserHavePermission(Permissionable permissionable, int permissionKey, com.liferay.portal.model.User user, boolean respectFrontendRoles)
          Return true if the user have over the permissionable the specified permission
 boolean doesUserOwn(Inode inode, com.liferay.portal.model.User user)
           
<P extends Permissionable>
java.util.List<P>
filterCollection(java.util.List<P> permissionables, int requiredPermission, boolean respectFrontendRoles, com.liferay.portal.model.User user)
           
 Permission find(long id)
          This method uses the permission cache to return a permission.
 java.util.List<Permission> findAll()
          Deprecated.  
 PermissionFactory getPermissionFactory()
          Gets the Permission Factory service reference used in this API .
 java.util.List<java.lang.String> getPermissionIdsFromRoles(Inode inode, com.liferay.portal.model.Role[] roles, com.liferay.portal.model.User user)
          This method should not be used anymore!!! It is left here until some of the other factories get refactored.
 java.util.List<Permission> getPermissions(Permissionable permissionable)
          Return a list of the permission associated
 java.util.Set<com.liferay.portal.model.Role> getPublishRoles(Permissionable permissionable)
           
 java.util.Set<com.liferay.portal.model.User> getPublishUsers(Permissionable permissionable)
          Returns all users who have write permissions on an permissionable
 java.util.Set<com.liferay.portal.model.Role> getReadRoles(Permissionable permissionable)
          Returns a set of role names whose has read access over a specific asset.
 java.util.Set<com.liferay.portal.model.User> getReadUsers(Permissionable permissionable)
          Returns all users who have write permissions on an permissionable
 int getRoleCount(long inode, int permissionType, java.lang.String filter)
           
 java.util.List<com.liferay.portal.model.Role> getRoles(long inode, int permissionType, java.lang.String filter, int start, int limit)
           
 int getUserCount(long inode, int permissionType, java.lang.String filter)
           
 java.util.List<com.liferay.portal.model.User> getUsers(long inode, int permissionType, java.lang.String filter, int start, int limit)
           
 java.util.Set<com.liferay.portal.model.Role> getWriteRoles(Permissionable permissionable)
           
 java.util.Set<com.liferay.portal.model.User> getWriteUsers(Permissionable permissionable)
          Returns all users who have write permissions on an permissionable
 void mapAllPermissions()
          Get a map of all the permission that live page have
 void removePermissions(Permissionable permissionable)
          Remove all the permissions
 void save(Permission permission)
           
 void setDefaultCMSAdminPermissions(Permissionable permissionable)
          Set the to the CMS_ADMINISTRATOR_ROLE permission over the permissionable
 void setPermissionFactory(PermissionFactory permissionFactory)
          Sets a Permission Factory for this API
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionAPIImpl

public PermissionAPIImpl()

PermissionAPIImpl

public PermissionAPIImpl(PermissionFactory serviceRef)
Builds a PermissionAPI initialized with its dependent objects.

Method Detail

getPermissionFactory

public PermissionFactory getPermissionFactory()
Gets the Permission Factory service reference used in this API .

Returns:
PermissionFactory service reference

setPermissionFactory

public void setPermissionFactory(PermissionFactory permissionFactory)
Sets a Permission Factory for this API

Parameters:
PermissionFactory - service reference

doesUserHavePermission

public boolean doesUserHavePermission(Permissionable permissionable,
                                      int permissionKey,
                                      com.liferay.portal.model.User user)
Description copied from interface: PermissionAPI
Return true if the user have over the permissionable the specified permission This method is meant to be used by frontend call because assumes that frontend roles should respected

Specified by:
doesUserHavePermission in interface PermissionAPI<Inode>
Returns:
boolean

doesRoleHavePermission

public boolean doesRoleHavePermission(Permissionable permissionable,
                                      int permissionKey,
                                      com.liferay.portal.model.Role role,
                                      boolean respectFrontendRoles)
Description copied from interface: PermissionAPI
Return true if the role has permission over the permissionable the specified permission

Specified by:
doesRoleHavePermission in interface PermissionAPI<Inode>
Returns:

doesUserHavePermission

public boolean doesUserHavePermission(Permissionable permissionable,
                                      int permissionKey,
                                      com.liferay.portal.model.User user,
                                      boolean respectFrontendRoles)
Description copied from interface: PermissionAPI
Return true if the user have over the permissionable the specified permission

Specified by:
doesUserHavePermission in interface PermissionAPI<Inode>
Returns:
boolean

removePermissions

public void removePermissions(Permissionable permissionable)
Description copied from interface: PermissionAPI
Remove all the permissions

Specified by:
removePermissions in interface PermissionAPI<Inode>

setDefaultCMSAdminPermissions

public void setDefaultCMSAdminPermissions(Permissionable permissionable)
Description copied from interface: PermissionAPI
Set the to the CMS_ADMINISTRATOR_ROLE permission over the permissionable

Specified by:
setDefaultCMSAdminPermissions in interface PermissionAPI<Inode>

copyPermissions

public void copyPermissions(Permissionable from,
                            Permissionable to)
Description copied from interface: PermissionAPI
copies permissions from one permissionable to another

Specified by:
copyPermissions in interface PermissionAPI<Inode>
Parameters:
from - permissionable
to - permissionable

find

public Permission find(long id)
This method uses the permission cache to return a permission.

Specified by:
find in interface GenericAPI<Permission>
Parameters:
id - of permission to find
Returns:
Permission

getPermissions

public java.util.List<Permission> getPermissions(Permissionable permissionable)
Description copied from interface: PermissionAPI
Return a list of the permission associated

Specified by:
getPermissions in interface PermissionAPI<Inode>
Returns:
List

delete

public void delete(Permission permission)
Specified by:
delete in interface GenericAPI<Permission>

findAll

public java.util.List<Permission> findAll()
Deprecated. 

This method is not implemented yet

Specified by:
findAll in interface GenericAPI<Permission>

save

public void save(Permission permission)
Specified by:
save in interface GenericAPI<Permission>
Parameters:
Permission - to save Saves passed in permission

getReadRoles

public java.util.Set<com.liferay.portal.model.Role> getReadRoles(Permissionable permissionable)
Description copied from interface: PermissionAPI
Returns a set of role names whose has read access over a specific asset. This method returns a set of string.

Specified by:
getReadRoles in interface PermissionAPI<Inode>
Returns:
set of role names

getPublishRoles

public java.util.Set<com.liferay.portal.model.Role> getPublishRoles(Permissionable permissionable)
Specified by:
getPublishRoles in interface PermissionAPI<Inode>

getWriteRoles

public java.util.Set<com.liferay.portal.model.Role> getWriteRoles(Permissionable permissionable)
Specified by:
getWriteRoles in interface PermissionAPI<Inode>

getWriteUsers

public java.util.Set<com.liferay.portal.model.User> getWriteUsers(Permissionable permissionable)
Description copied from interface: PermissionAPI
Returns all users who have write permissions on an permissionable

Specified by:
getWriteUsers in interface PermissionAPI<Inode>
Parameters:
permissionable - to look for
Returns:

getReadUsers

public java.util.Set<com.liferay.portal.model.User> getReadUsers(Permissionable permissionable)
Description copied from interface: PermissionAPI
Returns all users who have write permissions on an permissionable

Specified by:
getReadUsers in interface PermissionAPI<Inode>
Parameters:
permissionable - to look for
Returns:

getPublishUsers

public java.util.Set<com.liferay.portal.model.User> getPublishUsers(Permissionable permissionable)
Description copied from interface: PermissionAPI
Returns all users who have write permissions on an permissionable

Specified by:
getPublishUsers in interface PermissionAPI<Inode>
Parameters:
permissionable - to look for
Returns:

doesUserOwn

public boolean doesUserOwn(Inode inode,
                           com.liferay.portal.model.User user)
                    throws DotDataException
Specified by:
doesUserOwn in interface PermissionAPI<Inode>
Throws:
DotDataException

mapAllPermissions

public void mapAllPermissions()
Description copied from interface: PermissionAPI
Get a map of all the permission that live page have

Specified by:
mapAllPermissions in interface PermissionAPI<Inode>

getPermissionIdsFromRoles

public java.util.List<java.lang.String> getPermissionIdsFromRoles(Inode inode,
                                                                  com.liferay.portal.model.Role[] roles,
                                                                  com.liferay.portal.model.User user)
                                                           throws DotDataException
Description copied from interface: PermissionAPI
This method should not be used anymore!!! It is left here until some of the other factories get refactored.

Specified by:
getPermissionIdsFromRoles in interface PermissionAPI<Inode>
Returns:
List of PermissionIds
Throws:
DotDataException

getRoles

public java.util.List<com.liferay.portal.model.Role> getRoles(long inode,
                                                              int permissionType,
                                                              java.lang.String filter,
                                                              int start,
                                                              int limit)
Specified by:
getRoles in interface PermissionAPI<Inode>

getRoleCount

public int getRoleCount(long inode,
                        int permissionType,
                        java.lang.String filter)
Specified by:
getRoleCount in interface PermissionAPI<Inode>

getUsers

public java.util.List<com.liferay.portal.model.User> getUsers(long inode,
                                                              int permissionType,
                                                              java.lang.String filter,
                                                              int start,
                                                              int limit)
Specified by:
getUsers in interface PermissionAPI<Inode>

getUserCount

public int getUserCount(long inode,
                        int permissionType,
                        java.lang.String filter)
Specified by:
getUserCount in interface PermissionAPI<Inode>

clearCache

public void clearCache()
Description copied from interface: PermissionAPI
This method is to clear the permissions cache. Should only need to be called for maintenance or debug reasons

Specified by:
clearCache in interface PermissionAPI<Inode>

filterCollection

public <P extends Permissionable> java.util.List<P> filterCollection(java.util.List<P> permissionables,
                                                                     int requiredPermission,
                                                                     boolean respectFrontendRoles,
                                                                     com.liferay.portal.model.User user)
                                                          throws DotDataException,
                                                                 DotSecurityException
Specified by:
filterCollection in interface PermissionAPI<Inode>
Throws:
DotDataException
DotSecurityException


Copyright © 2009 Dotmarketing, Inc. All Rights Reserved.