Exemplo n.º 1
0
  public <O extends ObjectType> O resolveObject(ObjectReferenceType ref) {
    Validate.notNull(ref.getOid(), "Object oid must not be null");
    Validate.notNull(ref.getType(), "Object type must not be null");

    Class type = prismContext.getSchemaRegistry().determineCompileTimeClass(ref.getType());
    return resolveObject(type, ref.getOid());
  }
Exemplo n.º 2
0
  public <O extends ObjectType> List<PrismObject<O>> resolveLinkRefs(
      Collection<ObjectReferenceType> refs, Class type) {

    List<PrismObject<O>> objects = new ArrayList<>();

    for (ObjectReferenceType ref : refs) {
      Class clazz = getClassForType(ref.getType());
      if (!clazz.equals(type)) {
        continue;
      }
      Task task = taskManager.createTaskInstance();
      OperationResult parentResult = task.getResult();
      try {
        PrismObject<O> obj =
            model.getObject(
                type,
                ref.getOid(),
                SelectorOptions.createCollection(GetOperationOptions.createResolveNames()),
                task,
                parentResult);
        objects.add(obj);
      } catch (ObjectNotFoundException
          | SchemaException
          | SecurityViolationException
          | CommunicationException
          | ConfigurationException e) {
        // TODO Auto-generated catch block
        LOGGER.error(
            "Could not get object with oid " + ref.getOid() + ". Reason: " + e.getMessage());
      }
    }
    return objects;
  }
  public ObjectPolicyDialogDto(ObjectPolicyConfigurationTypeDto config, PageBase page) {
    this.config = config;
    type = config.getType();

    propertyConstraintsList = new ArrayList<>();

    if (config != null && config.getConstraints() != null) {
      propertyConstraintsList.addAll(config.getConstraints());
    } else {
      propertyConstraintsList.add(new PropertyConstraintTypeDto(null));
    }

    if (config.getTemplateRef() != null) {
      ObjectReferenceType ref = config.getTemplateRef();
      templateRef =
          new ObjectTemplateConfigTypeReferenceDto(
              ref.getOid(), getObjectTemplateName(ref.getOid(), page));
    }
  }
Exemplo n.º 4
0
  // TODO: refactor - this method is also in SchemaHandlerImpl
  private ResourceType resolveResource(ShadowType shadow, OperationResult result)
      throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    if (shadow.getResource() != null) {
      return shadow.getResource();
    }

    ObjectReferenceType ref = shadow.getResourceRef();
    if (ref == null) {
      throw new ExpressionEvaluationException(
          "Resource shadow object " + shadow + " doesn't have defined resource.");
    }
    if (ref.getOid() == null) {
      throw new ExpressionEvaluationException(
          "Resource shadow object " + shadow + " defines null resource OID.");
    }

    return modelObjectResolver.getObjectSimple(
        ResourceType.class, ref.getOid(), null, null, result);
  }
Exemplo n.º 5
0
  private AssignmentItemDto createAssignmentItem(
      PrismObject<UserType> user,
      PrismContainerValue assignment,
      Task task,
      OperationResult result) {
    PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
    if (targetRef == null || targetRef.isEmpty()) {
      // account construction
      PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
      String name = null;
      String description = null;
      if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
        ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
        description =
            (String)
                construction.getPropertyRealValue(ConstructionType.F_DESCRIPTION, String.class);

        if (constr.getResourceRef() != null) {
          ObjectReferenceType resourceRef = constr.getResourceRef();

          PrismObject resource =
              WebModelUtils.loadObject(
                  ResourceType.class, resourceRef.getOid(), this, task, result);
          name = WebMiscUtil.getName(resource);
        }
      }

      return new AssignmentItemDto(
          AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION, name, description, null);
    }

    PrismReferenceValue refValue = targetRef.getValue();
    PrismObject value = refValue.getObject();
    if (value == null) {
      // resolve reference
      value = WebModelUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result);
    }

    if (value == null) {
      // we couldn't resolve assignment details
      return new AssignmentItemDto(null, null, null, null);
    }

    String name = WebMiscUtil.getName(value);
    AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
    String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
    String description = null;
    if (RoleType.class.isAssignableFrom(value.getCompileTimeClass())) {
      description = (String) value.getPropertyRealValue(RoleType.F_DESCRIPTION, String.class);
    }

    return new AssignmentItemDto(type, name, description, relation);
  }
Exemplo n.º 6
0
  // Called from the ObjectResolver.resolve
  public ObjectType resolveRef(
      ObjectReferenceType ref, String contextDescription, OperationResult result)
      throws ObjectNotFoundException, SchemaException {

    Class<? extends ObjectType> type = ObjectType.class;
    if (ref.getType() != null) {
      ObjectTypes objectTypeType = ObjectTypes.getObjectTypeFromTypeQName(ref.getType());
      type = objectTypeType.getClassDefinition();
    }

    return repositoryService.getObject(type, ref.getOid(), null, result).asObjectable();
  }
Exemplo n.º 7
0
  private AccountCallableResult<List<SimpleAccountDto>> loadAccounts() throws Exception {
    LOGGER.debug("Loading accounts.");

    AccountCallableResult callableResult = new AccountCallableResult();
    List<SimpleAccountDto> list = new ArrayList<SimpleAccountDto>();
    callableResult.setValue(list);
    PrismObject<UserType> user = principalModel.getObject();
    if (user == null) {
      return callableResult;
    }

    Task task = createSimpleTask(OPERATION_LOAD_ACCOUNTS);
    OperationResult result = task.getResult();
    callableResult.setResult(result);
    Collection<SelectorOptions<GetOperationOptions>> options =
        SelectorOptions.createCollection(
            ShadowType.F_RESOURCE, GetOperationOptions.createResolve());

    List<ObjectReferenceType> references = user.asObjectable().getLinkRef();
    for (ObjectReferenceType reference : references) {
      PrismObject<ShadowType> account =
          WebModelUtils.loadObject(
              ShadowType.class, reference.getOid(), options, this, task, result);
      if (account == null) {
        continue;
      }

      ShadowType accountType = account.asObjectable();

      OperationResultType fetchResult = accountType.getFetchResult();

      if (fetchResult != null) {
        callableResult.getFetchResults().add(OperationResult.createOperationResult(fetchResult));
      }

      ResourceType resource = accountType.getResource();
      String resourceName = WebMiscUtil.getName(resource);
      list.add(
          new SimpleAccountDto(
              WebMiscUtil.getOrigStringFromPoly(accountType.getName()), resourceName));
    }
    result.recordSuccessIfUnknown();
    result.recomputeStatus();

    LOGGER.debug("Finished accounts loading.");

    return callableResult;
  }
Exemplo n.º 8
0
  public static RObjectReference jaxbRefToRepo(
      ObjectReferenceType reference,
      PrismContext prismContext,
      RObject owner,
      RReferenceOwner refOwner) {
    if (reference == null) {
      return null;
    }
    Validate.notNull(owner, "Owner of reference must not be null.");
    Validate.notNull(refOwner, "Reference owner of reference must not be null.");
    Validate.notEmpty(reference.getOid(), "Target oid reference must not be null.");

    RObjectReference repoRef = RReferenceOwner.createObjectReference(refOwner);
    repoRef.setOwner(owner);
    RObjectReference.copyFromJAXB(reference, repoRef, prismContext);

    return repoRef;
  }
 private String createResourceReadLabel(ObjectReferenceType ref) {
   return resourceMap.get(ref.getOid());
 }