コード例 #1
0
ファイル: PrismValuePanel.java プロジェクト: mythoss/midpoint
  private List<String> prepareAutoCompleteList(
      String input, PrismObject<LookupTableType> lookupTable) {
    List<String> values = new ArrayList<>();

    if (lookupTable == null) {
      return values;
    }

    List<LookupTableRowType> rows = lookupTable.asObjectable().getRow();

    if (input == null || input.isEmpty()) {
      for (LookupTableRowType row : rows) {
        values.add(WebComponentUtil.getOrigStringFromPoly(row.getLabel()));
      }
    } else {
      for (LookupTableRowType row : rows) {
        if (WebComponentUtil.getOrigStringFromPoly(row.getLabel()) != null
            && WebComponentUtil.getOrigStringFromPoly(row.getLabel())
                .toLowerCase()
                .contains(input.toLowerCase())) {
          values.add(WebComponentUtil.getOrigStringFromPoly(row.getLabel()));
        }
      }
    }

    return values;
  }
コード例 #2
0
  private void deleteDefinitionPerformed(
      AjaxRequestTarget target, AccessCertificationDefinitionType definition) {
    OperationResult result = new OperationResult(OPERATION_DELETE_DEFINITION);
    try {
      Task task = createSimpleTask(OPERATION_DELETE_DEFINITION);
      ObjectDelta<AccessCertificationDefinitionType> delta =
          ObjectDelta.createDeleteDelta(
              AccessCertificationDefinitionType.class, definition.getOid(), getPrismContext());
      getModelService()
          .executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
    } catch (Exception ex) {
      result.recordPartialError("Couldn't delete campaign definition.", ex);
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete campaign definition", ex);
    }

    result.computeStatusIfUnknown();
    if (result.isSuccess()) {
      result.recordStatus(
          OperationResultStatus.SUCCESS, "The definition has been successfully deleted.");
    }

    getDefinitionsTable().clearCache();

    showResult(result);
    target.add(getFeedbackPanel(), getDefinitionsTable());
  }
コード例 #3
0
  private void initRoot() {
    DropDownChoice<LoggingLevelType> rootLevel =
        new DropDownChoice<>(
            ID_ROOT_LEVEL,
            new PropertyModel<LoggingLevelType>(getModel(), LoggingDto.F_ROOT_LEVEL),
            WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
    rootLevel.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootLevel);

    DropDownChoice<String> rootAppender =
        new DropDownChoice<>(
            ID_ROOT_APPENDER,
            new PropertyModel<String>(getModel(), LoggingDto.F_ROOT_APPENDER),
            createAppendersListModel());
    rootAppender.setNullValid(true);
    rootAppender.add(
        new OnChangeAjaxBehavior() {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            rootAppenderChangePerformed(target);
          }
        });
    rootAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(rootAppender);
  }
コード例 #4
0
  public static InputStream createReport(
      ReportOutputType report,
      AjaxDownloadBehaviorFromStream ajaxDownloadBehaviorFromStream,
      PageBase pageBase) {
    OperationResult result = new OperationResult(OPERATION_DOWNLOAD_REPORT);
    ReportManager reportManager = pageBase.getReportManager();

    if (report == null) {
      return null;
    }

    String contentType = reportExportTypeMap.get(report.getExportType());
    if (StringUtils.isEmpty(contentType)) {
      contentType = "multipart/mixed; charset=UTF-8";
    }
    ajaxDownloadBehaviorFromStream.setContentType(contentType);

    InputStream input = null;
    try {
      input = reportManager.getReportOutputData(report.getOid(), result);
    } catch (Exception e) {
      pageBase.error(
          pageBase.getString("pageCreatedReports.message.downloadError") + " " + e.getMessage());
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't download report.", e);
      LOGGER.trace(result.debugDump());
    } finally {
      result.computeStatusIfUnknown();
    }

    if (WebComponentUtil.showResultInPage(result)) {
      pageBase.showResult(result);
    }

    return input;
  }
