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.liferay.meeting.webex.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from ww  w.  ja va 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,
                    "webex-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("webex-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 = "webex-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.microblogs.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,
                    "microblogs-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("microblogs-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 = "microblogs-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.mobile.pushnotifications.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//  ww  w .  jav  a2s  . 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,
                    "push-notifications-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("push-notifications-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 = "push-notifications-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.music.portlet.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from www.j  a va 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,
                    "music-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("music-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 = "music-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.newsletter.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from w  ww . j a  v a  2 s .  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,
                    "newsletter-portlet-deployment-context");

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

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

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

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

        return _servletContextName;
    }
}

From source file:com.liferay.newsletter.service.impl.NewsletterCampaignLocalServiceImpl.java

License:Open Source License

protected void sendEmail(long contactId, NewsletterCampaign campaign) throws PortalException, SystemException {

    String passwordString = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_PASSWORD);
    String userString = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_USER);
    String host = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);
    String port = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_PORT);

    if (passwordString.isEmpty()) {
        passwordString = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);
    }/*w w  w.jav  a  2s  .c  o m*/

    if (userString.isEmpty()) {
        userString = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);
    }

    if (host.isEmpty()) {
        host = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);
    }

    if (port.isEmpty()) {
        port = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST);
    }

    Properties properties = new Properties();

    properties.put(NewsletterConstants.MAIL_TRANSPORT_PROTOCOL, "smtp");
    properties.put(NewsletterConstants.MAIL_SMTP_HOST, host);
    properties.put(NewsletterConstants.MAIL_SMTP_SOCKET_FACTORY_PORT, port);
    properties.put(NewsletterConstants.MAIL_SMTP_PORT, port);
    properties.put(NewsletterConstants.MAIL_SMTP_SOCKET_FACTORY_FALLBACK, "false");
    properties.put(NewsletterConstants.MAIL_SMTP_STARTTLS_ENABLE, "true");
    properties.put(NewsletterConstants.MAIL_SMTP_AUTH, "true");

    MailAuthenticator mailAuthenticator = new MailAuthenticator(userString, passwordString);

    Session session = Session.getInstance(properties, mailAuthenticator);

    String senderEmail = campaign.getSenderEmail();
    String emailSubject = campaign.getEmailSubject();

    NewsletterContent content = campaign.getContent();

    String senderName = campaign.getSenderName();

    StringBundler sb = new StringBundler(10);

    sb.append(StringPool.QUOTE);
    sb.append(senderName);
    sb.append(StringPool.QUOTE);
    sb.append(StringPool.SPACE);
    sb.append(StringPool.LESS_THAN);
    sb.append(senderEmail);
    sb.append(StringPool.GREATER_THAN);

    String from = sb.toString();

    NewsletterContact contact = newsletterContactLocalService.getContact(contactId);

    try {
        MimeMessage message = new MimeMessage(session);

        message.setFrom(new InternetAddress(from));
        message.setRecipient(Message.RecipientType.TO, new InternetAddress(contact.getEmail()));
        message.setSentDate(new Date());
        message.setSubject(emailSubject);
        message.setContent(content.getContent(), "text/html");

        Transport.send(message);
    } catch (Exception e) {
        throw new SendEmailException(e.getMessage());
    }
}

From source file:com.liferay.notifications.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }// ww w.  j av  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,
                    "notifications-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("notifications-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 = "notifications-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.online.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from  w ww . j  a va  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,
                    "OnlineSDK-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("OnlineSDK-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 = "OnlineSDK-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.opensocial.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/* w w w .ja  v a  2 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,
                    "opensocial-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("opensocial-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 = "opensocial-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.liferay.opensocial.shindig.oauth.LiferayOAuthStoreProvider.java

License:Open Source License

private OAuthConsumer _getOAuthConsumer(String keyFileName, String keyName) {

    OAuthConsumer oAuthConsumer = new OAuthConsumerImpl();

    oAuthConsumer.setConsumerKey(_DEFAULT_CONSUMER_KEY);
    oAuthConsumer.setServiceName(_DEFAULT_SERVICE_NAME);

    String consumerSecret = null;

    String path = PropsUtil.get(PropsKeys.LIFERAY_HOME).concat(_KEY_DIR);

    path = path.replaceAll(StringPool.QUOTE, StringPool.BLANK);

    keyFileName = path.concat(keyFileName);

    try {//from  w  w  w  .  j a  v a2  s .  co  m
        consumerSecret = FileUtil.read(keyFileName);
    } catch (Exception e) {
    } finally {
        if (consumerSecret == null) {
            if (!FileUtil.exists(path)) {
                FileUtil.mkdirs(path);
            }

            if (_log.isWarnEnabled()) {
                _log.warn("Unable to load OAuth key from " + keyFileName);
            }

            return null;
        }
    }

    consumerSecret = _convertFromOpenSsl(consumerSecret);

    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE);
    oAuthConsumer.setKeyName(keyName);

    return oAuthConsumer;
}