예제 #1
0
  /**
   * This method will use the DocumentService to create a new document. The documentTypeName is
   * gathered by using MaintenanceDocumentDictionaryService which uses Account class to get the
   * document type name.
   *
   * @param AccountCreationStatusDTO
   * @return document returns a new document for the account document type or null if there is an
   *     exception thrown.
   */
  public Document createCGAccountMaintenanceDocument(
      AccountCreationStatusDTO accountCreationStatus) {

    boolean internalUserSession = false;
    try {
      if (GlobalVariables.getUserSession() == null) {
        internalUserSession = true;
        GlobalVariables.setUserSession(new UserSession(KFSConstants.SYSTEM_USER));
        GlobalVariables.clear();
      }
      Document document =
          getDocumentService()
              .getNewDocument(
                  maintenanceDocumentDictionaryService.getDocumentTypeName(Account.class));
      return document;

    } catch (Exception e) {
      accountCreationStatus.setErrorMessages(
          GlobalVariablesExtractHelper.extractGlobalVariableErrors());
      accountCreationStatus.setStatus(KcConstants.KcWebService.STATUS_KC_FAILURE);
      return null;
    } finally {
      // if a user session was established for this call, clear it our
      if (internalUserSession) {
        GlobalVariables.clear();
        GlobalVariables.setUserSession(null);
      }
    }
  }
 protected Maintainable getSubObjectMaintainable(String documentNumber) {
   Maintainable subObjectMaintainable;
   try {
     subObjectMaintainable =
         (Maintainable)
             maintenanceDocumentDictionaryService
                 .getMaintainableClass(SubObjectCode.class.getName())
                 .newInstance();
     subObjectMaintainable.setBoClass(SubObjectCode.class);
     subObjectMaintainable.setDocumentNumber(documentNumber);
   } catch (Exception e) {
     LOG.error("Unable to instantiate SubObject Maintainable", e);
     throw new RuntimeException("Unable to instantiate SubObject Maintainable", e);
   }
   return subObjectMaintainable;
 }
예제 #3
0
  /**
   * This method check to see if the user can create the account maintenance document and set the
   * user session
   *
   * @param String principalId
   * @return boolean
   */
  protected boolean isValidUser(String principalId) {

    if (principalId == null) {
      return false;
    }
    Person user = personService.getPerson(principalId);
    if (user == null) {
      return false;
    }
    DocumentAuthorizer documentAuthorizer = new MaintenanceDocumentAuthorizerBase();
    if (documentAuthorizer.canInitiate(
        maintenanceDocumentDictionaryService.getDocumentTypeName(Account.class), user)) {
      // set the user session so that the user name can be displayed in the saved document
      GlobalVariables.setUserSession(new UserSession(user.getPrincipalName()));
      return true;
    }

    LOG.error(
        KcUtils.getErrorMessage(
            KcConstants.AccountCreationService.ERROR_KC_DOCUMENT_INVALID_USER,
            new String[] {principalId}));

    return false;
  }