コード例 #5
0
  private ReportOutputSearchDto createSearchDto() {
    ReportOutputSearchDto dto = new ReportOutputSearchDto();
    Map<String, String> reportTypeMap = dto.getReportTypeMap();

    List<PrismObject<ReportType>> reportTypes =
        WebModelServiceUtils.searchObjects(ReportType.class, null, null, getPageBase());
    LOGGER.debug("Found {} report types.", reportTypes.size());

    for (PrismObject o : reportTypes) {
      ReportType reportType = (ReportType) o.asObjectable();

      if (reportType.isParent()) {
        String name = WebComponentUtil.getName(o);
        reportTypeMap.put(name, reportType.getOid());
      }
    }

    StringValue param = getPage().getPageParameters().get(OnePageParameterEncoder.PARAMETER);
    if (param != null) {
      for (String key : dto.getReportTypeMap().keySet()) {
        if (reportTypeMap.get(key).equals(param.toString())) {
          dto.setReportType(key);
        }
      }
    }

    return dto;
  }
コード例 #6
0
 @Override
 public Class<? extends PageBase> getHomePage() {
   if (WebComponentUtil.isAuthorized(
       AuthorizationConstants.AUTZ_UI_DASHBOARD_URL,
       AuthorizationConstants.AUTZ_UI_HOME_ALL_URL)) {
     return PageDashboard.class;
   } else {
     return PageSelfDashboard.class;
   }
 }
コード例 #7
0
  private void initAudit() {
    CheckBox auditLog =
        WebComponentUtil.createAjaxCheckBox(
            "auditLog", new PropertyModel<Boolean>(getModel(), "auditLog"));
    add(auditLog);

    CheckBox auditDetails =
        WebComponentUtil.createAjaxCheckBox(
            "auditDetails", new PropertyModel<Boolean>(getModel(), "auditDetails"));
    add(auditDetails);

    DropDownChoice<String> auditAppender =
        new DropDownChoice<>(
            "auditAppender",
            new PropertyModel<String>(getModel(), "auditAppender"),
            createAppendersListModel());
    auditAppender.setNullValid(true);
    auditAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(auditAppender);
  }
コード例 #8
0
  static {
    List<LocaleDescriptor> locales = new ArrayList<>();
    try {
      ClassLoader classLoader = MidPointApplication.class.getClassLoader();
      Enumeration<URL> urls = classLoader.getResources(LOCALIZATION_DESCRIPTOR);
      while (urls.hasMoreElements()) {
        final URL url = urls.nextElement();
        LOGGER.debug("Found localization descriptor {}.", new Object[] {url.toString()});

        Properties properties = new Properties();
        Reader reader = null;
        try {
          reader = new InputStreamReader(url.openStream(), "utf-8");
          properties.load(reader);

          Map<String, Map<String, String>> localeMap = new HashMap<>();
          Set<String> keys = (Set) properties.keySet();
          for (String key : keys) {
            String[] array = key.split("\\.");
            if (array.length != 2) {
              continue;
            }

            String locale = array[0];
            Map<String, String> map = localeMap.get(locale);
            if (map == null) {
              map = new HashMap<>();
              localeMap.put(locale, map);
            }

            map.put(key, properties.getProperty(key));
          }

          for (String key : localeMap.keySet()) {
            Map<String, String> localeDefinition = localeMap.get(key);
            if (!localeDefinition.containsKey(key + PROP_NAME)
                || !localeDefinition.containsKey(key + PROP_FLAG)) {
              continue;
            }

            LocaleDescriptor descriptor =
                new LocaleDescriptor(
                    localeDefinition.get(key + PROP_NAME),
                    localeDefinition.get(key + PROP_FLAG),
                    localeDefinition.get(key + PROP_DEFAULT),
                    WebComponentUtil.getLocaleFromString(key));
            locales.add(descriptor);
          }
        } catch (Exception ex) {
          LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load localization", ex);
        } finally {
          IOUtils.closeQuietly(reader);
        }
      }

      Collections.sort(locales);
    } catch (Exception ex) {
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load locales", ex);
    }

    AVAILABLE_LOCALES = Collections.unmodifiableList(locales);
  }
