List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add
public static void add(PortletRequest portletRequest, String key)
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {//from w w w .j av a 2 s .c om getCalendar(renderRequest); getCalendarBooking(renderRequest); getCalendarResource(renderRequest); setRenderRequestAttributes(renderRequest); } catch (Exception e) { if (e instanceof NoSuchResourceException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }
From source file:com.liferay.calendarimporter.portlet.CalendarImporterPortlet.java
License:Open Source License
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try {/*w w w . j a v a 2 s. com*/ long importEntryId = ParamUtil.getLong(renderRequest, "importEntryId"); ImportEntry importEntry = null; if (importEntryId > 0) { importEntry = ImportEntryLocalServiceUtil.getImportEntry(importEntryId); } renderRequest.setAttribute(WebKeys.IMPORT_ENTRY, importEntry); } catch (Exception e) { if (e instanceof NoSuchImportEntryException) { SessionErrors.add(renderRequest, e.getClass()); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }
From source file:com.liferay.CartAction.java
License:Open Source License
@Override public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {//ww w . j a va 2s . c om updateCart(actionRequest, actionResponse); String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { actionResponse.sendRedirect(redirect); } } catch (Exception e) { if (e instanceof NoSuchItemException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.shopping.error"); } else if (e instanceof CartMinQuantityException || e instanceof CouponActiveException || e instanceof CouponEndDateException || e instanceof CouponStartDateException || e instanceof NoSuchCouponException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } }
From source file:com.liferay.ci.jenkins.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String baseAPIURL = getParameter(actionRequest, "baseapiurl"); if (Validator.isNull(baseAPIURL)) { SessionErrors.add(actionRequest, "baseApiURLError"); }// w w w .ja v a 2 s . co m String user = getParameter(actionRequest, "username"); String password = getParameter(actionRequest, "password"); if (Validator.isNull(user) || Validator.isNull(password)) { SessionErrors.add(actionRequest, "httpAuthError"); } super.processAction(portletConfig, actionRequest, actionResponse); String base64EncodedPassword = Base64.encode(password.getBytes()); PortletPreferences preferences = actionRequest.getPreferences(); preferences.setValue("password", base64EncodedPassword); preferences.store(); }
From source file:com.liferay.ci.portlet.JenkinsIntegrationPortlet.java
License:Open Source License
protected void buildLights(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String jobName = portletPreferences.getValue("jobname", StringPool.BLANK); _log.debug("Getting builds for " + jobName); AuthConnectionParams connectionParams = getConnectionParams(portletPreferences); try {// w w w .j ava2 s . c om JenkinsBuild lastBuild = JenkinsConnectUtil.getLastBuild(connectionParams, jobName); request.setAttribute("LAST_BUILD_STATUS", lastBuild.getStatus()); if (lastBuild.getStatus().equals(JenkinsIntegrationConstants.JENKINS_BUILD_STATUS_UNSTABLE)) { // retrieve number of broken tests for last build request.setAttribute("TEST_RESULTS", lastBuild); } } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The job was not available", ioe); } catch (JSONException e) { _log.error("The job is not well-formed", e); } }
From source file:com.liferay.ci.portlet.JenkinsIntegrationPortlet.java
License:Open Source License
protected void buildProjectsStack(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String jobNamesParam = portletPreferences.getValue("jobnames", StringPool.BLANK); String[] jobNames = StringUtil.split(jobNamesParam, StringPool.NEW_LINE); AuthConnectionParams connectionParams = getConnectionParams(portletPreferences); try {/* w w w .jav a 2 s.c o m*/ JenkinsJob[] lastBuilds = JenkinsConnectUtil.getLastBuilds(connectionParams, jobNames); request.setAttribute("JENKINS_JOBS", lastBuilds); } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The jobs were not available", ioe); } catch (JSONException e) { _log.error("The jobs are not well-formed", e); } }
From source file:com.liferay.ci.portlet.JenkinsIntegrationPortlet.java
License:Open Source License
protected void buildSeries(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); String jobName = portletPreferences.getValue("jobname", StringPool.BLANK); _log.debug("Getting builds for " + jobName); String buildsNumber = portletPreferences.getValue("buildsnumber", StringPool.BLANK); try {/* w w w .jav a2 s . com*/ int maxBuildNumber = 0; if (Validator.isNotNull(buildsNumber)) { maxBuildNumber = Integer.parseInt(buildsNumber); _log.debug("Max BuildNumber for build: " + maxBuildNumber); } String jobCacheKey = jobName + StringPool.POUND + buildsNumber; if (!_cache.containsKey(portletId, jobCacheKey)) { JSONArray testResults = JenkinsConnectUtil.getBuilds(getConnectionParams(portletPreferences), jobName, maxBuildNumber); _cache.put(portletId, jobCacheKey, testResults); } request.setAttribute("TEST_RESULTS", _cache.get(portletId, jobCacheKey)); } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The job was not available", ioe); } catch (JSONException e) { _log.error("The job is not well-formed", e); } }
From source file:com.liferay.ci.portlet.TravisIntegrationPortlet.java
License:Open Source License
protected void buildLights(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String account = portletPreferences.getValue("account", StringPool.BLANK); String jobName = portletPreferences.getValue("jobname", StringPool.BLANK); _log.debug("Getting builds for " + jobName); AuthConnectionParams connectionParams = getConnectionParams(); try {//from w w w . ja v a2s . c o m ContinuousIntegrationBuild lastBuild = JSONBuildUtil.getLastBuild(connectionParams, account, jobName); request.setAttribute(TravisIntegrationConstants.LAST_BUILD_STATUS, lastBuild.getStatus()); if (lastBuild.getStatus() == TravisIntegrationConstants.TRAVIS_BUILD_STATUS_FAILED) { // retrieve number of broken tests for last build request.setAttribute("TEST_RESULTS", lastBuild); } } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The job was not available", ioe); } catch (JSONException e) { _log.error("The job is not well-formed", e); } }
From source file:com.liferay.ci.portlet.TravisIntegrationPortlet.java
License:Open Source License
protected void buildProjectsStack(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String jobNamesParam = portletPreferences.getValue("jobnames", StringPool.BLANK); AuthConnectionParams connectionParams = getConnectionParams(); try {//from ww w . ja v a2 s. c om ContinuousIntegrationJob[] jobs = parseJobNames(jobNamesParam); ContinuousIntegrationJob[] lastBuilds = JSONBuildUtil.getLastBuilds(connectionParams, jobs); request.setAttribute(TravisIntegrationConstants.TRAVIS_JOBS, lastBuilds); } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The jobs were not available", ioe); } catch (JSONException e) { _log.error("The jobs are not well-formed", e); } }
From source file:com.liferay.classregistration.admin.portlet.AdminPortlet.java
License:Open Source License
public void updateClassRegistration(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long classEntryId = ParamUtil.getLong(actionRequest, "classEntryId"); boolean registered = ParamUtil.getBoolean(actionRequest, "registered"); try {/*from w ww.ja v a 2s .co m*/ ClassEntryLocalServiceUtil.updateTotalAttendees(classEntryId, registered); if (registered) { long classRegistrationId = ParamUtil.getLong(actionRequest, "classRegistrationId"); ClassRegistrationLocalServiceUtil.deleteClassRegistration(classRegistrationId); } else { String comments = ParamUtil.getString(actionRequest, "comments"); ClassRegistrationLocalServiceUtil.updateClassRegistration(themeDisplay.getUserId(), classEntryId, comments); } } catch (Exception e) { SessionErrors.add(actionRequest, e.getClass().getName()); } }