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 void
_addError
(Errors errors, ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Add an errorprotected 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 metadata to be checkedGet the names of parent metadata to be checkedvoid
service
(ServiceManager smanager) void
Validates a content being editedvoid
Validates a content.Methods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, 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 validateerrors
- the structure to populate if the validation failed.
-
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 viewerrors
- the structure to populate if the validation failed.
-
getChildMetadataNames
Get the names of child metadata to be checked- Returns:
- the child metadata's names
-
getParentMetadataNames
Get the names of parent metadata to be checked- Returns:
- the parent metadata'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)
-
_addError
protected void _addError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Add an error- Parameters:
errors
- The list of errorschildDefinition
- The child metadata definitioncontent
- The content being editedchildContent
- The content to add as child contentcatalog
- the i18n catalogi18nKey
- the i18n key for the error message
-