List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add
public static void add(PortletRequest portletRequest, String key)
From source file:org.opencps.processmgt.portlet.ProcessOrderMenuPortlet.java
License:Open Source License
private void ajaxReturn(ActionRequest actionRequest, ActionResponse actionResponse, Map<String, String> par) { try {/*from w ww. j a v a2s . com*/ HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(actionResponse); httpResponse.setContentType("text"); JSONObject payloadJSON = JSONFactoryUtil.createJSONObject(); for (Map.Entry<String, String> entry : par.entrySet()) { payloadJSON.put(entry.getKey(), HtmlUtil.escape(entry.getValue())); } httpResponse.getWriter().print(payloadJSON.toString()); httpResponse.flushBuffer(); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE); } catch (Exception e) { _log.error(e); } }
From source file:org.opencps.servicemgt.portlet.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig arg0, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long plid = ParamUtil.getLong(actionRequest, "plid"); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);/*from ww w.j a v a 2 s . com*/ preferences.setValue("plid", String.valueOf(plid)); preferences.store(); SessionMessages.add(actionRequest, "potlet-config-saved"); }
From source file:org.opencps.servicemgt.portlet.ConfigurationDisrectoryImpl.java
License:Open Source License
@Override public void processAction(PortletConfig arg0, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { long plidServiceDetail = ParamUtil.getLong(actionRequest, "plidServiceDetail"); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);//from w w w . j a v a 2 s . c o m preferences.setValue("plidServiceDetail", String.valueOf(plidServiceDetail)); preferences.store(); SessionMessages.add(actionRequest, "potlet-config-saved"); }
From source file:org.opencps.servicemgt.portlet.ConfigurationImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String menuType = ParamUtil.getString(actionRequest, "menuType"); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);/*from ww w . j ava2 s .c o m*/ preferences.setValue("menuType", menuType); preferences.store(); SessionMessages.add(actionRequest, "potlet-config-saved"); }
From source file:org.opencps.servicemgt.portlet.ServiceMgtPortlet.java
License:Open Source License
/** * @param actionRequest/* ww w. j a va2s. c o m*/ * @param actionResponse * @throws IOException */ public void updateDomain(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { long dictItemId = ParamUtil.getLong(actionRequest, DictItemDisplayTerms.DICTITEM_ID); long parentItemId = ParamUtil.getLong(actionRequest, DictItemDisplayTerms.PARENTITEM_ID); String itemName = ParamUtil.getString(actionRequest, DictItemDisplayTerms.ITEM_NAME); String itemCode = ParamUtil.getString(actionRequest, DictItemDisplayTerms.ITEM_CODE); String isAddchirld = ParamUtil.getString(actionRequest, "isAddchirld"); String backURL = ParamUtil.getString(actionRequest, "backURL"); String currentURL = ParamUtil.getString(actionRequest, "currentURL"); Map<Locale, String> itemNameMap = LocalizationUtil.getLocalizationMap(actionRequest, DictItemDisplayTerms.ITEM_NAME); DictCollection dictCollection = null; try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); dictCollection = DictCollectionLocalServiceUtil.getDictCollection(serviceContext.getScopeGroupId(), PortletPropsValues.DATAMGT_MASTERDATA_SERVICE_DOMAIN); DataMamagementPortlet.validatetDictItem(dictItemId, itemName, itemCode, serviceContext); if (dictItemId == 0) { DictItemLocalServiceUtil.addDictItem(serviceContext.getUserId(), dictCollection.getDictCollectionId(), itemCode, itemNameMap, parentItemId, serviceContext); SessionMessages.add(actionRequest, MessageKeys.DATAMGT_ADD_SUCESS); } else { if (Validator.isNotNull(isAddchirld)) { DictItemLocalServiceUtil.addDictItem(serviceContext.getUserId(), dictCollection.getDictCollectionId(), itemCode, itemNameMap, parentItemId, serviceContext); SessionMessages.add(actionRequest, MessageKeys.DATAMGT_ADD_SUCESS); } else { //tam thoi hard code dictversionId = 0 DictItemLocalServiceUtil.updateDictItem(dictItemId, dictCollection.getDictCollectionId(), 0, itemCode, itemNameMap, parentItemId, serviceContext); SessionMessages.add(actionRequest, MessageKeys.DATAMGT_UPDATE_SUCESS); } } if (Validator.isNotNull(backURL)) { actionResponse.sendRedirect(backURL); } } catch (Exception e) { if (e instanceof EmptyItemCodeException) { SessionErrors.add(actionRequest, EmptyItemCodeException.class); } else if (e instanceof OutOfLengthItemCodeException) { SessionErrors.add(actionRequest, OutOfLengthItemCodeException.class); } else if (e instanceof EmptyDictItemNameException) { SessionErrors.add(actionRequest, EmptyDictItemNameException.class); } else if (e instanceof OutOfLengthItemNameException) { SessionErrors.add(actionRequest, OutOfLengthItemNameException.class); } else if (e instanceof DuplicateItemException) { SessionErrors.add(actionRequest, DuplicateItemException.class); } else if (e instanceof NoSuchDictItemException) { SessionErrors.add(actionRequest, NoSuchDictItemException.class); } else { SessionErrors.add(actionRequest, MessageKeys.DATAMGT_SYSTEM_EXCEPTION_OCCURRED); } if (Validator.isNotNull(currentURL)) { actionResponse.sendRedirect(currentURL); } } }
From source file:org.opencps.servicemgt.portlet.ServiceMgtPortlet.java
License:Open Source License
/** * @param renderRequest//from ww w .j a v a 2 s . com * @param renderResponse * @return * @throws PortalException * @throws SystemException */ public ServiceInfo updateService(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { ServiceDisplayTerms displayTerms = new ServiceDisplayTerms(actionRequest); long serviceInfoId = displayTerms.getServiceId(); String redirectURL = ParamUtil.getString(actionRequest, "redirectURL"); String returnURL = ParamUtil.getString(actionRequest, "returnURL"); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); String urlOnline = ParamUtil.getString(actionRequest, "urlOnline"); String onlineURL = Validator.isNotNull(urlOnline) ? urlOnline : displayTerms.getOnlineUrl(); try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); if (serviceInfoId <= 0) { // TODO: Validator in here // Add ServiceInfo ServiceInfoLocalServiceUtil.addService(displayTerms.getServiceNo(), displayTerms.getServiceName(), displayTerms.getFullName(), displayTerms.getServiceProcess(), displayTerms.getServiceMethod(), displayTerms.getServiceDossier(), displayTerms.getServiceCondition(), displayTerms.getServiceDuration(), displayTerms.getServiceActors(), displayTerms.getServiceResults(), displayTerms.getServiceRecords(), displayTerms.getServiceFee(), displayTerms.getServiceInstructions(), displayTerms.getAdministrationCode(), displayTerms.getAdministrationIndex(), displayTerms.getDomainCode(), displayTerms.getDomainIndex(), displayTerms.getActiveStatus(), onlineURL, displayTerms.setFileTemplateIds(actionRequest), serviceContext); // Redirect page if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } } else { // TODO: Validator in here // Update ServiceInfo ServiceInfoLocalServiceUtil.updateService(serviceInfoId, displayTerms.getServiceNo(), displayTerms.getServiceName(), displayTerms.getFullName(), displayTerms.getServiceProcess(), displayTerms.getServiceMethod(), displayTerms.getServiceDossier(), displayTerms.getServiceCondition(), displayTerms.getServiceDuration(), displayTerms.getServiceActors(), displayTerms.getServiceResults(), displayTerms.getServiceRecords(), displayTerms.getServiceFee(), displayTerms.getServiceInstructions(), displayTerms.getAdministrationCode(), displayTerms.getAdministrationIndex(), displayTerms.getDomainCode(), displayTerms.getDomainIndex(), onlineURL, displayTerms.setFileTemplateIds(actionRequest), serviceContext); // Redirect page if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } } } catch (Exception e) { if (Validator.isNotNull(returnURL)) { actionResponse.sendRedirect(returnURL); } } return null; }
From source file:org.opencps.servicemgt.portlet.ServiceMgtPortlet.java
License:Open Source License
/** * @param actionRequest//ww w.j a v a 2s .c o m * @param actionResponse * @return * @throws PortalException * @throws SystemException * @throws IOException */ public void updateTempalteFile(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { long templateFileId = ParamUtil.getLong(actionRequest, "templateFileId"); String fileNo = ParamUtil.getString(actionRequest, "fileNo"); String fileName = ParamUtil.getString(actionRequest, "fileName"); String redirectURL = ParamUtil.getString(actionRequest, "redirectURL"); String returnURL = ParamUtil.getString(actionRequest, "returnURL"); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); serviceContext.setAddGuestPermissions(true); if (templateFileId <= 0) { if (TemplateFileLocalServiceUtil.isDuplicateFileName(templateFileId, serviceContext.getScopeGroupId(), fileName)) { } if (TemplateFileLocalServiceUtil.isDuplicateFileNo(templateFileId, serviceContext.getScopeGroupId(), fileNo)) { } TemplateFileLocalServiceUtil.addServiceTemplateFile(fileNo, fileName, actionRequest, actionResponse, serviceContext); SessionMessages.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_UPDATE_SUCESS); } else { if (TemplateFileLocalServiceUtil.isDuplicateFileName(templateFileId, serviceContext.getScopeGroupId(), fileName)) { } if (TemplateFileLocalServiceUtil.isDuplicateFileNo(templateFileId, serviceContext.getScopeGroupId(), fileNo)) { } TemplateFileLocalServiceUtil.updateServiceTemplateFile(templateFileId, fileNo, fileName, actionRequest, actionResponse, serviceContext); SessionMessages.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_UPDATE_SUCESS); } if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } } catch (Exception e) { if (e instanceof DuplicateFileNameException) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_NAME_EXCEPTION); } else if (e instanceof DuplicateFileNoException) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_FILE_NO_EXCEPTION); } else if (e instanceof IOFileUploadException) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_UPLOAD_EXCEPTION); } else { SessionErrors.add(actionRequest, MessageKeys.SERVICE_TEMPLATE_EXCEPTION_OCCURRED); } if (Validator.isNotNull(returnURL)) { actionResponse.sendRedirect(returnURL); } } }
From source file:org.opencps.servicemgt.portlet.ServiceMgtPortlet.java
License:Open Source License
/** * @param actionRequest/*from w w w .ja v a 2 s.com*/ * @param actionResponse * @throws IOException * @throws SystemException * @throws PortalException */ public void deleteService(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException, SystemException { long serviceinfoId = ParamUtil.getLong(actionRequest, ServiceDisplayTerms.SERVICE_ID); String redirectURL = ParamUtil.getString(actionRequest, "redirectURL"); ServiceConfig serviceConfig = null; java.util.List<Dossier> dossier = new ArrayList<Dossier>(); java.util.List<ProcessOrder> processOrder = new ArrayList<ProcessOrder>(); try { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); serviceConfig = ServiceConfigLocalServiceUtil.getServiceConfigByG_S(serviceContext.getScopeGroupId(), serviceinfoId); dossier = DossierLocalServiceUtil.getDossiersByServiceInfo(serviceinfoId); processOrder = ProcessOrderLocalServiceUtil.getProcessOrdersByServiceInfoId(serviceinfoId); } catch (Exception e) { // nothing to do } if (serviceConfig != null) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_DELERR_EXITS_SERVICECONFIG); } else if (!dossier.isEmpty()) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_DELERR_EXITS_DOSSIER); } else if (!processOrder.isEmpty()) { SessionErrors.add(actionRequest, MessageKeys.SERVICE_DELERR_EXITS_PROCESSORDER); } else { ServiceInfoLocalServiceUtil.deleteService(serviceinfoId); SessionMessages.add(actionRequest, MessageKeys.SERVICE_DELSUCC); } if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } }
From source file:org.opencps.usermgt.portlet.UserMgtPortlet.java
License:Open Source License
/** * @param actionRequest//from ww w. java2 s .c o m * @param actionResponse * @throws IOException */ public void deleteEmployee(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { long employeeId = ParamUtil.getLong(actionRequest, EmployeeDisplayTerm.EMPLOYEE_ID); String redirectURL = ParamUtil.getString(actionRequest, "redirectURL"); try { EmployeeLocalServiceUtil.deletedPermanently(employeeId); SessionMessages.add(actionRequest, MessageKeys.USERMGT_EMPLOYEE_DELETE_SUCCESS); } catch (Exception e) { SessionErrors.add(actionRequest, MessageKeys.USERMGT_EMPLOYEE_DELETE_ERROR); _log.error(e); } finally { if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } } }
From source file:org.opencps.usermgt.portlet.UserMgtPortlet.java
License:Open Source License
public void deleteJobPos(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException, PortalException, IOException { long jobPosId = ParamUtil.getLong(actionRequest, JobPosDisplayTerms.ID_JOBPOS); String redirectURL = ParamUtil.getString(actionRequest, "redirectURL"); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); List<Employee> employees = EmployeeLocalServiceUtil.getEmployeesByMainJobPosId(jobPosId); if (jobPosId > 0 && employees.isEmpty()) { JobPosLocalServiceUtil.deleteJobPosById(jobPosId); SessionMessages.add(actionRequest, MessageKeys.USERMGT_JOBPOS_DELETE_SUCCESS); if (Validator.isNotNull(redirectURL)) { _log.info(redirectURL);//from w ww . j a v a 2s. com actionResponse.sendRedirect(redirectURL); } } else { SessionErrors.add(actionRequest, MessageKeys.USERMGT_JOBPOS_DELETE_ERROR); if (Validator.isNotNull(redirectURL)) { actionResponse.sendRedirect(redirectURL); } } }