Example usage for com.liferay.portal.kernel.util StringPool ISO_8859_1

List of usage examples for com.liferay.portal.kernel.util StringPool ISO_8859_1

Introduction

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

Prototype

String ISO_8859_1

To view the source code for com.liferay.portal.kernel.util StringPool ISO_8859_1.

Click Source Link

Usage

From source file:com.liferay.marketplace.internal.lpkg.deployer.LPKGDeployerRegistrar.java

License:Open Source License

private void _register(Bundle lpkgBundle, List<Bundle> bundles) throws Exception {

    URL url = lpkgBundle.getEntry("liferay-marketplace.properties");

    Properties properties = PropertiesUtil.load(url.openStream(), StringPool.ISO_8859_1);

    long remoteAppId = GetterUtil.getLong(properties.getProperty("remote-app-id"));
    String version = properties.getProperty("version");

    if ((remoteAppId <= 0) || Validator.isNull(version)) {
        return;//from  w  w w.  ja  va  2  s  .c o  m
    }

    String title = properties.getProperty("title");
    String description = properties.getProperty("description");
    String category = properties.getProperty("category");
    String iconURL = properties.getProperty("icon-url");
    boolean required = GetterUtil.getBoolean(properties.getProperty("required"));

    App app = _appLocalService.updateApp(0, remoteAppId, title, description, category, iconURL, version,
            required, null);

    _moduleLocalService.deleteModules(app.getAppId());

    if (!bundles.isEmpty()) {
        for (Bundle bundle : bundles) {
            Dictionary<String, String> headers = bundle.getHeaders();

            String contextName = ContextUtil
                    .getContextName(GetterUtil.getString(headers.get("Web-ContextPath")));

            _moduleLocalService.addModule(app.getAppId(), bundle.getSymbolicName(),
                    String.valueOf(bundle.getVersion()), contextName);
        }
    } else {
        String[] bundleStrings = StringUtil.split(properties.getProperty("bundles"));

        for (String bundleString : bundleStrings) {
            String[] bundleStringParts = StringUtil.split(bundleString, CharPool.POUND);

            String bundleSymbolicName = bundleStringParts[0];
            String bundleVersion = bundleStringParts[1];
            String contextName = bundleStringParts[2];

            _moduleLocalService.addModule(app.getAppId(), bundleSymbolicName, bundleVersion, contextName);
        }

        String[] contextNames = StringUtil.split(properties.getProperty("context-names"));

        for (String contextName : contextNames) {
            _moduleLocalService.addModule(app.getAppId(), contextName, StringPool.BLANK, contextName);
        }
    }
}