List of usage examples for com.liferay.portal.kernel.servlet SessionMessages add
public static void add(PortletRequest portletRequest, String key)
From source file:org.oep.core.logging.action.UserActivityAction.java
License:Apache License
public void activateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { long userId = ParamUtil.getLong(actionRequest, "userId"); try {// ww w .ja v a2s . c o m UserLocalServiceUtil.updateStatus(userId, WorkflowConstants.STATUS_APPROVED); SessionMessages.add(actionRequest, "org.oep.useractivity.success.active"); } catch (Exception e) { SessionErrors.add(actionRequest, "org.oep.useractivity.error.operation.fail"); } actionResponse.sendRedirect(ParamUtil.getString(actionRequest, PortletKeys.REDIRECT_PAGE)); }
From source file:org.oep.ssomgt.action.ApplicationManagementPortlet.java
License:Apache License
public void addEditApplication(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException { UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(request); validateParamsIntoSessionError(uploadRequest, request); String appName = null;//from w w w. j a v a 2 s . c om String appCode = null; String appPin = null; String appUrl = null; String publicKey = null; if (SessionErrors.isEmpty(request)) { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME, PortletKeys.TEXT_BOX); appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE, PortletKeys.TEXT_BOX); appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN, PortletKeys.TEXT_BOX); appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL, PortletKeys.TEXT_BOX); publicKey = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.PUBLICKEY, PortletKeys.TEXT_BOX); Long editId = ParamUtil.getLong(uploadRequest, ApplicationKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT); OutputBlob bigIconBlob = null; OutputBlob smallIconBlob = null; try { File bigIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_BIGICON); File smallIconFile = uploadRequest.getFile(ApplicationKeys.AddEditAttributes.APP_SMALLICON); InputStream bigIconStream = new FileInputStream(bigIconFile); InputStream smallIconStream = new FileInputStream(smallIconFile); bigIconBlob = new OutputBlob(bigIconStream, bigIconFile.length()); smallIconBlob = new OutputBlob(smallIconStream, smallIconFile.length()); } catch (NullPointerException ex) { SessionErrors.add(request, ApplicationKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATIONMANAGEMENT_APPICONNULL); } catch (FileNotFoundException ex) { } Date pingTime = new Date(); if (editId == PortletKeys.LONG_DEFAULT) { if (smallIconBlob != null && bigIconBlob != null) { ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, bigIconBlob, smallIconBlob, pingTime, publicKey, serviceContext); SessionMessages.add(request, ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_ADDNEW); } else { ApplicationLocalServiceUtil.addApplication(appCode, appName, appPin, appUrl, pingTime, publicKey, serviceContext); SessionMessages.add(request, ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_ADDNEW); } } else { Application application = ApplicationLocalServiceUtil.getApplication(editId); if (smallIconBlob != null) { application.setAppSmallIcon(smallIconBlob); } if (bigIconBlob != null) { application.setAppBigIcon(bigIconBlob); } application.setAppCode(appCode); application.setAppPin(appPin); application.setAppUrl(appUrl); application.setPingTime(pingTime); ApplicationLocalServiceUtil.updateApplication(application, serviceContext); SessionMessages.add(request, ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_UPDATE); } } SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); if (!SessionErrors.isEmpty(request)) { appName = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_NAME, PortletKeys.TEXT_BOX); appCode = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_CODE, PortletKeys.TEXT_BOX); appPin = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_PIN, PortletKeys.TEXT_BOX); appUrl = ParamUtil.getString(uploadRequest, ApplicationKeys.AddEditAttributes.APP_URL, PortletKeys.TEXT_BOX); response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_NAME, appName); response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_CODE, appCode); response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_PIN, appPin); response.setRenderParameter(ApplicationKeys.AddEditAttributes.APP_URL, appUrl); PortalUtil.copyRequestParameters(request, response); } else { response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); } }
From source file:org.oep.ssomgt.action.ApplicationManagementPortlet.java
License:Apache License
public void deleteApplication(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException { long deleteId = ParamUtil.getLong(request, ApplicationKeys.BaseApplicationAttributes.DELETE_ID, PortletKeys.LONG_DEFAULT);/*from w ww . ja va 2 s. c om*/ try { ApplicationLocalServiceUtil.removeApplication(deleteId); SessionMessages.add(request, ApplicationKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATION_SUCCESS_DELETE); } catch (Exception ex) { SessionMessages.add(request, ApplicationKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPLICATIONMANAGEMENT_ERROR_DELETE); } response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void addEditAppRole2JobPos(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException { if (SessionErrors.isEmpty(request)) { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); long appRoleId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.APPROLE_ID, PortletKeys.LONG_DEFAULT); long jobPosId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.JOBPOS_ID, PortletKeys.LONG_DEFAULT); Long editId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT); if (editId == PortletKeys.LONG_DEFAULT) { AppRole2JobPosLocalServiceUtil.addAppRole2JobPos(appRoleId, jobPosId, serviceContext); SessionMessages.add(request, AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2JOBPOS_SUCCESS_ADDNEW); } else {/*from w w w. j ava 2s . c o m*/ } } SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); if (!SessionErrors.isEmpty(request)) { PortalUtil.copyRequestParameters(request, response); } else { response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); } }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void addEditAppRole2Employee(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException { if (SessionErrors.isEmpty(request)) { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); long appRoleId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.APPROLE_ID, PortletKeys.LONG_DEFAULT); long employeeId = ParamUtil.getLong(request, AppRole2EmployeeKeys.AddEditAttributes.EMPLOYEE_ID, PortletKeys.LONG_DEFAULT); Long editId = ParamUtil.getLong(request, AppRole2EmployeeKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT); if (editId == PortletKeys.LONG_DEFAULT) { Employee employee = EmployeeLocalServiceUtil.getEmployee(employeeId); AppRole2EmployeeLocalServiceUtil.addAppRole2Employee(appRoleId, employeeId, serviceContext); AppRole role = AppRoleLocalServiceUtil.getAppRole(appRoleId); try { UserSync userSync = UserSyncLocalServiceUtil.findByApplicationEmployee(role.getApplicationId(), employeeId);//from w w w . jav a 2 s .c o m String roles = userSync.getRoles(); userSync.setCheckpoint(new Date()); if (!roles.contains(role.getRoleCode())) { if (roles.equals("")) roles = role.getRoleCode(); else roles += "," + role.getRoleCode(); } else { } UserSyncLocalServiceUtil.updateUserSync(userSync); } catch (Exception e) { e.printStackTrace(); User user = UserLocalServiceUtil.getUser(employee.getMappingUserId()); UserSyncLocalServiceUtil.addUserSync(role.getApplicationId(), employeeId, employee.getMappingUserId(), user.getScreenName(), user.getScreenName(), employee.getFullName(), user.getEmailAddress(), user.getPassword(), 1, role.getRoleCode(), new Date(), null); } SessionMessages.add(request, AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2EMPLOYEE_SUCCESS_ADDNEW); } else { } } SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); if (!SessionErrors.isEmpty(request)) { PortalUtil.copyRequestParameters(request, response); } else { response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); } }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void deleteJP(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException { long deleteId = ParamUtil.getLong(request, AppRole2JobPosKeys.BaseAppRole2JobPosAttributes.DELETE_ID, PortletKeys.LONG_DEFAULT);//from w w w . j ava 2 s. co m try { AppRole2JobPosLocalServiceUtil.removeAppRole2JobPos(deleteId); SessionMessages.add(request, AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2JOBPOS_SUCCESS_DELETE); } catch (Exception ex) { SessionMessages.add(request, AssignRoleKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2JOBPOS_ERROR_DELETE); } response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void deleteEP(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException { long deleteId = ParamUtil.getLong(request, AppRole2JobPosKeys.BaseAppRole2JobPosAttributes.DELETE_ID, PortletKeys.LONG_DEFAULT);/*from w w w .j a va2 s .c om*/ try { AppRole2Employee a2e = AppRole2EmployeeLocalServiceUtil.getAppRole2Employee(deleteId); if (a2e != null) { try { AppRole role = AppRoleLocalServiceUtil.getAppRole(a2e.getAppRoleId()); UserSync userSync = UserSyncLocalServiceUtil.findByApplicationEmployee(role.getApplicationId(), a2e.getEmployeeId()); userSync.setCheckpoint(new Date()); userSync.setAccessibleStatus(0); UserSyncLocalServiceUtil.updateUserSync(userSync); } catch (Exception e) { e.printStackTrace(); } } AppRole2EmployeeLocalServiceUtil.removeAppRole2Employee(deleteId); SessionMessages.add(request, AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2EMPLOYEE_SUCCESS_DELETE); } catch (Exception ex) { SessionMessages.add(request, AssignRoleKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2EMPLOYEE_ERROR_DELETE); } response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void addEditAppRole(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException { validateParamsIntoSessionError(request); if (SessionErrors.isEmpty(request)) { ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); long applicationId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.APPLICATION_ID, PortletKeys.LONG_DEFAULT); String roleCode = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_CODE, PortletKeys.TEXT_BOX);// w w w. j a v a2 s . c o m String roleName = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_NAME, PortletKeys.TEXT_BOX); Long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT); if (editId == PortletKeys.LONG_DEFAULT) { AppRoleLocalServiceUtil.addAppRole(applicationId, roleCode, roleName, serviceContext); SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_ADDNEW); } else { AppRoleLocalServiceUtil.updateAppRole(editId, applicationId, roleCode, roleName, serviceContext); SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_UPDATE); } } SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); if (!SessionErrors.isEmpty(request)) { PortalUtil.copyRequestParameters(request, response); } else { response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); } }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void deleteAppRole(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException { long deleteId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.DELETE_ID, PortletKeys.LONG_DEFAULT);//from w w w. j ava 2s . c o m try { AppRoleLocalServiceUtil.removeAppRole(deleteId); SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_DELETE); } catch (Exception ex) { SessionMessages.add(request, AppRoleKeys.ErrorMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ERROR_DELETE); } response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); }
From source file:org.oep.ssomgt.action.AppRolePortlet.java
License:Apache License
public void editAppRole(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException { long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT); AppRole appRole = AppRoleLocalServiceUtil.getAppRole(editId); setParameterIntoResponse(response, appRole); if (!SessionErrors.isEmpty(request)) { response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE)); SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_UPDATE); } else {// ww w . j a v a 2 s . c om PortalUtil.copyRequestParameters(request, response); } }