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;
}
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;
}
}
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);
}
}
}
}
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());
}
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);
}
}
Aggregations