Example usage for com.liferay.portal.kernel.util PropertiesUtil load

List of usage examples for com.liferay.portal.kernel.util PropertiesUtil load

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropertiesUtil load.

Prototype

public static Properties load(String s) throws IOException 

Source Link

Usage

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettier.java

License:Apache License

protected String processObsoleteCustomProperties(String liferayVersion, Properties customPortalProperties)
        throws IOException {
    if (customPortalProperties.isEmpty()) {
        return StringPool.BLANK;
    }/*from  ww w  .j  a v  a  2s . c  o m*/

    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();
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}

From source file:br.com.thiagomoreira.liferay.plugins.portalpropertiesprettier.PortalPropertiesPrettierTest.java

License:Apache License

@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);
}