use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class CamelAnyObjectProvisioningManager method unlink.
@Override
public String unlink(final AnyObjectPatch anyObjectPatch) {
PollingConsumer pollingConsumer = getConsumer("direct:unlinkAnyObjectPort");
sendMessage("direct:unlinkAnyObject", anyObjectPatch);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(AnyObjectPatch.class).getKey();
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class AnyObjectITCase method update.
@Test
public void update() {
AnyObjectTO anyObjectTO = getSampleTO("update");
anyObjectTO = createAnyObject(anyObjectTO).getEntity();
assertEquals(1, anyObjectTO.getPlainAttrs().size());
AnyObjectPatch anyObjectPatch = new AnyObjectPatch();
anyObjectPatch.setKey(anyObjectTO.getKey());
String newLocation = "new" + getUUIDString();
anyObjectPatch.getPlainAttrs().add(attrAddReplacePatch("location", newLocation));
anyObjectTO = updateAnyObject(anyObjectPatch).getEntity();
assertEquals(newLocation, anyObjectTO.getPlainAttr("location").get().getValues().get(0));
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class DefaultAnyObjectProvisioningManager method update.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public Pair<AnyObjectPatch, List<PropagationStatus>> update(final AnyObjectPatch anyObjectPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) {
WorkflowResult<AnyObjectPatch> updated = awfAdapter.update(anyObjectPatch);
List<PropagationTaskTO> tasks = propagationManager.getUpdateTasks(AnyTypeKind.ANY_OBJECT, updated.getResult().getKey(), false, null, updated.getPropByRes(), anyObjectPatch.getVirAttrs(), excludedResources);
PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
return Pair.of(updated.getResult(), propagationReporter.getStatuses());
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class AnyOperations method patch.
public static AnyObjectTO patch(final AnyObjectTO anyObjectTO, final AnyObjectPatch anyObjectPatch) {
AnyObjectTO result = SerializationUtils.clone(anyObjectTO);
patch(anyObjectTO, anyObjectPatch, result);
if (anyObjectPatch.getName() != null) {
result.setName(anyObjectPatch.getName().getValue());
}
// 1. relationships
anyObjectPatch.getRelationships().forEach(relPatch -> {
if (relPatch.getRelationshipTO() == null) {
LOG.warn("Invalid {} specified: {}", RelationshipPatch.class.getName(), relPatch);
} else {
result.getRelationships().remove(relPatch.getRelationshipTO());
if (relPatch.getOperation() == PatchOperation.ADD_REPLACE) {
result.getRelationships().add(relPatch.getRelationshipTO());
}
}
});
// 2. memberships
anyObjectPatch.getMemberships().forEach(membPatch -> {
if (membPatch.getGroup() == null) {
LOG.warn("Invalid {} specified: {}", MembershipPatch.class.getName(), membPatch);
} else {
Optional<MembershipTO> memb = result.getMemberships().stream().filter(membership -> membPatch.getGroup().equals(membership.getGroupKey())).findFirst();
if (memb.isPresent()) {
result.getMemberships().remove(memb.get());
}
if (membPatch.getOperation() == PatchOperation.ADD_REPLACE) {
MembershipTO newMembershipTO = new MembershipTO.Builder().group(membPatch.getGroup()).build();
// 3. plain attributes
newMembershipTO.getPlainAttrs().addAll(membPatch.getPlainAttrs());
// 4. virtual attributes
newMembershipTO.getVirAttrs().addAll(membPatch.getVirAttrs());
result.getMemberships().add(newMembershipTO);
}
}
});
return result;
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class RemediationLogic method remedy.
@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_REMEDY + "')")
public ProvisioningResult<?> remedy(final String key, final AnyPatch anyPatch, final boolean nullPriorityAsync) {
Remediation remediation = remediationDAO.find(key);
if (remediation == null) {
LOG.error("Could not find remediation '" + key + "'");
throw new NotFoundException(key);
}
ProvisioningResult<?> result;
switch(remediation.getAnyType().getKind()) {
case USER:
default:
result = userLogic.update((UserPatch) anyPatch, nullPriorityAsync);
break;
case GROUP:
result = groupLogic.update((GroupPatch) anyPatch, nullPriorityAsync);
break;
case ANY_OBJECT:
result = anyObjectLogic.update((AnyObjectPatch) anyPatch, nullPriorityAsync);
}
remediationDAO.delete(remediation);
return result;
}
Aggregations