List of usage examples for com.liferay.portal.kernel.util WebKeys PORTLET_ID
String PORTLET_ID
To view the source code for com.liferay.portal.kernel.util WebKeys PORTLET_ID.
Click Source Link
From source file:com.liferay.journal.web.asset.JournalArticleAssetRenderer.java
License:Open Source License
@Override public String getURLViewInContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = _article.getLayout(); if (layout == null) { layout = themeDisplay.getLayout(); }/* www . jav a 2 s . c o m*/ String portletId = (String) liferayPortletRequest.getAttribute(WebKeys.PORTLET_ID); PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout, portletId); String linkToLayoutUuid = GetterUtil.getString(portletSetup.getValue("portletSetupLinkToLayoutUuid", null)); if (Validator.isNotNull(_article.getLayoutUuid()) && Validator.isNull(linkToLayoutUuid)) { Group group = themeDisplay.getScopeGroup(); if (group.getGroupId() != _article.getGroupId()) { group = GroupLocalServiceUtil.getGroup(_article.getGroupId()); } String groupFriendlyURL = PortalUtil.getGroupFriendlyURL( LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), layout.isPrivateLayout()), themeDisplay); return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR).concat(_article.getUrlTitle())); } String hitLayoutURL = getHitLayoutURL(layout.isPrivateLayout(), noSuchEntryRedirect, themeDisplay); if (hitLayoutURL.equals(noSuchEntryRedirect)) { hitLayoutURL = getHitLayoutURL(!layout.isPrivateLayout(), noSuchEntryRedirect, themeDisplay); } return hitLayoutURL; }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
@Override protected void addSuccessMessage(ActionRequest actionRequest, ActionResponse actionResponse) { String portletId = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID); if (!portletId.equals(LoginPortletKeys.FAST_LOGIN)) { super.addSuccessMessage(actionRequest, actionResponse); }/* w w w .j av a 2s . com*/ }
From source file:com.liferay.timesheet.portlet.TimesheetPortlet.java
License:Open Source License
public void updateExpense(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY); String redirect = ParamUtil.getString(uploadRequest, "redirect"); long projectId = ParamUtil.getLong(uploadRequest, "projectId"); long expenseId = ParamUtil.getLong(uploadRequest, "expenseId"); try {/*from w w w. jav a 2 s .c om*/ long fileEntryId = ParamUtil.getLong(uploadRequest, "fileEntryId"); String description = ParamUtil.getString(uploadRequest, "description"); double value = ParamUtil.getDouble(uploadRequest, "value"); int purchasedDateMonth = ParamUtil.getInteger(uploadRequest, "purchasedDateMonth"); int purchasedDateDay = ParamUtil.getInteger(uploadRequest, "purchasedDateDay"); int purchasedDateYear = ParamUtil.getInteger(uploadRequest, "purchasedDateYear"); int type = ParamUtil.getInteger(uploadRequest, "type"); // Uploaded file File file = uploadRequest.getFile("file"); String sourceFileName = uploadRequest.getFileName("file"); if (Validator.isNotNull(file) && Validator.isNotNull(sourceFileName)) { if (!file.exists()) { file.createNewFile(); } String contentType = uploadRequest.getContentType("file"); String title = sourceFileName; String changeLog = StringPool.BLANK; long groupId = themeDisplay.getScopeGroupId(); DLFolder folder = null; try { folder = DLFolderLocalServiceUtil.getDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); } catch (Exception e) { folder = DLFolderLocalServiceUtil.createDLFolder(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID); folder = DLFolderLocalServiceUtil.addDLFolder(folder); } long folderId = folder.getFolderId(); ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), actionRequest); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); FileEntry fileEntry = null; if (fileEntryId > 0) { fileEntry = DLAppServiceUtil.updateFileEntry(fileEntryId, sourceFileName, contentType, title, description, changeLog, true, file, serviceContext); } else { fileEntry = DLAppServiceUtil.addFileEntry(groupId, folderId, sourceFileName, contentType, title, title, changeLog, file, serviceContext); } fileEntryId = fileEntry.getFileEntryId(); } ServiceContext serviceContext = ServiceContextFactory.getInstance(Expense.class.getName(), actionRequest); if (expenseId <= 0) { ExpenseServiceUtil.addExpense(projectId, description, purchasedDateMonth, purchasedDateDay, purchasedDateYear, type, value, fileEntryId, serviceContext); } else { ExpenseServiceUtil.updateExpense(expenseId, projectId, description, purchasedDateMonth, purchasedDateDay, purchasedDateYear, type, value, fileEntryId, serviceContext); } actionResponse.sendRedirect(redirect); } catch (Exception e) { if (e instanceof InvalidDescriptionException || e instanceof InvalidCurrencyFormatException) { SessionErrors.add(actionRequest, e.getClass().getName()); String portletName = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID); PortletURL redirectURL = PortletURLFactoryUtil.create( PortalUtil.getHttpServletRequest(actionRequest), portletName, themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE); redirectURL.setParameter("jspPage", "/html/edit_expense.jsp"); redirectURL.setParameter("projectId", String.valueOf(projectId)); redirectURL.setParameter("expenseId", String.valueOf(expenseId)); redirectURL.setParameter("redirect", redirect); actionResponse.sendRedirect(redirectURL.toString()); } else { throw e; } } }
From source file:com.liferay.web.extender.servlet.OSGiServlet.java
License:Open Source License
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); String pathInfo = request.getPathInfo(); if (pathInfo.startsWith(SERVLET_MAPPING)) { pathInfo = pathInfo.substring(5); }//from w ww.j a va 2 s . c o m String servletContextName = pathInfo; if (servletContextName.startsWith(StringPool.SLASH)) { servletContextName = servletContextName.substring(1); } int pos = servletContextName.indexOf(StringPool.SLASH); if (pos != -1) { pathInfo = servletContextName.substring(pos, servletContextName.length()); servletContextName = servletContextName.substring(0, pos); } ServletContext servletContext = ServletContextPool.get(servletContextName); if (servletContext == null) { PortalUtil.sendError(HttpServletResponse.SC_NOT_FOUND, new IllegalArgumentException("No application mapped to this path"), request, response); return; } service(request, response, servletContext, portletId, pathInfo); }
From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java
License:Open Source License
@Override public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { PortletSession portletSession = request.getPortletSession(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (themeDisplay.isSignedIn()) { if (((String) portletSession.getAttribute(ACCESS_TOKEN)) != null) { request.setAttribute(ACCESS_TOKEN, (String) portletSession.getAttribute(ACCESS_TOKEN)); request.setAttribute(NEED_AUTHORIZE, Boolean.FALSE); } else {//w w w .j a v a 2 s . c om request.setAttribute(NEED_AUTHORIZE, Boolean.TRUE); try { EvernoteUtil.authenticateEvernote(request, portletSession, themeDisplay); } catch (OAuthException e) { if (LOG.isDebugEnabled()) { LOG.error(EVERNOTE_AUTHENTICATION_ERROR, e); } if (SessionErrors.isEmpty(request)) { SessionMessages.add(request, request.getAttribute(WebKeys.PORTLET_ID) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); } SessionErrors.add(request, OAuthException.class); } } } super.doView(request, response); }
From source file:com.rivetlogic.hangouts.beans.PreferencesBean.java
License:Open Source License
public PreferencesBean(PortletRequest request) { PortletPreferences preferences = request.getPreferences(); portletId = GetterUtil.getString(request.getAttribute(WebKeys.PORTLET_ID)); usersPerPage = GetterUtil.getInteger( preferences.getValue(Constants.USERS_PER_PAGE, String.valueOf(Constants.DEFAULT_DELTA))); groupsPerPage = GetterUtil.getInteger( preferences.getValue(Constants.GROUPS_PER_PAGE, String.valueOf(Constants.DEFAULT_DELTA))); }
From source file:com.rivetlogic.portlet.GoogleDriveQuickLinks.java
License:Open Source License
@Override public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException { addDriveParamsToRequest(request);/*ww w . j a v a 2 s .c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { SessionMessages.add(request, request.getAttribute(WebKeys.PORTLET_ID) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); SessionErrors.add(request, "portlet-user-not-logged"); } super.doView(request, response); }
From source file:com.rivetlogic.skype.beans.PreferencesBean.java
License:Open Source License
public PreferencesBean(PortletRequest request, int defaultDeltaView) { PortletPreferences preferences = request.getPreferences(); portletId = GetterUtil.getString(request.getAttribute(WebKeys.PORTLET_ID)); usersPerPage = GetterUtil/*www. j av a 2 s . c o m*/ .getInteger(preferences.getValue(Constants.USERS_PER_PAGE, String.valueOf(defaultDeltaView))); groupsPerPage = GetterUtil .getInteger(preferences.getValue(Constants.GROUPS_PER_PAGE, String.valueOf(defaultDeltaView))); }
From source file:com.rivetlogic.whiteboard.portlet.PreferencesBean.java
License:Open Source License
public PreferencesBean(PortletRequest request, boolean useCustomWebsocketUrl, boolean useWebsocketSecured, String customWebsocketUrl) { PortletPreferences preferences = request.getPreferences(); portletId = GetterUtil.getString(request.getAttribute(WebKeys.PORTLET_ID)); this.useCustomWebsocketUrl = GetterUtil.getBoolean( preferences.getValue(Constants.USE_CUSTOM_WEBSOCKET_URL, String.valueOf(useCustomWebsocketUrl))); this.useWebsocketSecured = GetterUtil.getBoolean( preferences.getValue(Constants.USE_WEBSOCKET_SECURED, String.valueOf(useWebsocketSecured))); this.customWebsocketBasePath = GetterUtil.getString( preferences.getValue(Constants.CUSTOM_WEBSOCKET_BASE_PATH, String.valueOf(customWebsocketUrl))); _log.debug("useCustomWebsocketUrl:" + this.useCustomWebsocketUrl); }
From source file:com.wfp.videodisplay.portlet.VideoDisplayPortlet.java
License:Open Source License
@Override public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { System.out.println(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); System.out.println(//from w w w. ja v a 2 s . com " !!!!!!!!!!!!!!!!!!!VideoDisplayPortlet processAction START !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); System.out.println(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); PortletSession portletSession = actionRequest.getPortletSession(); try { String userId = actionRequest.getRemoteUser(); if (cmd.equals("updateIP") && userId != "0" && userId != null && portletSession.getAttribute("ip-" + userId, PortletSession.APPLICATION_SCOPE) == null) { String ip = ParamUtil.getString(actionRequest, "ip"); System.out.println(" ip from jsonip : " + ip); LookupService service = new LookupService(PortletProps.get("maxmind.database.file"), LookupService.GEOIP_MEMORY_CACHE); Location location = null; //location = service.getLocation( ip.trim() ); String userDetails = getUserDetailsByIP(ip); Location userLocation = new Location(); if (userDetails != null) { String[] userArray = userDetails.split(";"); userLocation.countryCode = userArray[3]; userLocation.countryName = userArray[4]; userLocation.city = userArray[6]; userLocation.latitude = Float.parseFloat(userArray[8]); userLocation.longitude = Float.parseFloat(userArray[9]); System.out.println(" userArray :" + userArray.length); } updateUserIP(userId, ip, userLocation); //updateUserLocation(userId , location.countryCode ); } else if (cmd.equals("savePreference")) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = ParamUtil.getString(actionRequest, WebKeys.PORTLET_ID); String videoURL = ParamUtil.getString(actionRequest, "videoURL"); String videoWidth = ParamUtil.getString(actionRequest, "videoWidth"); String videoHeight = ParamUtil.getString(actionRequest, "videoHeight"); PortletPreferences preferences = actionRequest.getPreferences(); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)) { preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } if (videoURL != null && videoURL != "") { if (videoURL.trim().endsWith(".swf") || true) { preferences.setValue("pref-videoURL", videoURL); preferences.setValue("pref-videoWidth", videoWidth); preferences.setValue("pref-videoHeight", videoHeight); preferences.store(); actionResponse.setWindowState(WindowState.MAXIMIZED); } } } } catch (Exception e) { e.printStackTrace(); } System.out.println(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); System.out.println( " !!!!!!!!!!!!!!!!!!!VideoDisplayPortlet processAction END !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); System.out.println(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); }