Esempio n. 1
0
  private void savePerformed(boolean raw, String operationName, AjaxRequestTarget target) {
    clearOldFeedback();

    OperationResult result = new OperationResult(operationName);

    if (!validateInput(raw)) {
      error(getString("pageImportObject.message.nullFile"));
      target.add(getFeedbackPanel());

      return;
    }
    InputStream stream = null;

    try {
      Task task = createSimpleTask(operationName);
      stream = getInputStream(raw);
      getModelService().importObjectsFromStream(stream, model.getObject(), task, result);

      result.recomputeStatus();
    } catch (Exception ex) {
      result.recordFatalError("Couldn't import file.", ex);
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't import file", ex);
    } finally {
      if (stream != null) {
        IOUtils.closeQuietly(stream);
      }
    }

    showResult(result);
    target.add(PageImportObject.this);
  }
Esempio n. 2
0
  private void clearSearchPerformed(AjaxRequestTarget target) {
    ReportOutputSearchDto dto = searchModel.getObject();
    dto.setReportType(null);
    dto.setText(null);

    refreshTable(target);
  }
Esempio n. 3
0
 private void updatePropagatedAccountIconsCssClass(String cssClassName) {
   MyPasswordsDto dto = model.getObject();
   for (PasswordAccountDto passwordAccountDto : dto.getAccounts()) {
     if (passwordAccountDto.isPasswordOutbound()) {
       passwordAccountDto.setCssClass(cssClassName);
     }
   }
 }
Esempio n. 4
0
  private void refreshTable(AjaxRequestTarget target) {
    Table panel = getReportOutputTable();

    ReportsStorage storage = getSessionStorage().getReports();
    storage.setReportOutputSearch(searchModel.getObject());
    storage.setReportOutputsPaging(null);
    panel.setCurrentPage(0);

    target.add((Component) panel);
    target.add(getFeedbackPanel());
  }
Esempio n. 5
0
  private void savePerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(PageInternals.class.getName() + ".changeTime");
    XMLGregorianCalendar offset = model.getObject();
    if (offset != null) {
      clock.override(offset);
    }

    result.recordSuccess();
    showResult(result);
    target.add(getFeedbackPanel(), getMainForm());
  }
Esempio n. 6
0
  private ObjectQuery createQuery() {
    ReportOutputSearchDto dto = searchModel.getObject();
    S_AtomicFilterEntry q = QueryBuilder.queryFor(ReportOutputType.class, getPrismContext());

    if (StringUtils.isNotEmpty(dto.getText())) {
      PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
      String normalizedString = normalizer.normalize(dto.getText());
      q = q.item(ReportOutputType.F_NAME).containsPoly(normalizedString).matchingNorm().and();
    }

    String oid = dto.getReportTypeMap().get(dto.getReportType());
    if (StringUtils.isNotEmpty(oid)) {
      q = q.item(ReportOutputType.F_REPORT_REF).ref(oid).and();
    }

    return q.all().build();
  }
Esempio n. 7
0
  private void claimPerformed(AjaxRequestTarget target) {

    OperationResult result = new OperationResult(OPERATION_CLAIM_WORK_ITEM);
    WorkflowService workflowService = getWorkflowService();
    try {
      workflowService.claimWorkItem(workItemDtoModel.getObject().getWorkItemId(), result);
    } catch (SecurityViolationException | ObjectNotFoundException | RuntimeException e) {
      result.recordFatalError("Couldn't claim work item due to an unexpected exception.", e);
    }
    result.computeStatusIfUnknown();

    if (!result.isSuccess()) {
      showResult(result);
      target.add(getFeedbackPanel());
    } else {
      showResult(result);
      redirectBack();
    }
  }
Esempio n. 8
0
  private void savePerformed(AjaxRequestTarget target, boolean decision) {
    LOGGER.debug("Saving work item changes.");

    OperationResult result = new OperationResult(OPERATION_SAVE_WORK_ITEM);

    try {
      WorkItemDto dto = workItemDtoModel.getObject();
      getWorkflowService()
          .approveOrRejectWorkItem(dto.getWorkItemId(), decision, dto.getApproverComment(), result);
    } catch (Exception ex) {
      result.recordFatalError("Couldn't save work item.", ex);
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save work item", ex);
    }

    result.computeStatusIfUnknown();

    if (!result.isSuccess()) {
      showResult(result, false);
      target.add(getFeedbackPanel());
    } else {
      showResult(result);
      redirectBack();
    }
  }
