Search in sources :

Example 6 with IServer

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

the class CleanAppServerJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    IStatus retval = Status.OK_STATUS;
    if (monitor != null) {
        monitor.beginTask(Msgs.runningCleanAppServerTask, IProgressMonitor.UNKNOWN);
    }
    try {
        final String appServerDir = ServerUtil.getPortalBundle(project).getAppServerDir().toOSString();
        IServer[] servers = ServerCore.getServers();
        for (IServer server : servers) {
            String mode = server.getServerState() == IServer.STATE_STARTED ? server.getMode() : null;
            if (mode != null) {
                if (server.getRuntime().getLocation().toOSString().equals(appServerDir))
                    LiferayTomcatUtil.syncStopServer(server);
            }
        }
        IStatus status = getSDK().cleanAppServer(project, bundleZipLocation, appServerDir, monitor);
        assertStatus(status);
        for (IServer server : servers) {
            // need to mark all other server modules at needing republishing since ext will wipe out webapps folder
            IModule[] modules = server.getModules();
            for (IModule mod : modules) {
                IModule[] m = new IModule[] { mod };
                ((LiferayTomcatServerBehavior) server.loadAdapter(LiferayTomcatServerBehavior.class, monitor)).setModulePublishState2(m, IServer.PUBLISH_STATE_FULL);
            }
        }
    } catch (Exception ex) {
        retval = LiferayTomcatPlugin.createErrorStatus(ex);
    }
    if (monitor != null) {
        monitor.done();
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) LiferayTomcatServerBehavior(com.liferay.ide.server.tomcat.core.LiferayTomcatServerBehavior) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with IServer

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

the class LiferayServerModuleLabelDecorator method decorateImage.

