/** * <br> * [機 能] 削除確認画面設定 <br> * [解 説] <br> * [備 考] * * @param map アクションマッピング * @param form アクションフォーム * @param req リクエスト * @return ActionForward */ private ActionForward __doDeleteKnDsp( ActionMapping map, Ipk100Form form, HttpServletRequest req) { ActionForward forward = null; Cmn999Form cmn999Form = new Cmn999Form(); ActionForward forwardOK = null; ActionForward forwardCancel = null; // トランザクショントークン設定 this.saveToken(req); // スペック情報削除の削除確認画面パラメータの設定 MessageResources msgRes = getResources(req); cmn999Form.setType(Cmn999Form.TYPE_OKCANCEL); cmn999Form.setIcon(Cmn999Form.ICON_INFO); cmn999Form.setWtarget(Cmn999Form.WTARGET_BODY); forwardOK = map.findForward("ipk100DeleteOk"); cmn999Form.setUrlOK(forwardOK.getPath()); forwardCancel = map.findForward("ipk100DeleteCancel"); cmn999Form.setUrlCancel(forwardCancel.getPath()); cmn999Form.setMessage(msgRes.getMessage("sakujo.kakunin.once", __getSpecKbn(form, req))); cmn999Form.addHiddenParam("backScreen", form.getBackScreen()); cmn999Form.addHiddenParam("ismSid", form.getIsmSid()); cmn999Form.addHiddenParam("editMode", form.getEditMode()); cmn999Form.addHiddenParam("ipk100name", form.getIpk100name()); cmn999Form.addHiddenParam("ipk100specLevel", form.getIpk100specLevel()); cmn999Form.addHiddenParam("ipk100scroll", form.getIpk100scroll()); cmn999Form.addHiddenParam("ipk100biko", form.getIpk100biko()); cmn999Form.addHiddenParam("specKbn", form.getSpecKbn()); req.setAttribute("cmn999Form", cmn999Form); forward = map.findForward("gf_msg"); return forward; }
/** * Return a URL path that will return control to the current action. This path is generated by * adding the specified parameter to the path of the forward specified as the "input" forward for * the given mapping. * * @param mapping the ActionMapping describing the current action's forwards * @param param the name of the path parameter to add * @param value the value of the parameter to add * @exception ServletException if encoding the path parameter fails or input has not been set */ public static String findReturnPath(ActionMapping mapping, Map params) throws Exception { ActionForward inputForward = mapping.getInputForward(); if (inputForward.getPath() == null) throw new ServletException( "input cannot be null for returnPath on url: " + mapping.getPath()); ActionForward returnForward = ActionUtils.changeForwardPath(inputForward, params); return returnForward.getPath(); }
@Override public ActionForward start( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward returnForward = super.execute(mapping, form, request, response); String docHandler = returnForward.getPath(); if (PROPOSAL_DEVELOPMENT_DOCUMENT.equals(request.getParameter(DOCUMENT_TYPE_NAME))) { docHandler = docHandler.replace(KRADConstants.DOC_HANDLER_METHOD, Constants.PROPOSAL_ACTIONS_PAGE); } else if (PROTOCOL_DOCUMENT.equals(request.getParameter(DOCUMENT_TYPE_NAME)) || IACUC_PROTOCOL_DOCUMENT.equals(request.getParameter(DOCUMENT_TYPE_NAME))) { docHandler = docHandler.replace(KRADConstants.DOC_HANDLER_METHOD, Constants.MAPPING_PROTOCOL_ACTIONS); } else if (AWARD_DOCUMENT.equals(request.getParameter(DOCUMENT_TYPE_NAME))) { docHandler = docHandler.replace( KRADConstants.DOC_HANDLER_METHOD, Constants.MAPPING_AWARD_ACTIONS_PAGE); } returnForward = new ActionForward(docHandler, returnForward.getRedirect()); return returnForward; }
public ActionForward show( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SiteMapForm siteForm = (SiteMapForm) form; ActionMessages errors = new ActionMessages(); ActionForward forward = new ActionForward(); // return value String next = "sitemap"; String domContext = getDomainAndContext(request); siteForm.setContestsMainUrl(VCURLHelper.getContestsMainUrl(domContext)); siteForm.setCreatePollUrl(VCURLHelper.getCreatePollUrl(domContext)); siteForm.setHomePageUrl(VCURLHelper.getHomePageUrl(domContext)); siteForm.setMyVCUrl(VCURLHelper.getMyVCMainUrl(domContext)); siteForm.setEditAccountUrl(VCURLHelper.getMyRegInfoUrl(domContext)); siteForm.setLoginUrl(VCURLHelper.getLoginUrl(domContext)); siteForm.setForgotPswdUrl(VCURLHelper.getForgotPasswordUrl(domContext)); siteForm.setRegUrl(VCURLHelper.getRegistrationUrl(domContext)); siteForm.setSearchUrl(VCURLHelper.getSearchUrl(domContext)); siteForm.setVacoWinnersUrl(VCURLHelper.getVacoWinnersUrl(domContext)); // Write logic determining how the user should be forwarded. forward = mapping.findForward(next); log.debug("forward:" + forward.getPath()); // Finish with return (forward); }
/** * <br> * [機 能] 完了画面設定 <br> * [解 説] <br> * [備 考] * * @param map アクションマッピング * @param form アクションフォーム * @param req リクエスト * @param res レスポンス * @return ActionForward */ private ActionForward __doCompDsp( ActionMapping map, Sml140knForm form, HttpServletRequest req, HttpServletResponse res) { ActionForward forward = null; Cmn999Form cmn999Form = new Cmn999Form(); ActionForward urlForward = null; // 完了画面パラメータの設定 MessageResources msgRes = getResources(req); cmn999Form.setType(Cmn999Form.TYPE_OK); cmn999Form.setIcon(Cmn999Form.ICON_INFO); cmn999Form.setWtarget(Cmn999Form.WTARGET_BODY); GsMessage gsMsg = new GsMessage(); String smail = gsMsg.getMessage(req, "cmn.shortmail"); urlForward = map.findForward("backToList"); cmn999Form.setUrlOK(urlForward.getPath()); cmn999Form.setMessage(msgRes.getMessage("sakujo.kanryo.object", smail)); // hiddenパラメータ cmn999Form.addHiddenParam("backScreen", form.getBackScreen()); cmn999Form.addHiddenParam("sml010ProcMode", form.getSml010ProcMode()); cmn999Form.addHiddenParam("sml010Sort_key", form.getSml010Sort_key()); cmn999Form.addHiddenParam("sml010Order_key", form.getSml010Order_key()); cmn999Form.addHiddenParam("sml010PageNum", form.getSml010PageNum()); cmn999Form.addHiddenParam("sml010SelectedSid", form.getSml010SelectedSid()); cmn999Form.addHiddenParam("sml010DelSid", form.getSml010DelSid()); req.setAttribute("cmn999Form", cmn999Form); forward = map.findForward("gf_msg"); return forward; }
/** Override super class method to perform additional population for Operation Context */ @Override protected void processPreparedOperationContext( ActionContext actionContext, OperationContext opContext) throws GTClientException { try { IGTSchemaMappingFileEntity entity = null; String indexString = actionContext.getRequest().getParameter("index"); opContext.setAttribute(INDEX_KEY, indexString); // so that when we save the entity, // we can differentiate whether we are saving // a new entity or an existing entity. (see detail in saveWithManager) if (indexString != null) { if (!indexString.equals("new")) { try { int index = Integer.parseInt(indexString); IGTImportSchemaEntity importSchema = getImportSchema(actionContext); ArrayList schemaMappingList = (ArrayList) importSchema.getFieldValue(IGTImportSchemaEntity.SCHEMA_MAPPING); if (schemaMappingList == null) { throw new NullPointerException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext] Null value for schemaMappingList."); } try { entity = (IGTSchemaMappingFileEntity) schemaMappingList.get(index); } catch (Throwable t) { throw new GTClientException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext] Error retrieving schemaMappingFile entity from list at index " + index, t); } if (entity == null) { throw new java.lang.NullPointerException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext] Null entity object at index " + index + " of schemaMappingList list retrieved from ImportSchema entity " + importSchema); } } catch (Throwable t) { throw new GTClientException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext] Error retrieving schemaMappingFile entity object from" + " importSchema entity in parent OperationContext", t); } } else { entity = (IGTSchemaMappingFileEntity) getRequestedEntity(actionContext); } } else { throw new GTClientException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext]No index specified"); } opContext.setAttribute(IOperationContextKeys.ENTITY, entity); ActionForward submitForward = actionContext.getMapping().findForward("submit"); opContext.setAttribute(IOperationContextKeys.FORM_SUBMIT_URL, submitForward.getPath()); } catch (Exception ex) { throw new GTClientException( "[SchemaMappingFileDispatchAction.processPreparedOperationContext] Error obtaining SchemaMappingFile entity object", ex); } }
protected String getSiteUrl(ActionMapping mapping, Unit sub) { ActionForward forward = mapping.findForward("view" + sub.getClass().getSimpleName() + "Site"); if (forward == null) { forward = mapping.findForward("viewUnitSite"); } return String.format(forward.getPath(), sub.getExternalId(), sub.getSite().getExternalId()); }
public void testUnselectAll() throws Exception { ActionHelper sah = new ActionHelper(); sah.setUpAction(action); sah.setupClampListBounds(); ActionForward forward = sah.executeAction("unselectall"); verifyRhnSetData(sah.getUser().getId(), action.getSetDecl().getLabel(), 0); verifyParam(forward.getPath(), "setupdated", "true"); }
public void testFilter() throws Exception { ActionHelper sah = new ActionHelper(); sah.setUpAction(action); sah.getRequest().setupAddParameter(RequestContext.FILTER_STRING, "zzzz"); sah.setupClampListBounds(); ActionForward forward = sah.executeAction("filter"); verifyParam(forward.getPath(), RequestContext.FILTER_STRING, "zzzz"); }
public void testUnspecified() throws Exception { ActionHelper sah = new ActionHelper(); sah.setUpAction(action); sah.setupClampListBounds(); sah.getRequest().setupAddParameter("items_selected", new String[] {"10", "20", "30"}); sah.getRequest().setupAddParameter("newset", (String) null); sah.getRequest().setupAddParameter("items_on_page", (String) null); ActionForward forward = sah.executeAction("unspecified"); verifyParam(forward.getPath(), "newset", "[10, 20, 30]"); }
public void testUpdateList() throws Exception { // TestAction action = new TestAction(); ActionHelper sah = new ActionHelper(); sah.setUpAction(action); sah.setupClampListBounds(); sah.getRequest().setRequestURL("foo"); sah.getRequest().setupAddParameter("items_selected", new String[] {"10", "20", "30"}); sah.getRequest().setupAddParameter("newset", (String) null); sah.getRequest().setupAddParameter("items_on_page", (String) null); ActionForward forward = sah.executeAction("updatelist"); // let's go find the data verifyRhnSetData(sah.getUser().getId(), action.getSetDecl().getLabel(), 3); verifyParam(forward.getPath(), "setupdated", "true"); }
/** 删除版面 */ public ActionForward del( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ForumForm forumForm = (ForumForm) form; try { forumService.deleteForum(forumForm.getId()); return mapping.findForward("showCategories"); } catch (ItcastNotEmptyException e) { addError(request, "delete", "版面中含有主题, 不能删除.", false); ActionForward af = mapping.findForward("showCategories"); return new ActionForward(af.getPath(), false); // 要转发 } }
protected void processPreparedOperationContext( ActionContext actionContext, OperationContext opContext) throws GTClientException { IGTConnectionSetupResultEntity entity = null; IGTSession gtasSession = getGridTalkSession(actionContext); IGTConnectionSetupResultManager manager = (IGTConnectionSetupResultManager) gtasSession.getManager(IGTManager.MANAGER_CONNECTION_SETUP_RESULT); entity = manager.getConnectionSetupResult(); if (entity == null) { throw new GTClientException("No connectionSetupResult entity to update"); } opContext.setAttribute(IOperationContextKeys.ENTITY, entity); ActionForward submitForward = actionContext.getMapping().findForward("submit"); opContext.setAttribute(IOperationContextKeys.FORM_SUBMIT_URL, submitForward.getPath()); }
public ActionForward rate( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Throwable { String itemNaturalKey = (String) request.getParameter("itemNaturalKey"); String value = (String) request.getParameter("rate"); ContentSessionBean contentSessionBean = getContentBean(request).getContentSessionBean(); Site site = contentSessionBean.getSiteDomain().getSite(); String siteId = site.getSiteId(); if (value != null) { EntityManager em = JpaConnection.getInstance().getCurrentEntityManager(); Item item = ItemDAO.loadNatural(siteId, itemNaturalKey); int itemRatingCount = item.getItemRatingCount().intValue(); float itemRating = item.getItemRating().floatValue(); int rate = Integer.parseInt(value); if (itemRatingCount != 0) { itemRating = ((itemRating * itemRatingCount) + rate) / (itemRatingCount + 1); itemRatingCount += 1; } else { itemRatingCount = 1; itemRating = rate; } item.setItemRating(new Float(itemRating)); item.setItemRatingCount(new Integer(itemRatingCount)); em.persist(item); } ActionForward forward = actionMapping.findForward("success"); forward = new ActionForward( forward.getPath() + contentSessionBean.getSiteDomain().getSiteDomainPrefix() + "/" + contentSessionBean .getSiteProfile() .getSiteProfileClass() .getSiteProfileClassName() + "/item/" + itemNaturalKey, forward.getRedirect()); return forward; }
public void testSelectAll() throws Exception { ActionHelper sah = new ActionHelper(); TestActionWithData a = new TestActionWithData() { protected DataResult getDataResult( User user, ActionForm formIn, HttpServletRequest request) { List retval = new LinkedList(); for (int i = 0; i < 10; i++) { retval.add(new TestIdObject(new Long(i))); } return new DataResult(retval); } }; sah.setUpAction(a); sah.setupClampListBounds(); ActionForward forward = sah.executeAction("selectall"); verifyRhnSetData(sah.getUser().getId(), a.getSetDecl().getLabel(), 10); verifyParam(forward.getPath(), "setupdated", "true"); }
public ActionForward submitPoll( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SubmitPollFormBean submitPollFormBean = (SubmitPollFormBean) form; ActionMessages errors = new ActionMessages(); ActionForward forward = new ActionForward(); // return value String next = "submitPoll"; String pollId = submitPollFormBean.getPollId(); pollId = VCRequestHelper.getValueFromRequest(request, RequestParameterObjects.POLL_ID, pollId); PollTO pto = PollBO.getInstance().getPollByPollId(pollId); submitPollFormBean.setPollName(pto.getPollName()); submitPollFormBean.setDisplayPollUrl( VCURLHelper.getDisplayPollUrl(getDomainAndContext(request), pollId)); submitPollFormBean.setContestsMainUrl( VCURLHelper.getContestsMainUrl(getDomainAndContext(request))); submitPollFormBean.setCreateMorePollsUrl( VCURLHelper.getCreatePollUrl(getDomainAndContext(request))); submitPollFormBean.setHomePageUrl(VCURLHelper.getHomePageUrl(getDomainAndContext(request))); submitPollFormBean.setMyVCUrl(VCURLHelper.getMyVCMainUrl(getDomainAndContext(request))); submitPollFormBean.setTwitterUpdateUrl( VCURLHelper.getTwitterUpdateUrl( pto.getPollName(), BitlyService.getInstance() .shorten( VCURLHelper.getDisplayPollUrl(getDomainAndContext(request), pto.getPollId())))); submitPollFormBean.setYahooBuzzUpUrl( VCURLHelper.getYahooBuzzUpUrl( VCURLHelper.getDisplayPollUrl(getDomainAndContext(request), pollId))); submitPollFormBean.setFacebookShareUrl( VCURLHelper.getFacebookShareUrl( VCURLHelper.getDisplayPollUrl(getDomainAndContext(request), pollId), pto.getPollName())); // Write logic determining how the user should be forwarded. forward = mapping.findForward(next); log.debug("forward:" + forward.getPath()); // Finish with return (forward); } /*
/** * <br> * [機 能] 削除完了画面設定 <br> * [解 説] <br> * [備 考] * * @param map アクションマッピング * @param form アクションフォーム * @param req リクエスト * @return ActionForward */ private ActionForward __doDeleteCompDsp( ActionMapping map, Ipk100Form form, HttpServletRequest req) { ActionForward forward = null; Cmn999Form cmn999Form = new Cmn999Form(); ActionForward forwardOK = null; // スペック情報の削除確認画面パラメータの設定 MessageResources msgRes = getResources(req); cmn999Form.setType(Cmn999Form.TYPE_OK); cmn999Form.setIcon(Cmn999Form.ICON_INFO); cmn999Form.setWtarget(Cmn999Form.WTARGET_BODY); forwardOK = map.findForward("ipk100DeleteComp"); cmn999Form.setUrlOK(forwardOK.getPath()); cmn999Form.setMessage(msgRes.getMessage("sakujo.kanryo.object", __getSpecKbn(form, req))); cmn999Form.addHiddenParam("backScreen", form.getBackScreen()); req.setAttribute("cmn999Form", cmn999Form); forward = map.findForward("gf_msg"); cmn999Form.addHiddenParam("ismSid", form.getIsmSid()); cmn999Form.addHiddenParam("specKbn", form.getSpecKbn()); return forward; }
public ActionForward returnToAward( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { final BudgetForm budgetForm = (BudgetForm) form; ActionForward forward = null; if (!"true" .equals(budgetForm.getEditingMode().get(AuthorizationConstants.EditMode.VIEW_ONLY))) { forward = this.save(mapping, form, request, response); } setupDocumentExit(); if (forward == null || !forward.getPath().contains(KNSConstants.QUESTION_ACTION)) { return this.getReturnToAwardForward(budgetForm); } return forward; }
public ActionForward executeAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, SessionAPI session) throws Exception { // Comprobar si el usuario tiene asignadas las funciones adecuadas FunctionHelper.checkFunctions( request, session.getClientContext(), new int[] {ISecurityAPI.FUNC_INV_PROCEDURES_EDIT}); int intTpObj = Integer.parseInt(request.getParameter("TpObj")); int intIdObj = Integer.parseInt(request.getParameter("IdObj")); // Prepara las API's a utilizar IInvesflowAPI invesFlowAPI = session.getAPI(); ICatalogAPI catalogAPI = invesFlowAPI.getCatalogAPI(); if (request.getParameter("idRule") != null) { catalogAPI.addPRuleEvent( intTpObj, intIdObj, Integer.parseInt(request.getParameter("codEvent")), Integer.parseInt(request.getParameter("idRule"))); ActionForward forward = mapping.findForward("showevents"); String path = forward.getPath() + "?TpObj=" + intTpObj + "&IdObj=" + intIdObj; return new ActionForward(forward.getName(), path, forward.getRedirect()); } request.setAttribute("TpObj", String.valueOf(intTpObj)); request.setAttribute("IdObj", String.valueOf(intIdObj)); CacheFormatterFactory factory = CacheFormatterFactory.getInstance(); String ispacbase = (String) servlet.getServletContext().getAttribute("ispacbase"); if (request.getParameter("codEvent") != null) { request.setAttribute("codEvent", request.getParameter("codEvent")); IItemCollection rulecol = catalogAPI.getCTRules(); List rulelist = CollectionBean.getBeanList(rulecol); request.setAttribute("RulesList", rulelist); BeanFormatter formatter = factory.getFormatter(getISPACPath("/formatters/events/ruleslistformatter.xml")); request.setAttribute("RulesListFormatter", formatter); request.setAttribute( "application", StaticContext.rewritePage(ispacbase, "common/events/ruleslist.jsp")); } else { List eventlist = DescriptionsPEvents.getDescEventsList(intTpObj, intIdObj); request.setAttribute("EventsList", eventlist); BeanFormatter formatter = factory.getFormatter(getISPACPath("/formatters/events/eventslistformatter.xml")); request.setAttribute("EventsListFormatter", formatter); request.setAttribute( "application", StaticContext.rewritePage(ispacbase, "common/events/eventslist.jsp")); } return mapping.findForward("success"); }
public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse reponse) { S_IFC_Form form = (S_IFC_Form) actionForm; String nextAction = form.getNextAction(); ActionForward forward = null; int id_set = form.getId_set(); boolean dbException = false; try { Session session = HibernateUtil.getCurrentSession(); HibernateUtil.beginTransaction(); if (nextAction.equals("save")) { Shared_IFC_Set shared_ifc_set; if (id_set == -1) { // create shared_ifc_set = new Shared_IFC_Set(); shared_ifc_set.setName(form.getName()); shared_ifc_set.setPriority(form.getPriority()); shared_ifc_set.setId_ifc(form.getId_ifc()); int max_id_set = Shared_IFC_Set_DAO.get_max_id_set(session); shared_ifc_set.setId_set(max_id_set + 1); Shared_IFC_Set_DAO.insert(session, shared_ifc_set); id_set = max_id_set + 1; form.setId_set(id_set); } else { // update Shared_IFC_Set_DAO.update_all_from_set(session, id_set, form.getName()); } forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id_set=" + id_set); } else if (nextAction.equals("refresh")) { Shared_IFC_Set shared_ifc_set = (Shared_IFC_Set) Shared_IFC_Set_DAO.get_by_set_ID(session, id_set); if (!S_IFC_Load.setForm(form, shared_ifc_set)) { logger.error( "The Shared IFC Set with the ID:" + id_set + " was not loaded from database!"); } forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id_set=" + id_set); } else if (nextAction.equals("delete")) { Shared_IFC_Set_DAO.delete_set_by_ID(session, id_set); forward = actionMapping.findForward(WebConstants.FORWARD_DELETE); } else if (nextAction.equals("attach_ifc")) { Shared_IFC_Set shared_ifc_set = new Shared_IFC_Set(); shared_ifc_set.setId_set(id_set); shared_ifc_set.setName(form.getName()); shared_ifc_set.setId_ifc(form.getId_ifc()); shared_ifc_set.setPriority(form.getPriority()); Shared_IFC_Set_DAO.insert(session, shared_ifc_set); forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id_set=" + id_set); } else if (nextAction.equals("detach_ifc")) { int cnt = Shared_IFC_Set_DAO.get_cnt_for_set(session, id_set); Shared_IFC_Set_DAO.delete_ifc_from_set(session, id_set, form.getAssociated_ID()); if (cnt == 1) { forward = actionMapping.findForward(WebConstants.FORWARD_DELETE); } else { forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id_set=" + id_set); } } S_IFC_Load.prepareForward(session, form, request, id_set); } catch (DatabaseException e) { logger.error("Database Exception occured!\nReason:" + e.getMessage()); e.printStackTrace(); dbException = true; forward = actionMapping.findForward(WebConstants.FORWARD_FAILURE); } catch (HibernateException e) { logger.error("Hibernate Exception occured!\nReason:" + e.getMessage()); e.printStackTrace(); dbException = true; forward = actionMapping.findForward(WebConstants.FORWARD_FAILURE); } finally { if (!dbException) { HibernateUtil.commitTransaction(); } HibernateUtil.closeSession(); } return forward; }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // User making this request User user = UserUtils.getUser(request); if (user == null) { ActionErrors errors = new ActionErrors(); errors.add("username", new ActionMessage("error.login.notloggedin")); saveErrors(request, errors); return mapping.findForward("authenticate"); } // we need a projectID so that we can restrict access to researchers on a project int projectId = 0; try { projectId = Integer.parseInt(request.getParameter("projectId")); } catch (NumberFormatException e) { projectId = 0; } if (projectId == 0) { ActionErrors errors = new ActionErrors(); errors.add( "payment", new ActionMessage("error.payment.invalidid", "Invalid projectID in request")); saveErrors(request, errors); return mapping.findForward("standardHome"); } // user should be an admin OR a researcher on the project Project project = ProjectFactory.getProject(projectId); if (!project.checkAccess(user.getResearcher())) { ActionErrors errors = new ActionErrors(); errors.add( "payment", new ActionMessage( "error.payment.invalidaccess", "User does not have access to view details of the payment method.")); saveErrors(request, errors); ActionForward fwd = mapping.findForward("Failure"); ActionForward newFwd = new ActionForward(fwd.getPath() + "?ID=" + projectId, fwd.getRedirect()); return newFwd; } // we need a paymentMethodId int paymentMethodId = 0; try { paymentMethodId = Integer.parseInt(request.getParameter("paymentMethodId")); } catch (NumberFormatException e) { paymentMethodId = 0; } if (paymentMethodId == 0) { ActionErrors errors = new ActionErrors(); errors.add( "payment", new ActionMessage("error.payment.invalidid", "Invalid paymentMethodID in request")); saveErrors(request, errors); ActionForward fwd = mapping.findForward("Failure"); ActionForward newFwd = new ActionForward(fwd.getPath() + "?ID=" + projectId, fwd.getRedirect()); return newFwd; } try { PaymentMethod paymentMethod = PaymentMethodDAO.getInstance().getPaymentMethod(paymentMethodId); request.setAttribute("paymentMethod", paymentMethod); request.setAttribute("projectId", projectId); } catch (Exception e) { ActionErrors errors = new ActionErrors(); errors.add("payment", new ActionMessage("error.payment.load", "ERROR: " + e.getMessage())); saveErrors(request, errors); log.error("Error loading payment method for ID: " + paymentMethodId, e); ActionForward fwd = mapping.findForward("Failure"); ActionForward newFwd = new ActionForward(fwd.getPath() + "?ID=" + projectId, fwd.getRedirect()); return newFwd; } return mapping.findForward("Success"); }
public ActionForward executeAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, SessionAPI session) throws Exception { // Comprobar si el usuario tiene asignadas las funciones adecuadas FunctionHelper.checkFunctions( request, session.getClientContext(), new int[] {ISecurityAPI.FUNC_INV_DOCTYPES_EDIT, ISecurityAPI.FUNC_INV_TEMPLATES_EDIT}); IInvesflowAPI invesFlowAPI = session.getAPI(); ICatalogAPI catalogAPI = invesFlowAPI.getCatalogAPI(); ITemplateAPI templateAPI = invesFlowAPI.getTemplateAPI(); // Formulario asociado a la acción UploadForm defaultForm = (UploadForm) form; int keyId = Integer.parseInt(defaultForm.getKey()); int entityId = Integer.parseInt(defaultForm.getEntity()); String name = defaultForm.getProperty("NOMBRE"); String code = defaultForm.getProperty("COD_PLANT"); CTTemplate template = null; try { if (keyId == ISPACEntities.ENTITY_NULLREGKEYID) { int type = Integer.parseInt(defaultForm.getProperty("ID_TPDOC")); String expresion = defaultForm.getProperty("EXPRESION"); FormFile fichero = defaultForm.getUploadFile(); EntityApp entityapp = catalogAPI.getCTDefaultEntityApp(entityId, getRealPath("")); // Comprobar si existe otra plantilla con el mismo nombre IItemCollection itemcol = catalogAPI.queryCTEntities( ICatalogAPI.ENTITY_CT_TEMPLATE, " WHERE NOMBRE = '" + DBUtil.replaceQuotes(name) + "'"); if (itemcol.next() && !isGeneric(templateAPI, itemcol)) { ActionMessages errors = new ActionMessages(); errors.add( "property(NOMBRE)", new ActionMessage("error.template.nameDuplicated", new String[] {name})); saveAppErrors(request, errors); return new ActionForward(mapping.getInput()); } // Comprobar si existe otra plantilla con el mismo código if (StringUtils.isNotBlank(code)) { itemcol = catalogAPI.queryCTEntities( ICatalogAPI.ENTITY_CT_TEMPLATE, " WHERE COD_PLANT = '" + DBUtil.replaceQuotes(code) + "'"); if (itemcol.next()) { ActionMessages errors = new ActionMessages(); errors.add( "property(COD_PLANT)", new ActionMessage("error.template.codeDuplicated", new String[] {code})); saveAppErrors(request, errors); return new ActionForward(mapping.getInput()); } } if (!entityapp.validate()) { ActionMessages errors = new ActionMessages(); List errorList = entityapp.getErrors(); Iterator iteError = errorList.iterator(); while (iteError.hasNext()) { ValidationError validError = (ValidationError) iteError.next(); ActionMessage error = new ActionMessage(validError.getErrorKey(), validError.getArgs()); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } saveAppErrors(request, errors); return new ActionForward(mapping.getInput()); } if (fichero.getFileName().equals("")) { template = templateAPI.newTemplate(type, name, code, 0, expresion, null); } else { if (fichero.getFileSize() > 0) { // Comprobar si el tipo MIME de la plantilla está soportado String mimeType = MimetypeMapping.getFileMimeType(fichero.getFileName()); // Se comprueba si esta habilitado el uso de plantillas ODT if (StringUtils.equals(mimeType, "application/vnd.oasis.opendocument.text") && !ConfigurationMgr.getVarGlobalBoolean( session.getClientContext(), ConfigurationMgr.USE_ODT_TEMPLATES, false)) { throw new ISPACInfo( getResources(request).getMessage("exception.template.odt.disabled")); } if (templateAPI.isMimeTypeSupported(mimeType)) { template = templateAPI.newTemplate( type, name, code, 0, expresion, fichero.getInputStream(), mimeType); } else { throw new ISPACInfo( getResources(request).getMessage("exception.template.document.invalidFile")); } } else { throw new ISPACInfo("exception.uploadfile.empty"); } } } else { EntityApp entityapp = catalogAPI.getCTDefaultEntityApp(entityId, getRealPath("")); // Comprobar si existe otra plantilla con el mismo nombre IItemCollection itemcol = catalogAPI.queryCTEntities( ICatalogAPI.ENTITY_CT_TEMPLATE, " WHERE NOMBRE = '" + DBUtil.replaceQuotes(name) + "' AND ID != " + keyId); if (itemcol.next() && !isGeneric(templateAPI, itemcol)) { ActionMessages errors = new ActionMessages(); errors.add( "property(NOMBRE)", new ActionMessage("error.template.nameDuplicated", new String[] {name})); saveAppErrors(request, errors); return new ActionForward(mapping.getInput()); } // Comprobar si existe otra plantilla con el mismo código if (StringUtils.isNotBlank(code)) { itemcol = catalogAPI.queryCTEntities( ICatalogAPI.ENTITY_CT_TEMPLATE, " WHERE COD_PLANT = '" + DBUtil.replaceQuotes(code) + "' AND ID != " + keyId); if (itemcol.next()) { ActionMessages errors = new ActionMessages(); errors.add( "property(COD_PLANT)", new ActionMessage("error.template.codeDuplicated", new String[] {code})); saveAppErrors(request, errors); return new ActionForward(mapping.getInput()); } } defaultForm.processEntityApp(entityapp); entityapp.getItem().set("FECHA", new Date()); entityapp.store(); } } catch (Exception e) { ActionForward action = mapping.findForward("success"); String url = action.getPath() + "?entity=" + entityId + "&type=" + defaultForm.getProperty("ID_TPDOC") + "&key=" + keyId; request.getSession().setAttribute(BaseAction.LAST_URL_SESSION_KEY, url); if (e instanceof ISPACInfo) { throw e; } else { throw new ISPACInfo(e.getMessage()); } } if (template != null) { keyId = template.getInt("TEMPLATE:ID"); } ActionForward action = mapping.findForward("success"); String redirected = action.getPath() + "?entity=" + entityId + "&type=" + defaultForm.getProperty("ID_TPDOC") + "&key=" + keyId; return new ActionForward(action.getName(), redirected, true); }
/** * Return a new <code>ActionForward</code> based on the given one but with the specified parameter * name and value added to the new forward's path. NOTE: this method would be unnecessary if * Struts allowed us to "unfreeze" the <code>ForwardConfig</code> that is the superclass of the * forward. * * @param forward the ActionForward on which the new forward is based * @param param the name of the path parameter to add * @param value the value of the parameter to add * @exception ServletException if encoding the path parameter fails */ public static ActionForward changeForwardPath(ActionForward forward, Map params) throws Exception { String newUrl = changeUrl(forward.getPath(), params); ActionForward newForward = new ActionForward(forward.getName(), newUrl, forward.getRedirect()); return newForward; }
protected void executeLogic( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { InventoryEntryFB fb = (InventoryEntryFB) form; InventoryEntry template = (InventoryEntry) getEnvironment().getEntityFactory().create("diary-inventoryentry"); template.setId(fb.getId()); InventoryEntry entry = (InventoryEntry) getEnvironment() .getEntityStorageFactory() .getStorage("diary-inventoryentry") .load(template); PropertyUtils.copyProperties(fb, entry); QueryFilter filter = new QueryFilter("allforid"); filter.setAttribute("id", entry.getId()); EntityInterface[] entities = getEnvironment() .getEntityStorageFactory() .getStorage("diary-inventoryentryevent") .search(filter); InventoryEntryEventFB[] pb = new InventoryEntryEventFB[entities.length]; for (int i = 0; i < entities.length; i++) { pb[i] = new InventoryEntryEventFB(); try { PropertyUtils.copyProperties(pb[i], entities[i]); } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } } fb.setEvents(pb); ActionForward forward = mapping.findForward("view-gallery"); if (forward != null) { Map parameters = new HashMap(); parameters.put("gallery", fb.getGallery()); String user = request.getRemoteUser(); if (user == null) { user = (String) request.getSession().getAttribute("user"); } parameters.put("user", user); fb.setGalleryLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } DescriptionId[] types = DescriptionIdHelper.getDescriptionIdList("diary-inventoryentrytype"); DescriptionIdPB[] typesPB = new DescriptionIdPB[types.length]; for (int i = 0; i < types.length; i++) { typesPB[i] = new DescriptionIdPB(); PropertyUtils.copyProperties(typesPB[i], types[i]); } request.getSession().setAttribute("inventoryEntryTypesPB", typesPB); filter = new QueryFilter("allforuser"); filter.setAttribute("username", request.getRemoteUser()); entities = getEnvironment().getEntityStorageFactory().getStorage("diary-gallery").search(filter); GalleryPB[] pbGalleries = new GalleryPB[entities.length]; for (int i = 0; i < entities.length; i++) { pbGalleries[i] = new GalleryPB(); PropertyUtils.copyProperties(pbGalleries[i], entities[i]); } request.getSession().setAttribute("galleriesPB", pbGalleries); }
protected void executeLogic( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SelectGalleryFB fb = (SelectGalleryFB) form; Gallery gallery = getGallery(fb.getGallery()); GalleryPB pbGallery = new GalleryPB(); PropertyUtils.copyProperties(pbGallery, gallery); String username = request.getRemoteUser(); if (username == null) { username = fb.getUser(); } Map parameters = new HashMap(); parameters.put("gallery", gallery.getId()); parameters.put("user", username); ActionForward forward = mapping.findForward("update-gallery-link"); if (forward != null) { pbGallery.setUpdateLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } forward = mapping.findForward("delete-gallery-link"); if (forward != null) { pbGallery.setRemoveLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } if (gallery.getGallery() != null && gallery.getGallery().intValue() != 0) { request.setAttribute("galleryInfoPB", pbGallery); request.setAttribute("externalgallery", gallery.getGallery()); return; } else { forward = mapping.findForward("new-picture-link"); if (forward != null) { pbGallery.setNewEntryLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } request.setAttribute("galleryInfoPB", pbGallery); QueryFilter filter = new QueryFilter("allforgallery"); filter.setAttribute("gallery", fb.getGallery()); EntityInterface[] entities = getEnvironment() .getEntityStorageFactory() .getStorage("diary-galleryentry") .search(filter); ActionForward updateForward = mapping.findForward("update-picture-link"); ActionForward deleteForward = mapping.findForward("delete-picture-link"); GalleryEntryPB[] pbPictures = new GalleryEntryPB[entities.length]; for (int i = 0; i < entities.length; i++) { pbPictures[i] = new GalleryEntryPB(); PropertyUtils.copyProperties(pbPictures[i], entities[i]); parameters.put("picture", pbPictures[i].getId()); if (updateForward != null) { pbPictures[i].setUpdateLink( ServletParameterHelper.replaceDynamicParameters(updateForward.getPath(), parameters)); } if (deleteForward != null) { pbPictures[i].setRemoveLink( ServletParameterHelper.replaceDynamicParameters(deleteForward.getPath(), parameters)); } } GalleryEntryCollectionPB pb = new GalleryEntryCollectionPB(); pb.setPictures(pbPictures); request.setAttribute("picturesPB", pb); } }
protected void executeLogic( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { SelectPictureFB fb = (SelectPictureFB) form; Integer virtualGalleryId = fb.getGallery(); setVirtualGalleryId(request, virtualGalleryId); Gallery gallery = GalleryHelper.getGallery(getEnvironment(), virtualGalleryId); if (gallery == null) { saveErrors(request, Arrays.asList(new String[] {"gallery.gallery.gallery-not-found"})); return; } setGallery(request, gallery); String language = fb.getLanguage(); if (StringUtil.asNull(language) == null) { language = request.getLocale().getLanguage(); } boolean useEnglish = !language.equals( getEnvironment().getConfigurableResources().getParameter("nativelanguage")); Integer galleryId = GalleryHelper.getGalleryId(gallery); setGalleryId(request, galleryId); Integer categoryId = fb.getCategory(); setCategoryId(request, categoryId); LOG.debug("Search pictures: " + fb.getGallery() + "," + fb.getCategory()); initRequestParameters(request); Collection categories = getCategories(request, form); Collection picturesAllowed = getPictures(request, form); QueryFilter filter; Integer max = fb.getMax(); if (max == null) { if (gallery.getNoOfCols() != null && gallery.getNoOfCols().intValue() > 0 && gallery.getNoOfRows() != null && gallery.getNoOfRows().intValue() > 0) { max = new Integer(gallery.getNoOfCols().intValue() * gallery.getNoOfRows().intValue()); } } if (fb.getStart() != null && max != null && max.intValue() != 0) { if (picturesAllowed != null) { if (categories != null) { filter = new QueryFilter(getCategoryTreeFilter(request) + "andpicturelist" + "withlimit"); filter.setAttribute("categories", categories); } else { filter = new QueryFilter(getAllFilter(request) + "andpicturelist" + "withlimit"); } filter.setAttribute("pictures", picturesAllowed); } else { if (categories != null) { filter = new QueryFilter(getCategoryTreeFilter(request) + "withlimit"); filter.setAttribute("categories", categories); } else { filter = new QueryFilter(getAllFilter(request) + "withlimit"); } } filter.setAttribute("start", fb.getStart()); if (max != null) { filter.setAttribute("max", max); } } else { if (picturesAllowed != null) { if (categories != null) { filter = new QueryFilter(getCategoryTreeFilter(request) + "andpicturelist"); filter.setAttribute("categories", categories); } else { filter = new QueryFilter(getAllFilter(request) + "andpicturelist"); } filter.setAttribute("pictures", picturesAllowed); } else { if (categories != null) { filter = new QueryFilter(getCategoryTreeFilter(request)); filter.setAttribute("categories", categories); } else { filter = new QueryFilter(getAllFilter(request)); } } } filter.setAttribute("gallery", galleryId); filter.setOrderName(gallery.getSortOrder()); setFilterAttributes(request, form, filter); EntityInterface[] entities = new EntityInterface[0]; if (picturesAllowed == null || (picturesAllowed != null && picturesAllowed.size() > 0)) { entities = getEnvironment().getEntityStorageFactory().getStorage("gallery-picture").search(filter); } String username = gallery.getUsername(); // String username = fb.getUser(); // if (username == null || username.length() == 0) { // username = request.getRemoteUser(); // } filter = new QueryFilter("allforuser"); filter.setAttribute("username", username); EntityInterface[] storageEntities = getEnvironment() .getEntityStorageFactory() .getStorage("gallery-picturestorage") .search(filter); if (gallery.getMaxWidth() != null && gallery.getMaxWidth().intValue() > 0) { filter = new QueryFilter("all-smaller-than"); filter.setAttribute("width", gallery.getMaxWidth()); } else { filter = new QueryFilter("all"); } EntityInterface[] resolutionEntities = getEnvironment().getEntityStorageFactory().getStorage("gallery-resolution").search(filter); ResolutionPB[] resolutionsPB = null; Integer defaultResolution = null; if (resolutionEntities.length > 0) { for (int i = 0; i < resolutionEntities.length; i++) { if (((Resolution) resolutionEntities[i]) .getId() .equalsIgnoreCase(gallery.getDefaultResolution())) { defaultResolution = ((Resolution) resolutionEntities[i]).getWidth(); break; } } resolutionsPB = new ResolutionPB[resolutionEntities.length]; for (int i = 0; i < resolutionsPB.length; i++) { resolutionsPB[i] = new ResolutionPB(); try { PropertyUtils.copyProperties(resolutionsPB[i], resolutionEntities[i]); } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { } catch (NoSuchMethodException e) { } } } Map pictureParameters = new HashMap(); if (StringUtil.asNull(request.getServerName()) != null) { pictureParameters.put("hostname", request.getServerName()); if (request.getServerPort() != 80) { pictureParameters.put("port", new Integer(request.getServerPort())); } } pictureParameters.put("contextpath", request.getContextPath()); pictureParameters.put("user", username); PicturePB[] picturesPB = new PicturePB[entities.length]; ActionForward updateForward = mapping.findForward("picture-update-link"); ActionForward removeForward = mapping.findForward("picture-remove-link"); ActionForward resolutionForward = mapping.findForward("picture-resolution-link"); ActionForward pictureLinkForward = mapping.findForward("picture-link"); ActionForward pictureImageForward = mapping.findForward("picture-image"); if (defaultResolution != null) { pictureParameters.put("width", defaultResolution.toString()); } if (StringUtil.asNull(request.getParameter("thumbnailwidth")) != null) { pictureParameters.put("thumbnailwidth", request.getParameter("thumbnailwidth")); } else if (gallery.getThumbnailWidth() != null && gallery.getThumbnailWidth().intValue() > 0) { pictureParameters.put("thumbnailwidth", gallery.getThumbnailWidth()); } if (StringUtil.asNull(request.getParameter("thumbnailheight")) != null) { pictureParameters.put("thumbnailheight", request.getParameter("thumbnailheight")); } else if (gallery.getThumbnailHeight() != null && gallery.getThumbnailHeight().intValue() > 0) { pictureParameters.put("thumbnailheight", gallery.getThumbnailHeight()); } List thumbnailInfoList = new ArrayList(); if (StringUtil.asNull(gallery.getThumbnailRow1()) != null) { thumbnailInfoList.add(gallery.getThumbnailRow1()); } if (StringUtil.asNull(gallery.getThumbnailRow2()) != null) { thumbnailInfoList.add(gallery.getThumbnailRow2()); } if (StringUtil.asNull(gallery.getThumbnailRow3()) != null) { thumbnailInfoList.add(gallery.getThumbnailRow3()); } String[] thumbnailInfo = (String[]) thumbnailInfoList.toArray(new String[0]); JPEGMetadataHandler jpegHandler = new JPEGMetadataHandler(false); FileMetadataHandler fileHandler = new FileMetadataHandler(false); Integer currentStart = fb.getStart(); if (currentStart == null) { currentStart = new Integer(0); } Map currentLinkPictureParameters = new HashMap(); Map currentParameters = new HashMap(); currentParameters.put("user", username); if (StringUtil.asNull(request.getServerName()) != null) { currentParameters.put("hostname", request.getServerName()); if (request.getServerPort() != 80) { currentParameters.put("port", new Integer(request.getServerPort())); } } currentParameters.put("contextpath", request.getContextPath()); Enumeration paramEnum = request.getParameterNames(); while (paramEnum.hasMoreElements()) { String parameter = (String) paramEnum.nextElement(); currentParameters.put(parameter, request.getParameter(parameter)); } ActionForward currentForward = mapping.findForward("current-link"); for (int i = 0; i < entities.length; i++) { picturesPB[i] = new PicturePB(); Picture picture = (Picture) entities[i]; if (StringUtil.asNull(picture.getFile()) != null) { picture.setFile(getImagePath(storageEntities, picture.getFile())); } PropertyUtils.copyProperties(picturesPB[i], entities[i]); if (useEnglish && StringUtil.asNull(picture.getTitleEnglish()) != null) { picturesPB[i].setTitle(picture.getTitleEnglish()); } if (useEnglish && StringUtil.asNull(picture.getDescriptionEnglish()) != null) { picturesPB[i].setDescription(picture.getDescriptionEnglish()); } pictureParameters.put("gallery", virtualGalleryId); pictureParameters.put("picture", picturesPB[i].getId()); if (picturesPB[i].getImage().startsWith("{")) { String path = pictureImageForward.getPath(); picturesPB[i].setImage( ServletParameterHelper.replaceDynamicParameters(path, pictureParameters)); } else { picturesPB[i].setImage(getImagePath(storageEntities, picturesPB[i].getImage())); } if (gallery.getUsername().equals(request.getRemoteUser())) { if (updateForward != null) { String path = updateForward.getPath(); picturesPB[i].setUpdateLink( ServletParameterHelper.replaceDynamicParameters(path, pictureParameters)); } if (removeForward != null) { String path = removeForward.getPath(); picturesPB[i].setRemoveLink( ServletParameterHelper.replaceDynamicParameters(path, pictureParameters)); } } else { if (gallery.getShowResolutionLinks() != null && gallery.getShowResolutionLinks().booleanValue() && resolutionForward != null) { ResolutionLinkPB[] resolutionLinksPB = new ResolutionLinkPB[resolutionsPB.length]; Map resolutionParameters = new HashMap(); resolutionParameters.put("gallery", virtualGalleryId); resolutionParameters.put("picture", picturesPB[i].getId()); for (int j = 0; j < resolutionLinksPB.length; j++) { resolutionParameters.put("width", resolutionsPB[j].getWidth()); String path = ServletParameterHelper.replaceDynamicParameters( resolutionForward.getPath(), resolutionParameters); resolutionLinksPB[j] = new ResolutionLinkPB( resolutionsPB[j].getId(), resolutionsPB[j].getDescription(), path); } picturesPB[i].setResolutions(resolutionLinksPB); } } if (picturesPB[i].getLink().startsWith("{")) { String path = null; if (defaultResolution != null) { if (resolutionForward != null) { path = resolutionForward.getPath(); } } if (path == null) { path = pictureLinkForward.getPath(); } picturesPB[i].setLink( ServletParameterHelper.replaceDynamicParameters(path, pictureParameters)); } else { picturesPB[i].setLink(getImagePath(storageEntities, picturesPB[i].getLink())); } if (gallery.getShowPictureTitle() != null && !gallery.getShowPictureTitle().booleanValue()) { picturesPB[i].setTitle(null); } picturesPB[i].setGallery(virtualGalleryId); if (picturesPB[i].getTitle() != null && gallery.getUseShortPictureNames() != null && gallery.getUseShortPictureNames().booleanValue()) { picturesPB[i].setTitle(((Picture) entities[i]).getShortTitle()); } if (StringUtil.asNull(gallery.getThumbnailPictureTitle()) != null) { picturesPB[i].setTitle( getPictureInfo( gallery.getThumbnailPictureTitle(), picture, picturesPB[i], jpegHandler, fileHandler)); } if (picturesPB[i].getTitle() != null && gallery.getCutLongPictureTitles() != null && gallery.getCutLongPictureTitles().booleanValue()) { if (picturesPB[i].getTitle() != null && picturesPB[i].getTitle().length() > 30) { picturesPB[i].setTitle( "..." + picturesPB[i].getTitle().substring(picturesPB[i].getTitle().length() - 27)); } } if (thumbnailInfo.length > 0) { picturesPB[i].setRow1Info( getPictureInfo(thumbnailInfo[0], picture, picturesPB[i], jpegHandler, fileHandler)); } if (thumbnailInfo.length > 1) { picturesPB[i].setRow2Info( getPictureInfo(thumbnailInfo[1], picture, picturesPB[i], jpegHandler, fileHandler)); } if (thumbnailInfo.length > 2) { picturesPB[i].setRow3Info( getPictureInfo(thumbnailInfo[2], picture, picturesPB[i], jpegHandler, fileHandler)); } if (currentForward != null) { currentLinkPictureParameters.clear(); currentLinkPictureParameters.putAll(pictureParameters); currentLinkPictureParameters.putAll(currentParameters); currentLinkPictureParameters.put("start", currentStart.toString()); picturesPB[i].setCurrentLink( ServletParameterHelper.replaceDynamicParameters( currentForward.getPath(), currentLinkPictureParameters)); currentStart = new Integer(currentStart.intValue() + 1); } } PictureCollectionPB pb = new PictureCollectionPB(); pb.setPictures(picturesPB); Map parameters = new HashMap(); parameters.putAll(currentParameters); addParameters(parameters, fb); Integer prevStart = getPreviousPage(fb.getStart(), max); if (prevStart != null) { parameters.put("start", prevStart.toString()); ActionForward forward = mapping.findForward("previous-link"); if (forward != null) { pb.setPrevLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } } else { pb.setPrevLink(null); } Integer nextStart = getNextPage(fb.getStart(), max, picturesPB.length); if (nextStart != null) { parameters.put("start", nextStart.toString()); ActionForward forward = mapping.findForward("next-link"); if (forward != null) { pb.setNextLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } } else { pb.setNextLink(null); } currentStart = fb.getStart(); if (currentStart == null) { currentStart = new Integer(0); } parameters.put("start", currentStart.toString()); if (currentForward != null) { pb.setCurrentLink( ServletParameterHelper.replaceDynamicParameters(currentForward.getPath(), parameters)); } ActionForward forward = null; if (gallery.getAllowSearch() != null && gallery.getAllowSearch().booleanValue()) { forward = mapping.findForward("search-link"); } else { forward = mapping.findForward("search-private-link"); } if (forward != null) { pb.setSearchLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } forward = mapping.findForward("page-link"); if (forward != null) { pb.setPageLink( ServletParameterHelper.replaceDynamicParameters(forward.getPath(), parameters)); } request.setAttribute("picturesPB", pb); GalleryPB galleryPB = new GalleryPB(); PropertyUtils.copyProperties(galleryPB, gallery); if (useEnglish && StringUtil.asNull(gallery.getTitleEnglish()) != null) { galleryPB.setTitle(gallery.getTitleEnglish()); } if (useEnglish && StringUtil.asNull(gallery.getDescriptionEnglish()) != null) { galleryPB.setDescription(gallery.getDescriptionEnglish()); } galleryPB.setVirtual(Boolean.valueOf(!virtualGalleryId.equals(galleryId))); if (galleryPB.getNoOfCols() != null && galleryPB.getNoOfCols().intValue() <= 0) { galleryPB.setNoOfCols(null); } if (galleryPB.getNoOfRows() != null && galleryPB.getNoOfRows().intValue() <= 0) { galleryPB.setNoOfRows(null); } if (max == null || max.intValue() == 0 || (gallery.getNoOfCols() != null && gallery.getNoOfRows() != null && (gallery.getNoOfRows().intValue() * gallery.getNoOfCols().intValue()) < max.intValue())) { galleryPB.setNoOfRows(null); } galleryPB.setNoOfThumnailInfoRows( thumbnailInfo.length > 0 ? new Integer(thumbnailInfo.length + 1) : new Integer(1)); request.setAttribute("galleryPB", galleryPB); String skin = gallery.getSkin(); if (StringUtil.asNull(fb.getSkin()) != null) { skin = fb.getSkin(); } if (mapping.getParameter() != null && mapping.getParameter().equals("useskin")) { SkinFB previous = (SkinFB) request.getSession().getAttribute("skinPB"); if (StringUtil.asNull(skin) == null) { UserAccount template = (UserAccount) getEnvironment().getEntityFactory().create("gallery-useraccount"); template.setUsername(username); UserAccount account = (UserAccount) getEnvironment() .getEntityStorageFactory() .getStorage("gallery-useraccount") .load(template); skin = account.getSkin(); } if (previous == null || previous.getId() == null || !previous.getId().equals(skin)) { SkinFB pbSkin = SkinHelper.loadSkin(mapping, skin); request.getSession().setAttribute("skinPB", pbSkin); } } SkinFB pbSkin = (SkinFB) request.getSession().getAttribute("skinPB"); if (pbSkin == null || StringUtil.asNull(pbSkin.getStylesheet()) == null) { if (gallery != null && gallery.getStylesheet() != null && gallery.getStylesheet().length() > 0) { request.getSession().setAttribute("stylesheetPB", gallery.getStylesheet()); } else { request.getSession().removeAttribute("stylesheetPB"); } } else { request.getSession().setAttribute("stylesheetPB", pbSkin.getStylesheet()); } String pbTitle = (String) request.getSession().getAttribute("titlePB"); if (StringUtil.asNull(pbTitle) == null) { UserAccount template = (UserAccount) getEnvironment().getEntityFactory().create("gallery-useraccount"); template.setUsername(username); UserAccount account = (UserAccount) getEnvironment() .getEntityStorageFactory() .getStorage("gallery-useraccount") .load(template); String title = account.getTitle(); if (useEnglish && StringUtil.asNull(account.getTitleEnglish()) != null) { title = account.getTitleEnglish(); } request.getSession().setAttribute("titlePB", title); } }
public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse reponse) { VN_Form form = (VN_Form) actionForm; String nextAction = form.getNextAction(); ActionForward forward = null; int id = form.getId(); boolean dbException = false; try { Session session = HibernateUtil.getCurrentSession(); HibernateUtil.beginTransaction(); if (nextAction.equals("save")) { VisitedNetwork visited_network; if (id == -1) { // create visited_network = new VisitedNetwork(); } else { // update visited_network = VisitedNetwork_DAO.get_by_ID(session, id); } // make the changes visited_network.setIdentity(form.getIdentity()); if (id == -1) { VisitedNetwork_DAO.insert(session, visited_network); id = visited_network.getId(); form.setId(id); } else { VisitedNetwork_DAO.update(session, visited_network); } forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id=" + id); } else if (nextAction.equals("refresh")) { VisitedNetwork visited_network = (VisitedNetwork) VisitedNetwork_DAO.get_by_ID(session, id); if (!VN_Load.setForm(form, visited_network)) { logger.error("The VisitedNetwork withe the ID:" + id + " was not loaded from database!"); } forward = actionMapping.findForward(WebConstants.FORWARD_SUCCESS); forward = new ActionForward(forward.getPath() + "?id=" + id); } else if (nextAction.equals("delete")) { VisitedNetwork_DAO.delete_by_ID(session, id); forward = actionMapping.findForward(WebConstants.FORWARD_DELETE); } VN_Load.prepareForward(session, form, request, id); } catch (DatabaseException e) { logger.error("Database Exception occured!\nReason:" + e.getMessage()); e.printStackTrace(); dbException = true; forward = actionMapping.findForward(WebConstants.FORWARD_FAILURE); } catch (HibernateException e) { logger.error("Hibernate Exception occured!\nReason:" + e.getMessage()); e.printStackTrace(); dbException = true; forward = actionMapping.findForward(WebConstants.FORWARD_FAILURE); } finally { if (!dbException) { HibernateUtil.commitTransaction(); } HibernateUtil.closeSession(); } return forward; }
public ActionForward executeSub( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Initialize action initAction(request); if (null == config) { return (mapping.findForward("noconfig")); } String forward = null; DynaActionForm monitorForm = getPersistentForm(mapping, form, request); if (isCancelled(request)) { log.debug("edit is canceled"); forward = determineExitForward(monitorForm); } else { // debugFormData(request,form); String action = request.getParameter("action"); String indexStr = request.getParameter("index"); String triggerIndexStr = request.getParameter("triggerIndex"); int index = -1; if (StringUtils.isNotEmpty(indexStr)) { index = Integer.parseInt(indexStr); } int triggerIndex = -1; if (StringUtils.isNotEmpty(triggerIndexStr)) { triggerIndex = Integer.parseInt(triggerIndexStr); } MonitorManager mm = MonitorManager.getInstance(); if ("getStatus".equals(action)) { response.setContentType("text/xml"); PrintWriter out = response.getWriter(); out.print(mm.getStatusXml().toXML()); out.close(); return null; } Lock lock = mm.getStructureLock(); try { lock.acquireExclusive(); forward = performAction(monitorForm, action, index, triggerIndex, response); log.debug("forward [" + forward + "] returned from performAction"); mm.reconfigure(); } catch (Exception e) { error( "could not perform action [" + action + "] on monitorIndex [" + index + "] triggerIndex [" + triggerIndex + "]", e); } finally { lock.releaseExclusive(); } if (response.isCommitted()) { return null; } } if (StringUtils.isEmpty(forward)) { log.debug("replacing empty forward with [success]"); forward = "success"; } initForm(monitorForm); ActionForward af = mapping.findForward(forward); if (af == null) { throw new ServletException("could not find forward [" + forward + "]"); } // Forward control to the specified success URI log.debug("forward to [" + forward + "], path [" + af.getPath() + "]"); return (af); }
/** * <br> * [機 能] 完了メッセージ画面遷移時のパラメータを設定 <br> * [解 説] <br> * [備 考] * * @param map マッピング * @param req リクエスト * @param form アクションフォーム * @return ActionForward */ private ActionForward __setCompPageParam( ActionMapping map, HttpServletRequest req, Rng020Form form) { Cmn999Form cmn999Form = new Cmn999Form(); ActionForward urlForward = null; cmn999Form.setType(Cmn999Form.TYPE_OK); MessageResources msgRes = getResources(req); cmn999Form.setIcon(Cmn999Form.ICON_INFO); cmn999Form.setWtarget(Cmn999Form.WTARGET_BODY); if (form.getRng130searchFlg() == 1) { urlForward = map.findForward("search"); } else { urlForward = map.findForward("rng010"); } cmn999Form.setUrlOK(urlForward.getPath()); // メッセージセット String msgState = null; if (form.getRngCmdMode() == RngConst.RNG_CMDMODE_ADD) { msgState = "touroku.kanryo.object"; } else if (form.getRngCmdMode() == RngConst.RNG_CMDMODE_EDIT) { msgState = "hensyu.kanryo.object"; } GsMessage gsMsg = new GsMessage(); String msg = gsMsg.getMessage(req, "rng.62"); cmn999Form.setMessage(msgRes.getMessage(msgState, msg)); cmn999Form.addHiddenParam("rngProcMode", form.getRngProcMode()); cmn999Form.addHiddenParam("rng010orderKey", form.getRng010orderKey()); cmn999Form.addHiddenParam("rng010sortKey", form.getRng010sortKey()); cmn999Form.addHiddenParam("rng010pageTop", form.getRng010pageTop()); cmn999Form.addHiddenParam("rng010pageBottom", form.getRng010pageBottom()); cmn999Form.addHiddenParam("rngKeyword", form.getRngKeyword()); cmn999Form.addHiddenParam("rng130Type", form.getRng130Type()); cmn999Form.addHiddenParam("sltGroupSid", form.getSltGroupSid()); cmn999Form.addHiddenParam("sltUserSid", form.getSltUserSid()); cmn999Form.addHiddenParam("rng130keyKbn", form.getRng130keyKbn()); cmn999Form.addHiddenParam("rng130searchSubject1", form.getRng130searchSubject1()); cmn999Form.addHiddenParam("rng130searchSubject2", form.getRng130searchSubject2()); cmn999Form.addHiddenParam("sltSortKey1", form.getSltSortKey1()); cmn999Form.addHiddenParam("rng130orderKey1", form.getRng130orderKey1()); cmn999Form.addHiddenParam("sltSortKey2", form.getSltSortKey2()); cmn999Form.addHiddenParam("rng130orderKey2", form.getRng130orderKey1()); cmn999Form.addHiddenParam("sltApplYearFr", form.getSltApplYearFr()); cmn999Form.addHiddenParam("sltApplMonthFr", form.getSltApplMonthFr()); cmn999Form.addHiddenParam("sltApplDayFr", form.getSltApplDayFr()); cmn999Form.addHiddenParam("sltApplYearTo", form.getSltApplYearTo()); cmn999Form.addHiddenParam("sltApplMonthTo", form.getSltApplMonthTo()); cmn999Form.addHiddenParam("sltApplDayTo", form.getSltApplDayTo()); cmn999Form.addHiddenParam("sltLastManageYearFr", form.getSltLastManageYearFr()); cmn999Form.addHiddenParam("sltLastManageMonthFr", form.getSltLastManageMonthFr()); cmn999Form.addHiddenParam("sltLastManageDayFr", form.getSltLastManageDayFr()); cmn999Form.addHiddenParam("sltLastManageYearTo", form.getSltLastManageYearTo()); cmn999Form.addHiddenParam("sltLastManageMonthTo", form.getSltLastManageMonthTo()); cmn999Form.addHiddenParam("sltLastManageDayTo", form.getSltLastManageDayTo()); cmn999Form.addHiddenParam("rng130pageTop", form.getRng130pageTop()); cmn999Form.addHiddenParam("rng130pageBottom", form.getRng130pageBottom()); cmn999Form.addHiddenParam("svRngKeyword", form.getSvRngKeyword()); cmn999Form.addHiddenParam("svRng130Type", form.getSvRng130Type()); cmn999Form.addHiddenParam("svGroupSid", form.getSvGroupSid()); cmn999Form.addHiddenParam("svUserSid", form.getSvUserSid()); cmn999Form.addHiddenParam("svRng130keyKbn", form.getSvRng130keyKbn()); cmn999Form.addHiddenParam("svRng130searchSubject1", form.getSvRng130searchSubject1()); cmn999Form.addHiddenParam("svRng130searchSubject2", form.getSvRng130searchSubject2()); cmn999Form.addHiddenParam("svSortKey1", form.getSvSortKey1()); cmn999Form.addHiddenParam("svRng130orderKey1", form.getSvRng130orderKey1()); cmn999Form.addHiddenParam("svSortKey2", form.getSvSortKey2()); cmn999Form.addHiddenParam("svRng130orderKey2", form.getSvRng130orderKey1()); cmn999Form.addHiddenParam("svApplYearFr", form.getSvApplYearFr()); cmn999Form.addHiddenParam("svApplMonthFr", form.getSvApplMonthFr()); cmn999Form.addHiddenParam("svApplDayFr", form.getSvApplDayFr()); cmn999Form.addHiddenParam("svApplYearTo", form.getSvApplYearTo()); cmn999Form.addHiddenParam("svApplMonthTo", form.getSvApplMonthTo()); cmn999Form.addHiddenParam("svApplDayTo", form.getSvApplDayTo()); cmn999Form.addHiddenParam("svLastManageYearFr", form.getSvLastManageYearFr()); cmn999Form.addHiddenParam("svLastManageMonthFr", form.getSvLastManageMonthFr()); cmn999Form.addHiddenParam("svLastManageDayFr", form.getSvLastManageDayFr()); cmn999Form.addHiddenParam("svLastManageYearTo", form.getSvLastManageYearTo()); cmn999Form.addHiddenParam("svLastManageMonthTo", form.getSvLastManageMonthTo()); cmn999Form.addHiddenParam("svLastManageDayTo", form.getSvLastManageDayTo()); cmn999Form.addHiddenParam("rng130searchFlg", form.getRng130searchFlg()); req.setAttribute("cmn999Form", cmn999Form); return map.findForward("gf_msg"); }
protected String getMappingPath(ActionMapping mapping, String name) { ActionForward forward = mapping.findForward(name); return forward == null ? null : forward.getPath(); }