Search in sources :

Example 1 with PortalBundleFactory

use of com.liferay.ide.server.core.portal.PortalBundleFactory in project liferay-ide by liferay.

the class ServerUtil method getPortalBundle.

public static PortalBundle getPortalBundle(IProject project) throws CoreException {
    SDK sdk = SDKUtil.getSDKFromProjectDir(project.getLocation().toFile());
    if (sdk == null || !sdk.validate().isOK()) {
        return null;
    }
    final Map<String, Object> appServerProperties = sdk.getBuildProperties();
    final String appServerType = (String) (appServerProperties.get("app.server.type"));
    PortalBundleFactory factory = LiferayServerCore.getPortalBundleFactories(appServerType);
    if (factory != null) {
        final IPath path = factory.canCreateFromPath(appServerProperties);
        if (path != null) {
            PortalBundle bundle = factory.create(path);
            return bundle;
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) PortalBundle(com.liferay.ide.server.core.portal.PortalBundle) SDK(com.liferay.ide.sdk.core.SDK) PortalBundleFactory(com.liferay.ide.server.core.portal.PortalBundleFactory)

Example 2 with PortalBundleFactory

use of com.liferay.ide.server.core.portal.PortalBundleFactory in project liferay-ide by liferay.

the class LiferayServerCore method getPortalBundleFactories.

public static PortalBundleFactory[] getPortalBundleFactories() {
    if (portalBundleFactories == null) {
        final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(PortalBundleFactory.EXTENSION_ID);
        try {
            final List<PortalBundleFactory> bundleFactories = new ArrayList<PortalBundleFactory>();
            for (IConfigurationElement element : elements) {
                final Object o = element.createExecutableExtension("class");
                if (o instanceof PortalBundleFactory) {
                    AbstractPortalBundleFactory portalBundleFactory = (AbstractPortalBundleFactory) o;
                    portalBundleFactory.setBundleFactoryType(element.getAttribute("type"));
                    bundleFactories.add(portalBundleFactory);
                }
            }
            portalBundleFactories = bundleFactories.toArray(new PortalBundleFactory[0]);
        } catch (Exception e) {
            // $NON-NLS-1$
            logError("Unable to get PortalBundleFactory extensions", e);
        }
    }
    return portalBundleFactories;
}
Also used : ArrayList(java.util.ArrayList) PortalBundleFactory(com.liferay.ide.server.core.portal.PortalBundleFactory) AbstractPortalBundleFactory(com.liferay.ide.server.core.portal.AbstractPortalBundleFactory) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) AbstractPortalBundleFactory(com.liferay.ide.server.core.portal.AbstractPortalBundleFactory) BackingStoreException(org.osgi.service.prefs.BackingStoreException) IOException(java.io.IOException)

Aggregations

PortalBundleFactory (com.liferay.ide.server.core.portal.PortalBundleFactory)2 SDK (com.liferay.ide.sdk.core.SDK)1 AbstractPortalBundleFactory (com.liferay.ide.server.core.portal.AbstractPortalBundleFactory)1 PortalBundle (com.liferay.ide.server.core.portal.PortalBundle)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IPath (org.eclipse.core.runtime.IPath)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1