@SuppressWarnings("unchecked") public B auxClass(final StringPatchItem auxClass) { getInstance().getAuxClasses().add(auxClass); return (B) this; }
@SuppressWarnings("unchecked") public B plainAttr(final AttrPatch plainAttr) { getInstance().getPlainAttrs().add(plainAttr); return (B) this; }
@SuppressWarnings("unchecked") public B resources(final Collection<StringPatchItem> resources) { getInstance().getResources().addAll(resources); return (B) this; }
private static <T extends AnyTO, K extends AnyUR> void patch(final T to, final K req, final T result) { if (to.getKey() == null || !to.getKey().equals(req.getKey())) { throw new IllegalArgumentException( to.getClass().getSimpleName() + " and " + req.getClass().getSimpleName() if (req.getRealm() != null) { result.setRealm(req.getRealm().getValue()); for (StringPatchItem auxClassPatch : req.getAuxClasses()) { switch (auxClassPatch.getOperation()) { case ADD_REPLACE: result.getPlainAttrs().addAll(patch(EntityTOUtils.buildAttrMap(to.getPlainAttrs()), req.getPlainAttrs())); result.getVirAttrs().addAll(req.getVirAttrs()); for (StringPatchItem resourcePatch : req.getResources()) { switch (resourcePatch.getOperation()) { case ADD_REPLACE:
result.setKey(updated.getKey()); result.setRealm(replacePatchItem(updated.getRealm(), original.getRealm(), new StringReplacePatchItem())); result.getAuxClasses().clear(); result.getAuxClasses().add(new StringPatchItem.Builder(). operation(PatchOperation.DELETE).value(auxClass).build()); }); result.getAuxClasses().add(new StringPatchItem.Builder(). operation(PatchOperation.ADD_REPLACE).value(auxClass).build()); }); result.getPlainAttrs().clear(); result.getPlainAttrs().add(new AttrPatch.Builder(new Attr.Builder(schema).build()). operation(PatchOperation.DELETE). build()); if (isEmpty(attr)) { if (!incremental) { result.getPlainAttrs().add(new AttrPatch.Builder(new Attr.Builder(attr.getSchema()).build()). operation(PatchOperation.DELETE). build()); result.getPlainAttrs().add(patch); result.getVirAttrs().clear();
} else { previousUserTO = new UserRestClient(). read(remediationTO.getAnyURPayload().getKey()); newUserTO = AnyOperations.patch( previousUserTO, (UserUR) remediationTO.getAnyURPayload()); } else { previousGroupTO = new GroupRestClient(). read(remediationTO.getAnyURPayload().getKey()); newGroupTO = AnyOperations.patch( previousGroupTO, (GroupUR) remediationTO.getAnyURPayload()); } else { previousAnyObjectTO = new AnyObjectRestClient(). read(remediationTO.getAnyURPayload().getKey()); newAnyObjectTO = AnyOperations.patch( previousAnyObjectTO, (AnyObjectUR) remediationTO.getAnyURPayload());
@SuppressWarnings("unchecked") public B virAttrs(final Collection<Attr> virAttrs) { getInstance().getVirAttrs().addAll(virAttrs); return (B) this; }
@Override public boolean isEmpty() { return super.isEmpty() && name == null && userOwner == null && groupOwner == null; }
@Override public int hashCode() { return new HashCodeBuilder(). appendSuper(super.hashCode()). append(name). append(userOwner). append(groupOwner). append(udynMembershipCond). append(adynMembershipConds). append(typeExtensions). build(); }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final UserUR other = (UserUR) obj; return new EqualsBuilder(). appendSuper(super.equals(obj)). append(username, other.username). append(securityQuestion, other.securityQuestion). append(securityAnswer, other.securityAnswer). append(mustChangePassword, other.mustChangePassword). append(relationships, other.relationships). append(memberships, other.memberships). append(roles, other.roles). build(); } }
Builder(final String key) { getInstance().setKey(key); }
@SuppressWarnings("unchecked") public B virAttr(final Attr virAttr) { getInstance().getVirAttrs().add(virAttr); return (B) this; }
@Override public boolean isEmpty() { return super.isEmpty() && name == null && relationships.isEmpty() && memberships.isEmpty(); }
@Override public int hashCode() { return new HashCodeBuilder(). appendSuper(super.hashCode()). append(name). append(relationships). append(memberships). build(); }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AnyObjectUR other = (AnyObjectUR) obj; return new EqualsBuilder(). appendSuper(super.equals(obj)). append(name, other.name). append(relationships, other.relationships). append(memberships, other.memberships). build(); } }
@SuppressWarnings("unchecked") public B plainAttrs(final Collection<AttrPatch> plainAttrs) { getInstance().getPlainAttrs().addAll(plainAttrs); return (B) this; }
@SuppressWarnings("unchecked") public B virAttrs(final Attr... virAttrs) { getInstance().getVirAttrs().addAll(Arrays.asList(virAttrs)); return (B) this; }
@Override public boolean isEmpty() { return super.isEmpty() && username == null && password == null && securityQuestion == null && securityAnswer == null && mustChangePassword == null && relationships.isEmpty() && memberships.isEmpty() && roles.isEmpty(); }
@SuppressWarnings("unchecked") public B auxClasses(final StringPatchItem... auxClasses) { getInstance().getAuxClasses().addAll(Arrays.asList(auxClasses)); return (B) this; }
@SuppressWarnings("unchecked") public B resources(final StringPatchItem... resources) { getInstance().getResources().addAll(Arrays.asList(resources)); return (B) this; }