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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_addError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Add an errorprotected booleancheckAncestors(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 booleancheckAncestors(ProgramItem programItem, ProgramItem childProgramItem) Check if the hierarchy of a program item will be still valid if adding the given program item as child.voidconfigure(Configuration configuration) Get the names of child metadata to be checkedGet the names of parent metadata to be checkedvoidservice(ServiceManager smanager) voidValidates a content being editedvoidValidates a content.Methods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, setContentTypeMethods 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:
servicein interfaceServiceable- Throws:
ServiceException
-
validate
Description copied from interface:ContentValidatorValidates a content.- Specified by:
validatein interfaceContentValidator- Parameters:
content- the content to validateerrors- the structure to populate if the validation failed.
-
configure
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
validate
Description copied from interface:ContentValidatorValidates a content being edited- Specified by:
validatein 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 theProgramItemto 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 theProgramItemto 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
-