List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:blade.portlet.BladePortletAction.java
License:Open Source License
@Override public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { _log.debug("BladePortletAction - render"); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); User loggedinUser = themeDisplay.getUser(); if (loggedinUser != null) { loggedinUser.setLastName("Blade"); loggedinUser.setGreeting("Hello," + loggedinUser.getFirstName() + " from BLADE!"); _userLocalService.updateUser(loggedinUser); }//from w w w . j a va2 s. c om return originalStrutsPortletAction.render(originalStrutsPortletAction, portletConfig, renderRequest, renderResponse); }
From source file:ca.efendi.datafeeds.web.internal.portlet.action.ActionUtil.java
License:Apache License
public static List<FtpSubscription> getFtpSubscriptions(final RenderRequest request) { final ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); final long groupId = themeDisplay.getScopeGroupId(); List<FtpSubscription> tempResults; try {//from ww w. j a v a2 s.c om tempResults = FtpSubscriptionLocalServiceUtil.getAllFtpSubscriptions(groupId); } catch (final SystemException se) { tempResults = Collections.EMPTY_LIST; } return tempResults; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected int getStatus(final RenderRequest renderRequest) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return WorkflowConstants.STATUS_APPROVED; }/*from ww w . j a v a 2s . c o m*/ final String value = renderRequest.getParameter("status"); final int status = GetterUtil.getInteger(value); if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) { return WorkflowConstants.STATUS_APPROVED; } final long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey"); if (resourcePrimKey == 0) { return WorkflowConstants.STATUS_APPROVED; } //final PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); /** * if (KBArticlePermission.contains( permissionChecker, resourcePrimKey, * ActionKeys.UPDATE)) { * * return ParamUtil.getInteger( renderRequest, "status", * WorkflowConstants.STATUS_ANY); } */ return WorkflowConstants.STATUS_APPROVED; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected MBMessage updateMessage(final ActionRequest actionRequest) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); final String className = ParamUtil.getString(actionRequest, "className"); final long classPK = ParamUtil.getLong(actionRequest, "classPK"); final String permissionClassName = ParamUtil.getString(actionRequest, "permissionClassName"); final long permissionClassPK = ParamUtil.getLong(actionRequest, "permissionClassPK"); final long permissionOwnerId = ParamUtil.getLong(actionRequest, "permissionOwnerId"); final long messageId = ParamUtil.getLong(actionRequest, "messageId"); final long threadId = ParamUtil.getLong(actionRequest, "threadId"); final long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId"); final String subject = ParamUtil.getString(actionRequest, "subject"); final String body = ParamUtil.getString(actionRequest, "body"); final ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest);/*w w w .j a va 2 s . c o m*/ final MBMessage message = null; /* * if (messageId <= 0) { message = * MBMessageServiceUtil.addDiscussionMessage( * serviceContext.getScopeGroupId(), className, classPK, * permissionClassName, permissionClassPK, permissionOwnerId, threadId, * parentMessageId, subject, body, serviceContext); } else { message = * MBMessageServiceUtil.updateDiscussionMessage( className, classPK, * permissionClassName, permissionClassPK, permissionOwnerId, messageId, * subject, body, serviceContext); } */ // Subscription final boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe"); if (subscribe) { SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK); } return message; }
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected void subscribeToComments(final ActionRequest actionRequest, final boolean subscribe) throws Exception { final ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); final String className = ParamUtil.getString(actionRequest, "className"); final long classPK = ParamUtil.getLong(actionRequest, "classPK"); if (subscribe) { SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK);//from ww w . j a v a 2 s.co m } else { SubscriptionLocalServiceUtil.deleteSubscription(themeDisplay.getUserId(), className, classPK); } }
From source file:ch.inofix.referencemanager.web.internal.portlet.ReferenceManagerPortlet.java
License:Apache License
/** * /*from w w w . ja v a2s . c o m*/ * @param actionRequest * @param actionResponse * @since 1.0.0 * @throws Exception */ public void importBibTeXFile(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); File file = uploadPortletRequest.getFile("file"); String fileName = file.getName(); long userId = themeDisplay.getUserId(); long groupId = themeDisplay.getScopeGroupId(); boolean privateLayout = themeDisplay.getLayout().isPrivateLayout(); String servletContextName = request.getSession().getServletContext().getServletContextName(); String[] servletContextNames = new String[] { servletContextName }; Map<String, String[]> parameterMap = new HashMap<String, String[]>(actionRequest.getParameterMap()); parameterMap.put("servletContextNames", servletContextNames); if (Validator.isNotNull(file)) { String message = PortletUtil.translate("upload-successfull-import-will-finish-in-a-separate-thread"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Reference.class.getName(), uploadPortletRequest); _referenceService.importReferencesInBackground(userId, fileName, groupId, privateLayout, parameterMap, file, serviceContext); SessionMessages.add(actionRequest, "request_processed", message); } else { SessionErrors.add(actionRequest, "file-not-found"); } }
From source file:com.abubusoft.liferay.google.GoogleOAuth.java
License:Open Source License
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long companyId = themeDisplay.getCompanyId(); String cmd = ParamUtil.getString(request, Constants.CMD); String redirectUri = PortalUtil.getPortalURL(request) + _REDIRECT_URI; if ("login".equals(cmd)) { GoogleAuthorizationCodeFlow flow = getFlow(companyId); GoogleAuthorizationCodeRequestUrl googleAuthorizationCodeRequestUrl = flow.newAuthorizationUrl(); googleAuthorizationCodeRequestUrl.setRedirectUri(redirectUri); String url = googleAuthorizationCodeRequestUrl.build(); response.sendRedirect(url);//from www . j av a 2 s. c o m } else if ("token".equals(cmd)) { HttpSession session = request.getSession(); String code = ParamUtil.getString(request, "code"); if (Validator.isNotNull(code)) { Credential credential = exchangeCode(companyId, code, redirectUri); Userinfoplus userinfo = getUserInfo(credential); User user = setGoogleCredentials(session, themeDisplay.getCompanyId(), userinfo); if ((user != null) && (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) { redirectUpdateAccount(request, response, user); return null; } PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("struts_action", "/login/login_redirect"); response.sendRedirect(portletURL.toString()); } } return null; }
From source file:com.abubusoft.liferay.google.GoogleOAuth.java
License:Open Source License
protected void redirectUpdateAccount(HttpServletRequest request, HttpServletResponse response, User user) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("saveLastPath", Boolean.FALSE.toString()); portletURL.setParameter("struts_action", "/login/update_account"); PortletURL redirectURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); redirectURL.setParameter("struts_action", "/login/login_redirect"); redirectURL.setParameter("emailAddress", user.getEmailAddress()); redirectURL.setParameter("anonymousUser", Boolean.FALSE.toString()); redirectURL.setPortletMode(PortletMode.VIEW); redirectURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("redirect", redirectURL.toString()); portletURL.setParameter("userId", String.valueOf(user.getUserId())); portletURL.setParameter("emailAddress", user.getEmailAddress()); portletURL.setParameter("firstName", user.getFirstName()); portletURL.setParameter("lastName", user.getLastName()); portletURL.setPortletMode(PortletMode.VIEW); portletURL.setWindowState(LiferayWindowState.POP_UP); response.sendRedirect(portletURL.toString()); }
From source file:com.abubusoft.liferay.linkedin.CreateAccountAction.java
License:Open Source License
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); Boolean linkedinLoginPending = (Boolean) session.getAttribute(LinkedinConstants.LINKEDIN_LOGIN_PENDING); if ((linkedinLoginPending != null) && linkedinLoginPending.booleanValue()) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException(); }//w ww. ja va 2 s.c om try { addUser(actionRequest, actionResponse); } catch (Exception e) { if (e instanceof DuplicateUserEmailAddressException || e instanceof DuplicateUserScreenNameException || e instanceof AddressCityException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof CaptchaMaxChallengesException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactFirstNameException || e instanceof ContactFullNameException || e instanceof ContactLastNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException || e instanceof NoSuchRegionException || e instanceof OrganizationParentException || e instanceof PhoneNumberException || e instanceof RequiredFieldException || e instanceof RequiredUserException || e instanceof ReservedUserEmailAddressException || e instanceof ReservedUserScreenNameException || e instanceof TermsOfUseException || e instanceof UserEmailAddressException || e instanceof UserIdException || e instanceof UserPasswordException || e instanceof UserScreenNameException || e instanceof UserSmsException || e instanceof WebsiteURLException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } } else { originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse); } }
From source file:com.abubusoft.liferay.linkedin.CreateAccountAction.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); long creatorUserId = 0; long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); boolean autoPassword = true; boolean autoScreenName = false; boolean male = ParamUtil.getBoolean(actionRequest, "male", true); boolean sendEmail = true; String linkedinId = ParamUtil.getString(actionRequest, "linkedinId"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); String screenName = ParamUtil.getString(actionRequest, "screenName"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String password1 = StringPool.BLANK; String password2 = StringPool.BLANK; String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); String openId = StringPool.BLANK; int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); int prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); int suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); Locale locale = themeDisplay.getLocale(); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) { autoPassword = false;/*from w ww. j a v a 2 s. c om*/ password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } ServiceContext serviceContext = new ServiceContext(); User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP()); user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false); user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false); ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, "linkedinId", user.getUserId(), linkedinId); session.setAttribute(LinkedinConstants.LINKEDIN_ID_LOGIN, new Long(user.getUserId())); session.removeAttribute(LinkedinConstants.LINKEDIN_LOGIN_PENDING); PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("struts_action", "/login/login_redirect"); actionResponse.sendRedirect(portletURL.toString()); }