Class AccessTypeInjector
- java.lang.Object
-
- org.openbravo.role.inheritance.access.AccessTypeInjector
-
- All Implemented Interfaces:
Comparable<AccessTypeInjector>
- Direct Known Subclasses:
AlertRecipientAccessInjector
,FieldAccessInjector
,FormAccessInjector
,OrgAccessInjector
,PreferenceAccessInjector
,ProcessDefinitionAccessInjector
,ReportAndProcessAccessInjector
,TabAccessInjector
,TableAccessInjector
,ViewImplementationAccessInjector
,WidgetClassAccessInjector
,WindowAccessInjector
@ApplicationScoped public abstract class AccessTypeInjector extends Object implements Comparable<AccessTypeInjector>
An AccessTypeInjector is used byRoleInheritanceManager
to retrieve the access types that should be inherited
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AccessTypeInjector.Qualifier
Defines the qualifier used to register an access type.static class
AccessTypeInjector.Selector
A class used to select the correct access type injector.
-
Constructor Summary
Constructors Constructor Description AccessTypeInjector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
addEntityWhereClause(String whereClause)
Includes in the where clause some filtering needed for same cases.void
checkAccessExistence(InheritedAccessEnabled access)
Checks if a particular access already existsprotected void
clearInheritedFromField(InheritedAccessEnabled access)
Sets to null the Inherited From field of an inherited access.protected void
clearInheritedFromField(InheritedAccessEnabled access, String roleId)
Sets to null the Inherited From field of an access whenever the value of the field is equal to the entered role id.void
clearInheritFromFieldInChilds(InheritedAccessEnabled access, boolean clearAll)
Sets to null the Inherited From field to child elements when applies (for example, this is used for TabAccess and FieldAccess).int
compareTo(AccessTypeInjector accessType)
Allows the comparison between AccessTypeInjector classes.<T extends BaseOBObject>
voiddoEntityParameterReplacement(OBQuery<T> query)
Performs the needed parameter substitution according to the entity represented by the injector.<T extends BaseOBObject>
InheritedAccessEnabledfindAccess(InheritedAccessEnabled access, String roleId)
<T extends BaseOBObject>
List<? extends InheritedAccessEnabled>getAccessList(Role role)
Returns the list of accesses of a particular type for the Role given as parameter.String
getClassName()
Returns the name of the inheritable class.int
getPriority()
Returns the priority of this injector.Role
getRole(InheritedAccessEnabled access)
Returns the role which the access given as parameter is assigned to.String
getRoleProperty()
Returns the role property related to the entity represented by the injector.protected abstract String
getSecuredElementGetter()
Returns the secured object.protected String
getSecuredElementIdentifier(InheritedAccessEnabled access)
Returns the id of the secured object for the given inheritable access.protected abstract String
getSecuredElementName()
Returns the secured element name.List<String>
getSkippedProperties()
Retrieves the properties of the entity related to the injector that will not be copied when updating an access by propagation.boolean
isInheritable(InheritedAccessEnabled access)
Determines if a particular access can be inherited according to this injectorvoid
removeReferenceInParentList(InheritedAccessEnabled access)
Removes references to child elements from the parent list.void
setParent(InheritedAccessEnabled newAccess, InheritedAccessEnabled parentAccess, Role role)
Sets the parent for an inheritable access object.
-
-
-
Method Detail
-
getClassName
public String getClassName()
Returns the name of the inheritable class.- Returns:
- A String with the class name
-
getSecuredElementGetter
protected abstract String getSecuredElementGetter()
Returns the secured object.- Returns:
- a String with the name of the method to retrieve the secured element
-
getSecuredElementName
protected abstract String getSecuredElementName()
Returns the secured element name.- Returns:
- a String with the name of the secured element
-
getPriority
public int getPriority()
Returns the priority of this injector. It is used to determine the order when adding, updating or removing a particular access, if needed.- Returns:
- an integer that represents the priority of this injector
-
compareTo
public int compareTo(AccessTypeInjector accessType)
Allows the comparison between AccessTypeInjector classes. The getPriority() method is used to determine the comparison result.- Specified by:
compareTo
in interfaceComparable<AccessTypeInjector>
- Returns:
- a negative integer, zero, or a positive integer as this object priority is less than, equal to, or greater than the priority of the specified AccessTypeInjector object.
-
isInheritable
public boolean isInheritable(InheritedAccessEnabled access)
Determines if a particular access can be inherited according to this injector- Parameters:
access
- the permission to decide whether is inheritable or not- Returns:
- true if the access is inheritable, false otherwise
-
checkAccessExistence
public void checkAccessExistence(InheritedAccessEnabled access)
Checks if a particular access already exists- Parameters:
access
- the permission to decide whether exists or not
-
setParent
public void setParent(InheritedAccessEnabled newAccess, InheritedAccessEnabled parentAccess, Role role)
Sets the parent for an inheritable access object.- Parameters:
newAccess
- Access whose parent object will be setparentAccess
- Access that is used in some cases to find the correct parentrole
- Parent role to set directly when applies
-
getRole
public Role getRole(InheritedAccessEnabled access)
Returns the role which the access given as parameter is assigned to. In general, the most part of inheritable accesses have Role as their parent entity. If not, this method must be overridden to retrieve the Role property for their particular case.- Parameters:
access
- An inheritable access- Returns:
- the Role owner of the access
-
getRoleProperty
public String getRoleProperty()
Returns the role property related to the entity represented by the injector.- Returns:
- the role property that can be retrieved according to the entity of the injector.
-
getSecuredElementIdentifier
protected String getSecuredElementIdentifier(InheritedAccessEnabled access)
Returns the id of the secured object for the given inheritable access.- Parameters:
access
- An object of an inheritable class,i.e., a class that implements InheritedAccessEnabled.- Returns:
- A String with the id of the secured object
-
getAccessList
public <T extends BaseOBObject> List<? extends InheritedAccessEnabled> getAccessList(Role role)
Returns the list of accesses of a particular type for the Role given as parameter.- Parameters:
role
- The role whose list of accesses of a particular type will be retrieved- Returns:
- a list of accesses
-
findAccess
public <T extends BaseOBObject> InheritedAccessEnabled findAccess(InheritedAccessEnabled access, String roleId) throws ClassNotFoundException
- Parameters:
access
- The access with the secured element to be foundroleId
- Id of the role owner of the access to be found- Returns:
- The searched access or null if not found
- Throws:
ClassNotFoundException
-
addEntityWhereClause
public String addEntityWhereClause(String whereClause)
Includes in the where clause some filtering needed for same cases.- Parameters:
whereClause
- The initial where clause- Returns:
- Entity where clause with the filtering included
-
doEntityParameterReplacement
public <T extends BaseOBObject> void doEntityParameterReplacement(OBQuery<T> query)
Performs the needed parameter substitution according to the entity represented by the injector.- Parameters:
query
- The query where to perform the parameter substitution
-
getSkippedProperties
public List<String> getSkippedProperties()
Retrieves the properties of the entity related to the injector that will not be copied when updating an access by propagation.- Returns:
- the list of the properties that will not be copied
-
clearInheritFromFieldInChilds
public void clearInheritFromFieldInChilds(InheritedAccessEnabled access, boolean clearAll)
Sets to null the Inherited From field to child elements when applies (for example, this is used for TabAccess and FieldAccess). This allows the cascade deletion of these elements when removing an inherited Window Access or Tab Access.- Parameters:
access
- The access to be removed from the parent listclearAll
- Flag to indicate if the Inherited From field should be nullified in every child inherited access or not
-
removeReferenceInParentList
public void removeReferenceInParentList(InheritedAccessEnabled access)
Removes references to child elements from the parent list. Using this method prevents the "deleted object would be re-saved by cascade" error. This can happen, for example, after deleting an inherited TabAccess or FieldAccess.- Parameters:
access
- The access to be removed from the parent list
-
clearInheritedFromField
protected void clearInheritedFromField(InheritedAccessEnabled access)
Sets to null the Inherited From field of an inherited access.- Parameters:
access
- The access with the Inherit From field to be nullified
-
clearInheritedFromField
protected void clearInheritedFromField(InheritedAccessEnabled access, String roleId)
Sets to null the Inherited From field of an access whenever the value of the field is equal to the entered role id.- Parameters:
access
- The access with the Inherit From field to be nullifiedroleId
- The id of the role used to decide whether the field should be nullified or not
-
-