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:custom.phuongna.icmp.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

From source file:de.ancud.shorturl.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

From source file:de.dlr.knowledgefinder.webapp.webservice.service.ClpSerializer.java

License:Apache License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/* w w  w.j  ava  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,
                    "knowledgefinder.webservice-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("knowledgefinder.webservice-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 = "knowledgefinder.webservice";
        }

        return _servletContextName;
    }
}

From source file:de.fhg.fokus.odp.boxes.RegistryClient.java

License:Open Source License

/**
 * Constructor for the singleton pattern.
 *//*from  w w w .ja  v a  2  s  .  c  o m*/
public RegistryClient() {
    clientInstance = OpenDataRegistry.getClient();
    Properties props = new Properties();
    props.setProperty("ckan.authorization.key", PropsUtil.get(PROP_NAME_AUTHORIZATION_KEY));
    props.setProperty("ckan.url", PropsUtil.get(PROP_NAME_CKAN_URL));
    clientInstance.init(props);
}

From source file:de.fhg.fokus.odp.categoriesgrid.CategoriesGrid.java

License:Open Source License

/**
 * Gets the categories./*from   w  w w .  ja  v a2  s.  c  o  m*/
 * 
 * @return the categories
 */
@SuppressWarnings("unchecked")
private List<Category> getCategories() {
    List<Category> categories = (List<Category>) MultiVMPoolUtil.getCache(BaseCache.CACHE_NAME_CATEGORIES_GRID)
            .get(CACHE_CATEGORIES_KEY);

    if (categories == null) {

        LOG.info("Empty {} cache, fetching categories from CKAN.", CACHE_CATEGORIES_KEY);
        Properties props = new Properties();
        props.setProperty("ckan.authorization.key", PropsUtil.get(PROP_NAME_AUTHORIZATION_KEY));
        props.setProperty("ckan.url", PropsUtil.get(PROP_NAME_CKAN_URL));

        odr = OpenDataRegistry.getClient(Constants.OPEN_DATA_PROVIDER_NAME);
        odr.init(props);

        List<Category> list = odr.listCategories();
        categories = new ArrayList<Category>();

        for (Category category : list) {
            if ("group".equalsIgnoreCase(category.getType())) {
                categories.add(category);
            }
        }
        Collections.sort(categories, new CategoriesTitleComparator());
        // safe cast: LinkedList
        MultiVMPoolUtil.getCache(BaseCache.CACHE_NAME_CATEGORIES_GRID).put(CACHE_CATEGORIES_KEY,
                (Serializable) categories);
    }

    return categories;
}

From source file:de.fhg.fokus.odp.OdCompliantScreenNameValidator.java

License:Open Source License

@Override
public boolean validate(long loginId, String screenName) {

    String stringPattern = PropsUtil.get("users.screen.name.validator.regexpattern");

    if (StringUtils.isBlank(stringPattern)) {
        stringPattern = "^[a-zA-Z]+\\w*$";
    }/*from   w  w  w  .j  a v a  2 s.  c  o  m*/

    log.debug(
            "Using [" + stringPattern + "] as pattern for new registered user with screen name: " + screenName);

    Pattern pattern = Pattern.compile(stringPattern);
    Matcher matcher = pattern.matcher(screenName);

    return matcher.find();
}

From source file:de.fhg.fokus.odp.portal.datasets.CurrentQuery.java

License:Open Source License

/**
 * Gets the resource format description.
 * //from ww w. j  a  v  a 2s  .  c o  m
 * @return the sorting
 */
public String getResourceFormatDes(String format) {

    String formatDesStr = PropsUtil.get(PROP_DATA_FORMAT_MAPPING + "." + format.toLowerCase());
    if (formatDesStr == null)
        formatDesStr = format;

    return formatDesStr + " Format.";
}

From source file:de.fhg.fokus.odp.portal.datasets.CurrentQuery.java

License:Open Source License

/**
 * Gets the sorting.//from w  w w . j  a  v a  2s. c o  m
 * 
 * @return the sorting
 */
public String getSorting() {
    if (query.getSortFields().isEmpty()) {
        // add default sorting
        String defaultSortStr = PropsUtil.get(PROP_DEFAULT_SORT_METADATA);
        if (defaultSortStr == null)
            defaultSortStr = "score desc";
        query.getSortFields().add(defaultSortStr);
    }
    return query.getSortFields().get(0);
}

From source file:de.fhg.fokus.odp.portal.datasets.Filters.java

License:Open Source License

@PostConstruct
public void init() {

    String MAX_QUERY_Str = PropsUtil.get(PROP_DISPLAY_MAX_QUERY_PRO_PAGE);
    try {/*from   w w w.  j a v  a2s  . c o  m*/
        MAX_QUERY = Integer.parseInt(MAX_QUERY_Str);
    } catch (NumberFormatException e) {
        MAX_QUERY = 15;
    }

    QueryResult<?> lastResult = currentQuery.getLastResult();

    selectedTags = currentQuery.getQuery().getTags();
    selectedCategories = currentQuery.getQuery().getCategories();
    selectedTypes = new ArrayList<String>();
    for (MetadataEnumType type : currentQuery.getQuery().getTypes()) {
        selectedTypes.add(type.toField());
    }
    selectedFormats = currentQuery.getQuery().getFormats();
    selectedLicences = currentQuery.getQuery().getLicences();
    Boolean isopen = currentQuery.getQuery().getIsOpen();
    if (isopen == null) {
        selectedOpeness = "0";
    } else if (isopen) {
        selectedOpeness = "true";
    } else {
        selectedOpeness = "false";
    }

    if (lastResult != null) {
        categories = lastResult.getFacets().get("groups");
        if (categories != null && !categories.getItems().isEmpty()) {
            Collections.sort(categories.getItems(), new FilterCountComparator());
            for (Category category : registryClient.getCategories()) {
                Iterator<QueryFacetItem> it = categories.getItems().iterator();
                while (it.hasNext()) {
                    QueryFacetItem item = it.next();
                    if (item.getName().equals(category.getName()) && category.getType().equals("subgroup")) {
                        it.remove();
                    }
                }
            }
        }

        openess = lastResult.getFacets().get("isopen");
        if (openess != null) {

        }

        types = lastResult.getFacets().get("type");

        if (types != null) {
            Collections.sort(types.getItems(), new FilterCountComparator());
        }

        formats = lastResult.getFacets().get("res_format");

        if (formats != null) {
            if (formats.getItems().size() > 0) {
                allformats = new ArrayList<QueryFacetItem>(formats.getItems());
            }
            changeViewFormats();
        }

        tags = lastResult.getFacets().get("tags");
        if (tags != null) {
            if (tags.getItems().size() > 0) {
                alltags = new ArrayList<QueryFacetItem>(tags.getItems());
            }
            changeViewTags();
        }

        licences = lastResult.getFacets().get("license_id");
        if (licences != null) {
            Collections.sort(licences.getItems(), new FilterCountComparator());
        }

        updateHitsCount();

    }
}

From source file:de.fhg.fokus.odp.portal.datasets.RegistryClient.java

License:Open Source License

@PostConstruct
public void init() {
    client = OpenDataRegistry.getClient();
    Properties props = new Properties();
    props.setProperty("ckan.authorization.key", PropsUtil.get(PROP_NAME_AUTHORIZATION_KEY));
    props.setProperty("ckan.url", PropsUtil.get(PROP_NAME_CKAN_URL));
    props.setProperty("sorting.default.metadata", PropsUtil.get(PROP_NAME_DEFAULT_SORT_METADATA));
    client.init(props);/*from   w ww  .j  a v a2s  . c o m*/
}