Exemplo n.º 1
0
  private void importAccount(AjaxRequestTarget target, AccountContentDto row) {
    List<AccountContentDto> accounts = isAnythingSelected(target, row);
    if (accounts.isEmpty()) {
      return;
    }

    OperationResult result = new OperationResult(OPERATION_CREATE_USER_FROM_ACCOUNTS);
    for (AccountContentDto dto : accounts) {
      OperationResult subResult = result.createMinorSubresult(OPERATION_CREATE_USER_FROM_ACCOUNT);
      try {
        getModelService()
            .importFromResource(
                dto.getAccountOid(),
                createSimpleTask(OPERATION_CREATE_USER_FROM_ACCOUNT),
                subResult);
      } catch (Exception ex) {
        subResult.computeStatus(
            getString("pageContentAccounts.message.cantImportAccount", dto.getAccountOid()));
        LoggingUtils.logException(
            LOGGER,
            "Can't import account {},oid={}",
            ex,
            dto.getAccountName(),
            dto.getAccountOid());
      } finally {
        subResult.computeStatusIfUnknown();
      }
    }

    result.computeStatus();
    showResult(result);

    target.add(getFeedbackPanel());
    target.add(getTable());
  }
Exemplo n.º 2
0
  private void updateAccountStatusPerformed(
      AjaxRequestTarget target, AccountContentDto dto, boolean enabled) {
    List<AccountContentDto> accounts = isAnythingSelected(target, dto);
    OperationResult result = new OperationResult(OPERATION_ADJUST_ACCOUNT_STATUS);

    if (accounts.isEmpty()) {
      return;
    }

    ActivationStatusType status =
        enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED;

    for (AccountContentDto acc : accounts) {

      ObjectDelta delta =
          ObjectDelta.createModificationReplaceProperty(
              ShadowType.class,
              acc.getAccountOid(),
              new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS),
              getPrismContext(),
              status);

      try {
        Task task = createSimpleTask(OPERATION_ADJUST_ACCOUNT_STATUS);
        getModelService()
            .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result);
      } catch (Exception e) {
        LoggingUtils.logException(LOGGER, "Couldn't enable/disable account(s) on resource", e);
        result.recordPartialError("Couldn't enable/disable account(s) on resource", e);
      }
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
  }
Exemplo n.º 3
0
  private void removeOwnerPerformed(AjaxRequestTarget target, AccountContentDto row) {
    List<AccountContentDto> accounts = isAnythingSelected(target, row);
    if (accounts.isEmpty()) {
      return;
    }

    for (AccountContentDto dto : accounts) {
      reloadOwnerChangeModel(dto.getAccountOid(), dto.getOwnerOid());
      ownerChangePerformed(target, null);
    }

    target.add(getTable());
    target.add(getFeedbackPanel());
  }
Exemplo n.º 4
0
  private void deleteConfirmedPerformed(AjaxRequestTarget target) {
    List<AccountContentDto> selected = new ArrayList<AccountContentDto>();

    if (singleDelete != null) {
      selected.add(singleDelete);
    } else {
      selected = isAnythingSelected(target, null);
    }

    OperationResult result = new OperationResult(OPERATION_DELETE_ACCOUNT_FROM_RESOURCE);

    for (AccountContentDto acc : selected) {
      String accOid = acc.getAccountOid();

      try {
        Task task = createSimpleTask(OPERATION_DELETE_ACCOUNT_FROM_RESOURCE);

        ObjectDelta delta =
            ObjectDelta.createDeleteDelta(ShadowType.class, accOid, getPrismContext());
        getModelService()
            .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result);

      } catch (Exception e) {
        result.recordPartialError("Couldn't delete account from resource.", e);
        LoggingUtils.logException(LOGGER, "Couldn't delete account from resource", e);
      }
    }

    if (result.isUnknown()) {
      result.recomputeStatus("Error occurred during resource account deletion.");
    }

    if (result.isSuccess()) {
      result.recordStatus(
          OperationResultStatus.SUCCESS, "Selected accounts have been successfully deleted.");
    }

    AccountContentDataProvider provider =
        (AccountContentDataProvider) getTable().getDataTable().getDataProvider();
    provider.clearCache();

    TablePanel table = getTable();
    target.add(table);
    showResult(result);
    target.add(getFeedbackPanel());
  }
Exemplo n.º 5
0
  private void changeOwnerPerformed(AjaxRequestTarget target, AccountContentDto dto) {
    reloadOwnerChangeModel(dto.getAccountOid(), dto.getOwnerOid());

    showModalWindow(MODAL_ID_OWNER_CHANGE, target);
  }