List of usage examples for com.liferay.portal.kernel.util StringPool DOLLAR
String DOLLAR
To view the source code for com.liferay.portal.kernel.util StringPool DOLLAR.
Click Source Link
From source file:com.liferay.rtl.scripting.ruby.RubyExecutor.java
License:Open Source License
protected Map<String, Object> doEval(Set<String> allowedClasses, Map<String, Object> inputObjects, Set<String> outputNames, File scriptFile, String script, ClassLoader... classLoaders) throws ScriptingException { if (allowedClasses != null) { throw new ExecutionException("Constrained execution not supported for Ruby"); }/*w ww . ja v a 2 s . c om*/ try { LocalContextProvider localContextProvider = _scriptingContainer.getProvider(); RubyInstanceConfig rubyInstanceConfig = localContextProvider.getRubyInstanceConfig(); rubyInstanceConfig.setCurrentDirectory(_basePath); if (ArrayUtil.isNotEmpty(classLoaders)) { ClassLoader aggregateClassLoader = AggregateClassLoader .getAggregateClassLoader(PortalClassLoaderUtil.getClassLoader(), classLoaders); rubyInstanceConfig.setLoader(aggregateClassLoader); } rubyInstanceConfig.setLoadPaths(_loadPaths); for (Map.Entry<String, Object> entry : inputObjects.entrySet()) { String inputName = entry.getKey(); Object inputObject = entry.getValue(); if (!inputName.startsWith(StringPool.DOLLAR)) { inputName = StringPool.DOLLAR + inputName; } _scriptingContainer.put(inputName, inputObject); } if (scriptFile != null) { _scriptingContainer.runScriptlet(new FileInputStream(scriptFile), scriptFile.toString()); } else { _scriptingContainer.runScriptlet(script); } if (outputNames == null) { return null; } Map<String, Object> outputObjects = new HashMap<String, Object>(); for (String outputName : outputNames) { outputObjects.put(outputName, _scriptingContainer.get(outputName)); } return outputObjects; } catch (RaiseException re) { throw new ScriptingException(re.getException().message.asJavaString() + "\n\n", re); } catch (FileNotFoundException fnfe) { throw new ScriptingException(fnfe); } finally { try { _globalRuntimeField.set(null, null); } catch (Exception e) { _log.error(e, e); } } }
From source file:com.stoxx.portlet.controller.RegistrationController.java
@RenderMapping public String handleRenderRequest(RenderRequest renderRequest, RenderResponse renderResponse, Model model, @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean) { log.info("STOXXRegistrationController.handleRenderRequest()"); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); Boolean isExistingUser = Boolean.FALSE; Boolean isDeletedUser = Boolean.FALSE; try {/*w w w .j a va 2 s .co m*/ log.info("the action parameter is " + renderRequest.getParameter(ACTION)); String portalUrl = PortalUtil.getCurrentURL(renderRequest); log.info("current Portal url>>>> " + portalUrl); String businessEmailAddressEncrypted = null; registrationBean = getListDetails(registrationBean, themeDisplay); registrationBean.setCompanyId(themeDisplay.getCompanyId()); registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("setupProfileTRANSLATOR")) { log.info("for Translator and the email address is $$$$" + businessEmailAddress + AND_BEAN_EMAIL_IS + registrationBean.getBusinessEmailAddress()); if (Validator.isNotNull(businessEmailAddress)) { registrationBean.setBusinessEmailAddress(businessEmailAddress); } log.info("user type is" + registrationBean.getUserType()); if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) { registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean); log.info("Company Name >>>>> is" + registrationBean.getCompanyName()); log.info("Translator agency ID >>>>> is" + registrationBean.getTranslatorAgencyId()); } if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) { registrationBean.setCompanyName(RegistrationConstants.STAFF_COMPANY); log.info("Company Name >>>>> is" + registrationBean.getCompanyName()); } if (registrationDelegator.checkIfRegistered(registrationBean.getBusinessEmailAddress())) { registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean); if (null != registrationBean.getUserType() && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String packageDetails = registrationDelegator .getPackageDetails(registrationBean.getSalesEntryId()); log.info(THE_PACKAGE_DETAILS + packageDetails); registrationBean.setPackageDetails(packageDetails); } } registrationBean = getListDetails(registrationBean, themeDisplay); registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); model.addAttribute(REGISTRATION_BEAN, registrationBean); return RegistrationConstants.SETUP_PROFILE; } else if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("userExists") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("invalidEmail") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("setupProfileGENERALLICENSED") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("setupProfileSTAFF") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("setupProfileGENERAL") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("linkAlreadysent")) { log.info("email address is $$$$" + businessEmailAddress + AND_BEAN_EMAIL_IS + registrationBean.getBusinessEmailAddress()); businessEmailAddress = registrationBean.getBusinessEmailAddress(); model.addAttribute(REGISTRATION_BEAN, registrationBean); return RegistrationConstants.INITIATE_REGISTRATION; } else if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("CaptchaException")) { log.info("email address is $$$$" + businessEmailAddress + AND_BEAN_EMAIL_IS + registrationBean.getBusinessEmailAddress()); model.addAttribute(REGISTRATION_BEAN, registrationBean); return RegistrationConstants.SETUP_PROFILE; } else if (portalUrl.contains(StringPool.QUESTION) && portalUrl.contains(StringPool.DOLLAR)) { log.info("inside registration link validation with dollar and questionmark"); getUserTypeandEmalaIdfromEncrptedUrl(model, registrationBean, portalUrl); model.addAttribute(REGISTRATION_BEAN, registrationBean); if (Validator.isNotNull(businessEmailAddress) && !registrationBean.getIsExistingUser()) { log.info("businessEmailAddress>>>>>>>>>>>>>>>>>>>>>>>>>>" + businessEmailAddress); log.info("USER_>>>>>>>>>>>>>>>" + registrationDelegator .checkIfUserExistsInLiferayDB(registrationBean, businessEmailAddress)); registrationBean.setCompanyId(themeDisplay.getCompanyId()); boolean isUserExistInCustomDB = registrationDelegator .checkIfUserExistsInLiferay(registrationBean, businessEmailAddress); log.info("STOXX_USER" + isUserExistInCustomDB); if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean, businessEmailAddress) && registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress) && Validator.isNotNull(registrationBean.getIsDeletedUser()) && !registrationBean.getIsDeletedUser()) { log.info("inside dupplicate registration block with dollar an questionmark"); SessionErrors.add(renderRequest, USER_EXISTS_KEY); } else { if (Validator.isNotNull(registrationBean.getIsDeletedUser()) && registrationBean.getIsDeletedUser()) { return RegistrationConstants.INITIATE_REGISTRATION; } if (!isUserExistInCustomDB) { SessionErrors.add(renderRequest, USER_DELETED_KEY); } else { log.info("inside registration block for new registration with dollar an questionmark"); if (fetchActivationLinkCreateDateDiff(registrationBean.getBusinessEmailAddress())) { SessionErrors.add(renderRequest, RegistrationConstants.REGISTRATION_LINK_EXPIRED); } if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_GENERAL_USER)) { SessionMessages.add(renderRequest, "user-activation-link-already-sent"); } } } } SessionMessages.add(renderRequest, "user-validation-done"); return RegistrationConstants.INITIATE_REGISTRATION; } else if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase(EXISTING_USER)) { log.info("FOR EXISTING USER STEO 1 >>>>> email address is $$$$" + businessEmailAddress + AND_BEAN_EMAIL_IS + registrationBean.getBusinessEmailAddress()); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean); if (Validator.isNotNull(registrationBean) && Validator.isNotNull(registrationBean.getStatus()) && registrationBean.getStatus() == 3) { isExistingUser = Boolean.TRUE; registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); } model.addAttribute(REGISTRATION_BEAN, registrationBean); SessionMessages.add(renderRequest, EXISTING_USER); return RegistrationConstants.INITIATE_REGISTRATION; } else if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase(CUST_USER_EXCEEDED)) { log.info("FOR EXCEEDING CUSTOMER USER STEO 1 >>>>> email address is $$$$" + registrationBean.getBusinessEmailAddress()); model.addAttribute(REGISTRATION_BEAN, registrationBean); SessionMessages.add(renderRequest, CUST_USER_EXCEEDED); return RegistrationConstants.INITIATE_REGISTRATION; } else if (portalUrl.contains(StringPool.QUESTION + EXISTING)) { log.info("new existing logic"); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean); if (Validator.isNotNull(registrationBean) && Validator.isNotNull(registrationBean.getStatus()) && registrationBean.getStatus() == 3) { isExistingUser = Boolean.TRUE; registrationBean.setIsExistingUser(isExistingUser); } model.addAttribute(REGISTRATION_BEAN, registrationBean); SessionErrors.add(renderRequest, USER_EXISTS_MIGRATION_KEY); return RegistrationConstants.INITIATE_REGISTRATION; } else if (null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase("existingUserStep2") || null != renderRequest.getParameter(ACTION) && renderRequest.getParameter(ACTION).equalsIgnoreCase(DELETED_USER)) { log.info("FOR EXISTING USER STEP 2 >>>>> email address is $$$$" + businessEmailAddress + AND_BEAN_EMAIL_IS + registrationBean.getBusinessEmailAddress()); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); log.info("Sales entry id is >>>>>>>>>" + registrationBean.getSalesEntryId() + " and the usertype is >>>>>>" + registrationBean.getUserType()); if (Validator.isNotNull(registrationBean.getStatus()) && registrationBean.getStatus() == 4 && registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER) && !Validator.isNotNull(registrationBean.getSalesEntryId())) { registrationDelegator.updateUserType(registrationBean.getBusinessEmailAddress(), STOXXConstants.STOXX_GENERAL_USER); registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); } User liferayStoxxUser = UserLocalServiceUtil.fetchUserByEmailAddress(themeDisplay.getCompanyId(), businessEmailAddress); if (Validator.isNotNull(registrationBean) && Validator.isNotNull(registrationBean.getStatus()) && registrationBean.getStatus() == 3) { isExistingUser = Boolean.TRUE; registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); if (Validator.isNotNull(liferayStoxxUser)) { registrationBean = populateFields(registrationBean, themeDisplay, liferayStoxxUser); } if (Validator.isNotNull(registrationBean.getSalesEntryId()) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String packageDetails = registrationDelegator .getPackageDetails(registrationBean.getSalesEntryId()); log.info(THE_PACKAGE_DETAILS + packageDetails); registrationBean.setPackageDetails(packageDetails); } getListDetails(registrationBean, themeDisplay); } if (Validator.isNotNull(registrationBean) && Validator.isNotNull(registrationBean.getStatus()) && registrationBean.getStatus() == 4) { isDeletedUser = Boolean.TRUE; isExistingUser = Boolean.FALSE; registrationBean.setIsDeletedUser(isDeletedUser); registrationBean.setIsExistingUser(isExistingUser); if (Validator.isNotNull(registrationBean.getSalesEntryId()) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String packageDetails = registrationDelegator .getPackageDetails(registrationBean.getSalesEntryId()); log.info(THE_PACKAGE_DETAILS + packageDetails); registrationBean.setPackageDetails(packageDetails); } User liferayDeletedUser = UserLocalServiceUtil.fetchUserByEmailAddress( themeDisplay.getCompanyId(), registrationBean.getBusinessEmailAddress()); if (Validator.isNotNull(liferayDeletedUser)) { registrationBean = populateFields(registrationBean, themeDisplay, liferayStoxxUser); } registrationBean = getListDetails(registrationBean, themeDisplay); registrationBean = registrationDelegator .getUserPreferenceDetails(registrationBean.getBusinessEmailAddress(), registrationBean); } if (!Validator.isNotNull(registrationBean.getStatus()) && liferayStoxxUser.getStatus() == 1 && Validator.isNotNull(registrationBean.getSalesEntryId())) { log.info("For customer who are going to add by admin into application after deletion."); isDeletedUser = Boolean.TRUE; isExistingUser = Boolean.FALSE; registrationBean.setIsDeletedUser(isDeletedUser); registrationBean.setIsExistingUser(isExistingUser); if (Validator.isNotNull(registrationBean.getSalesEntryId()) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String packageDetails = registrationDelegator .getPackageDetails(registrationBean.getSalesEntryId()); log.info(THE_PACKAGE_DETAILS + packageDetails); registrationBean.setPackageDetails(packageDetails); } getListDetails(registrationBean, themeDisplay); } registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); model.addAttribute(REGISTRATION_BEAN, registrationBean); return RegistrationConstants.SETUP_PROFILE; } else if (portalUrl.contains(StringPool.QUESTION)) { SessionMessages.add(renderRequest, "user-validation-done"); registrationBean = new RegistrationBean(); businessEmailAddressEncrypted = portalUrl.split(StringPool.BACK_SLASH + StringPool.QUESTION)[1]; log.info("businessEmailAddress value>>>> " + businessEmailAddressEncrypted); businessEmailAddress = STOXXEncrypter.decrypt(businessEmailAddressEncrypted, ENCRYPTION_KEY); log.info("decrypted email id is>>> " + businessEmailAddress); RegistrationBean registrationBean2 = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); if (Validator.isNotNull(registrationBean2) && Validator.isNotNull(registrationBean2.getStatus()) && registrationBean2.getStatus() == 3) { log.info("<<<<<<<<<the user is an eisting user>>>>>>>>"); isExistingUser = Boolean.TRUE; isDeletedUser = Boolean.FALSE; } registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); log.info("inside registration link validation with questionmark"); registrationBean.setCompanyId(themeDisplay.getCompanyId()); if (Validator.isNotNull(registrationBean2) && Validator.isNotNull(registrationBean2.getStatus()) && registrationBean2.getStatus() == 4 && registrationDelegator .isInactiveUser(registrationBean.getCompanyId(), businessEmailAddress)) { log.info("<<<<<<<<< the user has been deleted previously >>>>>>>>"); isDeletedUser = Boolean.TRUE; isExistingUser = Boolean.FALSE; } log.info("registrationBean.getIsDeletedUser() " + isDeletedUser); if (Validator.isNotNull(businessEmailAddress) && !registrationBean.getIsExistingUser()) { if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean, businessEmailAddress) && registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress) && !isDeletedUser) { log.info("inside dupplicate registration block with questionmark"); SessionErrors.add(renderRequest, USER_EXISTS_KEY); } else { boolean isUserExistInCustomDB = registrationDelegator .checkIfUserExistsInLiferay(registrationBean, businessEmailAddress); log.info("isUserExistInCustomDB : " + isUserExistInCustomDB); if (!isUserExistInCustomDB && !isDeletedUser) { SessionErrors.add(renderRequest, USER_DELETED_KEY); } else { log.info("inside registration block for new registration with questionmark"); registrationBean.setBusinessEmailAddress(businessEmailAddress); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean); registrationBean.setBusinessEmailAddress(businessEmailAddress); log.info( "registartion bean email address" + registrationBean.getBusinessEmailAddress()); log.info("the user type is " + registrationBean.getUserType()); if (fetchActivationLinkCreateDateDiff(registrationBean.getBusinessEmailAddress())) { SessionErrors.add(renderRequest, RegistrationConstants.REGISTRATION_LINK_EXPIRED); } if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER) && registrationBean.getUserType() .equalsIgnoreCase(STOXXConstants.STOXX_GENERAL_USER)) { SessionMessages.add(renderRequest, "user-activation-link-already-sent"); } } } } registrationBean.setIsDeletedUser(isDeletedUser); } registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); log.info("registrationBean.toString() : " + registrationBean.toString()); model.addAttribute(REGISTRATION_BEAN, registrationBean); } catch (STOXXException e) { log.error("STOXXException in handleRenderRequest", e); } catch (Exception e) { log.error("Exception in handleRenderRequest", e); } registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); return RegistrationConstants.INITIATE_REGISTRATION; }
From source file:com.stoxx.portlet.controller.RegistrationController.java
private void getUserTypeandEmalaIdfromEncrptedUrl(Model model, RegistrationBean registrationBean, String portalUrl) {/*w w w . j a v a 2 s .com*/ String businessEmailAddressEncrypted; String userTypEncrypted; Boolean isExistingUser = Boolean.FALSE; Boolean isDeletedUser = Boolean.FALSE; try { businessEmailAddressEncrypted = portalUrl.substring(portalUrl.indexOf(StringPool.QUESTION) + 1, portalUrl.indexOf(StringPool.DOLLAR)); businessEmailAddress = STOXXEncrypter.decrypt(businessEmailAddressEncrypted, ENCRYPTION_KEY); log.info("decrypted email id is&&&&& " + businessEmailAddress); registrationBean.setBusinessEmailAddress(businessEmailAddress); log.info("registartion bean email address" + registrationBean.getBusinessEmailAddress()); userTypEncrypted = portalUrl.split(StringPool.BACK_SLASH + StringPool.DOLLAR)[1]; userType = STOXXEncrypter.decrypt(userTypEncrypted, ENCRYPTION_KEY); registrationBean.setUserType(userType); RegistrationBean registrationBean2 = registrationDelegator.fetchFromStoxxUser(registrationBean); if (Validator.isNotNull(registrationBean2) && Validator.isNotNull(registrationBean2.getStatus()) && registrationBean2.getStatus() == 3) { log.info("<<<<<<<<<the user is an eisting user>>>>>>>>"); isExistingUser = Boolean.TRUE; } if (Validator.isNotNull(registrationBean2) && Validator.isNotNull(registrationBean2.getStatus()) && registrationBean2.getStatus() == 4) { log.info("<<<<<<<<<the user has been deleted previously>>>>>>>>"); isDeletedUser = Boolean.TRUE; } registrationBean.setIsExistingUser(isExistingUser); registrationBean.setIsDeletedUser(isDeletedUser); } catch (STOXXException e) { log.error("STOXXException ", e); } catch (Exception e) { log.error("Exception", e); } log.info("the user type is " + registrationBean.getUserType()); model.addAttribute(REGISTRATION_BEAN, registrationBean); }
From source file:com.stoxx.portlet.controller.RegistrationController.java
@ActionMapping(params = "action=addUserRegistrationAction") public void addUserRegistrationAction(ActionRequest actionRequest, ActionResponse actionResponse, Model model, @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean, BindingResult bindingResult) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); SessionMessages.add(actionRequest,/* www . jav a 2 s . c om*/ PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); String actionResponseParameter = null; try { log.info("***************************the business email address variable is" + businessEmailAddress); log.info("registrationBean.toString() : " + registrationBean.toString()); log.info("***************************On Linked in click" + registrationBean.getLinkedinReg()); log.info("registrationBean.getLinkedinReg() is" + registrationBean.getLinkedinReg()); if (Validator.isNull(registrationBean.getLinkedinReg())) { registrationBean.setLinkedinReg(Boolean.FALSE); } registrationBean.setCompanyId(themeDisplay.getCompanyId()); if (Validator.isNotNull(registrationBean) && registrationBean.getLinkedinReg()) { if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean)) { SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else { registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); registrationBean.setIsExistingUser(Boolean.FALSE); actionResponseParameter = "setupProfileTRANSLATOR"; createActivationLink(actionRequest, registrationBean, themeDisplay); actionResponse.setRenderParameter(ACTION, actionResponseParameter); return; } } if (Validator.isNotNull(registrationBean)) { registrationBean.setCompanyId(themeDisplay.getCompanyId()); log.info("the company id is" + registrationBean.getCompanyId()); log.info("registrationBean.getIsDeletedUser() : " + registrationBean.getIsDeletedUser()); if (Validator.isNotNull(registrationBean.getIsExistingUser()) && registrationBean.getIsExistingUser() && !(Validator.isNotNull(registrationBean.getIsDeletedUser()) && registrationBean.getIsDeletedUser())) { log.info("Return the user back to login page..."); actionResponse.setRenderParameter(ACTION, "existingUserStep2"); return; } } if (Validator.isNotNull(registrationBean) && null != registrationBean.getBusinessEmailAddress()) { log.info("the EXPECTED emailAddress id is" + registrationBean.getBusinessEmailAddress()); RegistrationBean regBean = registrationDelegator.fetchFromStoxxUser(registrationBean); log.info("the status is" + regBean.getStatus()); if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && (regBean.getStatus() == 3 || regBean.getStatus() == 4)) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); try { if (regBean.getStatus() == 4 && regBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String emailDomainName = registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().lastIndexOf("@")); EmailDomain emailDomain = EmailDomainLocalServiceUtil.getEmailDomain(emailDomainName); regBean.setSalesEntryId(emailDomain.getSalesEntryId()); SalesEntry salesEntry = SalesEntryLocalServiceUtil .getSalesEntry(emailDomain.getSalesEntryId()); int allowedLicenses = salesEntry.getUsersAllowed(); int alreadyUsedLicenses = registrationDelegator .getCustomerCountByGroupId(salesEntry.getSalesEntryId()); log.info("alreadyUsedLicenses from DB for salesentryID: " + salesEntry.getSalesEntryId() + " is: " + alreadyUsedLicenses); log.info("allowedLicenses: " + allowedLicenses + "for salesentry company: " + salesEntry.getCompanyName()); if (allowedLicenses <= alreadyUsedLicenses) { SessionErrors.add(actionRequest, CUST_USER_EXCEEDED); actionResponse.setRenderParameter(ACTION, CUST_USER_EXCEEDED); return; } } } catch (NoSuchEmailDomainException e) { log.info("No domain exist for provided email address."); regBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); } createActivationLink(actionRequest, regBean, themeDisplay); actionResponse.setRenderParameter(ACTION, EXISTING_USER); return; } if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean)) { SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else if (fetchActivationLinkCreateDateDiff(registrationBean.getBusinessEmailAddress())) { SessionErrors.add(actionRequest, RegistrationConstants.REGISTRATION_LINK_EXPIRED); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } else if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean)) { SessionErrors.add(actionRequest, "user-activation-link-already-sent"); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } } else if (null != businessEmailAddress) { log.info("Within else if : businessEmailAddress : " + businessEmailAddress); RegistrationBean regBean = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && regBean.getStatus() == 3) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); actionResponse.setRenderParameter(ACTION, EXISTING_USER); return; } if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && regBean.getStatus() == 4) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); actionResponse.setRenderParameter(ACTION, DELETED_USER); return; } if (Validator.isNotNull(registrationBean.getIsDeletedUser()) && registrationBean.getIsDeletedUser()) { log.info("User email address is : " + businessEmailAddress + ". User added as customer after delition"); actionResponse.setRenderParameter(ACTION, DELETED_USER); return; } if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean, businessEmailAddress)) { log.info("User exist in liferay DB"); SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else if (fetchActivationLinkCreateDateDiff(businessEmailAddress)) { log.info("The activation link is expired."); SessionErrors.add(actionRequest, LINK_EXPIRED); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } } if (null != registrationBean.getBusinessEmailAddress()) { log.info("Within If " + registrationBean.getBusinessEmailAddress()); if (registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().indexOf(StringPool.AT) + 1) .equalsIgnoreCase(RegistrationConstants.STAFF_DOMAIN_PATTERN)) { registrationBean.setUserType(STOXXConstants.STOXX_STAFF_USER); createActivationLink(actionRequest, registrationBean, themeDisplay); actionResponseParameter = "setupProfileSTAFF"; } else { try { String emailDomainName = registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().lastIndexOf("@")); EmailDomain emailDomain = EmailDomainLocalServiceUtil.getEmailDomain(emailDomainName); registrationBean.setSalesEntryId(emailDomain.getSalesEntryId()); SalesEntry salesEntry = SalesEntryLocalServiceUtil .getSalesEntry(emailDomain.getSalesEntryId()); int allowedLicenses = salesEntry.getUsersAllowed(); int alreadyUsedLicenses = registrationDelegator .getCustomerCountByGroupId(salesEntry.getSalesEntryId()); log.info("alreadyUsedLicenses from DB for salesentryID: " + salesEntry.getSalesEntryId() + "is: " + alreadyUsedLicenses); log.info("allowedLicenses: " + allowedLicenses + "for salesentry company: " + salesEntry.getCompanyName()); if (allowedLicenses <= alreadyUsedLicenses) { SessionErrors.add(actionRequest, CUST_USER_EXCEEDED); actionResponse.setRenderParameter(ACTION, CUST_USER_EXCEEDED); return; } registrationBean.setUserType(STOXXConstants.STOXX_REGISTERED_USER); registrationBean.setCompanyName(salesEntry.getCompanyName()); actionResponseParameter = "setupProfileGENERALLICENSED"; } catch (NoSuchEmailDomainException e) { log.info("No domain exist for provided email address."); registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); actionResponseParameter = "setupProfileGENERAL"; } createActivationLink(actionRequest, registrationBean, themeDisplay); } } else { log.info("Within If " + businessEmailAddress); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); if (Validator.isNotNull(registrationBean.getActivationLink()) && registrationBean.getActivationLink().indexOf(PropsUtil.get("INTRANET")) != -1 && registrationBean.getActivationLink().contains(StringPool.DOLLAR)) { if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress)) { registrationBean.setBusinessEmailAddress(businessEmailAddress); registrationDelegator.fetchFromStoxxUser(registrationBean); } else { registrationBean.setCompanyName(RegistrationConstants.STAFF_COMPANY); registrationBean.setUserType(STOXXConstants.STOXX_STAFF_USER); } } else if (Validator.isNotNull(registrationBean.getActivationLink()) && registrationBean.getActivationLink().indexOf(PropsUtil.get(INTERNET)) != -1) { if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress)) { registrationBean.setBusinessEmailAddress(businessEmailAddress); registrationDelegator.fetchFromStoxxUser(registrationBean); } else { registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); } } actionResponseParameter = "setupProfileTRANSLATOR"; } log.info("the action parameter is " + actionResponse.getRenderParameterMap()); actionResponse.setRenderParameter(ACTION, actionResponseParameter); } catch (STOXXException e) { log.error("STOXXException in addUserRegistrationAction", e); } catch (Exception e) { log.error("Exception in addUserRegistrationAction ", e); } }
From source file:com.stoxx.portlet.controller.RegistrationController.java
private void createActivationLink(ActionRequest actionRequest, RegistrationBean registrationBean, ThemeDisplay themeDisplay) {/* ww w. j a va 2 s . c o m*/ try { String encryptedEmailId = STOXXEncrypter.encrypt(registrationBean.getBusinessEmailAddress(), ENCRYPTION_KEY); String encrypteduserType = STOXXEncrypter.encrypt(registrationBean.getUserType(), ENCRYPTION_KEY); String activationLink = null; if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) { activationLink = themeDisplay.getPortalURL() + "/web/stoxxnet/registration?" + encryptedEmailId + StringPool.DOLLAR + encrypteduserType; } else { activationLink = themeDisplay.getPortalURL() + "/web/stoxxcom/registration?" + encryptedEmailId + StringPool.DOLLAR + encrypteduserType; } log.info("the activation link is" + activationLink); registrationBean.setActivationLink(activationLink); registrationBean.setActivationLinkCreatedDate(new Date()); log.info("registrationBean.getLinkedinReg() is" + registrationBean.getLinkedinReg()); if (Validator.isNull(registrationBean.getLinkedinReg())) { registrationBean.setLinkedinReg(Boolean.FALSE); } if (Validator.isNotNull(registrationBean) && !registrationBean.getLinkedinReg()) { sendEmailByTemplate(registrationBean, themeDisplay); SessionMessages.add(actionRequest, "mail-success-message"); } registrationDelegator.addUserRegistration(registrationBean); } catch (STOXXException e) { log.error("STOXXException createActivationLink", e); } catch (Exception e) { log.info("registrationBean ", e); } }