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 forProgramItemcontent. Check that structure to not create an infinite loop
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>_childMetadataNamesprotected ODFHelper_odfHelperThe ODF helper
-
Constructor Summary
Constructors Constructor Description ProgramItemHierarchyValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddHierarchyError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent)Add an error the ascendant hierarchy is invalid (infinite loop)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)protected Set<String>getChildMetadataNames()Get the names of child metadata to be checkedvoidservice(ServiceManager smanager)voidvalidate(Content content, Map<String,Object> values, View view, Errors errors)Validates a content being editedvoidvalidate(Content content, Errors errors)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 Detail
-
_odfHelper
protected ODFHelper _odfHelper
The ODF helper
-
_childMetadataNames
private Set<String> _childMetadataNames
-
-
Constructor Detail
-
ProgramItemHierarchyValidator
public ProgramItemHierarchyValidator()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
validate
public void validate(Content content, Errors errors)
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
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
validate
public void validate(Content content, Map<String,Object> values, View view, Errors errors)
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
protected Set<String> getChildMetadataNames()
Get the names of child metadata to be checked- Returns:
- the child metadata's names
-
checkAncestors
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. 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)
-
addHierarchyError
protected void addHierarchyError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent)
Add an error the ascendant hierarchy is invalid (infinite loop)- Parameters:
errors- The list of errorschildDefinition- The child metadata definitioncontent- The content being editedchildContent- The content to add as child content
-
-