コード例 #1
0
  /**
   * A yet unknown Internet user registers as a new organization at the platform.
   *
   * @return the logical outcome.
   * @throws NonUniqueBusinessKeyException Thrown if the organizationId is not unique
   * @throws ValidationException Thrown if the validation in the service layer failed
   * @throws ObjectNotFoundException Thrown if the organization contains a supplierId which doesn't
   *     exist in the database
   * @throws MailOperationException
   * @throws RegistrationException Thrown if no supplier is specified or in case the specified
   *     organization is not a supplier.
   */
  public String register()
      throws NonUniqueBusinessKeyException, ValidationException, ObjectNotFoundException,
          MailOperationException, RegistrationException {
    if (logger.isDebugLoggingEnabled()) {}

    String mId = getMarketplaceId();
    String parameter = getRequest().getParameter(Constants.REQ_PARAM_SERVICE_KEY);
    String outcome = BaseBean.OUTCOME_SUCCESS;

    Long serviceKey = null;
    if (parameter != null && parameter.trim().length() > 0) {
      serviceKey = Long.valueOf(parameter);
    }
    // FIXME: Must be fixed in identity service.
    if (!isInternalMode()) {
      // A confirmation mail must be send, not a user created mail.
      // If no password is given it will be generated
      password = "";
    }
    try {
      organization =
          getAccountingService()
              .registerCustomer(
                  getOrganization(),
                  user.getVOUserDetails(),
                  password,
                  serviceKey,
                  mId,
                  getSupplierId());
    } catch (NonUniqueBusinessKeyException ex) {
      if (isInternalMode()) {
        throw ex;
      }
      ex.setMessageKey(BaseBean.ERROR_USER_ALREADY_EXIST);
      ExceptionHandler.execute(ex, true);
      return BaseBean.OUTCOME_ERROR;
    }
    if (logger.isDebugLoggingEnabled()) {}

    return outcome;
  }
コード例 #2
0
 private void handleServletException(
     HttpServletRequest httpRequest, HttpServletResponse httpResponse, ServletException e)
     throws IOException, ServletException {
   EJBException ejbEx = ExceptionHandler.getEJBException(e);
   if (ejbEx != null
       && ejbEx.getCause() instanceof Exception
       && ejbEx.getCausedByException() instanceof AccessException) {
     String forwardErrorPage;
     if (BesServletRequestReader.isMarketplaceRequest(httpRequest)) {
       forwardErrorPage = Marketplace.MARKETPLACE_ROOT + Constants.INSUFFICIENT_AUTHORITIES_URI;
     } else {
       forwardErrorPage = Constants.INSUFFICIENT_AUTHORITIES_URI;
     }
     JSFUtils.sendRedirect(httpResponse, httpRequest.getContextPath() + forwardErrorPage);
   } else {
     // make sure we do not catch exceptions cause by
     // ViewExpiredException here, they'll be handled directly in the
     // doFilter()
     throw e;
   }
 }