Example usage for com.liferay.portal.kernel.plugin PluginPackage getName

List of usage examples for com.liferay.portal.kernel.plugin PluginPackage getName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.plugin PluginPackage getName.

Prototype

public String getName();

Source Link

Usage

From source file:com.liferay.marketplace.service.impl.AppLocalServiceImpl.java

License:Open Source License

@Override
public List<App> getInstalledApps() {
    if (_installedApps != null) {
        return _installedApps;
    }//from   w  ww. ja va 2s  .c  o  m

    List<App> installedApps = new ArrayList<App>();

    // Core app

    App coreApp = appPersistence.create(0);

    coreApp.setTitle("Liferay Core");
    coreApp.setDescription("Plugins bundled with Liferay Portal.");
    coreApp.setVersion(ReleaseInfo.getVersion());

    coreApp.addContextName(PortalUtil.getPathContext());

    installedApps.add(coreApp);

    // Deployed apps

    List<PluginPackage> pluginPackages = DeployManagerUtil.getInstalledPluginPackages();

    for (PluginPackage pluginPackage : pluginPackages) {
        List<Module> modules = modulePersistence.findByContextName(pluginPackage.getContext());

        boolean installedApp = false;

        for (Module module : modules) {
            App app = appPersistence.fetchByPrimaryKey(module.getAppId());

            if ((app != null) && app.isInstalled()) {
                installedApp = true;

                break;
            }
        }

        if (installedApp) {
            continue;
        }

        App app = appPersistence.create(0);

        app.setTitle(pluginPackage.getName());
        app.setDescription(pluginPackage.getLongDescription());
        app.setVersion(pluginPackage.getVersion());

        app.addContextName(pluginPackage.getContext());

        installedApps.add(app);
    }

    // Marketplace apps

    List<App> apps = appPersistence.findAll();

    for (App app : apps) {
        if (app.isInstalled()) {
            installedApps.add(app);
        }
    }

    installedApps = ListUtil.sort(installedApps, new AppTitleComparator());

    _installedApps = installedApps;

    return _installedApps;
}