Package org.apache.syncope.types

Examples of org.apache.syncope.types.EntityViolationType


    @Override
    public boolean isValid(final AbstractSchema object, final ConstraintValidatorContext context) {

        boolean isValid = false;
        EntityViolationType violation = null;

        try {
            if (object == null) {
                isValid = true;
            } else {
                isValid = object.getType() == null || !object.getType().equals(SchemaType.Enum)
                        || object.getEnumerationValues() != null;

                if (!isValid) {
                    violation = EntityViolationType.InvalidSchemaTypeSpecification;

                    throw new Exception(object + " miss enumeration values");
                }

                isValid = object.isMultivalue()
                        ? !object.isUniqueConstraint()
                        : true;

                if (!isValid) {
                    violation = EntityViolationType.MultivalueAndUniqueConstraint;

                    throw new Exception(object + " cannot be multivalue and have "
                            + "unique constraint at the same time");
                }
            }

            return isValid;
        } catch (Exception e) {
            LOG.error("Error saving schema", e);

            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(violation.toString()).addNode(object.toString())
                    .addConstraintViolation();

            return false;
        }
    }
View Full Code Here


        super();

        this.entityClassSimpleName = entityClassSimpleName;

        this.violations = new HashMap<Class, Set<EntityViolationType>>();
        EntityViolationType entityViolationType;
        for (ConstraintViolation<Object> violation : violations) {
            try {
                entityViolationType = EntityViolationType.valueOf(violation.getMessageTemplate());
            } catch (IllegalArgumentException e) {
                entityViolationType = EntityViolationType.Standard;
                entityViolationType.setMessageTemplate(violation.getPropertyPath() + ": " + violation.getMessage());
            }

            if (!this.violations.containsKey(violation.getLeafBean().getClass())) {

                this.violations.put(violation.getLeafBean().getClass(), EnumSet.noneOf(EntityViolationType.class));
View Full Code Here

    }

    @Override
    public boolean isValid(final Object object, final ConstraintValidatorContext context) {

        EntityViolationType violation = null;

        try {
            if (object != null) {
                final String schemaName;

                if (object instanceof USchema) {
                    schemaName = ((USchema) object).getName();
                    violation = EntityViolationType.InvalidUSchema;
                } else if (object instanceof UDerSchema) {
                    schemaName = ((UDerSchema) object).getName();
                    violation = EntityViolationType.InvalidUDerSchema;
                } else if (object instanceof UVirSchema) {
                    schemaName = ((UVirSchema) object).getName();
                    violation = EntityViolationType.InvalidUVirSchema;
                } else {
                    schemaName = null;
                }

                if (PERMITTED_USCHEMA_NAMES.contains(schemaName)) {
                    throw new Exception("Schema name not permitted");
                }
            }

            return true;
        } catch (Exception e) {
            LOG.error("Error saving schema", e);

            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(violation.toString()).addNode(object.toString())
                    .addConstraintViolation();

            return false;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.types.EntityViolationType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.