Search in sources :

Example 1 with PortalPropertiesConfiguration

use of com.liferay.ide.core.properties.PortalPropertiesConfiguration in project liferay-ide by liferay.

the class LiferayPropertiesSourceViewerConfiguration method _parseKeys.

private PropKey[] _parseKeys(InputStream inputStream) throws ConfigurationException, IOException {
    List<PropKey> parsed = new ArrayList<>();
    PortalPropertiesConfiguration config = new PortalPropertiesConfiguration();
    config.load(inputStream);
    inputStream.close();
    Iterator<?> keys = config.getKeys();
    PropertiesConfigurationLayout layout = config.getLayout();
    while (keys.hasNext()) {
        String key = keys.next().toString();
        String comment = layout.getComment(key);
        parsed.add(new PropKey(key, comment == null ? null : comment.replaceAll("\n", "\n<br/>")));
    }
    PropKey[] parsedKeys = parsed.toArray(new PropKey[0]);
    Arrays.sort(parsedKeys, new Comparator<PropKey>() {

        @Override
        public int compare(PropKey o1, PropKey o2) {
            return o1.getKey().compareTo(o2.getKey());
        }
    });
    return parsedKeys;
}
Also used : PropKey(com.liferay.ide.ui.editor.LiferayPropertiesContentAssistProcessor.PropKey) PortalPropertiesConfiguration(com.liferay.ide.core.properties.PortalPropertiesConfiguration) ArrayList(java.util.ArrayList) PropertiesConfigurationLayout(org.apache.commons.configuration.PropertiesConfigurationLayout)

Example 2 with PortalPropertiesConfiguration

use of com.liferay.ide.core.properties.PortalPropertiesConfiguration in project liferay-ide by liferay.

the class PortalServerBehavior method getRuntimeStartVMArguments.

private String[] getRuntimeStartVMArguments() {
    if (!getPortalServer().getLaunchSettings()) {
        File portalext = getPortalRuntime().getLiferayHome().append("portal-ext.properties").toFile();
        if (getPortalServer().getDeveloperMode()) {
            try {
                if (!portalext.exists()) {
                    portalext.createNewFile();
                }
                final PortalPropertiesConfiguration config = new PortalPropertiesConfiguration();
                InputStream in = Files.newInputStream(portalext.toPath());
                config.load(in);
                in.close();
                String[] p = config.getStringArray("include-and-override");
                boolean existing = false;
                for (String prop : p) {
                    if (prop.equals("portal-developer.properties")) {
                        existing = true;
                        break;
                    }
                }
                if (!existing) {
                    config.addProperty("include-and-override", "portal-developer.properties");
                }
                config.save(portalext);
            } catch (Exception e) {
                LiferayServerCore.logError(e);
            }
        } else if (portalext.exists()) {
            String contents = FileUtil.readContents(portalext, true);
            contents = contents.replace("include-and-override=portal-developer.properties", "");
            try {
                FileUtils.write(portalext, contents);
            } catch (IOException e) {
                LiferayServerCore.logError(e);
            }
        }
    }
    final List<String> retval = new ArrayList<>();
    Collections.addAll(retval, getPortalServer().getMemoryArgs());
    Collections.addAll(retval, getPortalRuntime().getPortalBundle().getRuntimeStartVMArgs());
    return retval.toArray(new String[0]);
}
Also used : InputStream(java.io.InputStream) PortalPropertiesConfiguration(com.liferay.ide.core.properties.PortalPropertiesConfiguration) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Aggregations

PortalPropertiesConfiguration (com.liferay.ide.core.properties.PortalPropertiesConfiguration)2 ArrayList (java.util.ArrayList)2 PropKey (com.liferay.ide.ui.editor.LiferayPropertiesContentAssistProcessor.PropKey)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PropertiesConfigurationLayout (org.apache.commons.configuration.PropertiesConfigurationLayout)1 CoreException (org.eclipse.core.runtime.CoreException)1