@Override public String getValueAsString(final PlainSchema schema) { return getValueAsString(schema.getType(), schema); }
@Override protected void doValidate(final PlainAttrValue attrValue) { if (AttrSchemaType.Enum == schema.getType()) { final String[] enumeration = schema.getEnumerationValues().split(SyncopeConstants.ENUM_VALUES_SEPARATOR); final String value = attrValue.getStringValue(); boolean found = false; for (int i = 0; i < enumeration.length && !found; i++) { if (enumeration[i].trim().equals(value)) { found = true; } } if (!found) { throw new InvalidPlainAttrValueException( "'" + value + "' is not one of: " + schema.getEnumerationValues()); } } } }
protected void parseOrderByForPlainSchema( final SearchSupport svs, final OrderBySupport obs, final OrderBySupport.Item item, final OrderByClause clause, final PlainSchema schema, final String fieldName) { // keep track of involvement of non-mandatory schemas in the order by clauses obs.nonMandatorySchemas = !"true".equals(schema.getMandatoryCondition()); if (schema.isUniqueConstraint()) { obs.views.add(svs.asSearchViewSupport().uniqueAttr()); item.select = new StringBuilder(). append(svs.asSearchViewSupport().uniqueAttr().alias).append('.'). append(svs.fieldName(schema.getType())). append(" AS ").append(fieldName).toString(); item.where = new StringBuilder(). append(svs.asSearchViewSupport().uniqueAttr().alias). append(".schema_id='").append(fieldName).append("'").toString(); item.orderBy = fieldName + " " + clause.getDirection().name(); } else { obs.views.add(svs.asSearchViewSupport().attr()); item.select = new StringBuilder(). append(svs.asSearchViewSupport().attr().alias).append('.').append(svs.fieldName(schema.getType())). append(" AS ").append(fieldName).toString(); item.where = new StringBuilder(). append(svs.asSearchViewSupport().attr().alias). append(".schema_id='").append(fieldName).append("'").toString(); item.orderBy = fieldName + " " + clause.getDirection().name(); } }
switch (schema.getType()) { case Boolean: bld.append("v.booleanValue = '").append(attrValues.get(i)).append("'");
@Override public String getValueAsString() { PlainSchema schema = getAttr() == null || getAttr().getSchema() == null ? null : getAttr().getSchema(); AttrSchemaType type = schema == null || schema.getType() == null ? AttrSchemaType.String : getAttr().getSchema().getType(); return getValueAsString(type, schema); }
String column = (cond instanceof AnyCond) ? cond.getSchema() : svs.fieldName(schema.getType()); if ((schema.getType() == AttrSchemaType.String || schema.getType() == AttrSchemaType.Enum) && ignoreCase) { column = "LOWER (" + column + ")"; if (schema.getType() == AttrSchemaType.String || schema.getType() == AttrSchemaType.Enum) { query.append(column); if (not) { query.append('='); if ((schema.getType() == AttrSchemaType.String || schema.getType() == AttrSchemaType.Enum) && ignoreCase) { query.append("LOWER(?").append(setParameter(parameters, attrValue.getValue())).append(')'); } else {
AttrSchemaType schemaType = schema == null ? AttrSchemaType.String : schema.getType(); if (value != null) { if (schemaType == AttrSchemaType.Binary) {
Exception exception = null; switch (schema.getType()) {
@Override public PlainSchema update(final PlainSchemaTO schemaTO, final PlainSchema schema) { SyncopeClientCompositeException scce = SyncopeClientException.buildComposite(); boolean hasAttrs = false; for (AnyTypeKind anyTypeKind : AnyTypeKind.values()) { AnyUtils anyUtils = anyUtilsFactory.getInstance(anyTypeKind); hasAttrs |= plainSchemaDAO.findAttrs(schema, anyUtils.plainAttrClass()).isEmpty(); } if (hasAttrs) { if (schema.getType() != schemaTO.getType()) { SyncopeClientException e = SyncopeClientException.build(ClientExceptionType.InvalidPlainSchema); e.getElements().add("Cannot change type since " + schema.getKey() + " has attributes"); scce.addException(e); } if (schema.isUniqueConstraint() != schemaTO.isUniqueConstraint()) { SyncopeClientException e = SyncopeClientException.build(ClientExceptionType.InvalidPlainSchema); e.getElements().add("Cannot alter unique contraint since " + schema.getKey() + " has attributes"); scce.addException(e); } } if (scce.hasExceptions()) { throw scce; } return fill(schema, schemaTO); }
@Override public boolean isValid(final PlainSchema schema, final ConstraintValidatorContext context) { boolean isValid = schema.getType() != AttrSchemaType.Enum || StringUtils.isNotBlank(schema.getEnumerationValues()); if (!isValid) { addPropertyNode("enumerationValues").addConstraintViolation(); } else { isValid = schema.getType() != AttrSchemaType.Encrypted || (schema.getSecretKey() != null && schema.getCipherAlgorithm() != null); if (!isValid) {
@Override public PlainSchemaTO getPlainSchemaTO(final String key) { PlainSchema schema = plainSchemaDAO.find(key); if (schema == null) { throw new NotFoundException("Schema '" + key + "'"); } PlainSchemaTO schemaTO = new PlainSchemaTO(); schemaTO.setKey(schema.getKey()); schemaTO.setType(schema.getType()); schemaTO.setCipherAlgorithm(schema.getCipherAlgorithm()); schemaTO.setConversionPattern(schema.getConversionPattern()); schemaTO.setEnumerationKeys(schema.getEnumerationKeys()); schemaTO.setEnumerationValues(schema.getEnumerationValues()); schemaTO.setMandatoryCondition(schema.getMandatoryCondition()); schemaTO.setMimeType(schema.getMimeType()); schemaTO.setMultivalue(schema.isMultivalue()); schemaTO.setReadonly(schema.isReadonly()); schemaTO.setSecretKey(schema.getSecretKey()); schemaTO.setUniqueConstraint(schema.isUniqueConstraint()); labels(schema, schemaTO); schemaTO.setAnyTypeClass(schema.getAnyTypeClass() == null ? null : schema.getAnyTypeClass().getKey()); if (schema.getValidator() != null) { schemaTO.setValidator(schema.getValidator().getKey()); } return schemaTO; }