use of org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue in project syncope by apache.
the class AbstractPlainAttr method add.
@Override
public void add(final String value, final AnyUtils anyUtils) {
checkNonNullSchema();
PlainAttrValue attrValue;
if (getSchema().isUniqueConstraint()) {
attrValue = anyUtils.newPlainAttrUniqueValue();
((PlainAttrUniqueValue) attrValue).setSchema(getSchema());
} else {
attrValue = anyUtils.newPlainAttrValue();
}
add(value, attrValue);
}
use of org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue in project syncope by apache.
the class ConfigurationDataBinderImpl method fillAttr.
private void fillAttr(final List<String> values, final PlainSchema schema, final CPlainAttr attr, final SyncopeClientException invalidValues) {
// if schema is multivalue, all values are considered for addition;
// otherwise only the fist one - if provided - is considered
List<String> valuesProvided = schema.isMultivalue() ? values : (values.isEmpty() ? Collections.<String>emptyList() : Collections.singletonList(values.iterator().next()));
if (valuesProvided.isEmpty()) {
JexlContext jexlContext = new MapContext();
JexlUtils.addPlainAttrsToContext(confDAO.get().getPlainAttrs(), jexlContext);
if (!schema.isReadonly() && Boolean.parseBoolean(JexlUtils.evaluate(schema.getMandatoryCondition(), jexlContext))) {
LOG.error("Mandatory schema " + schema.getKey() + " not provided with values");
SyncopeClientException reqValMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
reqValMissing.getElements().add(schema.getKey());
throw reqValMissing;
}
}
for (String value : valuesProvided) {
if (value == null || value.isEmpty()) {
LOG.debug("Null value for {}, ignoring", schema.getKey());
} else {
try {
PlainAttrValue attrValue;
if (schema.isUniqueConstraint()) {
attrValue = entityFactory.newEntity(CPlainAttrUniqueValue.class);
((PlainAttrUniqueValue) attrValue).setSchema(schema);
} else {
attrValue = entityFactory.newEntity(CPlainAttrValue.class);
}
attr.add(value, attrValue);
} catch (InvalidPlainAttrValueException e) {
LOG.warn("Invalid value for attribute " + schema.getKey() + ": " + value, e);
invalidValues.getElements().add(schema.getKey() + ": " + value + " - " + e.getMessage());
}
}
}
}
use of org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue in project syncope by apache.
the class ConfTest method add.
private void add(final CPlainAttr newAttr, final String value) {
JPACPlainAttrValue attrValue;
if (newAttr.getSchema().isUniqueConstraint()) {
attrValue = new JPACPlainAttrValue();
((PlainAttrUniqueValue) attrValue).setSchema(newAttr.getSchema());
} else {
attrValue = new JPACPlainAttrValue();
}
newAttr.add(value, attrValue);
}
use of org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue in project syncope by apache.
the class ConfTest method add.
private void add(final CPlainAttr newAttr, final String value) {
JPACPlainAttrValue attrValue;
if (newAttr.getSchema().isUniqueConstraint()) {
attrValue = new JPACPlainAttrValue();
((PlainAttrUniqueValue) attrValue).setSchema(newAttr.getSchema());
} else {
attrValue = new JPACPlainAttrValue();
}
newAttr.add(value, attrValue);
}
Aggregations