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 I18nizableText_getError(ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey) Retrieves an error messageprotected 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 attribute to be checkedGet the names of parent attribute to be checkedvoidservice(ServiceManager smanager) Validates a content.Validates a content being editedMethods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, initialize, 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 validate- Returns:
- the validation result
-
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 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 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)
-
_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
-