@Override protected void doServeResource(ResourceRequest request, ResourceResponse response) throws Exception { String cmd = ParamUtil.getString(request, Constants.CMD); String serializedJson = ""; if(cmd.equals(CMD_PAGELIST)) { serializedJson = getPageLists(request,response ); } else { _log.error("Unknown command is passed <" + cmd + ">"); } HttpServletResponse servletResponse = _portal.getHttpServletResponse( response); servletResponse.setContentType(ContentTypes.APPLICATION_JSON); ServletResponseUtil.write(servletResponse, serializedJson); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("numerateModules", actionRequest.getParameter("numerateModules")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); PortletRequestDispatcher portletRequestDispatcher = null; if (cmd.equals(Constants.IMPORT)) { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp"); } else { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/new_import/import_task_records_resources.jsp"); } portletRequestDispatcher.include(resourceRequest, resourceResponse); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, TaskRecord taskRecord, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editTaskRecord"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(taskRecord.getGroupId()), false); portletURL.setParameter( "taskRecordId", String.valueOf(taskRecord.getTaskRecordId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { _log.info("doProcessAction()"); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); _log.info("cmd = " + cmd); if (cmd.equals(Constants.DELETE)) { deleteBackgroundTasks(actionRequest, actionResponse); } else if (cmd.equals(Constants.EXPORT)) { exportTaskRecords(actionRequest, actionResponse); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); } }
@Override public int getPercentage() { if (_percentage > PERCENTAGE_NONE) { return _percentage; } _percentage = PERCENTAGE_MAX; if (_allProgressBarCountersTotal > PERCENTAGE_MIN) { int base = PERCENTAGE_MAX; if (_phase.equals(Constants.EXPORT) && !Objects.equals(_cmd, Constants.PUBLISH_TO_REMOTE)) { base = _EXPORT_PHASE_MAX_PERCENTAGE; } _percentage = Math.round((float) _currentProgressBarCountersTotal / _allProgressBarCountersTotal * base); } return _percentage; }
protected String getStatusMessageKey() { if (Validator.isNotNull(_messageKey)) { return _messageKey; } _messageKey = StringPool.BLANK; if (hasRemoteMessage()) { _messageKey = "please-wait-as-the-publication-processes-on-the-remote-site"; } else if (hasStagedModelMessage()) { _messageKey = "exporting"; if (Objects.equals(_cmd, Constants.IMPORT)) { _messageKey = "importing"; } else if (Objects.equals(_cmd, Constants.PUBLISH_TO_LIVE) || Objects.equals(_cmd, Constants.PUBLISH_TO_REMOTE)) { _messageKey = "publishing"; } } return _messageKey; }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Contact contact, Layout layout, String redirect) throws Exception { _log.info("getSaveAndContinueRedirect()"); PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editContact"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(contact.getGroupId()), false); portletURL.setParameter( "contactId", String.valueOf(contact.getContactId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); PortletRequestDispatcher portletRequestDispatcher = null; if (cmd.equals(Constants.IMPORT)) { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp"); } else { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/new_import/import_contacts_resources.jsp"); } portletRequestDispatcher.include(resourceRequest, resourceResponse); }
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (cmd.equals(Constants.DELETE)) { deleteBackgroundTasks(actionRequest, actionResponse); } else if (cmd.equals(Constants.EXPORT)) { exportContacts(actionRequest, actionResponse); } String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNotNull(redirect)) { sendRedirect(actionRequest, actionResponse, redirect); } }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); String serializedJson = ""; if (cmd.equals(CMD_ROLELIST)) { serializedJson = getRoleLists(resourceRequest, resourceResponse); } else { _log.error("Unknown command is passed <" + cmd + ">"); } HttpServletResponse response = _portal.getHttpServletResponse(resourceResponse); response.setContentType(ContentTypes.APPLICATION_JSON); ServletResponseUtil.write(response, serializedJson); }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); String serializedJson = ""; if(cmd.equals(CMD_THREAD_LIST)) { serializedJson = getThreadList(resourceRequest,resourceResponse ); } else if (cmd.equals(CMD_CATEGORY_LIST)) { serializedJson = getCategoryList(resourceRequest,resourceResponse ); } else { _log.error("Unknown command is passed <" + cmd + ">"); } HttpServletResponse response = _portal.getHttpServletResponse( resourceResponse); response.setContentType(ContentTypes.APPLICATION_JSON); ServletResponseUtil.write(response, serializedJson); }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { // _log.info("doServeResource()"); String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); // _log.info("cmd = " + cmd); PortletRequestDispatcher portletRequestDispatcher = null; if (cmd.equals(Constants.IMPORT)) { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp"); } else { portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/new_import/import_measurements_resources.jsp"); } portletRequestDispatcher.include(resourceRequest, resourceResponse); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Measurement measurement, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editMeasurement"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(measurement.getGroupId()), false); portletURL.setParameter( "measurementId", String.valueOf(measurement.getMeasurementId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override public boolean serveResource( ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException { final String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); if (cmd.equals("BOOKMARK_ORDERABLE")) { serveOlderUserBookmarks(resourceRequest, resourceResponse); } else { _editFolderMVCResourceCommand.serveResource( resourceRequest, resourceResponse); } return true; }
@Override public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (!cmd.equals(Constants.UPDATE)) { return; } // ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute( // WebKeys.THEME_DISPLAY); //ShoppingPreferences preferences = ShoppingPreferences.getInstance( // themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); // // String tabs2 = ParamUtil.getString(actionRequest, "tabs2"); // String tabs3 = ParamUtil.getString(actionRequest, "tabs3"); }
public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))){ return; } PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("showActionSocial", actionRequest.getParameter("showActionSocial")); prefs.setValue("showActionAudit", actionRequest.getParameter("showActionAudit")); prefs.store(); SessionMessages.add( actionRequest, portletConfig.getPortletName() + ".doConfigure"); //SessionMessages.add(actionRequest,"success"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("viewAlways", actionRequest.getParameter("viewAlways")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("viewMode", actionRequest.getParameter("viewMode")); prefs.setValue("numerateModules", actionRequest.getParameter("numerateModules")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))){ return; } PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("showPreviousModuleButton", actionRequest.getParameter("showPreviousModuleButton")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
private String verificaRedirecionamentoParaHttp(HttpServletRequest request, HttpServletResponse response, String retorno) throws IOException { if ("portal.update_password".equals(retorno) && !Validator.isNull(ParamUtil.getString(request, Constants.CMD))) { String ticketKey = ParamUtil.getString(request, "ticketKey"); String plid = ParamUtil.getString(request, "p_l_id"); String doAsUserId = ParamUtil.getString(request, "doAsUserId"); String urlHttp = PortalUtil.getPortalURL(request, false) + Portal.PATH_MAIN + "/portal/update_password"; if (!Validator.isNull(ticketKey)) urlHttp = HttpUtil.addParameter(urlHttp, "ticketKey", ticketKey); if (!Validator.isNull(plid)) urlHttp = HttpUtil.addParameter(urlHttp, "p_l_id", plid); if (!Validator.isNull(doAsUserId)) urlHttp = HttpUtil.addParameter(urlHttp, "doAsUserId", doAsUserId); response.sendRedirect(urlHttp); return null; } else { return retorno; } }
@Override public void serveResource(ResourceRequest request, ResourceResponse response) { String cmd = ParamUtil.getString(request, Constants.CMD); try { if (LOAD_NOTES_ACTION.equals(cmd)) { JSONArray resultJsonArray = JSONFactoryUtil.createJSONArray(); resultJsonArray = loadNotes(request); writeJSON(request, response, resultJsonArray); } else { JSONObject resultJsonObject = JSONFactoryUtil.createJSONObject(); if (LOAD_MORE_NOTES_ACTION.equals(cmd)) { resultJsonObject = loadMoreNotes(request); } else if (SELECT_NOTE_ACTION.equals(cmd)) { resultJsonObject = selectNote(request); } writeJSON(request, response, resultJsonObject); } } catch (IOException e) { LOG.error(JSON_RETURNING_ERROR, e); } }
public static void createMicroSite(ActionRequest request) throws Exception{ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(request, Constants.CMD); try { if (cmd.equals(Constants.ADD)) { Group group = updateGroup(request); long microSiteId = CounterLocalServiceUtil.increment(MicroSite.class.getName()); MicroSite microSite = MicroSiteLocalServiceUtil.createMicroSite(microSiteId); microSite.setCompanyId(themeDisplay.getCompanyId()); microSite.setUserId(themeDisplay.getUserId()); microSite.setUserName(themeDisplay.getUser().getScreenName()); microSite.setCreateDate(new Date()); microSite.setModifiedDate(new Date()); microSite.setGroupId(group.getGroupId()); MicroSiteLocalServiceUtil.updateMicroSite(microSite); } } catch (Exception e) { SessionErrors.add(request, e.getClass()); throw e; } }
public ExportImportBackgroundTaskDisplay(BackgroundTask backgroundTask) { super(backgroundTask); Map<String, Serializable> taskContextMap = backgroundTask.getTaskContextMap(); _cmd = MapUtil.getString(taskContextMap, Constants.CMD); _percentage = PERCENTAGE_NONE; if (backgroundTaskStatus == null) { _allProgressBarCountersTotal = 0; _currentProgressBarCountersTotal = 0; _phase = null; _stagedModelName = null; _stagedModelType = null; return; } long allModelAdditionCountersTotal = getBackgroundTaskStatusAttributeLong("allModelAdditionCountersTotal"); long allPortletAdditionCounter = getBackgroundTaskStatusAttributeLong("allPortletAdditionCounter"); _allProgressBarCountersTotal = allModelAdditionCountersTotal + allPortletAdditionCounter; long currentModelAdditionCountersTotal = getBackgroundTaskStatusAttributeLong( "currentModelAdditionCountersTotal"); long currentPortletAdditionCounter = getBackgroundTaskStatusAttributeLong("currentPortletAdditionCounter"); _currentProgressBarCountersTotal = currentModelAdditionCountersTotal + currentPortletAdditionCounter; _phase = getBackgroundTaskStatusAttributeString("phase"); _stagedModelName = getBackgroundTaskStatusAttributeString("stagedModelName"); _stagedModelType = getBackgroundTaskStatusAttributeString("stagedModelType"); }
@Override public boolean hasPercentage() { if (!hasBackgroundTaskStatus()) { return false; } if ((_allProgressBarCountersTotal > PERCENTAGE_MIN) && (!Objects.equals(_cmd, Constants.PUBLISH_TO_REMOTE) || (getPercentage() < PERCENTAGE_MAX))) { return true; } return false; }
protected boolean hasRemoteMessage() { if (Objects.equals(_cmd, Constants.PUBLISH_TO_REMOTE) && (getPercentage() == PERCENTAGE_MAX)) { return true; } return false; }
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { _log.info("doServeResource()"); String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); _log.info("cmd = " + cmd); // TODO: catch errors and redirect to error.jsp if ("getJSON".equals(cmd)) { getJSON(resourceRequest, resourceResponse); } else { // TODO: add i18n. if (Validator.isNull(cmd)) { PortletResponseUtil.write(resourceResponse, "Resource cmd is missing.".getBytes()); } else { PortletResponseUtil.write(resourceResponse, "Resource cmd " + cmd + " is unknown.".getBytes()); } } }