private void cloneAndMerge(List<ObjectReferenceType> reviewers, Collection<ObjectReferenceType> newReviewers) { if (newReviewers == null) { return; } for (ObjectReferenceType newReviewer : newReviewers) { if (!containsOid(reviewers, newReviewer.getOid())) { reviewers.add(newReviewer.clone()); } } }
/** * Creates a new {@code SequentialValueExpressionEvaluatorType} instance by deeply copying a given {@code SequentialValueExpressionEvaluatorType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public SequentialValueExpressionEvaluatorType(final SequentialValueExpressionEvaluatorType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'SequentialValueExpressionEvaluatorType' from 'null'."); } // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType this.sequenceRef = ((o.sequenceRef == null)?null:((o.getSequenceRef() == null)?null:o.getSequenceRef().clone())); }
/** * Creates and returns a deep copy of this object. * * * @return * A deep copy of this object. */ @Override public SequentialValueExpressionEvaluatorType clone() { try { { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 final SequentialValueExpressionEvaluatorType clone = ((SequentialValueExpressionEvaluatorType) super.clone()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType clone.sequenceRef = ((this.sequenceRef == null)?null:((this.getSequenceRef() == null)?null:this.getSequenceRef().clone())); return clone; } } catch (CloneNotSupportedException e) { // Please report this at https://apps.sourceforge.net/mantisbt/ccxjc/ throw new AssertionError(e); } }
public void setObjectRefTransient(ObjectReferenceType objectRefType) { taskPrism.asObjectable().setObjectRef(objectRefType != null ? objectRefType.clone() : null); }
public static Set<ObjectReferenceType> expandGroups(Set<ObjectReferenceType> approverRefs) { PrismContext prismContext = getPrismContext(); Set<ObjectReferenceType> rv = new HashSet<>(); for (ObjectReferenceType approverRef : approverRefs) { @SuppressWarnings({ "unchecked", "raw" }) Class<? extends Containerable> clazz = (Class<? extends Containerable>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(approverRef.getType()); if (clazz == null) { throw new IllegalStateException("Unknown object type " + approverRef.getType()); } if (UserType.class.isAssignableFrom(clazz)) { rv.add(approverRef.clone()); } else if (AbstractRoleType.class.isAssignableFrom(clazz)) { rv.addAll(expandAbstractRole(approverRef, prismContext)); } else { LOGGER.warn("Unexpected type {} for approver: {}", clazz, approverRef); rv.add(approverRef.clone()); } } return rv; }
public static void computeAssignees(List<ObjectReferenceType> newAssignees, List<ObjectReferenceType> delegatedTo, List<ObjectReferenceType> delegates, WorkItemDelegationMethodType method, AbstractWorkItemType workItem) { newAssignees.clear(); delegatedTo.clear(); switch (method) { case ADD_ASSIGNEES: newAssignees.addAll(CloneUtil.cloneCollectionMembers(workItem.getAssigneeRef())); break; case REPLACE_ASSIGNEES: break; default: throw new UnsupportedOperationException("Delegation method " + method + " is not supported yet."); } for (ObjectReferenceType delegate : delegates) { if (delegate.getType() != null && !QNameUtil.match(UserType.COMPLEX_TYPE, delegate.getType())) { throw new IllegalArgumentException("Couldn't use non-user object as a delegate: " + delegate); } if (delegate.getOid() == null) { throw new IllegalArgumentException("Couldn't use no-OID reference as a delegate: " + delegate); } if (!ObjectTypeUtil.containsOid(newAssignees, delegate.getOid())) { newAssignees.add(delegate.clone()); delegatedTo.add(delegate.clone()); } } }
private static List<PrismReferenceValue> getGroupsForUser(String userOid, RepositoryService repositoryService, RelationRegistry relationRegistry, OperationResult result) throws SchemaException { List<PrismReferenceValue> rv = new ArrayList<>(); UserType userType; try { userType = repositoryService.getObject(UserType.class, userOid, null, result).asObjectable(); } catch (ObjectNotFoundException e) { return rv; } userType.getRoleMembershipRef().stream() .filter(ref -> relationRegistry.isMember(ref.getRelation())) .forEach(ref -> rv.add(ref.clone().asReferenceValue())); userType.getDelegatedRef().stream() .filter(ref -> relationRegistry.isMember(ref.getRelation())) .filter(ref -> !QNameUtil.match(ref.getType(), UserType.COMPLEX_TYPE)) // we are not interested in deputies (but this should be treated above) .forEach(ref -> rv.add(ref.clone().asReferenceValue())); return rv; }
/** * Creates a new {@code SubreportType} instance by deeply copying a given {@code SubreportType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public SubreportType(final SubreportType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'SubreportType' from 'null'."); } // CBuiltinLeafInfo: java.lang.String this.name = ((o.name == null)?null:o.getName()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType this.reportRef = ((o.reportRef == null)?null:((o.getReportRef() == null)?null:o.getReportRef().clone())); }
/** * Creates a new {@code GenerateExpressionEvaluatorType} instance by deeply copying a given {@code GenerateExpressionEvaluatorType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public GenerateExpressionEvaluatorType(final GenerateExpressionEvaluatorType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'GenerateExpressionEvaluatorType' from 'null'."); } // CEnumLeafInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.GenerateExpressionEvaluatorModeType this.mode = ((o.mode == null)?null:o.getMode()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType this.valuePolicyRef = ((o.valuePolicyRef == null)?null:((o.getValuePolicyRef() == null)?null:o.getValuePolicyRef().clone())); }
private void getDeputyAssignees(List<ObjectReferenceType> deputies, AbstractWorkItemType workItem, Set<String> oidsToSkip, Task task, OperationResult result) throws SchemaException { List<PrismReferenceValue> assigneeReferencesToQuery = workItem.getAssigneeRef().stream() .map(assigneeRef -> assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue()) .collect(Collectors.toList()); ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_DELEGATED_REF).ref(assigneeReferencesToQuery) .build(); SearchResultList<PrismObject<UserType>> potentialDeputies = cacheRepositoryService .searchObjects(UserType.class, query, null, result); for (PrismObject<UserType> potentialDeputy : potentialDeputies) { if (oidsToSkip.contains(potentialDeputy.getOid())) { continue; } if (determineDeputyValidity(potentialDeputy, workItem.getAssigneeRef(), workItem, OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, task, result)) { deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); oidsToSkip.add(potentialDeputy.getOid()); } } }
@Override public List<ObjectReferenceType> prepareApprovedBy(ProcessEvent event, PcpWfTask job, OperationResult result) { WfContextType wfc = job.getTask().getWorkflowContext(); List<ObjectReferenceType> rv = new ArrayList<>(); if (!ApprovalUtils.isApprovedFromUri(event.getOutcome())) { // wfc.approved is not filled in yet return rv; } for (WorkItemCompletionEventType completionEvent : WfContextUtil.getEvents(wfc, WorkItemCompletionEventType.class)) { if (ApprovalUtils.isApproved(completionEvent.getOutput()) && completionEvent.getInitiatorRef() != null) { rv.add(completionEvent.getInitiatorRef().clone()); } } return rv; }
private void getDeputyAssigneesNoWorkItem(List<ObjectReferenceType> deputies, ObjectReferenceType assigneeRef, QName limitationItemName, Set<String> oidsToSkip, Task task, OperationResult result) throws SchemaException { PrismReferenceValue assigneeReferenceToQuery = assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue(); ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_DELEGATED_REF).ref(assigneeReferenceToQuery) .build(); SearchResultList<PrismObject<UserType>> potentialDeputies = cacheRepositoryService .searchObjects(UserType.class, query, null, result); for (PrismObject<UserType> potentialDeputy : potentialDeputies) { if (oidsToSkip.contains(potentialDeputy.getOid())) { continue; } if (determineDeputyValidity(potentialDeputy, Collections.singletonList(assigneeRef), null, limitationItemName, task, result)) { deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext)); oidsToSkip.add(potentialDeputy.getOid()); } } }
private ReferenceDelta setObjectRefAndPrepareDelta(ObjectReferenceType value) { setObjectRefTransient(value); return isPersistent() ? deltaFactory().reference().createModificationReplace(TaskType.F_OBJECT_REF, taskManager.getTaskObjectDefinition(), value.clone().asReferenceValue()) : null; }
public ReferenceResolver createReferenceResolver(ModelContext modelContext, Task taskFromModel, OperationResult result) { return (ref, sourceDescription) -> { if (ref == null) { return Collections.emptyList(); } else if (ref.getOid() != null) { return Collections.singletonList(ref.clone()); } else { Class<? extends ObjectType> clazz; if (ref.getType() != null) { clazz = prismContext.getSchemaRegistry().determineCompileTimeClass(ref.getType()); if (clazz == null) { throw new SchemaException("Cannot determine type from " + ref.getType() + " in approver reference in " + sourceDescription); } } else { throw new SchemaException("Missing type in target reference in " + sourceDescription); } return resolveReferenceFromFilter(clazz, ref.getFilter(), sourceDescription, (LensContext) modelContext, taskFromModel, result); } }; }
/** * Creates a new {@code MappingEvaluationSourceContextType} instance by deeply copying a given {@code MappingEvaluationSourceContextType} instance. * * * @param o * The instance to copy. * @throws NullPointerException * if {@code o} is {@code null}. */ public MappingEvaluationSourceContextType(final MappingEvaluationSourceContextType o) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 super(); if (o == null) { throw new NullPointerException("Cannot create a copy of 'MappingEvaluationSourceContextType' from 'null'."); } // CBuiltinLeafInfo: java.lang.String this.name = ((o.name == null)?null:o.getName()); // CClassInfo: com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType this.objectRef = ((o.objectRef == null)?null:((o.getObjectRef() == null)?null:o.getObjectRef().clone())); // 'Object' property. this.object = ((o.object == null)?null:copyOfObject(o.getObject())); // CClassInfo: com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType this.delta = ((o.delta == null)?null:((o.getDelta() == null)?null:o.getDelta().clone())); }
private void postProcessPasswordCredentialPolicy(SecurityPolicyType securityPolicyType, PasswordCredentialsPolicyType passwd, Task task, OperationResult result) { // Deprecated settings Integer passwordHistoryLength = passwd.getPasswordHistoryLength(); if (passwordHistoryLength != null && passwd.getHistoryLength() == null) { passwd.setHistoryLength(passwordHistoryLength); } ObjectReferenceType passwordPolicyRef = passwd.getPasswordPolicyRef(); if (passwordPolicyRef != null && passwd.getValuePolicyRef() == null) { passwd.setValuePolicyRef(passwordPolicyRef.clone()); } ValuePolicyType valuePolicyType = postProcessCredentialPolicy(securityPolicyType, passwd, "password credential policy", task, result); if (valuePolicyType != null) { setDeprecatedPasswordPolicyProperties(valuePolicyType, passwd); } }
private List<OrgType> generateOrgStructure(int level, int[] levels, String name, ObjectReferenceType parentRef) throws Exception { List<OrgType> orgs = new ArrayList<>(); if (level >= levels.length) { return orgs; } for (int i = 0; i < levels[level]; i++) { OrgType org = createOrgType(name + " " + i, parentRef != null ? parentRef.clone() : null); orgs.add(org); ObjectReferenceType ref = new ObjectReferenceType(); ref.setOid(org.getOid()); ref.setType(OrgType.COMPLEX_TYPE); orgs.addAll(generateOrgStructure(level + 1, levels, org.getName().getOrig(), ref)); } return orgs; }
private void compileCollection(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType, Task task, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { CollectionRefSpecificationType collectionSpec = objectListViewType.getCollection(); if (collectionSpec == null) { ObjectReferenceType collectionRef = objectListViewType.getCollectionRef(); if (collectionRef == null) { return; } // Legacy, deprecated collectionSpec = new CollectionRefSpecificationType(); collectionSpec.setCollectionRef(collectionRef.clone()); } if (existingView.getCollection() != null) { LOGGER.debug("Redefining collection in view {}", existingView.getViewIdentifier()); } existingView.setCollection(collectionSpec); compileCollection(existingView, collectionSpec, task, result); }
public ObjectReferenceType resolveObjectReferenceName(ObjectReferenceType ref, OperationResult result) { if (ref == null || ref.getTargetName() != null) { return ref; } PrismObject<?> object; if (ref.asReferenceValue().getObject() != null) { object = ref.asReferenceValue().getObject(); } else { object = resolveObjectReference(ref, result); if (object == null) { return ref; } } ref = ref.clone(); ref.setTargetName(PolyString.toPolyStringType(object.getName())); return ref; }
@Test // MID-5104 public void test350ReplaceAssignmentModifyApprover() throws Exception { final String TEST_NAME = "test350ReplaceAssignmentModifyApprover"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TEST_NAME); PrismObject<UserType> user = prismContext.createObjectable(UserType.class) .name("test350") .oid("oid-350") .beginAssignment() .id(123L) .targetRef("oid0", RoleType.COMPLEX_TYPE) .<UserType>end() .asPrismObject(); repositoryService.addObject(user, null, result); // WHEN ObjectReferenceType approver1 = new ObjectReferenceType() .oid("approver1-oid").type(UserType.COMPLEX_TYPE).relation(SchemaConstants.ORG_DEFAULT); List<ItemDelta<?, ?>> itemDeltas1 = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 123L, AssignmentType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF).replace(approver1.clone()) .asItemDeltas(); repositoryService.modifyObject(UserType.class, user.getOid(), itemDeltas1, getModifyOptions(), result); // THEN }