Esempio n. 9
0
  private void initLayout(final boolean oldPasswordVisible) {
    model = (LoadableModel<MyPasswordsDto>) getModel();

    Label oldPasswordLabel =
        new Label(
            ID_OLD_PASSWORD_LABEL, createStringResource("PageSelfCredentials.oldPasswordLabel"));
    add(oldPasswordLabel);
    oldPasswordLabel.add(
        new VisibleEnableBehaviour() {

          private static final long serialVersionUID = 1L;

          @Override
          public boolean isVisible() {
            return oldPasswordVisible;
          }
        });

    Label passwordLabel =
        new Label(ID_PASSWORD_LABEL, createStringResource("PageSelfCredentials.passwordLabel1"));
    add(passwordLabel);

    PasswordTextField oldPasswordField =
        new PasswordTextField(
            ID_OLD_PASSWORD_FIELD, new PropertyModel<String>(model, MyPasswordsDto.F_OLD_PASSWORD));
    oldPasswordField.setRequired(false);
    oldPasswordField.setResetPassword(false);
    add(oldPasswordField);
    oldPasswordField.add(
        new VisibleEnableBehaviour() {

          private static final long serialVersionUID = 1L;

          public boolean isVisible() {
            return oldPasswordVisible;
          };
        });

    PasswordPanel passwordPanel =
        new PasswordPanel(
            ID_PASSWORD_PANEL,
            new PropertyModel<ProtectedStringType>(model, MyPasswordsDto.F_PASSWORD));
    passwordPanel.getBaseFormComponent().add(new AttributeModifier("autofocus", ""));
    add(passwordPanel);

    WebMarkupContainer accountContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);

    List<IColumn<PasswordAccountDto, String>> columns = initColumns();
    ListDataProvider<PasswordAccountDto> provider =
        new ListDataProvider<PasswordAccountDto>(
            this, new PropertyModel<List<PasswordAccountDto>>(model, MyPasswordsDto.F_ACCOUNTS));
    TablePanel accounts = new TablePanel(ID_ACCOUNTS_TABLE, provider, columns);
    accounts.setItemsPerPage(30);
    accounts.setShowPaging(false);
    if (model.getObject().getPropagation() != null
        && model
            .getObject()
            .getPropagation()
            .equals(CredentialsPropagationUserControlType.MAPPING)) {
      accountContainer.setVisible(false);
    }
    accountContainer.add(accounts);

    AjaxLink help =
        new AjaxLink(ID_BUTTON_HELP) {
          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            showHelpPerformed(target);
          }
        };
    accountContainer.add(help);

    add(accountContainer);
  }
Esempio n. 10
0
  private WorkItemDto loadWorkItemDtoIfNecessary() {
    if (workItemDtoModel.isLoaded()) {
      return workItemDtoModel.getObject();
    }
    Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEM);
    OperationResult result = task.getResult();
    WorkItemDto workItemDto = null;
    try {
      final ObjectQuery query =
          QueryBuilder.queryFor(WorkItemType.class, getPrismContext())
              .item(F_WORK_ITEM_ID)
              .eq(taskId)
              .build();
      final Collection<SelectorOptions<GetOperationOptions>> options =
          resolveItemsNamed(F_ASSIGNEE_REF);
      List<WorkItemType> workItems =
          getModelService().searchContainers(WorkItemType.class, query, options, task, result);
      if (workItems.size() > 1) {
        throw new SystemException("More than one work item with ID of " + taskId);
      } else if (workItems.size() == 0) {
        throw new SystemException("No work item with ID of " + taskId);
      }
      final WorkItemType workItem = workItems.get(0);

      final String taskOid = workItem.getTaskRef() != null ? workItem.getTaskRef().getOid() : null;
      TaskType taskType = null;
      List<TaskType> relatedTasks = new ArrayList<>();
      if (taskOid != null) {
        final Collection<SelectorOptions<GetOperationOptions>> getTaskOptions =
            resolveItemsNamed(new ItemPath(F_WORKFLOW_CONTEXT, F_REQUESTER_REF));
        getTaskOptions.addAll(retrieveItemsNamed(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM)));
        try {
          taskType =
              getModelService()
                  .getObject(TaskType.class, taskOid, getTaskOptions, task, result)
                  .asObjectable();
        } catch (AuthorizationException e) {
          LoggingUtils.logExceptionOnDebugLevel(
              LOGGER, "Access to the task {} was denied", e, taskOid);
        }

        if (taskType != null && taskType.getParent() != null) {
          final ObjectQuery relatedTasksQuery =
              QueryBuilder.queryFor(TaskType.class, getPrismContext())
                  .item(F_PARENT)
                  .eq(taskType.getParent())
                  .build();
          List<PrismObject<TaskType>> relatedTaskObjects =
              getModelService()
                  .searchObjects(TaskType.class, relatedTasksQuery, null, task, result);
          for (PrismObject<TaskType> relatedObject : relatedTaskObjects) {
            relatedTasks.add(relatedObject.asObjectable());
          }
        }
      }
      workItemDto = new WorkItemDto(workItem, taskType, relatedTasks);
      workItemDto.prepareDeltaVisualization(
          "pageWorkItem.delta", getPrismContext(), getModelInteractionService(), task, result);
      result.recordSuccessIfUnknown();
    } catch (CommonException | RuntimeException ex) {
      result.recordFatalError("Couldn't get work item.", ex);
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get work item.", ex);
    }
    showResult(result, false);
    if (!result.isSuccess()) {
      throw getRestartResponseException(PageDashboard.class);
    }
    return workItemDto;
  }