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 protected ODFHelper_odfHelperThe ODF helper
-
Constructor Summary
Constructors Constructor Description ProgramItemHierarchyValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_addError(Errors errors, ElementDefinition childDefinition, Content content, Content childContent, String catalog, String i18nKey)Add an errorprotected 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
-
-
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)
-
_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
-
-