Example usage for com.liferay.portal.kernel.language LanguageUtil get

List of usage examples for com.liferay.portal.kernel.language LanguageUtil get

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.language LanguageUtil get.

Prototype

public static String get(ResourceBundle resourceBundle, String key) 

Source Link

Usage

From source file:com.rivetlogic.evernote.portlet.EvernotePortlet.java

License:Open Source License

public void createNote(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException {

    PortletSession portletSession = actionRequest.getPortletSession();
    String accessToken = (String) portletSession.getAttribute(ACCESS_TOKEN);
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, accessToken);
    NoteStoreClient noteStoreClient;//from  w w  w.  ja  va  2  s  .  co m
    try {
        noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient();

        // To create a new note, simply create a new Note object and fill in
        // attributes such as the note's title.
        Note note = new Note();

        String title = ParamUtil.getString(actionRequest, NEW_NOTE_TITLE);

        if (Validator.isNull(title)) {
            title = LanguageUtil.get(themeDisplay.getLocale(), UNTITLED_NOTE_KEY);
        }

        // The content of an Evernote note is represented using Evernote
        // Markup Language
        // (ENML). The full ENML specification can be found in the Evernote
        // API
        // Overview at
        // http://dev.evernote.com/documentation/cloud/chapters/ENML.php
        StringBundler sb = new StringBundler();
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
                .append("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")
                .append("<en-note>").append(ParamUtil.getString(actionRequest, "newNoteContent"))
                .append("</en-note>");

        String notebookGuid = ParamUtil.getString(actionRequest, NEW_NOTE_NOTEBOOK);

        note.setTitle(title);
        note.setContent(sb.toString());
        if (!notebookGuid.isEmpty())
            note.setNotebookGuid(notebookGuid);

        // Finally, send the new note to Evernote using the createNote
        // method
        // The new Note object that is returned will contain
        // server-generated
        // attributes such as the new note's unique GUID.
        Note createdNote = noteStoreClient.createNote(note);
        String newNoteGuid = createdNote.getGuid();

        if (LOG.isDebugEnabled()) {
            LOG.debug(GUID_SUCCESSFULL_CREATED_MESSAGE + newNoteGuid);
        }

    } catch (EDAMUserException e) {
        LOG.error(e);
        SessionErrors.add(actionRequest, EDAMUserException.class);
    } catch (EDAMSystemException e) {
        LOG.error(e);
        SessionErrors.add(actionRequest, EDAMSystemException.class);
    } catch (TException e) {
        LOG.error(e);
        SessionErrors.add(actionRequest, TException.class);
    } catch (EDAMNotFoundException e) {
        LOG.error(e);
        SessionErrors.add(actionRequest, EDAMNotFoundException.class);
    }
    if (!SessionErrors.isEmpty(actionRequest)) {
        actionResponse.setRenderParameter(MVC_PATH, getInitParameter(CREATE_NOTE_JSP));
    }

}

From source file:com.rivetlogic.portlet.whiteboard.atmosphere.WhiteboardHandler.java

License:Open Source License

@Override
public void onRequest(AtmosphereResource resource) throws IOException {

    ConcurrentMap<String, UserData> loggedUserMap = getLoggedUsersMap();

    String userName = StringPool.BLANK;
    String userImagePath = StringPool.BLANK;

    // user joined
    String sessionId = resource.session().getId();
    if (loggedUserMap.get(sessionId) == null) {

        try {/*ww  w.  j a v a 2s .c om*/

            String baseImagePath = URLDecoder
                    .decode(resource.getRequest().getParameter(WhiteboardHandlerUtil.BASE_IMAGEPATH), ENCODING);
            LOG.debug("base image path " + baseImagePath);

            User user = PortalUtil.getUser(resource.getRequest());
            long companyId = PortalUtil.getCompanyId(resource.getRequest());

            if (user == null || user.isDefaultUser()) {
                LOG.debug("This is guest user");
                user = UserLocalServiceUtil.getDefaultUser(companyId);
                userName = LanguageUtil.get(LocaleUtil.getDefault(),
                        WhiteboardHandlerUtil.GUEST_USER_NAME_LABEL);
            } else {
                userName = user.getFullName();
            }

            userImagePath = UserConstants.getPortraitURL(baseImagePath, user.isMale(), user.getPortraitId());

            LOG.debug(String.format("User full name: %s, User image path: %s", userName, userImagePath));
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }

        loggedUserMap.put(resource.session().getId(), new UserData(userName, userImagePath));

        /* listens to disconnection event */
        resource.addEventListener(new WhiteBoardResourceEventListener(loggedUserMap, sessionId));
    }
}

