Search in sources :

Example 1 with ILiferayRuntime

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

the class PluginClasspathContainerInitializer method initialize.

@Override
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
    IClasspathContainer classpathContainer = null;
    int count = containerPath.segmentCount();
    if (count != 2) {
        String msg = "Invalid plugin classpath container should expecting 2 segments.";
        throw new CoreException(ProjectCore.createErrorStatus(msg));
    }
    String root = containerPath.segment(0);
    if (!ID.equals(root)) {
        String msg = "Invalid plugin classpath container, expecting container root ";
        throw new CoreException(ProjectCore.createErrorStatus(msg + ID));
    }
    String finalSegment = containerPath.segment(1);
    IPath portalDir = ServerUtil.getPortalDir(project);
    if (portalDir == null) {
        return;
    }
    String javadocURL = null;
    IPath sourceLocation = null;
    try {
        ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project.getProject());
        if (liferayRuntime != null) {
            javadocURL = liferayRuntime.getJavadocURL();
            sourceLocation = liferayRuntime.getSourceLocation();
        }
    } catch (Exception e) {
        ProjectCore.logError(e);
    }
    classpathContainer = getCorrectContainer(containerPath, finalSegment, project, portalDir, javadocURL, sourceLocation);
    IJavaProject[] projects = { project };
    IClasspathContainer[] containers = { classpathContainer };
    JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with ILiferayRuntime

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

the class LiferayTomcatUtil method addRuntimeVMArgments.

public static void addRuntimeVMArgments(List<String> runtimeVMArgs, IPath installPath, IPath configPath, IPath deployPath, boolean isTestEnv, IServer currentServer, ILiferayTomcatServer liferayTomcatServer) {
    // $NON-NLS-1$
    runtimeVMArgs.add("-Dfile.encoding=UTF8");
    // $NON-NLS-1$
    runtimeVMArgs.add("-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false");
    // $NON-NLS-1$
    runtimeVMArgs.add("-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager");
    ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(currentServer);
    Version portalVersion = new Version(getVersion(runtime));
    if (CoreUtil.compareVersions(portalVersion, LiferayTomcatRuntime70.leastSupportedVersion) < 0) {
        // $NON-NLS-1$ //$NON-NLS-2$
        runtimeVMArgs.add("-Djava.security.auth.login.config=\"" + configPath.toOSString() + "/conf/jaas.config\"");
    } else {
        // $NON-NLS-1$
        runtimeVMArgs.add("-Djava.net.preferIPv4Stack=true");
    }
    runtimeVMArgs.add(// $NON-NLS-1$
    "-Djava.util.logging.config.file=\"" + installPath.toOSString() + // $NON-NLS-1$
    "/conf/logging.properties\"");
    // $NON-NLS-1$ //$NON-NLS-2$
    runtimeVMArgs.add("-Djava.io.tmpdir=\"" + installPath.toOSString() + "/temp\"");
    final boolean useDefaultPortalServerSettings = liferayTomcatServer.getUseDefaultPortalServerSettings();
    if (useDefaultPortalServerSettings) {
        addUserDefaultVMArgs(runtimeVMArgs);
    } else {
        addUserVMArgs(runtimeVMArgs, currentServer, liferayTomcatServer);
        File externalPropertiesFile = getExternalPropertiesFile(installPath, configPath, currentServer, liferayTomcatServer);
        runtimeVMArgs.add("-Dexternal-properties=\"" + externalPropertiesFile.getAbsolutePath() + "\"");
    }
}
Also used : Version(org.osgi.framework.Version) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 3 with ILiferayRuntime

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

the class LiferayTomcatServer method getDefaultServerMode.

public int getDefaultServerMode() {
    int defaultServerMode = ILiferayTomcatConstants.STANDARD_SERVER_MODE;
    try {
        String version = LiferayTomcatUtil.getVersion(((ILiferayRuntime) getServer().getRuntime()));
        Version portalVersion = Version.parseVersion(version);
        if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V620) < 0) {
            defaultServerMode = ILiferayTomcatConstants.DEVELOPMENT_SERVER_MODE;
        }
    } catch (Exception e) {
    }
    return defaultServerMode;
}
Also used : Version(org.osgi.framework.Version) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) CoreException(org.eclipse.core.runtime.CoreException) MalformedURLException(java.net.MalformedURLException)

Example 4 with ILiferayRuntime

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

the class WorkflowValidationProxy method getProxyClasspath.

