Search in sources :

Example 1 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class SlingLaunchpadCombo method getErrorMessage.

public String getErrorMessage(ValidationFlag... flags) {
    if (!hasServers() && project != null) {
        return "The selected project is not configured with/added to any Sling server";
    }
    IServer server = getServer();
    if (server == null) {
        return "Please select a repository";
    }
    Set<ValidationFlag> flagSet = flags.length == 0 ? EnumSet.noneOf(ValidationFlag.class) : EnumSet.copyOf(asList(flags));
    if (!flagSet.contains(ValidationFlag.SKIP_SERVER_STARTED)) {
        if (server.getServerState() != IServer.STATE_STARTED) {
            return "Selected server is not started";
        }
    }
    return null;
}
Also used : IServer(org.eclipse.wst.server.core.IServer)

Example 2 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class ServerUtil method getDefaultServer.

private static IServer getDefaultServer(IProject project) {
    IModule module = org.eclipse.wst.server.core.ServerUtil.getModule(project);
    if (module == null) {
        // is what we need to create a RepositoryInfo
        return null;
    }
    IServer server = ServerCore.getDefaultServer(module);
    if (server != null) {
        return server;
    }
    // then we cannot create a repository
    IServer[] allServers = ServerCore.getServers();
    out: for (int i = 0; i < allServers.length; i++) {
        IServer aServer = allServers[i];
        IModule[] allModules = aServer.getModules();
        for (int j = 0; j < allModules.length; j++) {
            IModule aMoudle = allModules[j];
            if (aMoudle.equals(module)) {
                server = aServer;
                break out;
            }
        }
    }
    return server;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer)

Example 3 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class ServerUtil method triggerIncrementalBuild.

public static void triggerIncrementalBuild(IResource anyResourceInThatProject, IProgressMonitor monitorOrNull) {
    if (anyResourceInThatProject == null) {
        throw new IllegalArgumentException("anyResourceInThatProject must not be null");
    }
    IProject proj = anyResourceInThatProject.getProject();
    if (proj == null) {
        throw new IllegalStateException("no project found for " + anyResourceInThatProject);
    }
    Set<IServer> servers = getAllServers(proj);
    if (servers != null) {
        if (monitorOrNull == null) {
            monitorOrNull = new NullProgressMonitor();
        }
        for (IServer server : servers) {
            if (server != null) {
                int autoPublishSetting = server.getAttribute(PROP_AUTO_PUBLISH_SETTING, AUTO_PUBLISH_RESOURCE);
                int autoPublishTime = server.getAttribute(PROP_AUTO_PUBLISH_TIME, 15);
                if (autoPublishSetting == AUTO_PUBLISH_RESOURCE) {
                    //TODO: ignoring the autoPublishTime - SLING-3587
                    server.publish(IServer.PUBLISH_INCREMENTAL, monitorOrNull);
                }
            }
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IProject(org.eclipse.core.resources.IProject)

Example 4 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class AbstractNewSlingApplicationWizard method deployProjectsOnServer.

protected void deployProjectsOnServer(Projects projects, IProgressMonitor monitor) throws CoreException {
    IServer server = setupServerWizardPage.getOrCreateServer(monitor);
    if (server == null) {
        monitor.done();
        return;
    }
    advance(monitor, 1);
    IServerWorkingCopy wc = server.createWorkingCopy();
    // add the bundle and content projects, ie modules, to the server
    List<IModule> modules = new LinkedList<>();
    for (IProject project : projects.getBundleProjects()) {
        IModule module = ServerUtil.getModule(project);
        if (module != null && shouldDeploy(module)) {
            modules.add(module);
        }
    }
    for (IProject project : projects.getContentProjects()) {
        IModule module = ServerUtil.getModule(project);
        if (module != null && shouldDeploy(module)) {
            modules.add(module);
        }
    }
    wc.modifyModules(modules.toArray(new IModule[modules.size()]), new IModule[0], monitor);
    wc.save(true, monitor);
    advance(monitor, 2);
    monitor.done();
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy) LinkedList(java.util.LinkedList) IProject(org.eclipse.core.resources.IProject)

Example 5 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class ApplyDefaultSlingServerValuesFragment method performFinish.

@Override
public void performFinish(IProgressMonitor monitor) throws CoreException {
    IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
    if (server instanceof IServerWorkingCopy) {
        IServerWorkingCopy wc = (IServerWorkingCopy) server;
        SlingLaunchpadConfigurationDefaults.applyDefaultValues(wc);
        wc.save(true, monitor);
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IServerWorkingCopy(org.eclipse.wst.server.core.IServerWorkingCopy)

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