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.rivetlogic.birthday.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

From source file:com.rivetlogic.crafter.social.listeners.CustomTrashEntryListener.java

License:Open Source License

private void init(long companyId) {
    try {/*www .j  a  v  a 2s. c  o m*/
        CrafterManager.init();

        // add crafterAuthCookie to HTTP client
        client.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
        client.setCookieStore(new BasicCookieStore());
        AuthenticationCookie authCookie = CrafterManager
                .getCrafterProfileCookie(PrefsPropsUtil.getString(companyId, CrafterConstants.PROFILE_ADMIN_KEY,
                        GetterUtil.getString(PropsUtil.get(CrafterConstants.PROFILE_ADMIN_KEY),
                                CrafterConstants.PROFILE_DEFAULT_USER)));

        BasicClientCookie cookie = new BasicClientCookie(AuthenticationCookie.COOKIE,
                authCookie.toCookieValue());
        cookie.setDomain(CrafterConstants.CRAFTER_DOMAIN);
        cookie.setExpiryDate(authCookie.getProfileOutdatedAfter());
        cookie.setPath(StringPool.SLASH);
        client.getCookieStore().addCookie(cookie);

    } catch (Exception e) {
        LOG.error(e.getMessage());
    }
}

From source file:com.rivetlogic.ecommerce.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java

License:Open Source License

/**
 * This method loads the needed properties from Elastic.props files and
 * makes necessary conversion using utility methods.
 *///  w w w  . j a va  2  s .  c  o m
public void loadESProperties() {

    /** Load Elastic server home and clustername from Portal level props*/
    this.esServerHome = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_HOME_PATH);
    this.esClusterName = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_CLUSTERNAME);

    /** Load other suggestion related props from Portlet properties*/
    this.suggestionsSize = getPortletProperty(ElasticsearchPortletConstants.SUGGESTIONS_SIZE_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_SIZE_DEFAULT_VALUE);

    this.suggestionsLength = getPortletProperty(ElasticsearchPortletConstants.SUGGESTIONS_LENGTH_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_LENGTH_DEFAULT_VALUE);

    this.suggestionsQueryMaxHits = getPortletProperty(
            ElasticsearchPortletConstants.SUGGESTION_QUERY_MAX_HITS_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_QUERY_MAX_HITS_DEFAULT_VALUE);

    setSuggestionQueryFields();
    setSuggestionExcludedTypes();
}

From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java

License:Open Source License

/**
 * Gets the transport hosts.//  w w w. ja  va  2s .c  o m
 * 
 * @return the transport hosts
 */
public InetSocketTransportAddress[] getTransportHosts() {

    String csNodeList = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_NODE);
    InetSocketTransportAddress[] transportAddresses = null;
    if (Validator.isNotNull(csNodeList)) {
        String[] nodeList = csNodeList.split(StringPool.COMMA);
        transportAddresses = new InetSocketTransportAddress[nodeList.length];

        /** Prepare a list of Hosts */
        for (int i = 0; i < nodeList.length; i++) {
            String[] hostnames = nodeList[i].split(StringPool.COLON);
            InetSocketTransportAddress transportAddress = new InetSocketTransportAddress(hostnames[0],
                    Integer.parseInt(hostnames[1]));
            transportAddresses[i] = transportAddress;
        }
    } else {
        _log.error("Elastic search nodes are missing from properties...");
    }

    return transportAddresses;
}

From source file:com.rivetlogic.event.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

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

License:Open Source License

public static String getConsumerKey(long companyId) throws SystemException {
    return PrefsPropsUtil.getString(companyId, EVERNOTE_CONSUMER_KEY,
            GetterUtil.getString(PropsUtil.get(EVERNOTE_CONSUMER_KEY)));
}

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

License:Open Source License

public static String getConsumerSecret(long companyId) throws SystemException {
    return PrefsPropsUtil.getString(companyId, EVERNOTE_CONSUMER_SECRET,
            GetterUtil.getString(PropsUtil.get(EVERNOTE_CONSUMER_SECRET)));
}

From source file:com.rivetlogic.geo.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from 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,
                    "geo-location-services-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("geo-location-services-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 = "geo-location-services-portlet";
        }

        return _servletContextName;
    }
}

From source file:com.rivetlogic.geoip.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}