List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INCOMPLETE
int STATUS_INCOMPLETE
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_INCOMPLETE.
Click Source Link
From source file:com.liferay.google.login.hook.action.GoogleLoginAction.java
License:Open Source License
protected User setCredential(HttpSession session, long companyId, Credential credential) throws Exception { Userinfo userinfo = getUserinfo(credential); if (userinfo == null) { return null; }/*w w w . j a v a 2 s. c o m*/ User user = null; String emailAddress = userinfo.getEmail(); if ((user == null) && Validator.isNotNull(emailAddress)) { user = UserLocalServiceUtil.fetchUserByEmailAddress(companyId, emailAddress); if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(WebKeys.GOOGLE_USER_EMAIL_ADDRESS, emailAddress); } } if (user != null) { if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) { session.setAttribute(WebKeys.GOOGLE_INCOMPLETE_USER_ID, userinfo.getId()); user.setEmailAddress(userinfo.getEmail()); user.setFirstName(userinfo.getGivenName()); user.setLastName(userinfo.getFamilyName()); return user; } user = updateUser(user, userinfo); } else { user = addUser(session, companyId, userinfo); } if (DeployManagerUtil.isDeployed(_GOOGLE_DRIVE_CONTEXT)) { updateExpandoValues(user, userinfo, credential.getAccessToken(), credential.getRefreshToken()); } return user; }
From source file:com.liferay.lms.model.CompetenceClp.java
License:Open Source License
public boolean isIncomplete() { if (getStatus() == WorkflowConstants.STATUS_INCOMPLETE) { return true; } else {/* ww w.ja va2 s.c om*/ return false; } }
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!_facebookConnect.isEnabled(themeDisplay.getCompanyId())) { throw new PrincipalException.MustBeEnabled(themeDisplay.getCompanyId(), FacebookConnect.class.getName()); }/*from ww w . j av a 2 s. c o m*/ HttpSession session = request.getSession(); String redirect = ParamUtil.getString(request, "redirect"); redirect = _portal.escapeRedirect(redirect); String code = ParamUtil.getString(request, "code"); String token = _facebookConnect.getAccessToken(themeDisplay.getCompanyId(), redirect, code); if (Validator.isNotNull(token)) { User user = setFacebookCredentials(session, themeDisplay.getCompanyId(), token); if ((user != null) && (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) { redirectUpdateAccount(request, response, user); return null; } } else { return _forwards.get("/common/referer_jsp.jsp"); } response.sendRedirect(redirect); return null; }
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
protected User setFacebookCredentials(HttpSession session, long companyId, String token) throws Exception { JSONObject jsonObject = _facebookConnect.getGraphResources(companyId, "/me", token, "id,email,first_name,last_name,gender,verified"); if ((jsonObject == null) || (jsonObject.getJSONObject("error") != null)) { return null; }//from www . ja va 2 s . c o m if (_facebookConnect.isVerifiedAccountRequired(companyId) && !jsonObject.getBoolean("verified")) { return null; } User user = null; long facebookId = jsonObject.getLong("id"); if (facebookId > 0) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_ACCESS_TOKEN, token); user = _userLocalService.fetchUserByFacebookId(companyId, facebookId); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_USER_ID, String.valueOf(facebookId)); } } String emailAddress = jsonObject.getString("email"); if ((user == null) && Validator.isNotNull(emailAddress)) { user = _userLocalService.fetchUserByEmailAddress(companyId, emailAddress); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(WebKeys.FACEBOOK_USER_EMAIL_ADDRESS, emailAddress); } } if (user != null) { if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) { session.setAttribute(WebKeys.FACEBOOK_INCOMPLETE_USER_ID, facebookId); user.setEmailAddress(jsonObject.getString("email")); user.setFirstName(jsonObject.getString("first_name")); user.setLastName(jsonObject.getString("last_name")); return user; } user = updateUser(user, jsonObject); } else { user = addUser(session, companyId, jsonObject); } return user; }
From source file:com.liferay.login.authentication.google.web.internal.portlet.action.GoogleLoginAction.java
License:Open Source License
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!_googleAuthorization.isEnabled(themeDisplay.getCompanyId())) { throw new PrincipalException.MustBeEnabled(themeDisplay.getCompanyId(), GoogleAuthorization.class.getName()); }// w w w . j a va 2 s .c o m String cmd = ParamUtil.getString(request, Constants.CMD); if (cmd.equals("login")) { String returnRequestUri = getReturnRequestUri(request); String loginRedirect = _googleAuthorization.getLoginRedirect(themeDisplay.getCompanyId(), returnRequestUri, _scopesLogin); response.sendRedirect(loginRedirect); } else if (cmd.equals("token")) { HttpSession session = request.getSession(); String authorizationCode = ParamUtil.getString(request, "code"); if (Validator.isNotNull(authorizationCode)) { String returnRequestUri = getReturnRequestUri(request); User user = _googleAuthorization.addOrUpdateUser(session, themeDisplay.getCompanyId(), authorizationCode, returnRequestUri, _scopesLogin); if ((user != null) && (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) { sendUpdateAccountRedirect(request, response, user); return null; } sendLoginRedirect(request, response); return null; } String error = ParamUtil.getString(request, "error"); if (error.equals("access_denied")) { sendLoginRedirect(request, response); return null; } } return null; }
From source file:com.liferay.login.authentication.iam.web.internal.portlet.action.IAMLoginAction.java
License:Apache License
@Override public final String execute(final HttpServletRequest request, final HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!iam.isEnabled(themeDisplay.getCompanyId())) { throw new PrincipalException.MustBeEnabled(themeDisplay.getCompanyId(), IAM.class.getName()); }//from www .j a v a 2 s. c o m String cmd = ParamUtil.getString(request, Constants.CMD); if (cmd.equals("login")) { String returnRequestUri = getReturnRequestUri(request); // Note: last version of orchestrator always require the // offline_access option String loginRedirect = iam.getLoginRedirect(themeDisplay.getCompanyId(), returnRequestUri, true); response.sendRedirect(loginRedirect); } else if (cmd.equals("token")) { HttpSession session = request.getSession(); String authorizationCode = ParamUtil.getString(request, "code"); if (Validator.isNotNull(authorizationCode)) { String returnRequestUri = getReturnRequestUri(request); User user = null; try { user = iam.addOrUpdateUser(session, themeDisplay.getCompanyId(), authorizationCode, returnRequestUri); if (!iam.hasRefreshToken(user)) { String loginRedirect = iam.getLoginRedirect(themeDisplay.getCompanyId(), returnRequestUri, true); response.sendRedirect(loginRedirect); return super.execute(request, response); } } catch (Exception ex) { log.error(ex); throw new PortalException("Impossible to authenticate the user"); } if ((user != null) && (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) { sendUpdateAccountRedirect(request, response, user); return null; } sendLoginRedirect(request, response); return null; } String error = ParamUtil.getString(request, "error"); if (Validator.isNotNull(error) && error.equals("access_denied")) { sendLoginRedirect(request, response); return null; } } return super.execute(request, response); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); }//from w w w.jav a 2 s. co m actionRequest = _wrapActionRequest(actionRequest); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.ADD)) { CaptchaConfiguration captchaConfiguration = getCaptchaConfiguration(); if (captchaConfiguration.createAccountCaptchaEnabled()) { CaptchaUtil.check(actionRequest); } addUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.RESET)) { resetUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.UPDATE)) { updateIncompleteUser(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof UserEmailAddressException.MustNotBeDuplicate || e instanceof UserScreenNameException.MustNotBeDuplicate) { String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); User user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { SessionErrors.add(actionRequest, e.getClass(), e); } else { actionResponse.setRenderParameter("mvcPath", "/update_account.jsp"); } } else if (e instanceof AddressCityException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException || e instanceof ContactNameException || e instanceof DuplicateOpenIdException || 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 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; } } if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) { return; } try { Layout layout = _layoutLocalService.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, PropsValues.COMPANY_SECURITY_STRANGERS_URL); String redirect = _portal.getLayoutURL(layout, themeDisplay); sendRedirect(actionRequest, actionResponse, redirect); } catch (NoSuchLayoutException nsle) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsle, nsle); } } }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void resetUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); User anonymousUser = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (anonymousUser.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { throw new PrincipalException.MustBeAuthenticated(anonymousUser.getUuid()); }/*from w w w. j a v a2 s . c om*/ _userLocalService.deleteUser(anonymousUser.getUserId()); addUser(actionRequest, actionResponse); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
protected void addAnonymousUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); boolean autoPassword = true; String password1 = null;/*w w w.j a va2 s . co m*/ String password2 = null; boolean autoScreenName = true; String screenName = null; String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = 0; String openId = StringPool.BLANK; String firstName = ParamUtil.getString(actionRequest, "firstName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); long prefixId = 0; long suffixId = 0; boolean male = true; int birthdayMonth = 0; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = null; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = false; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); serviceContext.setAttribute("anonymousUser", Boolean.TRUE); CaptchaConfiguration captchaConfiguration = getCaptchaConfiguration(); if (captchaConfiguration.createAccountCaptchaEnabled()) { CaptchaUtil.check(actionRequest); } serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); User user = _userService.addUser(themeDisplay.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, null, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); _userLocalService.updateStatus(user.getUserId(), WorkflowConstants.STATUS_INCOMPLETE, new ServiceContext()); // Session messages SessionMessages.add(request, "userAdded", user.getEmailAddress()); SessionMessages.add(request, "userAddedPassword", user.getPasswordUnencrypted()); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { throw new PrincipalException("Unable to create anonymous account"); }/*from w w w . jav a2s . c o m*/ if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, LoginPortletKeys.FAST_LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } jsonObject = updateIncompleteUser(actionRequest, actionResponse); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { User user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); _portal.sendError(e, actionRequest, actionResponse); } } }