use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class AnyOperations method diff.
/**
* Calculate modifications needed by first in order to be equal to second.
*
* @param updated updated GroupTO
* @param original original GroupTO
* @param incremental perform incremental diff (without removing existing info)
* @return GroupPatch containing differences
*/
public static GroupPatch diff(final GroupTO updated, final GroupTO original, final boolean incremental) {
GroupPatch result = new GroupPatch();
diff(updated, original, result, incremental);
// 1. name
result.setName(replacePatchItem(updated.getName(), original.getName(), new StringReplacePatchItem()));
// 2. ownership
result.setUserOwner(replacePatchItem(updated.getUserOwner(), original.getUserOwner(), new StringReplacePatchItem()));
result.setGroupOwner(replacePatchItem(updated.getGroupOwner(), original.getGroupOwner(), new StringReplacePatchItem()));
// 3. dynamic membership
result.setUDynMembershipCond(updated.getUDynMembershipCond());
result.getADynMembershipConds().putAll(updated.getADynMembershipConds());
// 4. type extensions
result.getTypeExtensions().addAll(updated.getTypeExtensions());
return result;
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class DefaultGroupWorkflowAdapter method doUpdate.
@Override
protected WorkflowResult<GroupPatch> doUpdate(final Group group, final GroupPatch groupPatch) {
GroupTO original = dataBinder.getGroupTO(group, true);
PropagationByResource propByRes = dataBinder.update(group, groupPatch);
Set<AttrTO> virAttrs = groupPatch.getVirAttrs();
GroupTO updated = dataBinder.getGroupTO(groupDAO.save(group), true);
GroupPatch effectivePatch = AnyOperations.diff(updated, original, false);
effectivePatch.getVirAttrs().clear();
effectivePatch.getVirAttrs().addAll(virAttrs);
return new WorkflowResult<>(effectivePatch, propByRes, "update");
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class CamelGroupProvisioningManager method link.
@Override
public String link(final GroupPatch groupPatch) {
PollingConsumer pollingConsumer = getConsumer("direct:linkGroupPort");
sendMessage("direct:linkGroup", groupPatch);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(GroupPatch.class).getKey();
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupITCase method patch.
@Test
public void patch() {
GroupTO original = getBasicSampleTO("patch");
original.setUDynMembershipCond("(($groups==3;$resources!=ws-target-resource-1);aLong==1)");
original.getADynMembershipConds().put("PRINTER", "(($groups==7;cool==ss);$resources==ws-target-resource-2);$type==PRINTER");
GroupTO updated = createGroup(original).getEntity();
updated.getPlainAttrs().add(new AttrTO.Builder().schema("icon").build());
updated.getPlainAttrs().add(new AttrTO.Builder().schema("show").build());
updated.getPlainAttrs().add(new AttrTO.Builder().schema("rderived_sx").value("sx").build());
updated.getPlainAttrs().add(new AttrTO.Builder().schema("rderived_dx").value("dx").build());
updated.getPlainAttrs().add(new AttrTO.Builder().schema("title").value("mr").build());
original = groupService.read(updated.getKey());
GroupPatch patch = AnyOperations.diff(updated, original, true);
GroupTO group = updateGroup(patch).getEntity();
Map<String, AttrTO> attrs = EntityTOUtils.buildAttrMap(group.getPlainAttrs());
assertFalse(attrs.containsKey("icon"));
assertFalse(attrs.containsKey("show"));
assertEquals(Collections.singletonList("sx"), attrs.get("rderived_sx").getValues());
assertEquals(Collections.singletonList("dx"), attrs.get("rderived_dx").getValues());
assertEquals(Collections.singletonList("mr"), attrs.get("title").getValues());
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupITCase method issueSYNCOPE717.
@Test
public void issueSYNCOPE717() {
String doubleSchemaName = "double" + getUUIDString();
// 1. create double schema without conversion pattern
PlainSchemaTO schema = new PlainSchemaTO();
schema.setKey(doubleSchemaName);
schema.setType(AttrSchemaType.Double);
schema = createSchema(SchemaType.PLAIN, schema);
assertNotNull(schema);
assertNull(schema.getConversionPattern());
AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
assertNotNull(minimalGroup);
minimalGroup.getPlainSchemas().add(doubleSchemaName);
anyTypeClassService.update(minimalGroup);
// 2. create group, provide valid input value
GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 3. update schema, set conversion pattern
schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
schema.setConversionPattern("0.000");
schemaService.update(SchemaType.PLAIN, schema);
// 4. re-read group, verify that pattern was applied
groupTO = groupService.read(groupTO.getKey());
assertNotNull(groupTO);
assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 5. modify group with new double value
GroupPatch patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 6. update schema, unset conversion pattern
schema.setConversionPattern(null);
schemaService.update(SchemaType.PLAIN, schema);
// 7. modify group with new double value, verify that no pattern is applied
patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
}
Aggregations