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.portlet.salesportlet.service.ClpSerializer.java

License:Open Source License

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

        return _servletContextName;
    }
}

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

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/* www.j  av 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,
                    "sample-wc-search-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-wc-search-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-wc-search-portlet";
        }

        return _servletContextName;
    }
}

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

License:Open Source License

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

        return _servletContextName;
    }
}

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

License:Open Source License

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

        return _servletContextName;
    }
}

From source file:com.liferay.push.hooks.DDLRecordModelListener.java

License:Open Source License

private List<User> findSomeUsers(int from, int to) throws PortalException, SystemException {
    Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
    long companyId = company.getCompanyId();
    return UserLocalServiceUtil.getCompanyUsers(companyId, from, to);
}

From source file:com.liferay.repository.external.ExtRepositoryAdapter.java

License:Open Source License

private String _getLogin() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login)) {
        return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_USERNAME);
    }//from w  w  w .ja  v  a2s.  c o m

    try {
        String authType = getAuthType();

        if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
            User user = userLocalService.getUser(GetterUtil.getLong(login));

            if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
                login = user.getEmailAddress();
            } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
                login = user.getScreenName();
            }
        }
    } catch (PortalException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
        }

        login = null;
    } catch (SystemException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
        }

        login = null;
    }

    return login;
}

From source file:com.liferay.repository.external.ExtRepositoryAdapter.java

License:Open Source License

private String _getPassword() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login)) {
        return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_PASSWORD);
    }/*from  ww  w  .  j  a va2s.c o m*/

    return PrincipalThreadLocal.getPassword();
}

From source file:com.liferay.resourcesimporter.util.FileSystemImporter.java

License:Open Source License

protected void addDDMStructures(String fileName, InputStream inputStream) throws Exception {

    fileName = FileUtil.stripExtension(fileName);

    String name = getName(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(groupId,
            PortalUtil.getClassNameId(DDLRecordSet.class), getKey(fileName));

    if (ddmStructure != null) {
        if (!developerModeEnabled) {
            if (_log.isInfoEnabled()) {
                _log.info("DDM structure with name " + name + " and version " + version + " already exists");
            }//  w  w w  . j a  va 2  s .  com

            return;
        }

        if (!updateModeEnabled) {
            DDMStructureLocalServiceUtil.deleteDDMStructure(ddmStructure);
        }
    }

    try {
        if (!updateModeEnabled || (ddmStructure == null)) {
            ddmStructure = DDMStructureLocalServiceUtil.addStructure(userId, groupId,
                    DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID,
                    PortalUtil.getClassNameId(DDLRecordSet.class), getKey(fileName), getMap(name), null,
                    StringUtil.read(inputStream), PropsUtil.get(PropsKeys.DYNAMIC_DATA_LISTS_STORAGE_TYPE),
                    DDMStructureConstants.TYPE_DEFAULT, serviceContext);
        } else {
            ddmStructure = DDMStructureLocalServiceUtil.updateStructure(ddmStructure.getStructureId(),
                    DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID, getMap(name), null,
                    StringUtil.read(inputStream), serviceContext);
        }
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to import DDM structure " + fileName, e);
        }

        throw e;
    }

    addDDLDisplayTemplates(ddmStructure.getStructureKey(), _DDL_STRUCTURE_DISPLAY_TEMPLATE_DIR_NAME, fileName);

    addDDLFormTemplates(ddmStructure.getStructureKey(), _DDL_STRUCTURE_FORM_TEMPLATE_DIR_NAME, fileName);
}

From source file:com.liferay.resourcesimporter.util.FileSystemImporter.java

License:Open Source License

protected void addDDMStructures(String parentDDMStructureKey, String fileName, InputStream inputStream)
        throws Exception {

    fileName = FileUtil.stripExtension(fileName);

    String name = getName(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(groupId,
            PortalUtil.getClassNameId(JournalArticle.class), getKey(fileName));

    if (ddmStructure != null) {
        if (!developerModeEnabled) {
            if (_log.isInfoEnabled()) {
                _log.info("DDM structure with name " + name + " and version " + version + " already exists");
            }/*w  w  w  .  j  a v  a2  s  .  c  om*/

            return;
        }

        if (!updateModeEnabled) {
            DDMStructureLocalServiceUtil.deleteDDMStructure(ddmStructure);
        }
    }

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    try {
        if (!updateModeEnabled || (ddmStructure == null)) {
            ddmStructure = DDMStructureLocalServiceUtil.addStructure(userId, groupId, parentDDMStructureKey,
                    PortalUtil.getClassNameId(JournalArticle.class), getKey(fileName), getMap(name), null, xsd,
                    PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE), DDMStructureConstants.TYPE_DEFAULT,
                    serviceContext);
        } else {
            DDMStructure parentStructure = DDMStructureLocalServiceUtil.fetchStructure(groupId,
                    PortalUtil.getClassNameId(JournalArticle.class), parentDDMStructureKey);

            long parentDDMStructureId = DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID;

            if (parentStructure != null) {
                parentDDMStructureId = parentStructure.getStructureId();
            }

            ddmStructure = DDMStructureLocalServiceUtil.updateStructure(ddmStructure.getStructureId(),
                    parentDDMStructureId, getMap(name), null, xsd, serviceContext);
        }
    } catch (PortalException e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to import DDM structure " + fileName, e);
        }

        throw e;
    }

    _ddmStructures.add(ddmStructure.getStructureKey());

    addDDMTemplates(ddmStructure.getStructureKey(), _JOURNAL_DDM_TEMPLATES_DIR_NAME + fileName);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(ddmStructure.getStructureKey(), _JOURNAL_DDM_STRUCTURES_DIR_NAME + fileName);
    }
}

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

License:Open Source License

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

        return _servletContextName;
    }
}