AssignmentType cloneAndCanonicalizeAssignment(AssignmentType assignmentType) { AssignmentType assignmentClone = assignmentType.clone(); PrismContainerValue.copyDefinition(assignmentClone, assignmentType, prismContext); assignmentClone.setTarget(null); return assignmentClone; }
AssignmentType cloneAndCanonicalizeAssignment(AssignmentType assignmentType) { AssignmentType assignmentClone = assignmentType.clone(); PrismContainerValue.copyDefinition(assignmentClone, assignmentType, prismContext); ConstructionType constructionType = assignmentClone.getConstruction(); if (constructionType != null) { // it should always be non-null constructionType.setResource(null); } return assignmentClone; } }
protected void unassignRoleByAssignmentValue(PrismObject<? extends FocusType> focus, String roleOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { AssignmentType assignment = findAssignmentByTargetRequired(focus, roleOid); ObjectDelta<? extends FocusType> delta = prismContext.deltaFor(focus.getCompileTimeClass()) .item(FocusType.F_ASSIGNMENT) .delete(assignment.clone()) .asObjectDeltaCast(focus.getOid()); modelService.executeChanges(singleton(delta), null, task, result); }
@SuppressWarnings("unchecked") private ObjectDelta<? extends FocusType> assignmentToDelta(Class<? extends Objectable> focusClass, AssignmentType assignmentType, boolean assignmentRemoved, String objectOid) throws SchemaException { PrismContainerValue value = assignmentType.clone().asPrismContainerValue(); S_ValuesEntry item = prismContext.deltaFor(focusClass) .item(FocusType.F_ASSIGNMENT); S_ItemEntry op = assignmentRemoved ? item.delete(value) : item.add(value); return op.asObjectDelta(objectOid); }
private AssignmentType toDelete(AssignmentType assignment, boolean byId) { if (assignment == null) { return null; } if (!byId) { return assignment.clone(); } else { AssignmentType rv = new AssignmentType(prismContext); rv.setId(assignment.getId()); return rv; } }
private ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> createAssignmentIdiAdd( PrismContainerValue<AssignmentType> cval) throws SchemaException { ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> idi = new ItemDeltaItem<>(); idi.setItemOld(null); @SuppressWarnings({"unchecked", "raw"}) ItemDelta<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> itemDelta = (ItemDelta<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>>) getDeltaItemFragment(cval) .add(cval.asContainerable().clone()) .asItemDelta(); idi.setDelta(itemDelta); idi.recompute(); return idi; }
private void processAssignment(AssignmentType assignment, ObjectType object, List<AccessCertificationCaseType> caseList) { AccessCertificationAssignmentCaseType assignmentCase = new AccessCertificationAssignmentCaseType(prismContext); assignmentCase.setAssignment(assignment.clone()); assignmentCase.setObjectRef(ObjectTypeUtil.createObjectRef(object, prismContext)); assignmentCase.setTenantRef(assignment.getTenantRef()); assignmentCase.setOrgRef(assignment.getOrgRef()); assignmentCase.setActivation(assignment.getActivation()); if (assignment.getTargetRef() != null) { assignmentCase.setTargetRef(assignment.getTargetRef()); } else { // very strange: assignment with no target, but participating in the exclusion? // maybe a dynamic target, though } caseList.add(assignmentCase); }
private void deleteAssignment(PrismObject<UserType> user, int index, Task task, OperationResult result) { try { login(userAdministrator); @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta<UserType> objectDelta = deltaFor(UserType.class) .item(FocusType.F_ASSIGNMENT).delete(user.asObjectable().getAssignment().get(index).clone()) .asObjectDelta(USER_JACK_OID); modelService.executeChanges(Collections.singletonList(objectDelta), null, task, Collections.singletonList(new DelayingProgressListener(0, 1000)), result); } catch (Throwable t) { throw new SystemException(t); } }
private ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> createAssignmentIdiDelete( PrismContainerValue<AssignmentType> cval) throws SchemaException { ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> idi = new ItemDeltaItem<>(); idi.setItemOld(LensUtil.createAssignmentSingleValueContainerClone(cval.asContainerable())); @SuppressWarnings({"unchecked", "raw"}) ItemDelta<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> itemDelta = (ItemDelta<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>>) getDeltaItemFragment(cval) .delete(cval.asContainerable().clone()) .asItemDelta(); idi.setDelta(itemDelta); idi.recompute(); return idi; }
/** * Creates a new {@code EvaluatedExclusionTriggerType} instance by deeply copying a given {@code EvaluatedExclusionTriggerType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public EvaluatedExclusionTriggerType(final EvaluatedExclusionTriggerType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(o); if (o == null) { throw new NullPointerException("Cannot create a copy of 'EvaluatedExclusionTriggerType' from 'null'."); } // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType this.conflictingObjectRef = ((o.conflictingObjectRef == null)?null:((o.getConflictingObjectRef() == null)?null:o.getConflictingObjectRef().clone())); // CClassInfo: com.evolveum.prism.xml.ns._public.types_3.PolyStringType this.conflictingObjectDisplayName = ((o.conflictingObjectDisplayName == null)?null:((o.getConflictingObjectDisplayName() == null)?null:o.getConflictingObjectDisplayName().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType this.conflictingObjectPath = ((o.conflictingObjectPath == null)?null:((o.getConflictingObjectPath() == null)?null:o.getConflictingObjectPath().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType this.conflictingAssignment = ((o.conflictingAssignment == null)?null:((o.getConflictingAssignment() == null)?null:o.getConflictingAssignment().clone())); }
clone.assignment = ((this.assignment == null)?null:((this.getAssignment() == null)?null:this.getAssignment().clone()));
@NotNull @Override public AssignmentPathSegmentType toAssignmentPathSegmentType(boolean includeAssignmentsContent) { AssignmentPathSegmentType rv = new AssignmentPathSegmentType(); AssignmentType assignment = getAssignment(evaluatedForOld); // a bit of hack, but probably ok for now if (assignment != null) { if (includeAssignmentsContent) { rv.setAssignment(assignment.clone()); } rv.setAssignmentId(assignment.getId()); } if (source != null) { rv.setSourceRef(ObjectTypeUtil.createObjectRef(source, prismContext)); rv.setSourceDisplayName(ObjectTypeUtil.getDisplayName(source)); } if (target != null) { rv.setTargetRef(ObjectTypeUtil.createObjectRef(target, prismContext)); rv.setTargetDisplayName(ObjectTypeUtil.getDisplayName(target)); } rv.setMatchingOrder(isMatchingOrder()); rv.setIsAssignment(isAssignment); return rv; }
@Test public void testAssignmentHashcode3() throws SchemaException { LOGGER.info("\n\n===[ testAssignmentHashcode3 ]===\n"); System.out.println("\n\n===[ testAssignmentHashcode3 ]===\n"); PrismContext prismContext = PrismTestUtil.getPrismContext(); AssignmentType a1a = new AssignmentType(prismContext) .beginActivation() .validTo("2018-01-01T00:00:00.000+01:00") .end(); AssignmentType a1b = a1a.clone(); // use unqualified item name for validTo a1b.getActivation().asPrismContainerValue() .findItem(ActivationType.F_VALID_TO) .setElementName(new QName("validTo")); System.out.println("a1a = " + a1a.asPrismContainerValue().debugDump()); System.out.println("a1b = " + a1b.asPrismContainerValue().debugDump()); // WHEN assertEquals("Wrong hashCode", a1a.hashCode(), a1b.hashCode()); }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public EvaluatedExclusionTriggerType clone() { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final EvaluatedExclusionTriggerType clone = ((EvaluatedExclusionTriggerType) super.clone()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType clone.conflictingObjectRef = ((this.conflictingObjectRef == null)?null:((this.getConflictingObjectRef() == null)?null:this.getConflictingObjectRef().clone())); // CClassInfo: com.evolveum.prism.xml.ns._public.types_3.PolyStringType clone.conflictingObjectDisplayName = ((this.conflictingObjectDisplayName == null)?null:((this.getConflictingObjectDisplayName() == null)?null:this.getConflictingObjectDisplayName().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPathType clone.conflictingObjectPath = ((this.conflictingObjectPath == null)?null:((this.getConflictingObjectPath() == null)?null:this.getConflictingObjectPath().clone())); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType clone.conflictingAssignment = ((this.conflictingAssignment == null)?null:((this.getConflictingAssignment() == null)?null:this.getConflictingAssignment().clone())); return clone; } }
this.assignment = ((o.assignment == null)?null:((o.getAssignment() == null)?null:o.getAssignment().clone()));
@Override public EvaluatedExclusionTriggerType toEvaluatedPolicyRuleTriggerType(PolicyRuleExternalizationOptions options, PrismContext prismContext) { EvaluatedExclusionTriggerType rv = new EvaluatedExclusionTriggerType(); fillCommonContent(rv); if (options.getTriggeredRulesStorageStrategy() == FULL) { rv.setConflictingObjectRef(ObjectTypeUtil.createObjectRef(conflictingTarget, prismContext)); rv.setConflictingObjectDisplayName(ObjectTypeUtil.getDisplayName(conflictingTarget)); if (conflictingPath != null) { rv.setConflictingObjectPath(conflictingPath.toAssignmentPathType(options.isIncludeAssignmentsContent())); } if (options.isIncludeAssignmentsContent() && conflictingAssignment.getAssignmentType() != null) { rv.setConflictingAssignment(conflictingAssignment.getAssignmentType().clone()); } } return rv; } }
private void processAssignment(AssignmentType assignment, boolean isInducement, AccessCertificationAssignmentReviewScopeType scope, AccessCertificationCampaignType campaign, ObjectType object, List<AccessCertificationCaseType> caseList, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException { AccessCertificationAssignmentCaseType assignmentCase = new AccessCertificationAssignmentCaseType(prismContext); assignmentCase.setAssignment(assignment.clone()); assignmentCase.setIsInducement(isInducement); assignmentCase.setObjectRef(ObjectTypeUtil.createObjectRef(object, prismContext));
@Test public void test130JackUnassignRolePirate() throws Exception { TestCtx t = createContext(this, "test130JackUnassignRolePirate"); // GIVEN UserType jack = getUser(USER_JACK_OID).asObjectable(); AssignmentType pirateAssignment = findAssignmentByTargetRequired(jack.asPrismObject(), ROLE_PIRATE_OID); // WHEN t.displayWhen(); ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) .delete(pirateAssignment.clone()) .asObjectDeltaCast(USER_JACK_OID); executeChangesAssertSuccess(delta, null, t.task, t.result); // THEN t.displayThen(); jack = getUser(USER_JACK_OID).asObjectable(); display("jack", jack); t.result.computeStatus(); TestUtil.assertSuccess(t.result); assertNotAssignedRole(jack.asPrismObject(), ROLE_PIRATE_OID); assertEquals("Wrong # of assignments", 1, jack.getAssignment().size()); assertEquals("Wrong policy situations", Collections.emptyList(), jack.getAssignment().get(0).getPolicySituation()); display("Audit", dummyAuditService); dummyAuditService.assertExecutionRecords(1); // executed in one shot }
AssignmentType assignmentType = getAssignmentType(ASSIGNMENT_ROLE_ENGINEER_FILE); AssignmentType assignmentForUser = assignmentType.clone(); assignmentForUser.asPrismContainerValue().setParent(null); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()