From source file:com.slemarchand.peoplepublisher.template.PeoplePublisherPortletDisplayTemplateHandler.java

License:Open Source License

@Override
public String getName(Locale locale) {
    String portletTitle = PortalUtil.getPortletTitle(PortletKeys.PEOPLE_PUBLISHER, locale);

    return portletTitle.concat(StringPool.SPACE).concat(LanguageUtil.get(locale, "template"));
}

From source file:com.stoxx.portlet.accountdetails.controller.AccountDetailsController.java

@ActionMapping(params = "action=deleteUser")
public void deleteUser(final ActionRequest request, final ActionResponse response,
        @ModelAttribute("accountDetails") AccountDetails accountDetails, final Model model) {
    Map<String, Object> emailBodyMap = new HashMap<String, Object>();
    try {/*w  w w  . jav a2s .  co m*/
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        String emailTemplateFolder = "templates";
        String emailVelocityTemplate = StringPool.BLANK;
        emailVelocityTemplate = emailTemplateFolder + "/" + "keyAccHolderDeactivationMail.vm";
        String deleteEmail = request.getParameter("deleteEmail");

        log.info("accountDetails.getKeyAccHolderName()>>>>> " + accountDetails.getKeyAccHolderName());
        log.info("deleteEmail>>>>> " + deleteEmail);

        if (StringUtils.isNotBlank(accountDetails.getKeyAccHolderName())
                && StringUtils.isNotBlank(deleteEmail)) {
            emailBodyMap.put(TO_NAME, deleteEmail);
            emailBodyMap.put(FROM_NAME, PrefsPropsUtil.getString("stoxx-mail-from-name"));
            emailBodyMap.put(FROM_ADDRESS, PropsUtil.get(STOXX_MAIL_FROM_ADDRESS));
            emailBodyMap.put(PORTAL_URL, PrefsPropsUtil.getString("stoxx-mail-from-url"));

            emailBodyMap.put(MESSAGE_SECTION,
                    LanguageUtil.get(themeDisplay.getLocale(), "stoxx-accountDetails-delete-licenced-user")
                            + StringPool.SPACE + accountDetails.getKeyAccHolderName());

            log.info(emailBodyMap.get(TO_NAME) + "  " + emailBodyMap.get(FROM_NAME) + "  "
                    + emailBodyMap.get(FROM_ADDRESS) + "  " + emailBodyMap.get(PORTAL_URL) + "  "
                    + emailBodyMap.get(MESSAGE_SECTION));

            accountDetailsDelegate.deleteUserByEmail(themeDisplay.getCompanyId(), deleteEmail,
                    themeDisplay.getUser());

            stoxxMailUtil.sendEmailNotification(
                    deleteEmail, PropsUtil.get(STOXX_MAIL_FROM_ADDRESS), emailVelocityTemplate, LanguageUtil
                            .get(themeDisplay.getLocale(), "stoxx-accountDetails-delete-licenced-user-subject"),
                    emailBodyMap);
        }
        request.setAttribute("deleteusermsg", "SUCCESS");
    } catch (SystemException e) {
        log.error(e.getMessage() + e);
    } catch (MessagingException e) {
        log.error(e.getMessage() + e);
    }
}

From source file:com.stoxx.portlet.accountdetails.controller.AccountDetailsController.java

@ActionMapping(params = "action=addUser")
public void saveCustomerAsStoxxUsersByEmail(ActionRequest request, ActionResponse response) {

    log.info("inside saveCustomerAsStoxxUsers--");
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    String emailTemplateFolder = "templates";
    String emailVelocityTemplate = emailTemplateFolder + "/" + "subUsersActivationEmail.vm";

    String userEmail = request.getParameter("memberData");
    userEmail = StringUtil.toLowerCase(userEmail);
    String accountType = request.getParameter("typeData");

    log.info("userEmail>>>>> " + userEmail);
    log.info("accountType>>>>> " + accountType);

    try {/*from   w  w w.  ja  va 2s .c o m*/

        log.info("unUsedUsers in adduser >>>>>>>>>>>>>>>>>>>>" + unUsedUsers);

        if (0 != unUsedUsers) {
            if (StringUtils.isNotBlank(userEmail) && StringUtils.isNotBlank(accountType)) {
                if (Validator
                        .isNotNull(StringUtil.trim(ListUtil.toString(accountDetails.getDomains(), "", "")))) {
                    boolean isValidDomain = false;
                    for (String domain : accountDetails.getDomains()) {
                        domain = StringUtil.toLowerCase(domain);
                        if (userEmail.endsWith(domain)) {
                            isValidDomain = true;
                            break;
                        }
                    }
                    if (!isValidDomain) {
                        request.setAttribute(ADDUSERMSG, "INVALID_DOMAIN");
                        return;
                    }
                }
                if (checkCaptcha(request)) {
                    log.info("Answer was entered correctly!");
                    Map<String, Object> emailBodyMap = new HashMap<String, Object>();
                    emailBodyMap.put(FROM_NAME, PrefsPropsUtil.getString("stoxx-mail-from-name"));
                    emailBodyMap.put(FROM_ADDRESS, PropsUtil.get(STOXX_MAIL_FROM_ADDRESS));
                    emailBodyMap.put(PORTAL_URL, PrefsPropsUtil.getString("stoxx-mail-from-url"));
                    log.info("Email addresses>>>>> ");
                    log.info("Email addresses>>>>> " + userEmail);
                    String encryptedEmailId = STOXXEncrypter.encrypt(userEmail, ENCRYPTION_KEY);
                    String activationLink = themeDisplay.getPortalURL()
                            + PrefsPropsUtil.getString("stoxx-pre-reg-admin-acount-registration")
                            + encryptedEmailId;
                    log.info("ADD USER activationlink >>>>>>>>>>>>>>>>>>>>>>>>>>" + activationLink);
                    if (StringUtils.isNotBlank(companyName)) {
                        User userlocal = null;
                        UserProfileDetails profileDetailsLocal = accountDetailsDelegate
                                .getUserProfile(userEmail);
                        boolean isDeletedUser = (profileDetailsLocal != null
                                && Validator.equals(profileDetailsLocal.getStatus(), Integer.valueOf(4)));
                        try {
                            userlocal = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(),
                                    userEmail);
                        } catch (NoSuchUserException e) {
                            log.error(e.getMessage(), e);
                        } catch (PortalException e) {
                            log.error(e.getMessage(), e);
                        }
                        if (null == userlocal
                                && !(StringUtils.isNotBlank(profileDetailsLocal.getEmailAddress()))) {
                            accountDetailsDelegate.saveStoxxUser(
                                    themeDisplay.getUser().getEmailAddress().toLowerCase(), userEmail,
                                    activationLink, companyName, accountType);
                            emailBodyMap.put(TO_NAME, userEmail);
                            emailBodyMap.put("userActivationLink", activationLink);
                            stoxxMailUtil.sendEmailNotification(userEmail,
                                    PropsUtil.get(STOXX_MAIL_FROM_ADDRESS), emailVelocityTemplate,
                                    LanguageUtil.get(themeDisplay.getLocale(), "stoxx-prereg-email-subject"),
                                    emailBodyMap);
                            request.setAttribute(ADDUSERMSG, "SUCCESS");
                        } else {
                            if (isDeletedUser) {
                                accountDetailsDelegate.updateStoxxUser(
                                        themeDisplay.getUser().getEmailAddress().toLowerCase(), activationLink,
                                        accountType, companyName, profileDetailsLocal);
                                emailBodyMap.put(TO_NAME, userEmail);
                                emailBodyMap.put("userActivationLink", activationLink);
                                stoxxMailUtil.sendEmailNotification(userEmail,
                                        PropsUtil.get(STOXX_MAIL_FROM_ADDRESS), emailVelocityTemplate,
                                        LanguageUtil.get(themeDisplay.getLocale(),
                                                "stoxx-prereg-email-subject"),
                                        emailBodyMap);
                                request.setAttribute(ADDUSERMSG, "SUCCESS");
                            } else if (null != userlocal
                                    && (StringUtils.isNotBlank(profileDetailsLocal.getEmailAddress()))
                                    && !isDeletedUser) {
                                if (null != profileDetailsLocal.getSalesEntryId()) {
                                    request.setAttribute(ADDUSERMSG, "ADDREGISTER");
                                } else {
                                    request.setAttribute(ADDUSERMSG, "ADDREGISTEROTHER");
                                }
                            } else if (null != userlocal
                                    && !(StringUtils.isNotBlank(profileDetailsLocal.getEmailAddress()))) {
                                request.setAttribute(ADDUSERMSG, "EXISTS");
                            } else if (null == userlocal
                                    && (StringUtils.isNotBlank(profileDetailsLocal.getEmailAddress()))) {
                                if (null != profileDetailsLocal.getSalesEntryId()) {
                                    request.setAttribute(ADDUSERMSG, "ADD");
                                } else {
                                    request.setAttribute(ADDUSERMSG, "ADDOTHER");
                                }
                            }
                        }
                    }
                } else {
                    request.setAttribute(ADDUSERMSG, "WRONGCAPTCHA");
                }
            }
        } else {
            request.setAttribute(ADDUSERMSG, "FAILURE");
        }
    } catch (STOXXException e) {
        log.error("STOXXException in AccountDetailsController", e);
    } catch (SystemException e) {
        log.error(e.getMessage(), e);
    } catch (MessagingException e) {
        log.error(e.getMessage(), e);
    } catch (PortletException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:com.stoxx.portlet.clientlist.delegate.ClientListInfoDelegator.java

@SuppressWarnings("unchecked")
public ClientModel getClientListInfo(long companyId, Locale locale, String alphabet, ClientModel clientModel,
        long userId) {
    List<SalesEntry> salesEntryList = null;
    try {//  w w w . j av  a2  s.co m
        if (alphabet.equalsIgnoreCase(ALL)) {
            salesEntryList = SalesEntryLocalServiceUtil.getSalesEntries(0,
                    SalesEntryLocalServiceUtil.getSalesEntriesCount());
        } else {
            salesEntryList = SalesEntryLocalServiceUtil.getSalesListByStartingAlphabet(alphabet);
        }
        List<ClientListVO> clientListVOList = new ArrayList<ClientListVO>();
        if (Validator.isNotNull(salesEntryList) && salesEntryList.size() > 0) {
            for (SalesEntry salesEntry : salesEntryList) {
                ClientListVO clientListVO = new ClientListVO();
                List<EmployeeVO> employeeList = new ArrayList<EmployeeVO>();
                long salesEntryId = salesEntry.getSalesEntryId();
                if (0 != salesEntryId) {
                    String companyName = salesEntry.getCompanyName();
                    if (StringUtils.isNotBlank(companyName)) {
                        companyName = companyName.trim();
                        clientListVO.setCompanyName(companyName);
                    }
                    Date endDate = salesEntry.getEndDate();
                    if (Validator.isNotNull(endDate)) {
                        String salesEntryEndDate = STOXXDateUtil
                                .convertDateToStringInStoxxApplicationDateFormat(salesEntry.getEndDate());
                        clientListVO.setEndDate(salesEntryEndDate);
                    } else {
                        clientListVO.setEndDate(NA);
                    }
                    clientListVO.setAllowedUsers(salesEntry.getUsersAllowed());
                    clientListVO.setPackagesSubscribed(salesEntry.getPackageNames());
                    List<UserProfileDetails> licensedUserDetails = userProfileService
                            .getLicensedUsers(salesEntryId);
                    if (Validator.isNotNull(licensedUserDetails) && licensedUserDetails.size() > 0) {
                        int usedLicenses = licensedUserDetails.size();
                        clientListVO.setUsedLicenses(usedLicenses);
                    }
                    List<EmailDomain> emailDomainList = EmailDomainLocalServiceUtil
                            .getEmailDomains(salesEntryId);
                    String commaSeperatedEmailDomain = new String();
                    for (EmailDomain emailDomain : emailDomainList) {
                        String domainName = emailDomain.getDomain();
                        commaSeperatedEmailDomain += domainName + StringPool.COMMA;

                    }
                    if (commaSeperatedEmailDomain.endsWith(StringPool.COMMA)) {
                        commaSeperatedEmailDomain = commaSeperatedEmailDomain.substring(0,
                                commaSeperatedEmailDomain.length() - 1);
                    }
                    if (StringUtils.isNotBlank(commaSeperatedEmailDomain)) {
                        clientListVO.setDomainName(commaSeperatedEmailDomain);
                    } else {
                        clientListVO.setDomainName(LanguageUtil.get(locale, "stoxx-client-no-domain-present"));
                    }
                    List<String> emailAddressList = userProfileService
                            .getLicensedUsersEmailAddress(salesEntryId);
                    if (Validator.isNotNull(emailAddressList) && emailAddressList.size() > 0) {
                        for (String emailAddress : emailAddressList) {
                            if (StringUtils.isNotBlank(emailAddress)) {
                                EmployeeVO employeeVO = new EmployeeVO();
                                User user = UserLocalServiceUtil.fetchUserByEmailAddress(companyId,
                                        emailAddress.toLowerCase());
                                UserProfileDetails userProfileDetails = userProfileService
                                        .getUserProfileData(emailAddress.toLowerCase());
                                if (Validator.isNotNull(userProfileDetails)) {
                                    Integer stoxxUserStatus = userProfileDetails.getStatus();
                                    String statusFlag = null;
                                    if (Validator.isNotNull(user)) {
                                        String fullName = user.getFirstName() + StringPool.SPACE
                                                + user.getLastName();
                                        employeeVO.setFullName(fullName);
                                        employeeVO.setEmailAddress(emailAddress);
                                        //PermissionChecker permissionChecker = setAnonymousUserPermission(UserLocalServiceUtil.getDefaultUserId(companyId)); 
                                        List<Address> addressList = AddressServiceUtil
                                                .getAddresses(Contact.class.getName(), user.getContactId());
                                        for (Address address : addressList) {
                                            if (address.getType().getName()
                                                    .equals(STOXXConstants.ADDRESS_TYPE_BUSINESS)) {
                                                String street = address.getStreet1();
                                                if (StringUtils.isNotBlank(address.getStreet2())) {
                                                    street = street.concat(
                                                            StringPool.COMMA + address.getStreet2().trim());
                                                }
                                                long countryId = address.getCountryId();
                                                String countryName = null;
                                                Country country = CountryServiceUtil.getCountry(countryId);
                                                if (Validator.isNotNull(country)) {
                                                    countryName = country.getName(locale);
                                                }
                                                employeeVO.setCountry(countryName);
                                                employeeVO.setAddress(street);
                                            }
                                        }
                                        int liferayUserstatus = user.getStatus();
                                        if (Validator.isNull(stoxxUserStatus)) {
                                            statusFlag = STOXXConstants.INTIATAED;
                                        } else {
                                            if (liferayUserstatus == 0 && stoxxUserStatus == 1) {
                                                statusFlag = STOXXConstants.ACTIVE;
                                            } else if (stoxxUserStatus == 3) {
                                                statusFlag = STOXXConstants.NOTREGISTERED;
                                            } else {
                                                statusFlag = STOXXConstants.SUSPENDED;
                                            }
                                        }
                                        employeeVO.setStatus(statusFlag);
                                        List<Phone> phoneList = PhoneServiceUtil
                                                .getPhones(Contact.class.getName(), user.getContactId());
                                        if (Validator.isNotNull(phoneList) && phoneList.size() > 0) {
                                            for (Phone phone : phoneList) {
                                                if (phone.getType().getName()
                                                        .equalsIgnoreCase(STOXXConstants.PHONE_TYPE_BUSINESS))
                                                    employeeVO.setPhoneNumber(phone.getNumber());
                                            }
                                        }
                                        employeeList.add(employeeVO);
                                    } else {
                                        employeeVO.setFullName(NA);
                                        employeeVO.setEmailAddress(emailAddress);
                                        String location = userProfileDetails.getLocation();
                                        if (StringUtils.isNotBlank(location)) {
                                            employeeVO.setEmailAddress(location);
                                        }
                                        employeeVO.setPhoneNumber(NA);
                                        if (Validator.isNull(stoxxUserStatus)) {
                                            statusFlag = STOXXConstants.INTIATAED;
                                        } else if (stoxxUserStatus.intValue() == 1
                                                || stoxxUserStatus.intValue() == 0) { // if a user starts 1st step of registration process its staus=1, but its not updated in user_ table, so its status is Initiated.
                                            statusFlag = STOXXConstants.INTIATAED; // if user is created from sales entry page or account detail page by KAH, then status=null, so its Initiated.
                                        } else {
                                            statusFlag = "No Status Found";
                                        }
                                        employeeVO.setStatus(statusFlag);
                                        employeeVO.setAddress(NA);
                                        employeeList.add(employeeVO);
                                    }
                                }
                            }
                        }
                    }
                }
                clientListVO.setEmployeeList(employeeList);
                clientListVOList.add(clientListVO);

            }
        }
        Collections.sort(clientListVOList);
        clientModel.setClientList(clientListVOList);
    } catch (Exception e) {
        log.error("Exception in getClientListInfo of ClientListInfoDelegator", e);
    }
    return clientModel;
}

From source file:com.stoxx.portlet.controller.RegistrationController.java

/**
 * @param registrationBean//w  ww. j  a v  a2 s  .  co m
 * @param themeDisplay
 * @param liferayStoxxUser
 * @throws SystemException
 * @throws PortalException
 * @throws STOXXException
 */
private RegistrationBean populateFields(RegistrationBean registrationBean, ThemeDisplay themeDisplay,
        User liferayStoxxUser) throws SystemException, PortalException, STOXXException {
    registrationBean.setFirstName(liferayStoxxUser.getFirstName());
    registrationBean.setLastName(liferayStoxxUser.getLastName());
    registrationBean.setJobTitle(liferayStoxxUser.getJobTitle());
    registrationBean.setCity(liferayStoxxUser.getAddresses().get(0).getCity());
    registrationBean.setCountryId(liferayStoxxUser.getAddresses().get(0).getCountryId());
    Map<String, Integer> titleList = STOXXUtil.getTitleList();
    registrationBean.setTitleList(titleList);
    String gender = LanguageUtil.get(themeDisplay.getLocale(), "stoxx-registration-female");
    if (liferayStoxxUser.isMale()) {
        gender = LanguageUtil.get(themeDisplay.getLocale(), "stoxx-registration-male");
    }
    registrationBean.setGender(gender);
    Date dateToConvert = liferayStoxxUser.getBirthday();
    String dateOfBirth = STOXXDateUtil.convertDateToStringInStoxxApplicationDateFormat(dateToConvert);
    String defaultBitrhday = PropsUtil.get("stoxx-registration-default-date-of-birthday");
    if (StringUtils.isNotBlank(defaultBitrhday)) {
        defaultBitrhday = defaultBitrhday.replace(StringPool.COMMA, StringPool.COMMA + StringPool.SPACE);
    }
    if (StringUtils.isNotBlank(dateOfBirth)) {
        if (defaultBitrhday.equalsIgnoreCase(dateOfBirth.trim())) {
            dateOfBirth = StringPool.BLANK;
        } else {
            registrationBean.setDateOfBirth(dateOfBirth);
        }
    } else {
        dateOfBirth = StringPool.BLANK;
    }
    log.info("The date of birth is >>>>>>>>" + dateOfBirth);
    registrationBean.setDateOfBirth(dateOfBirth);
    if (StringUtils.isNotBlank(dateOfBirth)) {
        registrationBean.setDateOfBirth(dateOfBirth);
    }
    if (Validator.isNotNull(registrationBean) && Validator.isNotNull(registrationBean.isEmailContactPref())) {
        registrationBean.setEmailContactPref(registrationBean.isEmailContactPref());
    }
    liferayStoxxUser.getAddresses().get(0).getCountry().getName(themeDisplay.getLocale());
    registrationBean.setPhoneNumber(liferayStoxxUser.getPhones().get(0).getNumber());
    registrationBean.setUserZipCode(liferayStoxxUser.getAddresses().get(0).getZip());
    registrationBean.setUserAddress(liferayStoxxUser.getAddresses().get(0).getStreet1());
    registrationBean.setUserAddress1(liferayStoxxUser.getAddresses().get(0).getStreet2());
    return registrationBean;
}

From source file:com.stoxx.portlet.controller.RegistrationController.java

/**
 * @param registrationBean// w w w.  j a va 2 s .  c  o  m
 * @param themeDisplay
 * @param emailBodyMap
 * @param emailTemplateFolder
 * @throws SystemException
 * @throws MessagingException
 */
protected void sendEmailByTemplate(RegistrationBean registrationBean, ThemeDisplay themeDisplay)
        throws SystemException, MessagingException {
    Map<String, Object> emailBodyMap = new HashMap<String, Object>();
    String emailTemplateFolder = "templates";
    try {
        String emailVelocityTemplate = StringPool.BLANK;
        emailVelocityTemplate = emailTemplateFolder + "/" + "registrationActivationMail.vm";
        emailBodyMap.put("toName", registrationBean.getBusinessEmailAddress());
        emailBodyMap.put("activationLink", registrationBean.getActivationLink());
        emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-reg-mail-from-name"));
        emailBodyMap.put("fromAddress", PropsUtil.get("stoxx-reg-mail-from-address"));
        emailBodyMap.put("portalURL", PrefsPropsUtil.getString("stoxx-reg-mail-from-url"));
        stoxxMailUtil.sendEmailNotification(registrationBean.getBusinessEmailAddress(),
                PropsUtil.get("stoxx-reg-mail-from-address"), emailVelocityTemplate,
                LanguageUtil.get(themeDisplay.getLocale(), "stoxx-reg-email-subject"), emailBodyMap);
    } catch (MessagingException e) {
        log.error("Exception in sendEmailByTemplate", e);
    }
}

From source file:com.stoxx.portlet.controller.RegistrationController.java

@ActionMapping(params = "action=setupProfileAction")
public void setupProfileAction(ActionRequest actionRequest, ActionResponse actionResponse, Model model,
        @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean, BindingResult bindingResult) {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String emailVelocityTemplate = StringPool.BLANK;
    try {//from w  ww .  j av a2 s  . co m
        ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);
        log.info("Within setupProfileAction...");
        log.info("registrationBean.toString() : " + registrationBean.toString());
        HttpServletRequest httpreq = PortalUtil.getHttpServletRequest(actionRequest);
        HttpServletRequest httpOriginalreq = PortalUtil.getOriginalServletRequest(httpreq);
        //String remoteAddr = httpOriginalreq.getHeader("remote_addr"); // Should be Client-IP to retrieve IP address of the client machine  //
        String remoteAddr = httpOriginalreq.getHeader("Client-IP");
        if (Validator.isNull(remoteAddr)) {
            remoteAddr = httpOriginalreq.getRemoteAddr();
        }
        try {
            CaptchaUtil.check(actionRequest);
        } catch (Exception e) {
            if (e instanceof CaptchaTextException) {
                SessionErrors.add(actionRequest, e.getClass(), e);
                actionResponse.setRenderParameter(ACTION, "CaptchaException");
                return;
            }
        }
        log.info("the remote address is " + remoteAddr);
        String location = RegistrationVOUtil.getLocationForUser(remoteAddr);
        if (null != location) {
            registrationBean.setLocation(location);
        }
        RegistrationBean registrationBean1 = registrationDelegator.fetchFromStoxxUser(registrationBean);
        registrationBean.setUserType(registrationBean1.getUserType());
        registrationBean.setCompanyId(themeDisplay.getCompanyId());
        registrationBean.setActivationLink(registrationBean.getActivationLink());
        log.info("registrationBean.getActivationLink() : " + registrationBean.getActivationLink());
        log.info("registrationBean.getIsExistingUser() : " + registrationBean.getIsExistingUser());
        log.info("registrationBean.getIsDeletedUser() : " + registrationBean.getIsDeletedUser());
        registrationBean.setActivationLinkCreatedDate(new Date());
        registrationDelegator.addUserRegistration(registrationBean, serviceContext, themeDisplay,
                registrationBean.getIsExistingUser(), registrationBean.getIsDeletedUser());

        Layout layout = themeDisplay.getLayout();
        PortletURL loginActionUrl = PortletURLFactoryUtil.create(actionRequest, "58", layout.getPlid(),
                "ACTION_PHASE");
        loginActionUrl.setWindowState(WindowState.MAXIMIZED);
        loginActionUrl.setPortletMode(PortletMode.VIEW);
        loginActionUrl.setParameter("saveLastPath", "0");
        loginActionUrl.setParameter("struts_action", "/login/login");
        loginActionUrl.setParameter("login", registrationBean.getBusinessEmailAddress());
        loginActionUrl.setParameter("password", registrationBean.getUserPassword());

        Map<String, Object> emailBodyMap = new HashMap<String, Object>();
        String emailTemplateFolder = "templates";
        emailBodyMap.put("toName", registrationBean.getBusinessEmailAddress());
        emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-reg-mail-from-name"));
        emailBodyMap.put("fromAddress", PrefsPropsUtil.getString("stoxx-reg-mail-fromAddress"));
        emailVelocityTemplate = emailTemplateFolder + StringPool.SLASH + "willingtocontact.vm";
        String subject = LanguageUtil.get(themeDisplay.getLocale(),
                "stoxx-reg-mail-subject-for-wiiling-to-contact");
        if (registrationBean.isContactMe())
            stoxxMailUtil.shareByEmail(registrationBean.getBusinessEmailAddress(),
                    PrefsPropsUtil.getString("stoxx-reg-mail-from-name"), emailVelocityTemplate, subject,
                    emailBodyMap, themeDisplay);
        if (null != registrationBean.getUserType()) {
            if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) {
                log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                        + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET)
                        + RegistrationConstants.REGISTRATION_DASHBOARD);
                log.info("registrationBean.getDashboardRedirectCondition()  1>>>>>>>>>"
                        + registrationBean.getDashboardRedirectCondition());
                loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                        + PropsUtil.get("INTRANET") + RegistrationConstants.REGISTRATION_DASHBOARD);

                actionResponse.sendRedirect(loginActionUrl.toString());
            } else if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) {
                log.info("registrationBean.getDashboardRedirectCondition()  2>>>>>>>>>"
                        + registrationBean.getDashboardRedirectCondition());
                if (StringUtils.isNotBlank(registrationBean.getDashboardRedirectCondition())) {
                    log.info("registrationBean.getDashboardRedirectCondition()  3>>>>>>>>>"
                            + registrationBean.getDashboardRedirectCondition());
                    if ("yes".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) {
                        log.info("registrationBean.getDashboardRedirectCondition()  4>>>>>>>>>"
                                + registrationBean.getDashboardRedirectCondition());

                        log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                                + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTERNET)
                                + RegistrationConstants.REGISTRATION_MYPROFILE);

                        loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                                + PropsUtil.get(INTERNET) + RegistrationConstants.REGISTRATION_MYPROFILE);
                        actionResponse.sendRedirect(loginActionUrl.toString());
                    } else {
                        if ("no".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) {
                            log.info("registrationBean.getDashboardRedirectCondition()  4>>>>>>>>>"
                                    + registrationBean.getDashboardRedirectCondition());

                            log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                                    + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET)
                                    + RegistrationConstants.REGISTRATION_DASHBOARD);

                            loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                                    + PropsUtil.get(INTRANET) + RegistrationConstants.REGISTRATION_DASHBOARD);
                            actionResponse.sendRedirect(loginActionUrl.toString());

                        }
                    }
                }
            } else {
                log.info("else redirected page is " + PortalUtil.getPortalURL(httpOriginalreq)
                        + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get("INTERNET")
                        + RegistrationConstants.REGISTRATION_DASHBOARD);
                loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP
                        + PropsUtil.get("INTERNET") + RegistrationConstants.REGISTRATION_DASHBOARD);
                actionResponse.sendRedirect(loginActionUrl.toString());
            }
        }

    } catch (STOXXException e) {
        log.error("STOXXException createActivationLink", e);
    } catch (Exception e) {
        log.error("Exception createActivationLink", e);
        try {
            registrationDelegator.deleteUser(registrationBean.getBusinessEmailAddress(),
                    themeDisplay.getCompanyId());
        } catch (STOXXException e1) {
            log.info("the delete user STOXXException ", e1);
        }
        log.error("Exception in setupProfileAction" + e.getMessage(), e);
    }
}

From source file:com.stoxx.portlet.manageusers.controller.ManageUsersController.java

@ActionMapping(params = "action=search")
public void searchUser(ActionRequest actionRequest, ActionResponse actionResponse, Model model) {
    log.info("Inside search User display>>> ");
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String userType = ParamUtil.get(actionRequest, TYPE, StringPool.BLANK);
    String searchCategory = ParamUtil.get(actionRequest, SEARCH_CATEGORY, StringPool.BLANK);
    String searchTerm = ParamUtil.get(actionRequest, SEARCH_TERM, StringPool.BLANK);
    log.info("the userType is " + userType + " searchCategory is " + searchCategory + " searchTerm is "
            + searchTerm);//  www  .  j  a  v a2 s  .c om
    actionResponse.setRenderParameter(SEARCH_CATEGORY, searchCategory);
    actionResponse.setRenderParameter(SEARCH_TERM, searchTerm);

    if (CUSTOMER_DATA.equalsIgnoreCase(userType)) {
        actionResponse.setRenderParameter(REDIRECTED_PAGE, CUSTOMER);
        if (LanguageUtil.get(themeDisplay.getLocale(), "stoxx-manage-user-individual").trim()
                .equalsIgnoreCase(searchCategory)
                || LanguageUtil.get(themeDisplay.getLocale(), "stoxx-manage-user-email").trim()
                        .equalsIgnoreCase(searchCategory)) {
            actionResponse.setRenderParameter(REDIRECTED_PAGE, COMPANY_USER);
        }
    } else if (STAFF_DATA.equalsIgnoreCase(userType)) {
        actionResponse.setRenderParameter(REDIRECTED_PAGE, STAFF);
    } else if (GENERAL_DATA.equalsIgnoreCase(userType)) {
        actionResponse.setRenderParameter(REDIRECTED_PAGE, GENERAL_USER);
    }
}