Examples of EntityViolationType


Examples of org.apache.syncope.types.EntityViolationType

    }

    @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
Copyright © 2018 www.massapi.com. 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.