Interface IUnitService
-
- All Known Implementing Classes:
UnitService
public interface IUnitServiceIUnitService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanCreateSubUnit(int nIdUnit)Check if the given id unit, we can create sub unit.intcreateUnit(Unit unit, javax.servlet.http.HttpServletRequest request)Create a unitjava.util.List<Unit>getAllSubUnits(Unit unit, boolean bGetAdditionalInfos)Get all the sub units in the unit tree from the specified unitjava.util.List<Unit>getAllUnits(boolean bGetAdditionalInfos)Get all unitsjava.util.List<IAction>getListActions(java.lang.String strActionType, java.util.Locale locale, Unit unit, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)Get the list of actionsjava.util.List<Unit>getListParentUnits(Unit unit)Get the unit parent list, from a given unit.UnitgetRootUnit(boolean bGetAdditionalInfos)Get the root unitjava.util.List<Unit>getSubUnits(int nIdUnit, boolean bGetAdditionalInfos)Get the direct sub units from a given id unitfr.paris.lutece.util.ReferenceListgetSubUnitsAsReferenceList(int nIdUnit, java.util.Locale locale)Get the direct sub units as aReferenceListjavax.xml.transform.SourcegetTreeXsl()Get the XSL of the treeUnitgetUnit(int nIdUnit, boolean bGetAdditionalInfos)Get the unitUnitgetUnitByCode(java.lang.String strCode, boolean bGetAdditionalInfos)Get the unit by codejava.util.List<Unit>getUnitsByIdUser(int nIdUser, boolean bGetAdditionalInfos)Get the unit by id userjava.util.List<Unit>getUnitsFirstLevel(boolean bGetAdditionalInfos)Get the units first leveljava.util.List<Unit>getUnitWithNoChildren()Return all the Unit with no children (level 0)java.lang.StringgetXMLUnits(fr.paris.lutece.portal.business.user.AdminUser user)Get the XML unitsbooleanhasSubUnits(int nIdUnit)Check if the given id unit has sub unitsbooleanisAuthorized(Unit unit, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)Check if the given user is authorized to do the action for a given unit.booleanisAuthorized(java.lang.String strIdResource, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)See#isAuthorized(Unit, String, AdminUser)booleanisParent(Unit unitParent, Unit unitRef)Check if the first unit in parameter is parent of the second unit in parameterbooleanisUnitInList(Unit unitToCheck, java.util.Collection<Unit> listUnits)Check if an unit is in a given list of unitbooleanmoveSubTree(Unit unitToMove, Unit newUnitParent)Change the parent of a unit.voidpopulateTreeUnit(TreeUnit treeUnit, fr.paris.lutece.portal.business.user.AdminUser user, boolean bGetAdditionnalInfos)populate a TreeUnit with all sub units (recursive)voidremoveUnit(int nIdUnit, javax.servlet.http.HttpServletRequest request)Remove the unit only if the unit does not have sub unitsvoidupdateUnit(Unit unit, javax.servlet.http.HttpServletRequest request)Update the unit
-
-
-
Method Detail
-
getUnit
Unit getUnit(int nIdUnit, boolean bGetAdditionalInfos)
Get the unit- Parameters:
nIdUnit- the id unitbGetAdditionalInfos- true if it must get the additional infos- Returns:
- an instance of
Unit
-
getUnitByCode
Unit getUnitByCode(java.lang.String strCode, boolean bGetAdditionalInfos)
Get the unit by code- Parameters:
strCode- the unit codebGetAdditionalInfos- true if it must get the additional infos- Returns:
- an instance of
Unit
-
getRootUnit
Unit getRootUnit(boolean bGetAdditionalInfos)
Get the root unit- Parameters:
bGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- an instance of
Unit
-
getUnitsByIdUser
java.util.List<Unit> getUnitsByIdUser(int nIdUser, boolean bGetAdditionalInfos)
Get the unit by id user- Parameters:
nIdUser- the id userbGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- a list of
Unit
-
getAllUnits
java.util.List<Unit> getAllUnits(boolean bGetAdditionalInfos)
Get all units- Parameters:
bGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- a list of
Unit
-
getUnitsFirstLevel
java.util.List<Unit> getUnitsFirstLevel(boolean bGetAdditionalInfos)
Get the units first level- Parameters:
bGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- a list of
Unit
-
getSubUnits
java.util.List<Unit> getSubUnits(int nIdUnit, boolean bGetAdditionalInfos)
Get the direct sub units from a given id unit- Parameters:
nIdUnit- the id unitbGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- a list of
Unit
-
getListParentUnits
java.util.List<Unit> getListParentUnits(Unit unit)
Get the unit parent list, from a given unit. The unit itselft is included- Parameters:
unit- the unit- Returns:
- the list of parent units.
-
getAllSubUnits
java.util.List<Unit> getAllSubUnits(Unit unit, boolean bGetAdditionalInfos)
Get all the sub units in the unit tree from the specified unit- Parameters:
unit- the unitbGetAdditionalInfos- true if it must get the additionnal infos- Returns:
- a list of
Unit
-
getListActions
java.util.List<IAction> getListActions(java.lang.String strActionType, java.util.Locale locale, Unit unit, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)
Get the list of actions- Parameters:
strActionType- the action typelocale- the localeunit- the unituser- the userrecursiveType- the recursive type- Returns:
- a list of
IAction
-
getSubUnitsAsReferenceList
fr.paris.lutece.util.ReferenceList getSubUnitsAsReferenceList(int nIdUnit, java.util.Locale locale)Get the direct sub units as aReferenceList- Parameters:
nIdUnit- the id unitlocale- the locale- Returns:
- a
ReferenceList
-
getXMLUnits
java.lang.String getXMLUnits(fr.paris.lutece.portal.business.user.AdminUser user)
Get the XML units- Parameters:
user- the admin user- Returns:
- an XML
-
getTreeXsl
javax.xml.transform.Source getTreeXsl()
Get the XSL of the tree- Returns:
- the XSL
-
getUnitWithNoChildren
java.util.List<Unit> getUnitWithNoChildren()
Return all the Unit with no children (level 0)- Returns:
- all the Unit with no children (level 0)
-
hasSubUnits
boolean hasSubUnits(int nIdUnit)
Check if the given id unit has sub units- Parameters:
nIdUnit- the id unit- Returns:
- true if the unit has sub units, false otherwise
-
isParent
boolean isParent(Unit unitParent, Unit unitRef)
Check if the first unit in parameter is parent of the second unit in parameter- Parameters:
unitParent- the parent unitunitRef- the unit to check- Returns:
- true if there is a parent link between those two units
-
canCreateSubUnit
boolean canCreateSubUnit(int nIdUnit)
Check if the given id unit, we can create sub unit.
Return false if the unit can not be created- Parameters:
nIdUnit- the id unit- Returns:
- true if we can create sub unit, false otherwise
-
isAuthorized
boolean isAuthorized(Unit unit, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)
Check if the given user is authorized to do the action for a given unit.
This method calls the service RBACService to check the permission. However, the resource on which the permission must be checked is not necessarily the given unit. It may be a parent unit of the given unit.
There are 5 cases to handle :- 1) The given user is admin => The user is always authorized
- 2) The given user does not belong to any unit => The user is not authorized
- 3) The given user belongs to the given unit => Check with RBACService with the given unit
- 4) The given user belongs to a parent unit of the given unit => Check with RBACService with the parent unit
- 5) The given user belongs to an unit who is not a parent unit of the given unit => The user is not authorized
- Parameters:
unit- the unitstrPermission- the permissionuser- the userrecursiveType- the recursive type of RBAC- Returns:
- true if he is authorized, false otherwise
-
isAuthorized
boolean isAuthorized(java.lang.String strIdResource, java.lang.String strPermission, fr.paris.lutece.portal.business.user.AdminUser user, UnittreeRBACRecursiveType recursiveType)See#isAuthorized(Unit, String, AdminUser)- Parameters:
strIdResource- the id resourcestrPermission- the permissionuser- the userrecursiveType- the recursive type of RBAC- Returns:
- true if he is authorized, false otherwise
-
createUnit
@Transactional("unittree.transactionManager") int createUnit(Unit unit, javax.servlet.http.HttpServletRequest request) throws UnitErrorExceptionCreate a unit- Parameters:
unit- the unitrequest- the HTTP request- Returns:
- the id unit
- Throws:
UnitErrorException- exception if there is an application error
-
updateUnit
@Transactional("unittree.transactionManager") void updateUnit(Unit unit, javax.servlet.http.HttpServletRequest request) throws UnitErrorExceptionUpdate the unit- Parameters:
unit- the unitrequest- the HTTP request- Throws:
UnitErrorException- exception if there is an application error
-
removeUnit
@Transactional("unittree.transactionManager") void removeUnit(int nIdUnit, javax.servlet.http.HttpServletRequest request)Remove the unit only if the unit does not have sub units- Parameters:
nIdUnit- the id unitrequest- the HTTP request
-
moveSubTree
@Transactional("unittree.transactionManager") boolean moveSubTree(Unit unitToMove, Unit newUnitParent)Change the parent of a unit.- Parameters:
unitToMove- The unit to change the parent of.newUnitParent- The new parent of the unit- Returns:
- True if the sub tree was successfully move, false if the new parent is a child of the unit.
-
isUnitInList
boolean isUnitInList(Unit unitToCheck, java.util.Collection<Unit> listUnits)
Check if an unit is in a given list of unit- Parameters:
unitToCheck- the unit to checklistUnits- the list of units- Returns:
- true if the unit is in the given list, false otherwise
-
populateTreeUnit
void populateTreeUnit(TreeUnit treeUnit, fr.paris.lutece.portal.business.user.AdminUser user, boolean bGetAdditionnalInfos)
populate a TreeUnit with all sub units (recursive)- Parameters:
treeUnit- the treeUnituser- the admin user (for RBAC)bGetAdditionnalInfos- if true, populate the tree units with additionnal infos
-
-