@Override public <O extends Objectable> ObjectDelta<O> createModificationAddReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for(int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationAddReference(type, oid, propertyName, referenceValues); }
@Override public <O extends Objectable> ObjectDelta<O> createModificationDeleteReference(Class<O> type, String oid, QName propertyName, String... targetOids) { PrismReferenceValue[] referenceValues = new PrismReferenceValue[targetOids.length]; for (int i=0; i < targetOids.length; i++) { referenceValues[i] = prismContext.itemFactory().createReferenceValue(targetOids[i]); } return createModificationDeleteReference(type, oid, propertyName, referenceValues); }
public static <T extends Objectable> ReferenceDeltaImpl createModificationAdd(Class<T> type, ItemName refName, PrismContext prismContext, PrismObject<?> refTarget) { PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(refTarget); return createModificationAdd(type, refName, prismContext, refValue); }
public static ReferenceDeltaImpl createModificationDelete(QName refName, PrismObjectDefinition<?> objectDefinition, PrismObject<?> refTarget, PrismContext prismContext) { PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(refTarget); return createModificationDelete(refName, objectDefinition, refValue); }
public static <T extends Objectable> ReferenceDeltaImpl createModificationDelete(Class<T> type, QName refName, PrismContext prismContext, PrismObject<?> refTarget) { PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(refTarget); return createModificationDelete(type, refName, prismContext, refValue); }
protected void applyPasswordPolicy(String passwordPolicyOid, String securityPolicyOid, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { if (passwordPolicyOid == null) { modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, task, result /* no value */); } else { PrismReferenceValue passPolicyRef = itemFactory().createReferenceValue(passwordPolicyOid, ValuePolicyType.COMPLEX_TYPE); modifyObjectReplaceReference(SecurityPolicyType.class, securityPolicyOid, PATH_CREDENTIALS_PASSWORD_VALUE_POLICY_REF, task, result, passPolicyRef); } }
private RefFilter createResourceRefFilter(String oid) throws SchemaException { PrismContext prismContext = context.getPrismContext(); List<PrismReferenceValue> values = new ArrayList<>(); if (oid != null) { values.add(prismContext.itemFactory().createReferenceValue(oid, ResourceType.COMPLEX_TYPE)); } SchemaRegistry registry = prismContext.getSchemaRegistry(); PrismReferenceDefinition def = registry.findItemDefinitionByFullPath(ShadowType.class, PrismReferenceDefinition.class, ShadowType.F_RESOURCE_REF); return prismContext.queryFactory().createReferenceEqual(ShadowType.F_RESOURCE_REF, def, values); }
private void collectMembership(AssignmentHolderType targetType, QName relation, EvaluationContext ctx) { PrismReferenceValue refVal = prismContext.itemFactory().createReferenceValue(); refVal.setObject(targetType.asPrismObject()); refVal.setTargetType(ObjectTypes.getObjectType(targetType.getClass()).getTypeQName()); refVal.setRelation(relation); refVal.setTargetName(targetType.getName().toPolyString()); collectMembershipRefVal(refVal, targetType.getClass(), relation, targetType, ctx); }
protected PrismReferenceValue createPrismValue(String oid, QName targetTypeQName, List<ItemDelta<PrismReferenceValue, PrismReferenceDefinition>> additionalAttributeValues, ExpressionEvaluationContext params) { PrismReferenceValue refVal = getPrismContext().itemFactory().createReferenceValue(); refVal.setOid(oid); refVal.setTargetType(targetTypeQName); refVal.setRelation(((ReferenceSearchExpressionEvaluatorType)getExpressionEvaluatorType()).getRelation()); return refVal; }
protected int countAssignees(String targetOid, QName relation, OperationResult result) throws SchemaException { PrismReferenceValue refVal = itemFactory().createReferenceValue(); refVal.setOid(targetOid); refVal.setRelation(relation); ObjectQuery query = prismContext.queryFor(FocusType.class) .item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(refVal) .build(); return repositoryService.countObjects(FocusType.class, query, null, result); }
private static PrismReferenceValue getAuditTarget(ObjectDelta<? extends ObjectType> delta, PrismContext prismContext) { PrismReferenceValue targetRef = prismContext.itemFactory().createReferenceValue(delta.getOid()); targetRef.setTargetType(ObjectTypes.getObjectType(delta.getObjectTypeClass()).getTypeQName()); if (delta.isAdd()) { targetRef.setObject(delta.getObjectToAdd()); } return targetRef; }
protected ObjectDelta<UserType> createModifyUserUnlinkAccount(String userOid, PrismObject<ResourceType> resource) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String accountOid = getLinkRefOid(userOid, resource.getOid()); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setOid(accountOid); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); return userDelta; }
private void collectMembership(ObjectReferenceType targetRef, QName relation, EvaluationContext ctx) { PrismReferenceValue refVal = prismContext.itemFactory().createReferenceValue(); refVal.setOid(targetRef.getOid()); refVal.setTargetType(targetRef.getType()); refVal.setRelation(relation); refVal.setTargetName(targetRef.getTargetName()); Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(targetRef.getType()).getClassDefinition(); collectMembershipRefVal(refVal, targetClass, relation, targetRef, ctx); }
protected ObjectDelta<UserType> createModifyUserDeleteAccount(String userOid, String resourceOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { String accountOid = getLinkRefOid(userOid, resourceOid); PrismObject<ShadowType> account = getShadowModel(accountOid); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationDelete(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); return userDelta; }
protected void modifyUserAddAccount(String userOid, File accountFile, Task task, OperationResult result) throws SchemaException, IOException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismObject<ShadowType> account = prismContext.parseObject(accountFile); ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid ); PrismReferenceValue accountRefVal = itemFactory().createReferenceValue(); accountRefVal.setObject(account); ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal); userDelta.addModification(accountDelta); Collection<ObjectDelta<? extends ObjectType>> deltas = (Collection)MiscUtil.createCollection(userDelta); modelService.executeChanges(deltas, null, task, result); }
@Test public void orgAssignmentSearchTestNoTargetType() throws Exception { PrismReferenceValue org = itemFactory().createReferenceValue("00000000-8888-6666-0000-100000000085", null); ObjectQuery query = prismContext.queryFor(UserType.class) .item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(org) .build(); OperationResult result = new OperationResult("search"); List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, result); result.recomputeStatus(); assertTrue(result.isSuccess()); assertEquals("Should find one user", 1, users.size()); assertEquals("Wrong user name", "atestuserX00002", users.get(0).getName().getOrig()); }
@Test public void test100ParentOrgRefFilterNullRelation() throws Exception { final String TEST_NAME = "test100ParentOrgRefFilterNullRelation"; TestUtil.displayTestTitle(TEST_NAME); OperationResult opResult = new OperationResult(TEST_NAME); ObjectQuery query = prismContext.queryFor(ObjectType.class) .item(ObjectType.F_PARENT_ORG_REF).ref(itemFactory().createReferenceValue(ORG_F001_OID)) .build(); // WHEN List<PrismObject<ObjectType>> orgs = repositoryService.searchObjects(ObjectType.class, query, null, opResult); // THEN PrismAsserts.assertOids(orgs, ORG_F002_OID, ORG_F003_OID, ORG_F004_OID, ELAINE_OID); }
private void assertDeputySearchAssignmentTarget(String delegatorOid, String... expectedDeputyOids) throws Exception { PrismReferenceValue rval = itemFactory().createReferenceValue(delegatorOid, UserType.COMPLEX_TYPE); rval.setRelation(SchemaConstants.ORG_DEPUTY); ObjectQuery query = queryFor(UserType.class) .item(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rval).build(); assertSearch(UserType.class, query, expectedDeputyOids); }
private <F extends FocusType> void unlink(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationDeleteReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }
private <F extends FocusType> void link(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationAddReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }