Example usage for com.liferay.portal.kernel.util PropsUtil get

List of usage examples for com.liferay.portal.kernel.util PropsUtil get

Introduction

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

Prototype

public static String get(String key) 

Source Link

Usage

From source file:com.sympo.login.action.CreateAccountAction.java

License:Open Source License

protected void addTwitterUser(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();

    boolean autoPassword = true;
    String password1 = null;/*from   w ww  .ja  va  2 s  .  com*/
    String password2 = null;
    boolean autoScreenName = false;
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    String openId = ParamUtil.getString(actionRequest, "openId");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendEmail = false;

    String twitterId = ParamUtil.getString(actionRequest, "twitterId");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {

        autoPassword = false;

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    User user = UserServiceUtil.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2,
            autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, "twitterId", user.getUserId(), twitterId);

    session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(TwitterConstants.TWITTER_LOGIN_PENDING);

    // Send redirect

    String login = null;

    if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_ID)) {
        login = String.valueOf(user.getUserId());
    } else if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_SN)) {
        login = user.getScreenName();
    } else {
        login = user.getEmailAddress();
    }

    String redirect = PortalUtil.getPortalURL(request);

    actionResponse.sendRedirect(redirect);
}

From source file:com.sympo.portlet.messageboards.service.MentionUsersMessageServiceImpl.java

License:Open Source License

private MBMessage notifyMentions(MBMessage message, ServiceContext serviceContext)
        throws PortalException, SystemException {

    if (!message.isDiscussion()) {
        return message;
    }/*from  w w  w  . j a  v a2s. com*/

    ExpandoBridge expandoBridge = message.getExpandoBridge();

    String mentionedUsers = GetterUtil.getString(expandoBridge.getAttribute("mentionedUsers"));

    if (Validator.isNull(mentionedUsers)) {
        return message;
    }

    long companyId = message.getCompanyId();

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    String mailUserAddress = PortalUtil.getUserEmailAddress(message.getUserId());
    String mailUserName = PortalUtil.getUserName(message.getUserId(), StringPool.BLANK);

    String fromName = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(message.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    String mailSubject = ContentUtil.get(PropsUtil.get("discussion.mentioned.email.subject"));
    String mailBody = ContentUtil.get(PropsUtil.get("discussion.mentioned.email.body"));

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(mailBody);
    subscriptionSender.setCompanyId(companyId);
    subscriptionSender.setContextAttribute("[$COMMENTS_BODY$]", message.getBody(true), false);
    subscriptionSender.setContextAttributes("[$COMMENTS_USER_ADDRESS$]", mailUserAddress,
            "[$COMMENTS_USER_NAME$]", mailUserName, "[$CONTENT_URL$]", contentURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("mb_discussion", message.getCategoryId(), message.getMessageId());
    subscriptionSender.setScopeGroupId(message.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(mailSubject);
    subscriptionSender.setUserId(message.getUserId());

    String[] mentionedUsersArray = StringUtil.split(mentionedUsers);

    for (int i = 0; i < mentionedUsersArray.length; i++) {
        String screenName = mentionedUsersArray[i];

        try {
            User mentionedUser = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);

            subscriptionSender.addRuntimeSubscribers(mentionedUser.getEmailAddress(),
                    mentionedUser.getFullName());
        } catch (Exception e) {
        }
    }

    return message;
}

From source file:com.sympo.twitter.TwitterOAuth.java

License:Open Source License

public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    HttpSession session = request.getSession();

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String twitterApiKey = PropsUtil.get("twitter.api.key");
    String twitterApiSecret = PropsUtil.get("twitter.api.secret");

    OAuthService service = new ServiceBuilder().provider(TwitterApi.class).apiKey(twitterApiKey)
            .apiSecret(twitterApiSecret).build();

    String oauthVerifier = ParamUtil.getString(request, "oauth_verifier");
    String oauthToken = ParamUtil.getString(request, "oauth_token");

    if (Validator.isNull(oauthVerifier) || Validator.isNull(oauthToken)) {
        return null;
    }//  w w  w .  j ava  2 s. com

    Verifier v = new Verifier(oauthVerifier);

    Token requestToken = new Token(oauthToken, twitterApiSecret);

    Token accessToken = service.getAccessToken(requestToken, v);

    String verifyCredentialsURL = PropsUtil.get("twitter.api.verify.credentials.url");

    OAuthRequest authrequest = new OAuthRequest(Verb.GET, verifyCredentialsURL);

    service.signRequest(accessToken, authrequest);

    String bodyResponse = authrequest.send().getBody();

    Document document = SAXReaderUtil.read(bodyResponse);

    Element rootElement = document.getRootElement();

    Element idElement = rootElement.element("id");

    String twitterId = idElement.getStringValue();

    ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME);

    ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(),
            "twitterId");

    List<ExpandoValue> expandoValues = ExpandoValueLocalServiceUtil.getColumnValues(
            expandoColumn.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME,
            "twitterId", twitterId, QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    int usersCount = expandoValues.size();

    if (usersCount == 1) {
        ExpandoValue expandoValue = expandoValues.get(0);

        long userId = expandoValue.getClassPK();

        User user = UserLocalServiceUtil.getUser(userId);

        session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, user.getUserId());

        String redirect = PortalUtil.getPortalURL(request) + themeDisplay.getURLSignIn();

        response.sendRedirect(redirect);

        return null;
    } else if (usersCount > 1) {
        if (_log.isDebugEnabled()) {
            _log.debug("There is more than 1 user with the same Twitter Id");
        }
    }

    Element nameElement = rootElement.element("name");
    Element screenNameElement = rootElement.element("screen_name");

    String userName = nameElement.getStringValue();
    String screenName = screenNameElement.getStringValue();

    session.setAttribute(TwitterConstants.TWITTER_LOGIN_PENDING, Boolean.TRUE);

    String createAccountURL = PortalUtil.getCreateAccountURL(request, themeDisplay);

    createAccountURL = HttpUtil.setParameter(createAccountURL, "firstName", userName);
    createAccountURL = HttpUtil.setParameter(createAccountURL, "screenName", screenName);
    createAccountURL = HttpUtil.setParameter(createAccountURL, "twitterId", twitterId);

    response.sendRedirect(createAccountURL);

    return null;
}

From source file:com.tamarack.creekridge.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from   w  ww .  j av a 2 s  . com*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "CreekRidgeCapital-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("CreekRidgeCapital-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "CreekRidgeCapital-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.test.demo.controller.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from   w w w  . j av a  2s .  c om

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "SpringHello-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("SpringHello-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "SpringHello-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.test.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*ww w. j a v  a 2  s . c  o m*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "test-webservice-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("test-webservice-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "test-webservice-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.test.slayer.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from  w w w .  ja va2 s.  c  o  m*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "sample-permission-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("sample-permission-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "sample-permission-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.thanhnhan.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*w w  w .  j  av  a2s. co  m*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "MienTayAds-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("MienTayAds-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "MienTayAds-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.tls.liferaylms.mail.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from w  w w. j a v  a  2s.c o m*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "lmsmailing-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("lmsmailing-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "lmsmailing-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.tookasoft.portlet.addtocontacts.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }// w w  w.  j av a2 s .c  om

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "add-to-contacts-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("add-to-contacts-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "add-to-contacts-portlet";
        }

        return _servletContextName;
    }
}