use of org.apache.syncope.common.lib.to.AttrTO 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.to.AttrTO in project syncope by apache.
the class DefaultUserWorkflowAdapter method doUpdate.
@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doUpdate(final User user, final UserPatch userPatch) {
UserTO original = dataBinder.getUserTO(user, true);
PropagationByResource propByRes = dataBinder.update(user, userPatch);
PasswordPatch password = userPatch.getPassword();
Set<AttrTO> virAttrs = userPatch.getVirAttrs();
UserTO updated = dataBinder.getUserTO(userDAO.save(user), true);
UserPatch effectivePatch = AnyOperations.diff(updated, original, false);
effectivePatch.setPassword(password);
effectivePatch.getVirAttrs().clear();
effectivePatch.getVirAttrs().addAll(virAttrs);
return new WorkflowResult<>(Pair.of(effectivePatch, !user.isSuspended()), propByRes, "update");
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class UserITCase method updateMultivalueAttribute.
@Test
public void updateMultivalueAttribute() {
UserTO userTO = getUniqueSampleTO("multivalue@syncope.apache.org");
userTO.getResources().clear();
userTO.getVirAttrs().clear();
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
AttrTO loginDate = userTO.getPlainAttr("loginDate").get();
assertNotNull(loginDate);
assertEquals(1, loginDate.getValues().size());
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
loginDate.getValues().add("2000-01-01");
userPatch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(loginDate).build());
userTO = updateUser(userPatch).getEntity();
assertNotNull(userTO);
loginDate = userTO.getPlainAttr("loginDate").get();
assertNotNull(loginDate);
assertEquals(2, loginDate.getValues().size());
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class UserITCase method enforceMandatoryCondition.
@Test
public void enforceMandatoryCondition() {
UserTO userTO = getUniqueSampleTO("enforce@apache.org");
userTO.getResources().add(RESOURCE_NAME_WS2);
userTO.setPassword("newPassword12");
AttrTO type = null;
for (AttrTO attr : userTO.getPlainAttrs()) {
if ("ctype".equals(attr.getSchema())) {
type = attr;
}
}
assertNotNull(type);
userTO.getPlainAttrs().remove(type);
try {
userTO = createUser(userTO).getEntity();
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
userTO.getPlainAttrs().add(type);
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class UserITCase method createWithRequiredValueMissing.
@Test
public void createWithRequiredValueMissing() {
UserTO userTO = getUniqueSampleTO("a.b@c.it");
AttrTO type = userTO.getPlainAttr("ctype").get();
userTO.getPlainAttrs().remove(type);
userTO.getMemberships().add(new MembershipTO.Builder().group("f779c0d4-633b-4be5-8f57-32eb478a3ca5").build());
// 1. create user without type (mandatory by UserSchema)
try {
createUser(userTO);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
userTO.getPlainAttrs().add(attrTO("ctype", "F"));
AttrTO surname = userTO.getPlainAttr("surname").get();
userTO.getPlainAttrs().remove(surname);
// 2. create user without surname (mandatory when type == 'F')
try {
createUser(userTO);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
}
Aggregations