Java 类com.liferay.portal.kernel.util.PropertiesUtil 实例源码

项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierPortlet.java   
protected String prettify(PortletRequest request) throws IOException,
        PortletException {
    UploadPortletRequest uploadPortletRequest = PortalUtil
            .getUploadPortletRequest(request);

    String liferayVersion = ParamUtil.getString(uploadPortletRequest,
            "liferayVersion", "7.0.4-ga5");
    boolean printDefaultValue = ParamUtil.getBoolean(uploadPortletRequest,
            "printDefaultValue");

    Properties customProperties = PropertiesUtil.load(
            uploadPortletRequest.getFileAsStream("portalPropertiesFile"),
            "UTF-8");

    String prettyProperties = prettier.prettify(customProperties,
            liferayVersion, printDefaultValue);

    incrementCounter(request);

    return prettyProperties;
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue10() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-10-expected.properties");
    String actual = getContent("/portal-issue-10.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4");

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue12() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-12-expected.properties");
    String actual = getContent("/portal-issue-12.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4");

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue13() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-13-expected.properties");
    String actual = getContent("/portal-issue-13.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", true);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue18() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-18-expected.properties");
    String actual = getContent("/portal-issue-18.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", true);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue19() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-19-expected.properties");
    String actual = getContent("/portal-issue-19.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", true);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue22() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-22-expected.properties");
    String actual = getContent("/portal-issue-22.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue27DB2() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-27-db2-expected.properties");
    String actual = getContent("/portal-issue-27-db2.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue27Derby() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-27-derby-expected.properties");
    String actual = getContent("/portal-issue-27-derby.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue27MySQL() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-27-mysql-expected.properties");
    String actual = getContent("/portal-issue-27-mysql.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue27SQLServer() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-27-sqlserver-expected.properties");
    String actual = getContent("/portal-issue-27-sqlserver.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue28() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-28-expected.properties");
    String actual = getContent("/portal-issue-28.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettierTest.java   
@Test
public void testIssue30() throws Exception {
    PortalPropertiesPrettier prettier = new PortalPropertiesPrettier();
    String expected = getContent("/portal-issue-30-expected.properties");
    String actual = getContent("/portal-issue-30.properties");
    Properties customProperties = PropertiesUtil.load(actual);

    actual = prettier.prettify(customProperties, "6.2.3-ga4", false);

    Assert.assertEquals(expected, actual);
}
项目:liferay-evernote    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:liferay-elasticsearch-integration    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:liferay-microsite-manager    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:liferay-document-and-media-treeview    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:hr-portal    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:liferay-voice-command    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:jukebox    文件:ResourcesImporterServletContextListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:hr-portal    文件:ResourcesImporterHotDeployMessageListener.java   
protected Properties getPluginPackageProperties(
    ServletContext servletContext) {

    Properties properties = new Properties();

    try {
        String propertiesString = StringUtil.read(
            servletContext.getResourceAsStream(
                "/WEB-INF/liferay-plugin-package.properties"));

        if (propertiesString == null) {
            return properties;
        }

        String contextPath = servletContext.getRealPath(StringPool.SLASH);

        contextPath = StringUtil.replace(
            contextPath, StringPool.BACK_SLASH, StringPool.SLASH);

        propertiesString = propertiesString.replace(
            "${context.path}", contextPath);

        PropertiesUtil.load(properties, propertiesString);
    }
    catch (IOException ioe) {
        _log.error(ioe, ioe);
    }

    return properties;
}
项目:OEPv2    文件:ManagerLdap.java   
public Properties getUserMappings(long companyId) throws Exception {
    Properties userMappings = PropertiesUtil.load(PrefsPropsUtil.getString(
            companyId, PropsKeys.LDAP_USER_MAPPINGS));
    LogUtil.debug(_log, userMappings);
    return userMappings;
}
项目:OEPv2    文件:EmployeeExportToLdap.java   
public Properties getUserMappings(long companyId) throws Exception {
    Properties userMappings = PropertiesUtil.load(PrefsPropsUtil.getString(
            companyId, PropsKeys.LDAP_USER_MAPPINGS));
    return userMappings;
}
项目:portal-properties-prettier-app    文件:PortalPropertiesPrettier.java   
protected String processObsoleteCustomProperties(String liferayVersion,
        Properties customPortalProperties) throws IOException {
    if (customPortalProperties.isEmpty()) {
        return StringPool.BLANK;
    }

    StringBuilder stringBuilder = new StringBuilder();
    int index = Arrays.binarySearch(portalFileNames, liferayVersion);

    for (int i = index; i >= 0; i--) {
        boolean processedContext = false;
        Properties portalProperties = PropertiesUtil
                .load(getDefaultPortalProperties(portalFileNames[i]));
        SortedSet<String> keys = new TreeSet<String>(
                customPortalProperties.stringPropertyNames());
        Iterator<String> iterator = keys.iterator();

        while (iterator.hasNext()) {
            String key = iterator.next();

            if (portalProperties.containsKey(key)) {
                if (!processedContext) {
                    stringBuilder.append("##\n## Obsolete properties of ");
                    stringBuilder.append(portalFileNames[i]);
                    stringBuilder.append("\n##\n\n");
                    stringBuilder.append("    #\n");
                    stringBuilder
                            .append("    # The properties listed below are obsolete for version ");
                    stringBuilder.append(liferayVersion);
                    stringBuilder.append(" which\n");
                    stringBuilder
                            .append("    # means that they don't have any influence in how Liferay is configured\n");
                    stringBuilder
                            .append("    # and are safe be to removed.\n");
                    stringBuilder.append("    #");

                    processedContext = true;
                }

                String value = fixLineBreak(customPortalProperties
                        .getProperty(key));

                stringBuilder.append("\n");
                stringBuilder.append("    #" + key + "=" + value);
                customPortalProperties.remove(key);
            }
        }
        if (processedContext) {
            stringBuilder.append("\n");
            stringBuilder.append("\n");
        }
    }

    return stringBuilder.toString();
}
项目:edemocracia    文件:BaseDB.java   
protected Set<String> dropIndexes(
        Connection con, String tablesSQL, String indexesSQL,
        String indexesProperties, List<Index> indexes)
    throws IOException, SQLException {

    if (_log.isInfoEnabled()) {
        _log.info("Dropping stale indexes");
    }

    Set<String> validIndexNames = new HashSet<String>();

    if (indexes.isEmpty()) {
        return validIndexNames;
    }

    String tablesSQLLowerCase = tablesSQL.toLowerCase();
    String indexesSQLLowerCase = indexesSQL.toLowerCase();

    Properties indexesPropertiesObj = PropertiesUtil.load(
        indexesProperties);

    Enumeration<String> enu =
        (Enumeration<String>)indexesPropertiesObj.propertyNames();

    while (enu.hasMoreElements()) {
        String key = enu.nextElement();

        String value = indexesPropertiesObj.getProperty(key);

        indexesPropertiesObj.setProperty(key.toLowerCase(), value);
    }

    for (Index index : indexes) {
        String indexNameUpperCase = index.getIndexName().toUpperCase();
        String indexNameLowerCase = indexNameUpperCase.toLowerCase();
        String tableName = index.getTableName();
        String tableNameLowerCase = tableName.toLowerCase();
        boolean unique = index.isUnique();

        validIndexNames.add(indexNameUpperCase);

        if (indexesPropertiesObj.containsKey(indexNameLowerCase)) {
            if (unique &&
                indexesSQLLowerCase.contains(
                    "create unique index " + indexNameLowerCase + " ")) {

                continue;
            }

            if (!unique &&
                indexesSQLLowerCase.contains(
                    "create index " + indexNameLowerCase + " ")) {

                continue;
            }
        }
        else if (!tablesSQLLowerCase.contains(
                    "create table " + tableNameLowerCase + " (")) {

            continue;
        }

        validIndexNames.remove(indexNameUpperCase);

        String sql =
            "drop index " + indexNameUpperCase + " on " + tableName;

        if (_log.isInfoEnabled()) {
            _log.info(sql);
        }

        runSQL(con, sql);
    }

    return validIndexNames;
}