Search in sources :

Example 11 with PortalBundle

use of com.liferay.ide.server.core.portal.PortalBundle 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 12 with PortalBundle

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

the class PortalLanguagePropertiesCacheUtil method getPortalLanguageProperties.

public static Properties getPortalLanguageProperties(ILiferayProject project) {
    if (project == null) {
        return new Properties();
    }
    Properties retval = null;
    JarFile jar = null;
    InputStream in = null;
    try {
        ILiferayPortal portal = project.adapt(ILiferayPortal.class);
        if (portal == null) {
            IRuntime[] runtimes = ServerCore.getRuntimes();
            if (ListUtil.isNotEmpty(runtimes)) {
                for (IRuntime runtime : runtimes) {
                    PortalBundle portalBundle = LiferayServerCore.newPortalBundle(runtime.getLocation());
                    if (portalBundle != null) {
                        portal = portalBundle;
                        break;
                    }
                }
            }
            if (portal == null) {
                return retval;
            }
        }
        IPath appServerPortalDir = portal.getAppServerPortalDir();
        retval = _languagePortalMap.get(appServerPortalDir);
        if (retval == null) {
            if ((appServerPortalDir != null) && appServerPortalDir.toFile().exists()) {
                jar = new JarFile(appServerPortalDir.append("WEB-INF/lib/portal-impl.jar").toFile());
                ZipEntry lang = jar.getEntry("content/Language.properties");
                retval = new Properties();
                in = jar.getInputStream(lang);
                retval.load(in);
            }
            _languagePortalMap.put(appServerPortalDir, retval);
        }
    } catch (Exception e) {
        LiferayXMLSearchUI.logError("Unable to find portal language properties", e);
    } finally {
        try {
            if (in != null) {
                in.close();
            }
            if (jar != null) {
                jar.close();
            }
        } catch (IOException ioe) {
        // no errors this is best effort
        }
    }
    return retval;
}
Also used : PortalBundle(com.liferay.ide.server.core.portal.PortalBundle) IPath(org.eclipse.core.runtime.IPath) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) Properties(java.util.Properties) JarFile(java.util.jar.JarFile) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IOException(java.io.IOException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Aggregations

PortalBundle (com.liferay.ide.server.core.portal.PortalBundle)12 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IPath (org.eclipse.core.runtime.IPath)6 SDK (com.liferay.ide.sdk.core.SDK)3 File (java.io.File)3 JarFile (java.util.jar.JarFile)3 IProject (org.eclipse.core.resources.IProject)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 JarEntry (java.util.jar.JarEntry)2 DebugException (org.eclipse.debug.core.DebugException)2 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)2 Path (org.eclipse.sapphire.modeling.Path)2 IRuntime (org.eclipse.wst.server.core.IRuntime)2 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 PluginType (com.liferay.ide.project.core.model.PluginType)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 ILiferayRuntime (com.liferay.ide.server.core.ILiferayRuntime)1