示例#1
0
  public ActionForward listSubscribedServices(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:listSubscribedServices() ");

    ActionMessages msgs = new ActionMessages();
    Set srvs = null;

    try {

      // String personId = request.getParameter(BSIConstants.PERSON_ID);
      User user = (User) request.getSession().getAttribute(BSIConstants.USER);
      // String personId = user.getPerson().getId().toString();
      String personId = null;
      if (request.getParameter(BSIConstants.PERSON_ID) != null) {
        personId = request.getParameter(BSIConstants.PERSON_ID);
      } else {
        personId = user.getPerson().getId().toString();
      }
      String personType = request.getParameter(BSIConstants.PERSON_TYPE);

      CommonLogger.logDebug(log, "The person id is " + personId);

      PersonManager clientHandler = new PersonManager();
      Person personObj = clientHandler.getPerson(personId);

      // Get the service region for the person
      // TODO should support multiple service region, each for a service.
      Long serviceId = null;
      if (personType != null && personType.equalsIgnoreCase(BSIConstants.BUYER)) {
        srvs = personObj.getRequestedSevices();
      } else if (personType != null && personType.equalsIgnoreCase(BSIConstants.SUPPLIER)) {
        srvs = personObj.getOfferedServices();
      }

      // srvs = personObj.getServices();
      if (log.isDebugEnabled()) {
        if (srvs != null) {
          Object[] services = srvs.toArray();
          if (services.length > 0) serviceId = ((Service) services[0]).getNodeId();
          CommonLogger.logDebug(log, "The service id is " + serviceId);
        }
      }

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:subscribeService()  \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } finally {
      request.setAttribute(BSIConstants.SUBSCRIBED_SERVICES_LIST, srvs);
    }
    return mapping.findForward("success");
  }