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 forProgramItem
content. Check that structure to not create an infinite loop
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>
_childMetadataNames
protected ODFHelper
_odfHelper
The ODF helper
-
Constructor Summary
Constructors Constructor Description ProgramItemHierarchyValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addHierarchyError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent)
Add an error the ascendant hierarchy is invalid (infinite loop)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)
protected Set<String>
getChildMetadataNames()
Get the names of child metadata to be checkedvoid
service(ServiceManager smanager)
void
validate(Content content, Map<String,Object> values, View view, Errors errors)
Validates a content being editedvoid
validate(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:
service
in interfaceServiceable
- Throws:
ServiceException
-
validate
public void validate(Content content, Errors errors)
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
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
validate
public void validate(Content content, Map<String,Object> values, View view, Errors errors)
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
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 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)
-
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
-
-