Beispiel #1
0
  private List<ContainerWrapper> createReportContainers(PageBase pageBase) throws SchemaException {
    List<ContainerWrapper> containers = new ArrayList<ContainerWrapper>();

    PrismContainer container = object.findContainer(ReportType.F_CONFIGURATION);
    ContainerStatus status = container != null ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;

    if (container == null) {
      PrismSchema schema =
          ReportTypeUtil.parseReportConfigurationSchema(
              (PrismObject<ReportType>) object, object.getPrismContext());
      PrismContainerDefinition definition =
          ReportTypeUtil.findReportConfigurationDefinition(schema);
      if (definition == null) {
        return containers;
      }
      container = definition.instantiate();
    }

    ContainerWrapper wrapper =
        new ContainerWrapper(
            this, container, status, new ItemPath(ReportType.F_CONFIGURATION), pageBase);
    addSubresult(wrapper.getResult());

    containers.add(wrapper);

    return containers;
  }
Beispiel #2
0
  private List<ContainerWrapper> createCustomContainerWrapper(
      PrismObject object, QName name, PageBase pageBase) {
    PrismContainer container = object.findContainer(name);
    ContainerStatus status = container == null ? ContainerStatus.ADDING : ContainerStatus.MODIFYING;
    List<ContainerWrapper> list = new ArrayList<ContainerWrapper>();
    if (container == null) {
      PrismContainerDefinition definition = getDefinition().findContainerDefinition(name);
      container = definition.instantiate();
    }

    ContainerWrapper wrapper =
        new ContainerWrapper(this, container, status, new ItemPath(name), pageBase);
    addSubresult(wrapper.getResult());
    list.add(wrapper);
    // list.addAll(createContainerWrapper(container, null, pageBase));
    if (!ShadowType.F_ASSOCIATION.equals(name)) {
      // [pm] is this OK? "name" is the name of the container itself; originally here was an empty
      // path - that seems more logical
      list.addAll(createContainerWrapper(container, new ItemPath(name), pageBase));
    }

    return list;
  }
Beispiel #3
0
  private List<ContainerWrapper> createContainerWrapper(
      PrismContainer parent, ItemPath path, PageBase pageBase) {

    PrismContainerDefinition definition = parent.getDefinition();
    List<ContainerWrapper> wrappers = new ArrayList<ContainerWrapper>();

    List<ItemPathSegment> segments = new ArrayList<ItemPathSegment>();
    if (path != null) {
      segments.addAll(path.getSegments());
    }
    ItemPath parentPath = new ItemPath(segments);
    for (ItemDefinition def : (Collection<ItemDefinition>) definition.getDefinitions()) {
      if (!(def instanceof PrismContainerDefinition)) {
        continue;
      }
      if (ObjectSpecificationType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue; // TEMPORARY FIX
      }
      if (TriggerType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue; // TEMPORARY FIX TODO: remove after getEditSchema
        // (authorization) will be fixed.
      }
      if (ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName())) {
        continue;
      }

      LOGGER.trace("ObjectWrapper.createContainerWrapper processing definition: {}", def);

      PrismContainerDefinition containerDef = (PrismContainerDefinition) def;
      if (!showAssignments && AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName())) {
        continue;
      }
      if (!showInheritedObjectAttributes) {
        boolean result = INHERITED_OBJECT_SUBCONTAINERS.contains(containerDef.getName());
        LOGGER.info("checking " + containerDef.getName() + ", result = " + result);
        if (result) {
          continue;
        }
      }

      ItemPath newPath = createPropertyPath(parentPath, containerDef.getName());

      // [med]
      // The following code fails to work when parent is multivalued or
      // potentially multivalued.
      // Therefore (as a brutal hack), for multivalued parents we simply
      // skip it.
      if (parent.size() <= 1) {

        // the same check as in getValue() implementation
        boolean isMultiValued =
            parent.getDefinition() != null
                && !parent.getDefinition().isDynamic()
                && !parent.getDefinition().isSingleValue();
        if (!isMultiValued) {
          PrismContainer prismContainer = parent.findContainer(def.getName());

          ContainerWrapper container;
          if (prismContainer != null) {
            container =
                new ContainerWrapper(
                    this, prismContainer, ContainerStatus.MODIFYING, newPath, pageBase);
          } else {
            prismContainer = containerDef.instantiate();
            container =
                new ContainerWrapper(
                    this, prismContainer, ContainerStatus.ADDING, newPath, pageBase);
          }
          addSubresult(container.getResult());
          wrappers.add(container);

          if (!AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName())
              || !ShadowType.F_ASSOCIATION.equals(parent.getElementName())) { // do
            // not
            // show
            // internals
            // of
            // Assignments
            // (e.g.
            // activation)
            wrappers.addAll(createContainerWrapper(prismContainer, newPath, pageBase));
          }
        }
      }
    }

    return wrappers;
  }
Beispiel #4
0
  private List<ContainerWrapper> createContainers(PageBase pageBase) {
    result = new OperationResult(CREATE_CONTAINERS);

    List<ContainerWrapper> containers = new ArrayList<ContainerWrapper>();

    try {
      Class clazz = object.getCompileTimeClass();
      if (ShadowType.class.isAssignableFrom(clazz)) {
        PrismContainer attributes = object.findContainer(ShadowType.F_ATTRIBUTES);
        ContainerStatus status = attributes != null ? getStatus() : ContainerStatus.ADDING;
        if (attributes == null) {
          PrismContainerDefinition definition =
              object.getDefinition().findContainerDefinition(ShadowType.F_ATTRIBUTES);
          attributes = definition.instantiate();
        }

        ContainerWrapper container =
            new ContainerWrapper(
                this, attributes, status, new ItemPath(ShadowType.F_ATTRIBUTES), pageBase);
        addSubresult(container.getResult());

        container.setMain(true);
        containers.add(container);

        if (hasResourceCapability(
            ((ShadowType) object.asObjectable()).getResource(), ActivationCapabilityType.class)) {
          containers.addAll(
              createCustomContainerWrapper(object, ShadowType.F_ACTIVATION, pageBase));
        }
        if (hasResourceCapability(
            ((ShadowType) object.asObjectable()).getResource(), CredentialsCapabilityType.class)) {
          containers.addAll(
              createCustomContainerWrapper(object, ShadowType.F_CREDENTIALS, pageBase));
        }

        PrismContainer<ShadowAssociationType> associationContainer =
            object.findOrCreateContainer(ShadowType.F_ASSOCIATION);
        container =
            new ContainerWrapper(
                this,
                associationContainer,
                ContainerStatus.MODIFYING,
                new ItemPath(ShadowType.F_ASSOCIATION),
                pageBase);
        addSubresult(container.getResult());
        containers.add(container);
      } else if (ResourceType.class.isAssignableFrom(clazz)) {
        containers = createResourceContainers(pageBase);
      } else if (ReportType.class.isAssignableFrom(clazz)) {
        containers = createReportContainers(pageBase);
      } else {
        ContainerWrapper container =
            new ContainerWrapper(this, object, getStatus(), null, pageBase);
        addSubresult(container.getResult());
        containers.add(container);

        containers.addAll(createContainerWrapper(object, null, pageBase));
      }
    } catch (Exception ex) {
      // TODO: shouldn't be this exception thrown????
      LoggingUtils.logUnexpectedException(LOGGER, "Error occurred during container wrapping", ex);
      result.recordFatalError(
          "Error occurred during container wrapping, reason: " + ex.getMessage(), ex);
    }

    Collections.sort(containers, new ItemWrapperComparator());
    result.recomputeStatus();
    result.recordSuccessIfUnknown();

    return containers;
  }