protected boolean isAssignmentRelevant(AssignmentType assignmentType) { if (assignmentType.getTarget() != null) { return assignmentType.getTarget() instanceof AbstractRoleType; } else if (assignmentType.getTargetRef() != null) { QName targetType = assignmentType.getTargetRef().getType(); return QNameUtil.match(targetType, RoleType.COMPLEX_TYPE) || QNameUtil.match(targetType, OrgType.COMPLEX_TYPE) || QNameUtil.match(targetType, AbstractRoleType.COMPLEX_TYPE); // this case should not occur } else { return false; // should not occur } }
public static String toShortString(AssignmentType assignment) { if (assignment == null) { return "null"; } StringBuilder sb = new StringBuilder("Assignment("); if (assignment.getConstruction() != null) { sb.append("construction"); // TODO } if (assignment.getTarget() != null) { sb.append(toShortString(assignment.getTarget())); } if (assignment.getTargetRef() != null) { sb.append(toShortString(assignment.getTargetRef())); } sb.append(")"); return sb.toString(); }
public <T extends ObjectType> T resolveTargetRefUnchecked(AssignmentType a, OperationResult result) throws SchemaException, ObjectNotFoundException { if (a == null) { return null; } ObjectType object = a.getTarget(); if (object == null) { if (a.getTargetRef() == null || a.getTargetRef().getOid() == null) { return null; } Class<? extends ObjectType> clazz = null; if (a.getTargetRef().getType() != null) { clazz = prismContext.getSchemaRegistry().determineCompileTimeClass(a.getTargetRef().getType()); } if (clazz == null) { clazz = ObjectType.class; } object = repositoryService.getObject(clazz, a.getTargetRef().getOid(), null, result).asObjectable(); a.setTarget(object); } return (T) object; }
public static String prettyPrint(AssignmentType assignmentType) { if (assignmentType == null) { return "null"; } StringBuilder sb = new StringBuilder("AssignmentType("); if (assignmentType.getTarget() != null) { sb.append("target:"); sb.append(prettyPrint(assignmentType.getTarget())); } if (assignmentType.getTargetRef() != null) { sb.append("target:"); sb.append(prettyPrint(assignmentType.getTargetRef())); } if (assignmentType.getConstruction() != null) { sb.append(prettyPrint(assignmentType.getConstruction())); } sb.append(", "); if (assignmentType.getActivation() != null) { sb.append(prettyPrint(assignmentType.getActivation())); } sb.append(")"); return sb.toString(); }
@NotNull private <O extends ObjectType> List<PrismObject<O>> getTargets(AssignmentPathSegmentImpl segment, EvaluationContext ctx) throws SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { AssignmentType assignmentType = getAssignmentType(segment, ctx); if (assignmentType.getTarget() != null) { return Collections.singletonList((PrismObject<O>) assignmentType.getTarget().asPrismObject()); } else if (assignmentType.getTargetRef() != null) { try { return resolveTargets(segment, ctx); } catch (ObjectNotFoundException ex) { // Do not throw an exception. We don't have referential integrity. Therefore if a role is deleted then throwing // an exception would prohibit any operations with the users that have the role, including removal of the reference. // The failure is recorded in the result and we will log it. It should be enough. LOGGER.error(ex.getMessage()+" in assignment target reference in "+segment.sourceDescription,ex); // For OrgType references we trigger the reconciliation (see MID-2242) ctx.evalAssignment.setForceRecon(true); return Collections.emptyList(); } } else { throw new IllegalStateException("Both target and targetRef are null. We should not be here. Assignment: " + assignmentType); } }
public void resolveAssignmentTargetReferences(PrismObject<? extends UserType> object, OperationResult result) { for (AssignmentType assignmentType : object.asObjectable().getAssignment()) { if (assignmentType.getTarget() == null && assignmentType.getTargetRef() != null) { PrismObject<? extends ObjectType> target = null; try { target = repositoryService.getObject(ObjectType.class, assignmentType.getTargetRef().getOid(), null, result); assignmentType.setTarget(target.asObjectable()); } catch (ObjectNotFoundException e) { LoggingUtils.logException(LOGGER, "Couldn't resolve assignment " + assignmentType, e); } catch (SchemaException e) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't resolve assignment " + assignmentType, e); } } } }
public void resolveRolesAndOrgUnits(PrismObject<UserType> user, OperationResult result) { for (AssignmentType assignmentType : user.asObjectable().getAssignment()) { if (assignmentType.getTargetRef() != null && assignmentType.getTarget() == null) { QName type = assignmentType.getTargetRef().getType(); if (RoleType.COMPLEX_TYPE.equals(type) || OrgType.COMPLEX_TYPE.equals(type)) { String oid = assignmentType.getTargetRef().getOid(); try { PrismObject<ObjectType> o = repositoryService.getObject(ObjectType.class, oid, null, result); assignmentType.setTarget(o.asObjectable()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Resolved {} to {} in {}", new Object[]{oid, o, user}); } } catch (ObjectNotFoundException e) { LoggingUtils.logException(LOGGER, "Couldn't resolve reference to {} in {}", e, oid, user); } catch (SchemaException e) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't resolve reference to {} in {}", e, oid, user); } } } } }
clazz = getClassForType(assignment.getTargetRef().getType()); oid = assignment.getTargetRef().getOid(); } else if (assignment.getTarget() != null) { clazz = assignment.getTarget().getClass(); } else if (assignment.getTenantRef() != null) { clazz = getClassForType(assignment.getTenantRef().getType()); if (assignment.getTarget() != null) { resolvedAssignments.add((PrismObject<O>) assignment.getTarget().asPrismObject()); continue;
if (assignmentType.getTarget() != null || assignmentType.getTargetRef() != null) { QName relation = getRelation(assignmentType); if (loginMode && !relationRegistry.isProcessedOnLogin(relation)) {
if (jaxb.getTarget() != null) { LOGGER.warn("Target from assignment type won't be saved. It should be translated to target reference.");