use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.
the class PortalPublishTask method getTasks.
@SuppressWarnings("rawtypes")
public PublishOperation[] getTasks(IServer server, int kind, List modules, List kindList) {
List<BundlePublishOperation> tasks = new ArrayList<BundlePublishOperation>();
PortalServerBehavior serverBehavior = (PortalServerBehavior) server.loadAdapter(PortalServerBehavior.class, null);
if (ListUtil.isNotEmpty(modules)) {
final int size = modules.size();
for (int i = 0; i < size; i++) {
IModule[] module = (IModule[]) modules.get(i);
Integer deltaKind = (Integer) kindList.get(i);
boolean needClean = false;
IModuleResourceDelta[] deltas = ((Server) server).getPublishedResourceDelta(module);
for (IModuleResourceDelta delta : deltas) {
final IModuleResource resource = delta.getModuleResource();
final IFile resourceFile = (IFile) resource.getAdapter(IFile.class);
if (resourceFile != null && resourceFile.getName().equals("bnd.bnd")) {
needClean = true;
break;
}
}
switch(kind) {
case IServer.PUBLISH_FULL:
case IServer.PUBLISH_INCREMENTAL:
case IServer.PUBLISH_AUTO:
final IProject project = module[0].getProject();
switch(deltaKind) {
case ServerBehaviourDelegate.ADDED:
addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
break;
case ServerBehaviourDelegate.CHANGED:
if (needClean) {
addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
} else {
addOperation(BundlePublishFullAdd.class, tasks, server, module);
}
break;
case ServerBehaviourDelegate.REMOVED:
addOperation(BundlePublishFullRemove.class, tasks, server, module);
break;
case ServerBehaviourDelegate.NO_CHANGE:
final IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, project);
if (bundleProject != null) {
try {
if (isUserRedeploy(serverBehavior, module[0]) || !isDeployed(server, serverBehavior, bundleProject.getSymbolicName())) {
addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
}
} catch (CoreException e) {
LiferayServerCore.logError("Unable to get bsn for project " + project.getName(), e);
}
}
break;
default:
break;
}
break;
default:
break;
}
}
}
return tasks.toArray(new PublishOperation[0]);
}
use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.
the class ServerUtil method deleteRuntimeAndServer.
public static void deleteRuntimeAndServer(String runtimeType, File portalBundle) throws Exception {
IRuntime[] runtimes = ServerCore.getRuntimes();
IRuntime targetRuntime = null;
for (IRuntime runtime : runtimes) {
if (runtime.getRuntimeType().getId().equals(runtimeType)) {
File runtimeFile = runtime.getLocation().toFile();
if (runtimeFile.getCanonicalFile().equals(portalBundle)) {
targetRuntime = runtime;
}
}
}
if (targetRuntime != null) {
IServer[] servers = ServerCore.getServers();
for (IServer server : servers) {
IRuntime runtime = server.getRuntime();
if (runtime != null && runtime.equals(targetRuntime)) {
server.delete();
}
}
targetRuntime.delete();
}
}
use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.
the class PortalSourcePathComputerDelegate method computeSourceContainers.
@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
final List<ISourceContainer> sourceContainers = new ArrayList<ISourceContainer>();
final IServer server = ServerUtil.getServer(configuration);
IWorkspaceProject workspaceProject = LiferayCore.create(IWorkspaceProject.class, server);
if (workspaceProject != null) {
addSourceContainers(configuration, monitor, sourceContainers, workspaceProject.getProject());
}
Stream.of(server.getModules()).map(module -> LiferayCore.create(module.getProject())).filter(liferayProject -> liferayProject != null).forEach(liferayProject -> addSourceContainers(configuration, monitor, sourceContainers, liferayProject.getProject()));
return sourceContainers.toArray(new ISourceContainer[0]);
}
use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.
the class RemoteServerWizardFragment method performFinish.
@Override
public void performFinish(IProgressMonitor monitor) throws CoreException {
try {
this.wizard.run(false, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (lastServerStatus == null || (!lastServerStatus.isOK())) {
lastServerStatus = getRemoteServerWC().validate(monitor);
if (!lastServerStatus.isOK()) {
throw new InterruptedException(lastServerStatus.getMessage());
}
}
}
});
} catch (Exception e) {
}
ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {
String id = getServerWorkingCopy().getId();
public void serverAdded(final IServer server) {
if (server.getId().equals(id)) {
UIUtil.async(new Runnable() {
public void run() {
// $NON-NLS-1$
IViewPart serversView = UIUtil.showView("org.eclipse.wst.server.ui.ServersView");
CommonViewer viewer = (CommonViewer) serversView.getAdapter(CommonViewer.class);
viewer.setSelection(new StructuredSelection(server));
}
});
ServerCore.removeServerLifecycleListener(this);
server.addServerListener(new IServerListener() {
public void serverChanged(ServerEvent event) {
if (event.getServer().getServerState() == IServer.STATE_STARTED) {
server.publish(IServer.PUBLISH_INCREMENTAL, null, null, null);
server.removeServerListener(this);
}
}
});
}
}
public void serverChanged(IServer server) {
}
public void serverRemoved(IServer server) {
}
});
}
use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.
the class OpenLiferayHomeFolderHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
List selectedObj = ((IStructuredSelection) selection).toList();
if ((selectedObj.size() == 1) && (selectedObj.get(0) instanceof IServer)) {
final IServer server = (IServer) selectedObj.get(0);
final IPath path = ServerUtil.getLiferayRuntime(server.getRuntime()).getAppServerDir();
try {
ServerUIUtil.openFileInSystemExplorer(path);
} catch (IOException e) {
LiferayServerUI.logError("Error opening portal home folder.", e);
}
}
}
return null;
}
Aggregations