コード例 #9
0
  @Override
  public String getCaseInfoButtonTitle(
      IModel<? extends CertCaseOrDecisionDto> rowModel, PageBase page) {
    CertCaseOrDecisionDto dto = rowModel.getObject();
    AccessCertificationCaseType _case = dto.getCertCase();
    if (!(_case instanceof AccessCertificationAssignmentCaseType)) {
      return null; // should not occur, TODO treat gracefully
    }
    AccessCertificationAssignmentCaseType assignmentCase =
        (AccessCertificationAssignmentCaseType) _case;
    AssignmentType assignment = assignmentCase.getAssignment();

    List<String> infoList = new ArrayList<>();

    String assignmentOrInducement;
    if (Boolean.TRUE.equals(assignmentCase.isIsInducement())) {
      assignmentOrInducement =
          page.createStringResource("PageCert.message.textInducement").getString();
    } else {
      assignmentOrInducement =
          page.createStringResource("PageCert.message.textAssignment").getString();
    }
    String targetType = getLocalizedTypeName(_case.getTargetRef().getType(), page);
    String targetName = dto.getTargetName();
    String objectType = getLocalizedTypeName(_case.getObjectRef().getType(), page);
    String objectName = dto.getObjectName();

    infoList.add(
        page.createStringResource(
                "PageCert.message.assignment",
                assignmentOrInducement,
                emptyToDash(targetType),
                emptyToDash(targetName),
                emptyToDash(objectType),
                emptyToDash(objectName))
            .getString());

    if (StringUtils.isNotEmpty(assignment.getDescription())) {
      infoList.add(
          page.createStringResource("PageCert.message.textDescription", assignment.getDescription())
              .getString());
    }
    if (assignment.getOrder() != null) {
      infoList.add(
          page.createStringResource("PageCert.message.textOrder", assignment.getOrder())
              .getString());
    }
    if (assignment.getConstruction() != null) {
      if (assignment.getConstruction().getKind() != null) {
        infoList.add(
            page.createStringResource(
                    "PageCert.message.textKind",
                    page.createStringResource(assignment.getConstruction().getKind()).getString())
                .getString());
      }
      if (assignment.getConstruction().getIntent() != null) {
        infoList.add(
            page.createStringResource(
                    "PageCert.message.textIntent", assignment.getConstruction().getIntent())
                .getString());
      }
    }
    if (_case.getTargetRef().getRelation() != null) {
      infoList.add(
          page.createStringResource(
                  "PageCert.message.textRelation",
                  _case.getTargetRef().getRelation().getLocalPart())
              .getString());
    }
    Task task = page.createSimpleTask("dummy");
    if (assignment.getOrgRef() != null) {
      String orgName =
          WebModelServiceUtils.resolveReferenceName(
              assignment.getOrgRef(), page, task, task.getResult());
      infoList.add(page.createStringResource("PageCert.message.textOrg", orgName).getString());
    }
    if (assignment.getTenantRef() != null) {
      String tenantName =
          WebModelServiceUtils.resolveReferenceName(
              assignment.getTenantRef(), page, task, task.getResult());
      infoList.add(
          page.createStringResource("PageCert.message.textTenant", tenantName).getString());
    }

    PrismContainer<? extends Containerable> extensionContainer =
        assignment.asPrismContainerValue().findContainer(AssignmentType.F_EXTENSION);
    if (extensionContainer != null && !extensionContainer.isEmpty()) {
      List<String> extensionItemNameList = new ArrayList<>();
      for (Item extensionItem : extensionContainer.getValue().getItems()) {
        extensionItemNameList.add(extensionItem.getElementName().getLocalPart());
      }
      infoList.add(
          page.createStringResource(
                  "PageCert.message.textExtensions", StringUtils.join(extensionItemNameList, ", "))
              .getString());
    }

    if (assignment.getActivation() != null) {
      String validFrom = WebComponentUtil.formatDate(assignment.getActivation().getValidFrom());
      if (validFrom != null) {
        infoList.add(
            page.createStringResource("PageCert.message.textValidFrom", validFrom).getString());
      }
      String validTo = WebComponentUtil.formatDate(assignment.getActivation().getValidTo());
      if (validTo != null) {
        infoList.add(
            page.createStringResource("PageCert.message.textValidTo", validTo).getString());
      }
      if (assignment.getActivation().getAdministrativeStatus() != null) {
        infoList.add(
            page.createStringResource(
                    "PageCert.message.textAdministrativeState",
                    page.createStringResource(assignment.getActivation().getAdministrativeStatus())
                        .getString())
                .getString());
      }
    }

    String rv = StringUtils.join(infoList, "<br/>");
    return rv;
  }
