Search in sources :

Example 6 with IModule

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

the class SlingContentModuleAdapterTest method projectMembersContainContentXmlFirst.

@Test
public void projectMembersContainContentXmlFirst() throws Exception {
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
    // install bundle facet
    project.installFacet("sling.content", "1.0");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/1_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/2_folder/filler.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/3_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/4_folder/filler.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/5_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/.content.xml"), new ByteArrayInputStream(new byte[0]));
    IModule module = ServerUtil.getModule(contentProject);
    SlingContentModuleFactory moduleFactory = new SlingContentModuleFactory();
    ModuleDelegate moduleDelegate = moduleFactory.getModuleDelegate(module);
    IModuleResource[] members = moduleDelegate.members();
    assertThat("members[0].path", members[0].getModuleRelativePath().toPortableString(), equalTo(""));
    assertThat("members[1].path", members[1].getModuleRelativePath().toPortableString(), equalTo("content"));
    assertThat("members[2].path", members[2].getModuleRelativePath().toPortableString(), equalTo("content/.content.xml"));
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) ModuleDelegate(org.eclipse.wst.server.core.model.ModuleDelegate) IProject(org.eclipse.core.resources.IProject) SlingContentModuleFactory(org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory) Test(org.junit.Test)

Example 7 with IModule

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

the class ServerBehaviourDelegateWithModulePublishSupport method computeDelta.

// from WST's ServerBehavior
private List<Integer> computeDelta(final List<IModule[]> moduleList) {
    final List<Integer> deltaKindList = new ArrayList<>();
    final Iterator<IModule[]> iterator = moduleList.iterator();
    while (iterator.hasNext()) {
        IModule[] module = iterator.next();
        if (hasBeenPublished(module)) {
            IModule m = module[module.length - 1];
            if ((m.getProject() != null && !m.getProject().isAccessible()) || getPublishedResourceDelta(module).length == 0) {
                deltaKindList.add(new Integer(ServerBehaviourDelegate.NO_CHANGE));
            } else {
                deltaKindList.add(new Integer(ServerBehaviourDelegate.CHANGED));
            }
        } else {
            deltaKindList.add(new Integer(ServerBehaviourDelegate.ADDED));
        }
    }
    //        }
    return deltaKindList;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList)

Example 8 with IModule

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

the class ServerUtil method getAllServers.

private static Set<IServer> getAllServers(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;
    }
    Set<IServer> result = new HashSet<>();
    IServer defaultServer = ServerCore.getDefaultServer(module);
    if (defaultServer != null) {
        result.add(defaultServer);
    }
    IServer[] allServers = ServerCore.getServers();
    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)) {
                result.add(aServer);
                break;
            }
        }
    }
    return result;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) HashSet(java.util.HashSet)

Example 9 with IModule

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

the class SelectionUtils method getServersLinkedToProject.

public static List<IServer> getServersLinkedToProject(IProject project, IProgressMonitor monitor) {
    if (project == null) {
        return Collections.emptyList();
    }
    List<IServer> servers = new ArrayList<>();
    IModule[] modules = ServerUtil.getModules(project);
    for (IServer server : ServerCore.getServers()) {
        for (IModule module : modules) {
            if (ServerUtil.containsModule(server, module, monitor)) {
                servers.add(server);
            }
        }
    }
    return servers;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList)

Example 10 with IModule

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

the class AbstractNewSlingApplicationWizard method publishModules.

protected void publishModules(final List<IProject> createdProjects, IProgressMonitor monitor) throws CoreException {
    IServer server = setupServerWizardPage.getOrCreateServer(monitor);
    if (server == null) {
        return;
    }
    if (setupServerWizardPage.getStartServer()) {
        server.start(ILaunchManager.RUN_MODE, monitor);
    }
    List<IModule[]> modules = new ArrayList<>();
    for (IProject project : createdProjects) {
        IModule module = ServerUtil.getModule(project);
        if (module != null && shouldDeploy(module)) {
            modules.add(new IModule[] { module });
        }
    }
    if (modules.size() > 0) {
        server.publish(IServer.PUBLISH_CLEAN, modules, null, null);
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject)

Aggregations

IModule (org.eclipse.wst.server.core.IModule)12 IProject (org.eclipse.core.resources.IProject)6 IServer (org.eclipse.wst.server.core.IServer)6 ArrayList (java.util.ArrayList)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SlingContentModuleFactory (org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory)2 JcrNode (org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)2 ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)2 IResource (org.eclipse.core.resources.IResource)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ISelection (org.eclipse.jface.viewers.ISelection)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2 ModuleDelegate (org.eclipse.wst.server.core.model.ModuleDelegate)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1