Package org.ametys.odf.validator
Class ProgramItemHierarchyValidator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.contenttype.validation.AbstractContentValidator
org.ametys.odf.validator.ProgramItemHierarchyValidator
- All Implemented Interfaces:
ContentValidator
,Configurable
,LogEnabled
,Serviceable
public class ProgramItemHierarchyValidator
extends AbstractContentValidator
implements Serviceable, Configurable
Global validator for
ProgramItem
content.
Check that structure to not create an infinite loop-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected I18nizableText
_getError
(ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Retrieves an error messageprotected boolean
checkAncestors
(ProgramItem childProgramItem, List<? extends ProgramItem> parentProgramItems) Check if the hierarchy of a program item will be still valid if adding the given program item as child.protected boolean
checkAncestors
(ProgramItem programItem, ProgramItem childProgramItem) Check if the hierarchy of a program item will be still valid if adding the given program item as child.void
configure
(Configuration configuration) Get the names of child attribute to be checkedGet the names of parent attribute to be checkedvoid
service
(ServiceManager smanager) Validates a content.Validates a content being editedMethods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, initialize, setContentType
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_odfHelper
The ODF helper
-
-
Constructor Details
-
ProgramItemHierarchyValidator
public ProgramItemHierarchyValidator()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
validate
Description copied from interface:ContentValidator
Validates a content.- Specified by:
validate
in interfaceContentValidator
- Parameters:
content
- the content to validate- Returns:
- the validation result
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
validate
Description copied from interface:ContentValidator
Validates a content being edited- Specified by:
validate
in interfaceContentValidator
- Parameters:
content
- the content to validatevalues
- the values being setview
- the view- Returns:
- the validation result
-
getChildAttributeNames
Get the names of child attribute to be checked- Returns:
- the child attribute's names
-
getParentAttributeNames
Get the names of parent attribute to be checked- Returns:
- the parent attribute's names
-
checkAncestors
Check if the hierarchy of a program item will be still valid if adding the given program item as child. Return false if theProgramItem
to add is in the hierarchy of the givenProgramItem
- Parameters:
programItem
- The content to start searchchildProgramItem
- The child program item to search in ancestors- Returns:
- true if child program item is already part of the hierarchy (ascendant search)
-
checkAncestors
protected boolean checkAncestors(ProgramItem childProgramItem, List<? extends ProgramItem> parentProgramItems) Check if the hierarchy of a program item will be still valid if adding the given program item as child. Return false if theProgramItem
to add is in the hierarchy of the givenProgramItem
- Parameters:
childProgramItem
- The child program item to addparentProgramItems
- The parent program items of the target- Returns:
- true if child program item is already part of the hierarchy (ascendant search)
-
_getError
protected I18nizableText _getError(ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Retrieves an error message- Parameters:
childDefinition
- The child attribute definitioncontent
- The content being editedchildContent
- The content to add as child contentcatalog
- the i18n catalogi18nKey
- the i18n key for the error message- Returns:
- the error message
-