Search in sources :

Example 6 with M2Constraint

use of org.alfresco.repo.dictionary.M2Constraint in project records-management by Alfresco.

the class RecordsManagementAdminServiceImpl method removeCustomConstraintDefinition.

/**
 * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomConstraintDefinition(org.alfresco.service.namespace.QName)
 */
public void removeCustomConstraintDefinition(QName constraintName) {
    mandatory("constraintName", constraintName);
    NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI());
    M2Model deserializedModel = readCustomContentModel(modelRef);
    String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService());
    M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString);
    if (customConstraint == null) {
        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString));
    }
    deserializedModel.removeConstraint(constraintNameAsPrefixString);
    writeCustomContentModel(modelRef, deserializedModel);
    if (logger.isInfoEnabled()) {
        logger.info("deleteCustomConstraintDefinition: " + constraintNameAsPrefixString);
    }
}
Also used : M2Constraint(org.alfresco.repo.dictionary.M2Constraint) NodeRef(org.alfresco.service.cmr.repository.NodeRef) M2Model(org.alfresco.repo.dictionary.M2Model) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ParameterCheck.mandatoryString(org.springframework.extensions.surf.util.ParameterCheck.mandatoryString)

Aggregations

M2Constraint (org.alfresco.repo.dictionary.M2Constraint)6 M2Model (org.alfresco.repo.dictionary.M2Model)5 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 ParameterCheck.mandatoryString (org.springframework.extensions.surf.util.ParameterCheck.mandatoryString)4 CustomModelConstraint (org.alfresco.rest.api.model.CustomModelConstraint)2 LinkedHashSet (java.util.LinkedHashSet)1 M2Aspect (org.alfresco.repo.dictionary.M2Aspect)1 M2Property (org.alfresco.repo.dictionary.M2Property)1 M2Type (org.alfresco.repo.dictionary.M2Type)1 CustomAspect (org.alfresco.rest.api.model.CustomAspect)1 CustomModelProperty (org.alfresco.rest.api.model.CustomModelProperty)1 CustomType (org.alfresco.rest.api.model.CustomType)1 ApiException (org.alfresco.rest.framework.core.exceptions.ApiException)1 ConstraintViolatedException (org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException)1 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)1 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)1 PermissionDeniedException (org.alfresco.rest.framework.core.exceptions.PermissionDeniedException)1 CustomModelException (org.alfresco.service.cmr.dictionary.CustomModelException)1 ActiveModelConstraintException (org.alfresco.service.cmr.dictionary.CustomModelException.ActiveModelConstraintException)1