Search in sources :

Example 31 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class ServerNameChangeTests method setupRuntime.

private String setupRuntime(IPath runtimeZipPath, IPath runitmeDirPath, String runtimeName, IPath runtimUnzipDir, String runtimeId) throws Exception {
    assertEquals("Expected liferayBundlesPath to exist: " + runtimeZipPath.toOSString(), true, runtimeZipPath.toFile().exists());
    extractLiferayRuntime(runtimeZipPath, runtimUnzipDir);
    final NullProgressMonitor npm = new NullProgressMonitor();
    IRuntime findRuntime = ServerCore.findRuntime(runtimeName);
    if (findRuntime == null) {
        final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(runtimeId).createRuntime(runtimeName, npm);
        runtimeWC.setName(runtimeName);
        runtimeWC.setLocation(runitmeDirPath);
        findRuntime = runtimeWC.save(true, npm);
    }
    assertNotNull(findRuntime);
    final PortalRuntime liferayRuntime = (PortalRuntime) ServerCore.findRuntime(runtimeName).loadAdapter(PortalRuntime.class, npm);
    assertNotNull(liferayRuntime);
    return findRuntime.getId();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PortalRuntime(com.liferay.ide.server.core.portal.PortalRuntime) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 32 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class ServerNameChangeTests method setup62Runtime.

private String setup62Runtime(IPath runtimeZipPath, IPath runitmeDirPath, String runtimeName, IPath runtimUnzipDir, String runtimeId) throws Exception {
    assertEquals("Expected liferayBundlesPath to exist: " + runtimeZipPath.toOSString(), true, runtimeZipPath.toFile().exists());
    extractLiferayRuntime(runtimeZipPath, runtimUnzipDir);
    final NullProgressMonitor npm = new NullProgressMonitor();
    IRuntime findRuntime = ServerCore.findRuntime(runtimeName);
    if (findRuntime == null) {
        final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(runtimeId).createRuntime(runtimeName, npm);
        runtimeWC.setName(runtimeName);
        runtimeWC.setLocation(runitmeDirPath);
        findRuntime = runtimeWC.save(true, npm);
    }
    assertNotNull(findRuntime);
    final LiferayTomcatRuntime liferayRuntime = (LiferayTomcatRuntime) ServerCore.findRuntime(runtimeName).loadAdapter(LiferayTomcatRuntime.class, npm);
    assertNotNull(liferayRuntime);
    return findRuntime.getId();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) LiferayTomcatRuntime(com.liferay.ide.server.tomcat.core.LiferayTomcatRuntime) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 33 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class ServerUtil method getRuntime.

public static IRuntimeWorkingCopy getRuntime(String runtimeTypeId, IPath location) {
    IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypeId);
    try {
        // $NON-NLS-1$
        IRuntime runtime = runtimeType.createRuntime("runtime", null);
        IRuntimeWorkingCopy runtimeWC = runtime.createWorkingCopy();
        // $NON-NLS-1$
        runtimeWC.setName("Runtime");
        runtimeWC.setLocation(location);
        return runtimeWC;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 34 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class LiferayTomcatUtil method validateRuntimeStubLocation.

public static IStatus validateRuntimeStubLocation(String runtimeTypeId, IPath runtimeStubLocation) {
    try {
        IRuntimeWorkingCopy runtimeStub = ServerCore.findRuntimeType(runtimeTypeId).createRuntime(null, null);
        runtimeStub.setLocation(runtimeStubLocation);
        runtimeStub.setStub(true);
        return runtimeStub.validate(null);
    } catch (Exception e) {
        return LiferayTomcatPlugin.createErrorStatus(e);
    }
}
Also used : IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) NoSuchFileException(java.nio.file.NoSuchFileException) CoreException(org.eclipse.core.runtime.CoreException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 35 with IRuntimeWorkingCopy

use of org.eclipse.wst.server.core.IRuntimeWorkingCopy in project liferay-ide by liferay.

the class PortalRuntimeWizard method exit.

public void exit() {
    IRuntimeWorkingCopy runtime = (IRuntimeWorkingCopy) getTaskModel().getObject(TaskModel.TASK_RUNTIME);
    IPath path = runtime.getLocation();
    if (runtime.validate(null).getSeverity() != IStatus.ERROR) {
        LiferayServerCore.setPreference("location." + runtime.getRuntimeType().getId(), path.toPortableString());
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy)

Aggregations

IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)41 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)16 IRuntime (org.eclipse.wst.server.core.IRuntime)13 IRuntimeType (org.eclipse.wst.server.core.IRuntimeType)12 CoreException (org.eclipse.core.runtime.CoreException)9 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)9 IServerType (org.eclipse.wst.server.core.IServerType)8 IPath (org.eclipse.core.runtime.IPath)6 IStatus (org.eclipse.core.runtime.IStatus)6 Path (org.eclipse.core.runtime.Path)6 Test (org.junit.Test)6 PortalRuntime (com.liferay.ide.server.core.portal.PortalRuntime)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)2 OverrideFilePath (com.liferay.ide.project.core.modules.fragment.OverrideFilePath)2 HashMap (java.util.HashMap)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 GenericServerRuntime (org.eclipse.jst.server.generic.core.internal.GenericServerRuntime)2 ITomcatRuntimeWorkingCopy (org.eclipse.jst.server.tomcat.core.internal.ITomcatRuntimeWorkingCopy)2