@Override
public Image decorateImage(Image image, Object element) {
    try {
        IModule module = null;
        Image bundleImage = image;
        if (element instanceof IModule) {
            module = (IModule) element;
        } else if (element instanceof ModuleServer) {
            IModule[] modules = ((ModuleServer) element).module;
            module = modules[modules.length - 1];
            ModuleServer portalServer = (ModuleServer) element;
            IServer server = portalServer.getServer();
            IServerType serverType = server.getServerType();
            if (serverType.getRuntimeType().getId().equals("com.liferay.ide.server.portal.runtime")) {
                bundleImage = getBundleModuleImage();
            }
        }
        if (module == null) {
            return null;
        }
        IProject project = module.getProject();
        if (project == null) {
            return null;
        }
        IMarker[] markers = project.findMarkers(LiferayServerCore.BUNDLE_OUTPUT_ERROR_MARKER_TYPE, false, 0);
        if (ListUtil.isNotEmpty(markers)) {
            bundleImage = BundlesImages.IMG_BUNDLE_ERROR;
        }
        return PlatformUI.getWorkbench().getDecoratorManager().decorateImage(bundleImage, project);
    } catch (Exception e) {
        return null;
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) IServerType(org.eclipse.wst.server.core.IServerType) IMarker(org.eclipse.core.resources.IMarker) Image(org.eclipse.swt.graphics.Image) IProject(org.eclipse.core.resources.IProject)

Example 8 with IServer

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

the class CreateNewLiferayServerAction method run.

@Override
public void run(IAction action) {
    final ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
    if (selection instanceof IStructuredSelection) {
        final IStructuredSelection sSelection = (IStructuredSelection) selection;
        final Object element = sSelection.getFirstElement();
        if (element instanceof IFolder) {
            final IFolder folder = (IFolder) element;
            final String[] serverName = new String[] { folder.getName() };
            final IPath location = folder.getRawLocation();
            final List<IRuntime> runtimes = Arrays.asList(ServerCore.getRuntimes());
            while (runtimes.stream().anyMatch(r -> r.getName().equals(serverName[0]))) {
                serverName[0] = serverName[0] + "Extra";
            }
            final List<IServer> servers = Arrays.asList(ServerCore.getServers());
            while (servers.stream().anyMatch(s -> s.getName().equals(serverName[0]))) {
                serverName[0] = serverName[0] + "Extra";
            }
            try {
                ServerUtil.addPortalRuntimeAndServer(serverName[0], location, new NullProgressMonitor());
            } catch (CoreException e) {
                LiferayServerUI.logError("Unable to add server at specified location", e);
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IPath(org.eclipse.core.runtime.IPath) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRuntime(org.eclipse.wst.server.core.IRuntime) CoreException(org.eclipse.core.runtime.CoreException) ISelection(org.eclipse.jface.viewers.ISelection) IFolder(org.eclipse.core.resources.IFolder)

Example 9 with IServer

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

the class AllBladeSamplesPublishTest method importAllBladeSamples.

@BeforeClass
public static void importAllBladeSamples() throws Exception {
    Util.deleteAllWorkspaceProjects();
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    File projectDir = copyTestProjectToWorkspace("projects/all-blade-samples");
    op.setWorkspaceLocation(projectDir.getCanonicalPath());
    op.setProvisionLiferayBundle(true);
    op.setServerName(WORKSPACE_SERVER_NAME);
    final NullProgressMonitor monitor = new NullProgressMonitor();
    op.execute(ProgressMonitorBridge.create(monitor));
    Util.waitForBuildAndValidation();
    IProject rootProject = CoreUtil.getWorkspaceRoot().getProject("all-blade-samples");
    assertNotNull(rootProject);
    assertTrue(rootProject.exists());
    assertLiferayProject("blade.portlet.jsp");
    assertLiferayProject("blade.gogo");
    IServer wsServer = ServerUtil.getServer(WORKSPACE_SERVER_NAME);
    assertNotNull(wsServer);
    long timeoutExpiredMs = System.currentTimeMillis() + 300000;
    wsServer.start("run", monitor);
    while (true) {
        assertEquals(wsServer.getServerState(), IServer.STATE_STARTING, wsServer.getServerState());
        Thread.sleep(500);
        if (wsServer.getServerState() == IServer.STATE_STARTED || System.currentTimeMillis() >= timeoutExpiredMs) {
            break;
        }
    }
    assertEquals(wsServer.getServerState(), IServer.STATE_STARTED, wsServer.getServerState());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) File(java.io.File) IProject(org.eclipse.core.resources.IProject) BeforeClass(org.junit.BeforeClass)

Example 10 with IServer

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

the class AllBladeSamplesPublishTest method testPublishAllBladeSamples.

@Test
public void testPublishAllBladeSamples() throws Exception {
    IServer server = ServerUtil.getServer(WORKSPACE_SERVER_NAME);
    IServerWorkingCopy serverWC = server.createWorkingCopy();
    List<IProject> bladeProjects = getAllBladeProjects();
    List<IModule> modules = new ArrayList<>();
    for (IProject bladeProject : bladeProjects) {
        final String name = bladeProject.getName();
        IModule module = new Module(null, name, name, "liferay.bundle", "1.0", bladeProject);
        modules.add(module);
    }
    IProgressMonitor monitor = new NullProgressMonitor();
    serverWC.modifyModules(modules.toArray(new IModule[0]), null, monitor);
    server = serverWC.save(true, monitor);
    Util.waitForBuildAndValidation();
    IModule[] serverModules = server.getModules();
    assertEquals(35, serverModules.length);
    String[] retval = BladeCLI.execute("sh lb -s blade");
    for (IModule serverModule : serverModules) {
        IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, serverModule.getProject());
        String bsn = bundleProject.getSymbolicName();
        boolean foundBundle = false;
        for (String bundleString : retval) {
            if (bundleString.contains(bsn)) {
                foundBundle = true;
                if (!bundleString.contains("blade.hook.jsp")) {
                    assertTrue("Error in bundle state: " + bundleString, bundleString.contains("Active"));
                } else {
                    assertTrue("Error in bundle state: " + bundleString, bundleString.contains("Resolved"));
                }
                break;
            }
        }
        assertTrue(foundBundle);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) IBundleProject(com.liferay.ide.core.IBundleProject) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) Module(org.eclipse.wst.server.core.internal.Module) IModule(org.eclipse.wst.server.core.IModule) Test(org.junit.Test)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8