コード例 #10
0
ファイル: PrismValuePanel.java プロジェクト: mythoss/midpoint
  // normally this method returns an InputPanel;
  // however, for some special readonly types (like ObjectDeltaType) it will return a Panel
  private Panel createTypedInputComponent(String id) {
    //        ValueWrapper valueWrapper = model.getObject();
    //        ItemWrapper itemWrapper =
    final Item item = valueWrapperModel.getObject().getItem().getItem();

    Panel panel = null;
    if (item instanceof PrismProperty) {
      final PrismProperty property = (PrismProperty) item;
      PrismPropertyDefinition definition = property.getDefinition();
      final QName valueType = definition.getTypeName();

      final String baseExpression = "value.value"; // pointing to prism property real value

      // fixing MID-1230, will be improved with some kind of annotation or something like that
      // now it works only in description
      if (ObjectType.F_DESCRIPTION.equals(definition.getName())) {
        return new TextAreaPanel(id, new PropertyModel(valueWrapperModel, baseExpression), null);
      }

      if (ActivationType.F_ADMINISTRATIVE_STATUS.equals(definition.getName())) {
        return WebComponentUtil.createEnumPanel(
            ActivationStatusType.class,
            id,
            new PropertyModel<ActivationStatusType>(valueWrapperModel, baseExpression),
            this);
      } else if (ActivationType.F_LOCKOUT_STATUS.equals(definition.getName())) {
        return new LockoutStatusPanel(
            id, new PropertyModel<LockoutStatusType>(valueWrapperModel, baseExpression));
      } else {
        // nothing to do
      }

      if (DOMUtil.XSD_DATETIME.equals(valueType)) {
        panel =
            new DatePanel(
                id, new PropertyModel<XMLGregorianCalendar>(valueWrapperModel, baseExpression));

      } else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
        boolean showRemovePasswordButton = true;
        if (pageBase instanceof PageUser
            && ((PageUser) pageBase).getObjectWrapper().getObject() != null
            && ((PageUser) pageBase).getObjectWrapper().getObject().getOid() != null
            && ((PageUser) pageBase)
                .getObjectWrapper()
                .getObject()
                .getOid()
                .equals(SecurityUtils.getPrincipalUser().getOid())) {
          showRemovePasswordButton = false;
        }
        panel =
            new PasswordPanel(
                id,
                new PropertyModel<ProtectedStringType>(valueWrapperModel, baseExpression),
                valueWrapperModel.getObject().isReadonly(),
                showRemovePasswordButton);
      } else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) {
        panel =
            new TriStateComboPanel(
                id, new PropertyModel<Boolean>(valueWrapperModel, baseExpression));

      } else if (SchemaConstants.T_POLY_STRING_TYPE.equals(valueType)) {
        InputPanel inputPanel;
        PrismPropertyDefinition def = property.getDefinition();

        if (def.getValueEnumerationRef() != null) {
          PrismReferenceValue valueEnumerationRef = def.getValueEnumerationRef();
          String lookupTableUid = valueEnumerationRef.getOid();
          Task task = pageBase.createSimpleTask("loadLookupTable");
          OperationResult result = task.getResult();

          Collection<SelectorOptions<GetOperationOptions>> options =
              SelectorOptions.createCollection(
                  LookupTableType.F_ROW,
                  GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
          final PrismObject<LookupTableType> lookupTable =
              WebModelServiceUtils.loadObject(
                  LookupTableType.class, lookupTableUid, options, pageBase, task, result);

          if (lookupTable != null) {

            inputPanel =
                new AutoCompleteTextPanel<String>(
                    id,
                    new LookupPropertyModel<String>(
                        valueWrapperModel, baseExpression + ".orig", lookupTable.asObjectable()),
                    String.class) {

                  @Override
                  public Iterator<String> getIterator(String input) {
                    return prepareAutoCompleteList(input, lookupTable).iterator();
                  }
                };

          } else {
            inputPanel =
                new TextPanel<>(
                    id,
                    new PropertyModel<String>(valueWrapperModel, baseExpression + ".orig"),
                    String.class);
          }

        } else {

          inputPanel =
              new TextPanel<>(
                  id,
                  new PropertyModel<String>(valueWrapperModel, baseExpression + ".orig"),
                  String.class);
        }

        if (ObjectType.F_NAME.equals(def.getName()) || UserType.F_FULL_NAME.equals(def.getName())) {
          inputPanel.getBaseFormComponent().setRequired(true);
        }
        panel = inputPanel;

      } else if (DOMUtil.XSD_BASE64BINARY.equals(valueType)) {
        panel =
            new UploadDownloadPanel(id, valueWrapperModel.getObject().isReadonly()) {

              @Override
              public InputStream getStream() {
                Object object =
                    ((PrismPropertyValue) valueWrapperModel.getObject().getValue()).getValue();
                return object != null
                    ? new ByteArrayInputStream((byte[]) object)
                    : new ByteArrayInputStream(new byte[0]);
                //                		return super.getStream();
              }

              @Override
              public void updateValue(byte[] file) {
                ((PrismPropertyValue) valueWrapperModel.getObject().getValue()).setValue(file);
              }

              @Override
              public void uploadFilePerformed(AjaxRequestTarget target) {
                super.uploadFilePerformed(target);
                target.add(PrismValuePanel.this.get(ID_FEEDBACK));
              }

              @Override
              public void removeFilePerformed(AjaxRequestTarget target) {
                super.removeFilePerformed(target);
                target.add(PrismValuePanel.this.get(ID_FEEDBACK));
              }

              @Override
              public void uploadFileFailed(AjaxRequestTarget target) {
                super.uploadFileFailed(target);
                target.add(PrismValuePanel.this.get(ID_FEEDBACK));
                target.add(((PageBase) getPage()).getFeedbackPanel());
              }
            };

      } else if (ObjectDeltaType.COMPLEX_TYPE.equals(valueType)) {
        panel =
            new ModificationsPanel(
                id,
                new AbstractReadOnlyModel<DeltaDto>() {
                  @Override
                  public DeltaDto getObject() {
                    if (valueWrapperModel.getObject() == null
                        || valueWrapperModel.getObject().getValue() == null
                        || ((PrismPropertyValue) valueWrapperModel.getObject().getValue())
                                .getValue()
                            == null) {
                      return null;
                    }
                    PrismContext prismContext = ((PageBase) getPage()).getPrismContext();
                    ObjectDeltaType objectDeltaType =
                        (ObjectDeltaType)
                            ((PrismPropertyValue) valueWrapperModel.getObject().getValue())
                                .getValue();
                    try {
                      ObjectDelta delta =
                          DeltaConvertor.createObjectDelta(objectDeltaType, prismContext);
                      return new DeltaDto(delta);
                    } catch (SchemaException e) {
                      throw new IllegalStateException(
                          "Couldn't convert object delta: " + objectDeltaType);
                    }
                  }
                });
      } else if (QueryType.COMPLEX_TYPE.equals(valueType)
          || CleanupPoliciesType.COMPLEX_TYPE.equals(valueType)) {
        return new TextAreaPanel(
            id,
            new AbstractReadOnlyModel() {
              @Override
              public Object getObject() {
                if (valueWrapperModel.getObject() == null
                    || valueWrapperModel.getObject().getValue() == null) {
                  return null;
                }
                PrismPropertyValue ppv =
                    (PrismPropertyValue) valueWrapperModel.getObject().getValue();
                if (ppv == null || ppv.getValue() == null) {
                  return null;
                }
                QName name = property.getElementName();
                if (name == null && property.getDefinition() != null) {
                  name = property.getDefinition().getName();
                }
                if (name == null) {
                  name = SchemaConstants.C_VALUE;
                }
                PrismContext prismContext = ((PageBase) getPage()).getPrismContext();
                try {
                  return prismContext.serializeAnyData(ppv.getValue(), name, PrismContext.LANG_XML);
                } catch (SchemaException e) {
                  throw new SystemException(
                      "Couldn't serialize property value of type: "
                          + valueType
                          + ": "
                          + e.getMessage(),
                      e);
                }
              }
            },
            10);
      } else {
        Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
        if (type != null && type.isPrimitive()) {
          type = ClassUtils.primitiveToWrapper(type);
        }

        if (isEnum(property)) {
          return WebComponentUtil.createEnumPanel(
              definition, id, new PropertyModel<>(valueWrapperModel, baseExpression), this);
        }
        //                  // default QName validation is a bit weird, so let's treat QNames as
        // strings [TODO finish this - at the parsing side]
        //                  if (type == QName.class) {
        //                      type = String.class;
        //                  }

        PrismPropertyDefinition def = property.getDefinition();

        if (def.getValueEnumerationRef() != null) {
          PrismReferenceValue valueEnumerationRef = def.getValueEnumerationRef();
          String lookupTableUid = valueEnumerationRef.getOid();
          Task task = pageBase.createSimpleTask("loadLookupTable");
          OperationResult result = task.getResult();

          Collection<SelectorOptions<GetOperationOptions>> options =
              SelectorOptions.createCollection(
                  LookupTableType.F_ROW,
                  GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
          final PrismObject<LookupTableType> lookupTable =
              WebModelServiceUtils.loadObject(
                  LookupTableType.class, lookupTableUid, options, pageBase, task, result);

          if (lookupTable != null) {

            panel =
                new AutoCompleteTextPanel<String>(
                    id,
                    new LookupPropertyModel<String>(
                        valueWrapperModel,
                        baseExpression,
                        lookupTable == null ? null : lookupTable.asObjectable()),
                    type) {

                  @Override
                  public Iterator<String> getIterator(String input) {
                    return prepareAutoCompleteList(input, lookupTable).iterator();
                  }

                  @Override
                  public void checkInputValue(
                      AutoCompleteTextField input,
                      AjaxRequestTarget target,
                      LookupPropertyModel model) {
                    Iterator<String> lookupTableValuesIterator =
                        prepareAutoCompleteList("", lookupTable).iterator();

                    String value = input.getInput();
                    boolean isValueExist = false;
                    if (value != null) {
                      if (value.trim().equals("")) {
                        isValueExist = true;
                      } else {
                        while (lookupTableValuesIterator.hasNext()) {
                          String lookupTableValue = lookupTableValuesIterator.next();
                          if (value.trim().equals(lookupTableValue)) {
                            isValueExist = true;
                            break;
                          }
                        }
                      }
                    }
                    if (isValueExist) {
                      input.setModelValue(new String[] {value});
                      target.add(PrismValuePanel.this.get(ID_FEEDBACK));
                    } else {
                      input.error(
                          "Entered value doesn't match any of available values and will not be saved.");
                      target.add(PrismValuePanel.this.get(ID_FEEDBACK));
                    }
                  }
                };

          } else {

            panel =
                new TextPanel<>(
                    id, new PropertyModel<String>(valueWrapperModel, baseExpression), type);
          }

        } else {
          panel =
              new TextPanel<>(
                  id, new PropertyModel<String>(valueWrapperModel, baseExpression), type);
        }
      }
    } else if (item instanceof PrismReference) {
      PrismContext prismContext = item.getPrismContext();
      if (prismContext == null) {
        prismContext = pageBase.getPrismContext();
      }
      QName targetTypeName = ((PrismReferenceDefinition) item.getDefinition()).getTargetTypeName();
      Class targetClass = null;
      if (targetTypeName != null && prismContext != null) {
        targetClass = prismContext.getSchemaRegistry().determineCompileTimeClass(targetTypeName);
      }
      final Class typeClass =
          targetClass != null
              ? targetClass
              : (item.getDefinition().getTypeClassIfKnown() != null
                  ? item.getDefinition().getTypeClassIfKnown()
                  : FocusType.class);
      Collection typeClasses = new ArrayList();

      // HACK HACK MID-3201 MID-3231
      if (isUserOrgItem(item, typeClass)) {
        typeClasses.add(UserType.class);
        typeClasses.add(OrgType.class);
      } else {
        typeClasses.add(typeClass);
      }

      panel =
          new ValueChoosePanel(
              id,
              new PropertyModel<>(valueWrapperModel, "value"),
              item.getValues(),
              false,
              typeClasses);

    } else if (item instanceof PrismContainer<?>) {
      AssociationWrapper itemWrapper = (AssociationWrapper) valueWrapperModel.getObject().getItem();
      final PrismContainer container = (PrismContainer) item;
      PrismContainerDefinition definition = container.getDefinition();
      QName valueType = definition.getTypeName();

      if (ShadowAssociationType.COMPLEX_TYPE.equals(valueType)) {

        PrismContext prismContext = item.getPrismContext();
        if (prismContext == null) {
          prismContext = pageBase.getPrismContext();
        }

        ShadowType shadowType =
            ((ShadowType) itemWrapper.getContainer().getObject().getObject().asObjectable());
        PrismObject<ResourceType> resource = shadowType.getResource().asPrismObject();
        // HACK. The revive should not be here. Revive is no good. The next use of the resource will
        // cause parsing of resource schema. We need some centralized place to maintain live cached
        // copies
        // of resources.
        try {
          resource.revive(prismContext);
        } catch (SchemaException e) {
          throw new SystemException(e.getMessage(), e);
        }
        RefinedResourceSchema refinedSchema;
        CompositeRefinedObjectClassDefinition rOcDef;
        try {
          refinedSchema = RefinedResourceSchema.getRefinedSchema(resource);
          rOcDef =
              refinedSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject());
        } catch (SchemaException e) {
          throw new SystemException(e.getMessage(), e);
        }
        RefinedAssociationDefinition assocDef = itemWrapper.getRefinedAssociationDefinition();
        RefinedObjectClassDefinition assocTargetDef = assocDef.getAssociationTarget();

        ObjectQuery query =
            getAssociationsSearchQuery(
                prismContext,
                resource,
                assocTargetDef.getTypeName(),
                assocTargetDef.getKind(),
                assocTargetDef.getIntent());

        List values = item.getValues();
        return new AssociationValueChoicePanel(
            id, valueWrapperModel, values, false, ShadowType.class, query, assocTargetDef);
      }
    }

    return panel;
  }