use of org.apache.syncope.core.persistence.api.entity.resource.Mapping in project syncope by apache.
the class AbstractProvisioningJobDelegate method doExecute.
@Override
protected String doExecute(final boolean dryRun) throws JobExecutionException {
try {
Class<T> clazz = getTaskClassReference();
if (!clazz.isAssignableFrom(task.getClass())) {
throw new JobExecutionException("Task " + task.getKey() + " isn't a ProvisioningTask");
}
T provisioningTask = clazz.cast(task);
Connector connector;
try {
connector = connFactory.getConnector(provisioningTask.getResource());
} catch (Exception e) {
String msg = String.format("Connector instance bean for resource %s and connInstance %s not found", provisioningTask.getResource(), provisioningTask.getResource().getConnector());
throw new JobExecutionException(msg, e);
}
boolean noMapping = true;
for (Provision provision : provisioningTask.getResource().getProvisions()) {
Mapping mapping = provision.getMapping();
if (mapping != null) {
noMapping = false;
if (mapping.getConnObjectKeyItem() == null) {
throw new JobExecutionException("Invalid ConnObjectKey mapping for provision " + provision);
}
}
}
if (noMapping) {
noMapping = provisioningTask.getResource().getOrgUnit() == null;
}
if (noMapping) {
return "No provisions nor orgUnit available: aborting...";
}
return doExecuteProvisioning(provisioningTask, connector, dryRun);
} catch (Throwable t) {
LOG.error("While executing provisioning job {}", getClass().getName(), t);
throw t;
}
}
use of org.apache.syncope.core.persistence.api.entity.resource.Mapping in project syncope by apache.
the class MappingManagerImpl method getIntValues.
@Transactional(readOnly = true)
@Override
public List<PlainAttrValue> getIntValues(final Provision provision, final Item mapItem, final IntAttrName intAttrName, final Any<?> any) {
LOG.debug("Get internal values for {} as '{}' on {}", any, mapItem.getIntAttrName(), provision.getResource());
Any<?> reference = null;
Membership<?> membership = null;
if (intAttrName.getEnclosingGroup() == null && intAttrName.getRelatedAnyObject() == null) {
reference = any;
}
if (any instanceof GroupableRelatable) {
GroupableRelatable<?, ?, ?, ?, ?> groupableRelatable = (GroupableRelatable<?, ?, ?, ?, ?>) any;
if (intAttrName.getEnclosingGroup() != null) {
Group group = groupDAO.findByName(intAttrName.getEnclosingGroup());
if (group == null || !groupableRelatable.getMembership(group.getKey()).isPresent()) {
LOG.warn("No membership for {} in {}, ignoring", intAttrName.getEnclosingGroup(), groupableRelatable);
} else {
reference = group;
}
} else if (intAttrName.getRelatedAnyObject() != null) {
AnyObject anyObject = anyObjectDAO.findByName(intAttrName.getRelatedAnyObject());
if (anyObject == null || groupableRelatable.getRelationships(anyObject.getKey()).isEmpty()) {
LOG.warn("No relationship for {} in {}, ignoring", intAttrName.getRelatedAnyObject(), groupableRelatable);
} else {
reference = anyObject;
}
} else if (intAttrName.getMembershipOfGroup() != null) {
Group group = groupDAO.findByName(intAttrName.getMembershipOfGroup());
membership = groupableRelatable.getMembership(group.getKey()).orElse(null);
}
}
if (reference == null) {
LOG.warn("Could not determine the reference instance for {}", mapItem.getIntAttrName());
return Collections.emptyList();
}
List<PlainAttrValue> values = new ArrayList<>();
boolean transform = true;
AnyUtils anyUtils = anyUtilsFactory.getInstance(reference);
if (intAttrName.getField() != null) {
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
switch(intAttrName.getField()) {
case "key":
attrValue.setStringValue(reference.getKey());
values.add(attrValue);
break;
case "realm":
attrValue.setStringValue(reference.getRealm().getFullPath());
values.add(attrValue);
break;
case "password":
// ignore
break;
case "userOwner":
case "groupOwner":
Mapping uMapping = provision.getAnyType().equals(anyTypeDAO.findUser()) ? provision.getMapping() : null;
Mapping gMapping = provision.getAnyType().equals(anyTypeDAO.findGroup()) ? provision.getMapping() : null;
if (reference instanceof Group) {
Group group = (Group) reference;
String groupOwnerValue = null;
if (group.getUserOwner() != null && uMapping != null) {
groupOwnerValue = getGroupOwnerValue(provision, group.getUserOwner());
}
if (group.getGroupOwner() != null && gMapping != null) {
groupOwnerValue = getGroupOwnerValue(provision, group.getGroupOwner());
}
if (StringUtils.isNotBlank(groupOwnerValue)) {
attrValue.setStringValue(groupOwnerValue);
values.add(attrValue);
}
}
break;
case "suspended":
if (reference instanceof User) {
attrValue.setBooleanValue(((User) reference).isSuspended());
values.add(attrValue);
}
break;
case "mustChangePassword":
if (reference instanceof User) {
attrValue.setBooleanValue(((User) reference).isMustChangePassword());
values.add(attrValue);
}
break;
default:
try {
Object fieldValue = FieldUtils.readField(reference, intAttrName.getField(), true);
if (fieldValue instanceof Date) {
// needed because ConnId does not natively supports the Date type
attrValue.setStringValue(DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.format((Date) fieldValue));
} else if (Boolean.TYPE.isInstance(fieldValue)) {
attrValue.setBooleanValue((Boolean) fieldValue);
} else if (Double.TYPE.isInstance(fieldValue) || Float.TYPE.isInstance(fieldValue)) {
attrValue.setDoubleValue((Double) fieldValue);
} else if (Long.TYPE.isInstance(fieldValue) || Integer.TYPE.isInstance(fieldValue)) {
attrValue.setLongValue((Long) fieldValue);
} else {
attrValue.setStringValue(fieldValue.toString());
}
values.add(attrValue);
} catch (Exception e) {
LOG.error("Could not read value of '{}' from {}", intAttrName.getField(), reference, e);
}
}
} else if (intAttrName.getSchemaType() != null) {
switch(intAttrName.getSchemaType()) {
case PLAIN:
PlainAttr<?> attr;
if (membership == null) {
attr = reference.getPlainAttr(intAttrName.getSchemaName()).orElse(null);
} else {
attr = ((GroupableRelatable<?, ?, ?, ?, ?>) reference).getPlainAttr(intAttrName.getSchemaName(), membership).orElse(null);
}
if (attr == null) {
LOG.warn("Invalid PlainSchema {} or PlainAttr not found for {}", intAttrName.getSchemaName(), reference);
} else {
if (attr.getUniqueValue() != null) {
values.add(anyUtils.clonePlainAttrValue(attr.getUniqueValue()));
} else if (attr.getValues() != null) {
attr.getValues().forEach(value -> values.add(anyUtils.clonePlainAttrValue(value)));
}
}
break;
case DERIVED:
DerSchema derSchema = derSchemaDAO.find(intAttrName.getSchemaName());
if (derSchema == null) {
LOG.warn("Invalid DerSchema: {}", intAttrName.getSchemaName());
} else {
String derValue = membership == null ? derAttrHandler.getValue(reference, derSchema) : derAttrHandler.getValue(reference, membership, derSchema);
if (derValue != null) {
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
attrValue.setStringValue(derValue);
values.add(attrValue);
}
}
break;
case VIRTUAL:
// virtual attributes don't get transformed
transform = false;
VirSchema virSchema = virSchemaDAO.find(intAttrName.getSchemaName());
if (virSchema == null) {
LOG.warn("Invalid VirSchema: {}", intAttrName.getSchemaName());
} else {
LOG.debug("Expire entry cache {}-{}", reference, intAttrName.getSchemaName());
virAttrCache.expire(reference.getType().getKey(), reference.getKey(), intAttrName.getSchemaName());
List<String> virValues = membership == null ? virAttrHandler.getValues(reference, virSchema) : virAttrHandler.getValues(reference, membership, virSchema);
virValues.forEach(virValue -> {
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
attrValue.setStringValue(virValue);
values.add(attrValue);
});
}
break;
default:
}
} else if (intAttrName.getPrivilegesOfApplication() != null && reference instanceof User) {
Application application = applicationDAO.find(intAttrName.getPrivilegesOfApplication());
if (application == null) {
LOG.warn("Invalid application: {}", intAttrName.getPrivilegesOfApplication());
} else {
userDAO.findAllRoles((User) reference).stream().flatMap(role -> role.getPrivileges(application).stream()).forEach(privilege -> {
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
attrValue.setStringValue(privilege.getKey());
values.add(attrValue);
});
}
}
LOG.debug("Internal values: {}", values);
List<PlainAttrValue> transformed = values;
if (transform) {
for (ItemTransformer transformer : MappingUtils.getItemTransformers(mapItem)) {
transformed = transformer.beforePropagation(mapItem, any, transformed);
}
LOG.debug("Transformed values: {}", values);
} else {
LOG.debug("No transformation occurred");
}
return transformed;
}
use of org.apache.syncope.core.persistence.api.entity.resource.Mapping in project syncope by apache.
the class ResourceTest method saveInvalidProvision.
@Test
public void saveInvalidProvision() {
assertThrows(InvalidEntityException.class, () -> {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("invalidProvision");
Provision provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findUser());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
Mapping mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
connObjectKey.setExtAttrName("username");
connObjectKey.setIntAttrName("fullname");
connObjectKey.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(connObjectKey);
provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findGroup());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
resource.setConnector(connector);
// save the resource
resourceDAO.save(resource);
});
}
use of org.apache.syncope.core.persistence.api.entity.resource.Mapping in project syncope by apache.
the class ResourceDataBinderImpl method update.
@Override
public ExternalResource update(final ExternalResource resource, final ResourceTO resourceTO) {
if (resource.getKey() != null) {
ResourceTO current = getResourceTO(resource);
if (!current.equals(resourceTO)) {
// 1. save the current configuration, before update
ExternalResourceHistoryConf resourceHistoryConf = entityFactory.newEntity(ExternalResourceHistoryConf.class);
resourceHistoryConf.setCreator(AuthContextUtils.getUsername());
resourceHistoryConf.setCreation(new Date());
resourceHistoryConf.setEntity(resource);
resourceHistoryConf.setConf(current);
resourceHistoryConfDAO.save(resourceHistoryConf);
// 2. ensure the maximum history size is not exceeded
List<ExternalResourceHistoryConf> history = resourceHistoryConfDAO.findByEntity(resource);
long maxHistorySize = confDAO.find("resource.conf.history.size", 10L);
if (maxHistorySize < history.size()) {
// always remove the last item since history was obtained by a query with ORDER BY creation DESC
for (int i = 0; i < history.size() - maxHistorySize; i++) {
resourceHistoryConfDAO.delete(history.get(history.size() - 1).getKey());
}
}
}
}
resource.setKey(resourceTO.getKey());
if (resourceTO.getConnector() != null) {
ConnInstance connector = connInstanceDAO.find(resourceTO.getConnector());
resource.setConnector(connector);
if (!connector.getResources().contains(resource)) {
connector.add(resource);
}
}
resource.setEnforceMandatoryCondition(resourceTO.isEnforceMandatoryCondition());
resource.setPropagationPriority(resourceTO.getPropagationPriority());
resource.setRandomPwdIfNotProvided(resourceTO.isRandomPwdIfNotProvided());
// 1. add or update all (valid) provisions from TO
resourceTO.getProvisions().forEach(provisionTO -> {
AnyType anyType = anyTypeDAO.find(provisionTO.getAnyType());
if (anyType == null) {
LOG.debug("Invalid {} specified {}, ignoring...", AnyType.class.getSimpleName(), provisionTO.getAnyType());
} else {
Provision provision = resource.getProvision(anyType).orElse(null);
if (provision == null) {
provision = entityFactory.newEntity(Provision.class);
provision.setResource(resource);
resource.add(provision);
provision.setAnyType(anyType);
}
if (provisionTO.getObjectClass() == null) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidProvision);
sce.getElements().add("Null " + ObjectClass.class.getSimpleName());
throw sce;
}
provision.setObjectClass(new ObjectClass(provisionTO.getObjectClass()));
// add all classes contained in the TO
for (String name : provisionTO.getAuxClasses()) {
AnyTypeClass anyTypeClass = anyTypeClassDAO.find(name);
if (anyTypeClass == null) {
LOG.warn("Ignoring invalid {}: {}", AnyTypeClass.class.getSimpleName(), name);
} else {
provision.add(anyTypeClass);
}
}
// remove all classes not contained in the TO
provision.getAuxClasses().removeIf(anyTypeClass -> !provisionTO.getAuxClasses().contains(anyTypeClass.getKey()));
if (provisionTO.getMapping() == null) {
provision.setMapping(null);
} else {
Mapping mapping = provision.getMapping();
if (mapping == null) {
mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
} else {
mapping.getItems().clear();
}
AnyTypeClassTO allowedSchemas = new AnyTypeClassTO();
for (Iterator<AnyTypeClass> itor = new IteratorChain<>(provision.getAnyType().getClasses().iterator(), provision.getAuxClasses().iterator()); itor.hasNext(); ) {
AnyTypeClass anyTypeClass = itor.next();
allowedSchemas.getPlainSchemas().addAll(anyTypeClass.getPlainSchemas().stream().map(s -> s.getKey()).collect(Collectors.toList()));
allowedSchemas.getDerSchemas().addAll(anyTypeClass.getDerSchemas().stream().map(s -> s.getKey()).collect(Collectors.toList()));
allowedSchemas.getVirSchemas().addAll(anyTypeClass.getVirSchemas().stream().map(s -> s.getKey()).collect(Collectors.toList()));
}
populateMapping(provisionTO.getMapping(), mapping, allowedSchemas);
}
if (provisionTO.getVirSchemas().isEmpty()) {
for (VirSchema schema : virSchemaDAO.findByProvision(provision)) {
virSchemaDAO.delete(schema.getKey());
}
} else {
for (String schemaName : provisionTO.getVirSchemas()) {
VirSchema schema = virSchemaDAO.find(schemaName);
if (schema == null) {
LOG.debug("Invalid {} specified: {}, ignoring...", VirSchema.class.getSimpleName(), schemaName);
} else {
schema.setProvision(provision);
}
}
}
}
});
// 2. remove all provisions not contained in the TO
for (Iterator<? extends Provision> itor = resource.getProvisions().iterator(); itor.hasNext(); ) {
Provision provision = itor.next();
if (resourceTO.getProvision(provision.getAnyType().getKey()) == null) {
virSchemaDAO.findByProvision(provision).forEach(schema -> {
virSchemaDAO.delete(schema.getKey());
});
itor.remove();
}
}
// 3. orgUnit
if (resourceTO.getOrgUnit() == null && resource.getOrgUnit() != null) {
resource.getOrgUnit().setResource(null);
resource.setOrgUnit(null);
} else if (resourceTO.getOrgUnit() != null) {
OrgUnitTO orgUnitTO = resourceTO.getOrgUnit();
OrgUnit orgUnit = resource.getOrgUnit();
if (orgUnit == null) {
orgUnit = entityFactory.newEntity(OrgUnit.class);
orgUnit.setResource(resource);
resource.setOrgUnit(orgUnit);
}
if (orgUnitTO.getObjectClass() == null) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidOrgUnit);
sce.getElements().add("Null " + ObjectClass.class.getSimpleName());
throw sce;
}
orgUnit.setObjectClass(new ObjectClass(orgUnitTO.getObjectClass()));
if (orgUnitTO.getConnObjectLink() == null) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidOrgUnit);
sce.getElements().add("Null connObjectLink");
throw sce;
}
orgUnit.setConnObjectLink(orgUnitTO.getConnObjectLink());
SyncopeClientCompositeException scce = SyncopeClientException.buildComposite();
SyncopeClientException invalidMapping = SyncopeClientException.build(ClientExceptionType.InvalidMapping);
SyncopeClientException requiredValuesMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
orgUnit.getItems().clear();
for (ItemTO itemTO : orgUnitTO.getItems()) {
if (itemTO == null) {
LOG.error("Null {}", ItemTO.class.getSimpleName());
invalidMapping.getElements().add("Null " + ItemTO.class.getSimpleName());
} else if (itemTO.getIntAttrName() == null) {
requiredValuesMissing.getElements().add("intAttrName");
scce.addException(requiredValuesMissing);
} else {
if (!"name".equals(itemTO.getIntAttrName()) && !"fullpath".equals(itemTO.getIntAttrName())) {
LOG.error("Only 'name' and 'fullpath' are supported for Realms");
invalidMapping.getElements().add("Only 'name' and 'fullpath' are supported for Realms");
} else {
// no mandatory condition implies mandatory condition false
if (!JexlUtils.isExpressionValid(itemTO.getMandatoryCondition() == null ? "false" : itemTO.getMandatoryCondition())) {
SyncopeClientException invalidMandatoryCondition = SyncopeClientException.build(ClientExceptionType.InvalidValues);
invalidMandatoryCondition.getElements().add(itemTO.getMandatoryCondition());
scce.addException(invalidMandatoryCondition);
}
OrgUnitItem item = entityFactory.newEntity(OrgUnitItem.class);
BeanUtils.copyProperties(itemTO, item, ITEM_IGNORE_PROPERTIES);
item.setOrgUnit(orgUnit);
if (item.isConnObjectKey()) {
orgUnit.setConnObjectKeyItem(item);
} else {
orgUnit.add(item);
}
itemTO.getTransformers().forEach(transformerKey -> {
Implementation transformer = implementationDAO.find(transformerKey);
if (transformer == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", transformerKey);
} else {
item.add(transformer);
}
});
// remove all implementations not contained in the TO
item.getTransformers().removeIf(implementation -> !itemTO.getTransformers().contains(implementation.getKey()));
}
}
}
if (!invalidMapping.getElements().isEmpty()) {
scce.addException(invalidMapping);
}
if (scce.hasExceptions()) {
throw scce;
}
}
resource.setCreateTraceLevel(resourceTO.getCreateTraceLevel());
resource.setUpdateTraceLevel(resourceTO.getUpdateTraceLevel());
resource.setDeleteTraceLevel(resourceTO.getDeleteTraceLevel());
resource.setProvisioningTraceLevel(resourceTO.getProvisioningTraceLevel());
resource.setPasswordPolicy(resourceTO.getPasswordPolicy() == null ? null : (PasswordPolicy) policyDAO.find(resourceTO.getPasswordPolicy()));
resource.setAccountPolicy(resourceTO.getAccountPolicy() == null ? null : (AccountPolicy) policyDAO.find(resourceTO.getAccountPolicy()));
resource.setPullPolicy(resourceTO.getPullPolicy() == null ? null : (PullPolicy) policyDAO.find(resourceTO.getPullPolicy()));
resource.setConfOverride(new HashSet<>(resourceTO.getConfOverride()));
resource.setOverrideCapabilities(resourceTO.isOverrideCapabilities());
resource.getCapabilitiesOverride().clear();
resource.getCapabilitiesOverride().addAll(resourceTO.getCapabilitiesOverride());
resourceTO.getPropagationActions().forEach(propagationActionKey -> {
Implementation propagationAction = implementationDAO.find(propagationActionKey);
if (propagationAction == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", propagationActionKey);
} else {
resource.add(propagationAction);
}
});
// remove all implementations not contained in the TO
resource.getPropagationActions().removeIf(implementation -> !resourceTO.getPropagationActions().contains(implementation.getKey()));
return resource;
}
use of org.apache.syncope.core.persistence.api.entity.resource.Mapping in project syncope by apache.
the class ResourceDataBinderImpl method populateMapping.
private void populateMapping(final MappingTO mappingTO, final Mapping mapping, final AnyTypeClassTO allowedSchemas) {
mapping.setConnObjectLink(mappingTO.getConnObjectLink());
SyncopeClientCompositeException scce = SyncopeClientException.buildComposite();
SyncopeClientException invalidMapping = SyncopeClientException.build(ClientExceptionType.InvalidMapping);
SyncopeClientException requiredValuesMissing = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
for (ItemTO itemTO : mappingTO.getItems()) {
if (itemTO == null) {
LOG.error("Null {}", ItemTO.class.getSimpleName());
invalidMapping.getElements().add("Null " + ItemTO.class.getSimpleName());
} else if (itemTO.getIntAttrName() == null) {
requiredValuesMissing.getElements().add("intAttrName");
scce.addException(requiredValuesMissing);
} else {
IntAttrName intAttrName = null;
try {
intAttrName = intAttrNameParser.parse(itemTO.getIntAttrName(), mapping.getProvision().getAnyType().getKind());
} catch (ParseException e) {
LOG.error("Invalid intAttrName '{}'", itemTO.getIntAttrName(), e);
}
if (intAttrName == null || intAttrName.getSchemaType() == null && intAttrName.getField() == null && intAttrName.getPrivilegesOfApplication() == null) {
LOG.error("'{}' not existing", itemTO.getIntAttrName());
invalidMapping.getElements().add("'" + itemTO.getIntAttrName() + "' not existing");
} else {
boolean allowed = true;
if (intAttrName.getSchemaType() != null && intAttrName.getEnclosingGroup() == null && intAttrName.getRelatedAnyObject() == null && intAttrName.getPrivilegesOfApplication() == null) {
switch(intAttrName.getSchemaType()) {
case PLAIN:
allowed = allowedSchemas.getPlainSchemas().contains(intAttrName.getSchemaName());
break;
case DERIVED:
allowed = allowedSchemas.getDerSchemas().contains(intAttrName.getSchemaName());
break;
case VIRTUAL:
allowed = allowedSchemas.getVirSchemas().contains(intAttrName.getSchemaName());
break;
default:
}
}
if (allowed) {
// no mandatory condition implies mandatory condition false
if (!JexlUtils.isExpressionValid(itemTO.getMandatoryCondition() == null ? "false" : itemTO.getMandatoryCondition())) {
SyncopeClientException invalidMandatoryCondition = SyncopeClientException.build(ClientExceptionType.InvalidValues);
invalidMandatoryCondition.getElements().add(itemTO.getMandatoryCondition());
scce.addException(invalidMandatoryCondition);
}
MappingItem item = entityFactory.newEntity(MappingItem.class);
BeanUtils.copyProperties(itemTO, item, ITEM_IGNORE_PROPERTIES);
item.setMapping(mapping);
if (item.isConnObjectKey()) {
if (intAttrName.getSchemaType() == SchemaType.VIRTUAL) {
invalidMapping.getElements().add("Virtual attributes cannot be set as ConnObjectKey");
}
if ("password".equals(intAttrName.getField())) {
invalidMapping.getElements().add("Password attributes cannot be set as ConnObjectKey");
}
mapping.setConnObjectKeyItem(item);
} else {
mapping.add(item);
}
itemTO.getTransformers().forEach(transformerKey -> {
Implementation transformer = implementationDAO.find(transformerKey);
if (transformer == null) {
LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", transformerKey);
} else {
item.add(transformer);
}
});
// remove all implementations not contained in the TO
item.getTransformers().removeIf(implementation -> !itemTO.getTransformers().contains(implementation.getKey()));
if (intAttrName.getEnclosingGroup() != null && item.getPurpose() != MappingPurpose.PROPAGATION) {
invalidMapping.getElements().add("Only " + MappingPurpose.PROPAGATION.name() + " allowed when referring to groups");
}
if (intAttrName.getRelatedAnyObject() != null && item.getPurpose() != MappingPurpose.PROPAGATION) {
invalidMapping.getElements().add("Only " + MappingPurpose.PROPAGATION.name() + " allowed when referring to any objects");
}
if (intAttrName.getPrivilegesOfApplication() != null && item.getPurpose() != MappingPurpose.PROPAGATION) {
invalidMapping.getElements().add("Only " + MappingPurpose.PROPAGATION.name() + " allowed when referring to privileges");
}
if (intAttrName.getSchemaType() == SchemaType.DERIVED && item.getPurpose() != MappingPurpose.PROPAGATION) {
invalidMapping.getElements().add("Only " + MappingPurpose.PROPAGATION.name() + " allowed for derived");
}
if (intAttrName.getSchemaType() == SchemaType.VIRTUAL) {
if (item.getPurpose() != MappingPurpose.PROPAGATION) {
invalidMapping.getElements().add("Only " + MappingPurpose.PROPAGATION.name() + " allowed for virtual");
}
VirSchema schema = virSchemaDAO.find(item.getIntAttrName());
if (schema != null && schema.getProvision().equals(item.getMapping().getProvision())) {
invalidMapping.getElements().add("No need to map virtual schema on linking resource");
}
}
} else {
LOG.error("'{}' not allowed", itemTO.getIntAttrName());
invalidMapping.getElements().add("'" + itemTO.getIntAttrName() + "' not allowed");
}
}
}
}
if (!invalidMapping.getElements().isEmpty()) {
scce.addException(invalidMapping);
}
if (scce.hasExceptions()) {
throw scce;
}
}
Aggregations