@SuppressWarnings("deprecation")
protected URL[] getProxyClasspath() throws CoreException {
    List<URL> scriptUrlList = new ArrayList<>();
    IRuntime serverRuntime = _runtime;
    if (serverRuntime == null) {
        throw new CoreException(KaleoCore.createErrorStatus("Could not get server runtime."));
    }
    ILiferayRuntime liferayRuntime = (ILiferayRuntime) serverRuntime.loadAdapter(ILiferayRuntime.class, null);
    IPath appServerPortalDir = liferayRuntime.getAppServerPortalDir();
    IPath appServerPortalLibDir = appServerPortalDir.append("WEB-INF/lib");
    File libFolder = appServerPortalLibDir.toFile();
    FilenameFilter fileNameFilter = new FilenameFilter() {

        public boolean accept(File dir, String name) {
            if (name.endsWith(".jar") && (name.contains("dom4j") || name.contains("xercesImpl") || name.contains("portal-impl") || name.contains("util-java") || name.contains("commons-lang"))) {
                return true;
            }
            return false;
        }
    };
    String[] libs = libFolder.list(fileNameFilter);
    for (String lib : libs) {
        File libJar = new File(libFolder, lib);
        if (FileUtil.exists(libJar)) {
            try {
                scriptUrlList.add(libJar.toURL());
            } catch (MalformedURLException murle) {
            }
        }
    }
    IPath runtimePath = _runtime.getLocation();
    IPath kaleoWebServiceJarDir = runtimePath.append("webapps/kaleo-designer-portlet/WEB-INF/lib/kaleo-web-service.jar");
    IPath portalServiceJarDir = runtimePath.append("lib/ext/portal-service.jar");
    File[] jars = { kaleoWebServiceJarDir.toFile(), portalServiceJarDir.toFile() };
    for (File jar : jars) {
        if (FileUtil.exists(jar)) {
            try {
                scriptUrlList.add(jar.toURL());
            } catch (MalformedURLException murle) {
            }
        }
    }
    IPath classesDir = runtimePath.append("webapps/kaleo-web/WEB-INF/classes/");
    File parserDir = classesDir.toFile();
    if (FileUtil.exists(parserDir)) {
        try {
            scriptUrlList.add(parserDir.toURL());
        } catch (Exception e) {
        }
    }
    return scriptUrlList.toArray(new URL[0]);
}
Also used : MalformedURLException(java.net.MalformedURLException) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) IRuntime(org.eclipse.wst.server.core.IRuntime) FilenameFilter(java.io.FilenameFilter) CoreException(org.eclipse.core.runtime.CoreException) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) File(java.io.File)

Example 5 with ILiferayRuntime

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

the class WorkflowValidationProxy method getGroovyFile.

protected File getGroovyFile() throws Exception {
    Object loadAdapter = _runtime.loadAdapter(ILiferayRuntime.class, null);
    ILiferayRuntime liferayRuntime = (ILiferayRuntime) loadAdapter;
    KaleoCore kaleoCore = KaleoCore.getDefault();
    if (liferayRuntime != null) {
        Version version = new Version(liferayRuntime.getPortalVersion());
        Bundle bundle = kaleoCore.getBundle();
        URL bundleURL = FileLocator.toFileURL(bundle.getEntry(_getGroovyWorkflowValidationScript(version)));
        return new File(bundleURL.getFile());
    }
    IStatus error = KaleoCore.createErrorStatus("Unable to locate groovy script");
    ILog log = kaleoCore.getLog();
    log.log(error);
    throw new CoreException(error);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) Version(org.osgi.framework.Version) Bundle(org.osgi.framework.Bundle) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) ILog(org.eclipse.core.runtime.ILog) KaleoCore(com.liferay.ide.kaleo.core.KaleoCore) File(java.io.File) URL(java.net.URL)

Aggregations

ILiferayRuntime (com.liferay.ide.server.core.ILiferayRuntime)18 CoreException (org.eclipse.core.runtime.CoreException)10 File (java.io.File)9 IPath (org.eclipse.core.runtime.IPath)7 Version (org.osgi.framework.Version)6 IRuntime (org.eclipse.wst.server.core.IRuntime)5 URL (java.net.URL)4 ArrayList (java.util.ArrayList)3 JarFile (java.util.jar.JarFile)3 IStatus (org.eclipse.core.runtime.IStatus)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IServer (org.eclipse.wst.server.core.IServer)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 Path (org.eclipse.core.runtime.Path)2 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)2 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1