public ActionForward getPersonInfo( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // If user pressed 'Cancel' button, // return to home page ActionForward forward = null; CommonLogger.logDebug(log, "In PersonAction:getPersonInfo() "); if (isCancelled(request)) { return mapping.findForward("home"); } String personId = request.getParameter(BSIConstants.PERSON_ID); User user = (User) request.getSession().getAttribute(BSIConstants.USER); // String personId = user.getPerson().getId().toString(); CommonLogger.logInfo(log, "Executing the view action for the person id:" + personId); try { PersonManager clientHandler = new PersonManager(); Person personObj = clientHandler.getPerson(personId); CommonLogger.logDebug(log, "Populating the person form"); PersonForm personForm = (PersonForm) form; PropertyUtils.copyProperties(personForm, personObj); CommonLogger.logDebug( log, "After Populating the person form, the name is " + personForm.getName()); String personType = personForm.getPersonType(); if (personType != null && personType.equalsIgnoreCase(BSIConstants.BUYER)) { forward = mapping.findForward("Buyer"); } else if (personType != null && personType.equalsIgnoreCase(BSIConstants.SUPPLIER)) { forward = mapping.findForward("Supplier"); } } catch (BSIException ex1) { ActionErrors errors = new ActionErrors(); CommonLogger.logDebug( log, "In BuyerAction:editPersonalInfo() \n exception occured. Exception message is " + ex1.getMessage()); errors.add( ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage())); saveErrors(request, errors); } catch (Exception ex2) { throw ex2; } finally { request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT); } return forward; }
public ActionForward updatePersonInfo( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { CommonLogger.logDebug(log, "In PersonAction:updatePersonInfo() "); // If user pressed 'Cancel' button, // return to home page if (isCancelled(request)) { return mapping.findForward("home"); } // Person personObj = new Person(); // PropertyUtils.copyProperties(personObj, (PersonForm)form); try { PersonManager clientHandler = new PersonManager(); Person oldPersonObj = clientHandler.getPerson(((PersonForm) form).getId().toString()); CommonLogger.logDebug(log, "the retrieved person id is " + oldPersonObj.getId()); PropertyUtils.copyProperties(oldPersonObj, (PersonForm) form); clientHandler.updatePersonInfo(oldPersonObj); ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("common.update.succesfull")); saveMessages(request, msgs); } catch (BSIException ex1) { ActionErrors errors = new ActionErrors(); CommonLogger.logDebug( log, "In PersonAction:updatePersonInfo() \n exception occured. Exception message is " + ex1.getMessage()); errors.add( ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage())); saveErrors(request, errors); } catch (Exception ex2) { throw ex2; } finally { request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT); } return mapping.findForward("success"); }
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"); }