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