Package org.ametys.plugins.forms.dao
Class FormDirectoryDAO
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.dao.FormDirectoryDAO
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
DAO for manipulating form directories
-
Field Summary
Modifier and TypeFieldDescriptionprotected FormDAO
The form DAOprotected ObservationManager
Observer manager.protected AmetysObjectResolver
The Ametys object resolverprotected RightManager
The right managerprotected SiteManager
The site managerprotected CurrentUserProvider
The current user providerstatic final String
The right id to handle formsstatic final String
The Avalon rolestatic final String
The alias id of the rootFormDirectory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected UserIdentity
Provides the current user._getUserRights
(FormDirectory formDirectory) Get user rights for the given form directoryprotected boolean
Can the current user delete all theFormDirectory
s from the list ?Determines if the current user can delete the givenFormDirectory
svoid
checkHandleFormDirectoriesRight
(AmetysObject formElement) Check rights for a form element as ametys objectcreateFormDirectory
(String siteName, String parentId, String name) Creates a newFormDirectory
deleteFormDirectory
(List<String> ids) DeletesFormDirectory
(s)getChildFormDirectories
(FormDirectory parent) Gets all form directories for given parentgetChildFormsForAdministrator
(FormDirectory parent, boolean onlyDirect) Gets all forms for administrator for given parentgetChildFormsInReadAccess
(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in READ access for given parentgetChildFormsInRightAccess
(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in WRITE access for given parentgetChildFormsInWriteAccess
(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in WRITE access for given parentgetFormDirectoriesRootNode
(String siteName) Get the root plugin storage object.getFormDirectory
(String siteName, String id) Get form directory with given idgetFormDirectoryPath
(FormDirectory formDirectory, String separator) Get the path of a form directorygetFormDirectoryProperties
(String siteName, String id) Get the form directory propertiesgetFormDirectoryProperties
(FormDirectory formDirectory, boolean withRights) Get the form directory propertiesgetRootProperties
(String siteName) Get the root directory propertieshasAnyAssignableDescendant
(UserIdentity userIdentity, FormDirectory formDirectory) Check if a directory have descendant in right assignment access for a given userhasAnyReadableDescendant
(UserIdentity userIdentity, FormDirectory formDirectory) Check if a directory have a descendant in read access for a given userhasAnyWritableDescendant
(UserIdentity userIdentity, FormDirectory formDirectory) Check if a directory have descendant in write access for a given userboolean
hasReadRightOnFormDirectory
(UserIdentity userIdentity, FormDirectory directory) Check if a user have read rights on a form directoryboolean
hasRightAffectationRightOnFormDirectory
(UserIdentity userIdentity, FormDirectory formDirectory) Check if a user have write rights on a form directoryboolean
hasWriteRightOnFormAndParent
(UserIdentity userIdentity, Form form, FormDirectory formDirectory) Check if a user have write rights on a formboolean
hasWriteRightOnFormDirectory
(UserIdentity userIdentity, FormDirectory formDirectory) Check if a user have write rights on a form directoryboolean
isRoot
(FormDirectory formDirectory) Determines if the form directory is the root directoryvoid
Moves aFormDirectory
or aForm
moveFormDirectory
(String siteName, String id, String newParentId) Moves aFormDirectory
boolean
mustWarnBeforeDeletion
(List<String> ids) Determines if application must warn before deleting the givenFormDirectory
srenameFormDirectory
(String id, String newName) Renames aFormDirectory
void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
ROOT_FORM_DIRECTORY_ID
The alias id of the rootFormDirectory
- See Also:
-
HANDLE_FORM_DIRECTORIES_RIGHT_ID
The right id to handle forms- See Also:
-
_observationManager
Observer manager. -
_siteManager
The site manager -
_userProvider
The current user provider -
_resolver
The Ametys object resolver -
_rightManager
The right manager -
_formDAO
The form DAO
-
-
Constructor Details
-
FormDirectoryDAO
public FormDirectoryDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
hasWriteRightOnFormDirectory
Check if a user have write rights on a form directory- Parameters:
userIdentity
- the userformDirectory
- the form directory- Returns:
- true if the user have write rights on a form directory
-
checkHandleFormDirectoriesRight
Check rights for a form element as ametys object- Parameters:
formElement
- the form element as ametys object
-
getFormDirectoriesRootNode
Get the root plugin storage object.- Parameters:
siteName
- the site's name- Returns:
- the root plugin storage object.
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
getRootProperties
Get the root directory properties- Parameters:
siteName
- the site's name- Returns:
- The root directory properties
-
getFormDirectoryProperties
Get the form directory properties- Parameters:
siteName
- the site's nameid
- The form directory id. Can beROOT_FORM_DIRECTORY_ID
for the root directory.- Returns:
- The form directory properties
-
getFormDirectoryProperties
public Map<String,Object> getFormDirectoryProperties(FormDirectory formDirectory, boolean withRights) Get the form directory properties- Parameters:
formDirectory
- The form directorywithRights
-true
to add rights to the properties- Returns:
- The form directory properties
-
_getUserRights
Get user rights for the given form directory- Parameters:
formDirectory
- the form directory- Returns:
- the set of rights
-
getFormDirectory
Get form directory with given id- Parameters:
siteName
- the site name where to search in jcrid
- the directory id- Returns:
- the form directory having given id
-
getFormDirectoryPath
Get the path of a form directory- Parameters:
formDirectory
- the form directoryseparator
- the seperator to use from path- Returns:
- the path in form's directory
-
isRoot
Determines if the form directory is the root directory- Parameters:
formDirectory
- the form directory. Cannot be null.- Returns:
- true if is the root directory
-
createFormDirectory
Creates a newFormDirectory
- Parameters:
siteName
- the site's nameparentId
- The id of the parent. UseROOT_FORM_DIRECTORY_ID
for the root directory.name
- The desired name for the newFormDirectory
- Returns:
- A result map
-
renameFormDirectory
Renames aFormDirectory
- Parameters:
id
- The id of the form directorynewName
- The new name of the directory- Returns:
- A result map
-
deleteFormDirectory
DeletesFormDirectory
(s)- Parameters:
ids
- The ids of the form directories to delete- Returns:
- A result map
-
moveFormDirectory
Moves aFormDirectory
- Parameters:
siteName
- name of the siteid
- The id of the form directorynewParentId
- The id of the new parent directory of the form directory. UseROOT_FORM_DIRECTORY_ID
for the root directory.- Returns:
- A result map
-
move
public void move(MovableAmetysObject obj, String siteName, String newParentId, Map<String, Object> results) Moves aFormDirectory
or aForm
- Parameters:
obj
- form or directory to movesiteName
- name of the sitenewParentId
- id of directory where to drop objresults
- a result map
-
mustWarnBeforeDeletion
Determines if application must warn before deleting the givenFormDirectory
s- Parameters:
ids
- TheFormDirectory
ids- Returns:
true
if application must warn
-
canDeleteAllFormDirectories
Can the current user delete all theFormDirectory
s from the list ?- Parameters:
ids
- TheFormDirectory
ids- Returns:
true
if he can
-
canDeleteFormDirectories
Determines if the current user can delete the givenFormDirectory
s- Parameters:
ids
- TheFormDirectory
ids- Returns:
- A map with
true
for each id if the current user can delete the associatedFormDirectory
-
hasWriteRightOnFormAndParent
public boolean hasWriteRightOnFormAndParent(UserIdentity userIdentity, Form form, FormDirectory formDirectory) Check if a user have write rights on a form- Parameters:
userIdentity
- the userform
- the source for the formformDirectory
- the form directory- Returns:
- true if the user have write rights on a form
-
getChildFormsInWriteAccess
public Stream<Form> getChildFormsInWriteAccess(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in WRITE access for given parent- Parameters:
parent
- TheFormDirectory
, defining the context from which getting childrenonlyDirect
-true
in order to have only direct child forms from parent path,false
otherwise to have all forms at any level underneath the parent pathuser
- The user- Returns:
- all forms in WRITE access for given parent
-
getChildFormsInRightAccess
public Stream<Form> getChildFormsInRightAccess(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in WRITE access for given parent- Parameters:
parent
- TheFormDirectory
, defining the context from which getting childrenonlyDirect
-true
in order to have only direct child forms from parent path,false
otherwise to have all forms at any level underneath the parent pathuser
- The user- Returns:
- all forms in WRITE access for given parent
-
getChildFormsInReadAccess
public Stream<Form> getChildFormsInReadAccess(FormDirectory parent, boolean onlyDirect, UserIdentity user) Gets all forms in READ access for given parent- Parameters:
parent
- TheFormDirectory
, defining the context from which getting childrenonlyDirect
-true
in order to have only direct child forms from parent path,false
otherwise to have all forms at any level underneath the parent pathuser
- The user- Returns:
- all forms in READ access for given parent
-
getChildFormsForAdministrator
public AmetysObjectIterable<Form> getChildFormsForAdministrator(FormDirectory parent, boolean onlyDirect) Gets all forms for administrator for given parent- Parameters:
parent
- TheFormDirectory
, defining the context from which getting childrenonlyDirect
-true
in order to have only direct child forms from parent path,false
otherwise to have all forms at any level underneath the parent path- Returns:
- all forms for administrator for given parent
-
getChildFormDirectories
Gets all form directories for given parent- Parameters:
parent
- TheFormDirectory
, defining the context from which getting children- Returns:
- all form directories for given parent
-
_getCurrentUser
Provides the current user.- Returns:
- the user which cannot be
null
.
-
hasRightAffectationRightOnFormDirectory
public boolean hasRightAffectationRightOnFormDirectory(UserIdentity userIdentity, FormDirectory formDirectory) Check if a user have write rights on a form directory- Parameters:
userIdentity
- the userformDirectory
- the form directory- Returns:
- true if the user have write rights on a form
-
hasReadRightOnFormDirectory
Check if a user have read rights on a form directory- Parameters:
userIdentity
- the userdirectory
- the form directory- Returns:
- true if the user have read rights on a form directory
-
hasAnyReadableDescendant
Check if a directory have a descendant in read access for a given user- Parameters:
userIdentity
- the userformDirectory
- the form directory- Returns:
- true if the user have read right for at least one child of this directory
-
hasAnyWritableDescendant
Check if a directory have descendant in write access for a given user- Parameters:
userIdentity
- the userformDirectory
- the form directory- Returns:
- true if the user have write right for at least one child of this directory
-
hasAnyAssignableDescendant
Check if a directory have descendant in right assignment access for a given user- Parameters:
userIdentity
- the userformDirectory
- the form directory- Returns:
- true if the user have right assignment right for at least one child of this directory
-