use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.servertools by eclipse.
the class AbstractTomcatServerTestCase method verifyPublishedModuleFiles.
protected void verifyPublishedModuleFiles(IModule module) throws Exception {
File moduleDir = new File(getTomcatServerBehaviour().getModuleDeployDirectory(module).toOSString());
assertTrue("Module " + module.getName() + " root directory doesn't exist: " + moduleDir.getPath(), moduleDir.exists());
IModuleResource[] resources = ((Server) getServer()).getResources(new IModule[] { module });
for (int i = 0; i < resources.length; i++) {
if (resources[i] instanceof IModuleFolder) {
verifyPublishedModuleFolder(moduleDir, (IModuleFolder) resources[i]);
} else {
String path = resources[i].getModuleRelativePath().append(resources[i].getName()).toOSString();
File file = new File(moduleDir, path);
assertTrue("Module file doesn't exist: " + file.getPath(), file.exists());
}
}
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.servertools by eclipse.
the class ModulePublishInfo method getDelta.
protected IModuleResourceDelta[] getDelta(IModule[] module) {
if (module == null)
return EMPTY_MODULE_RESOURCE_DELTA;
if (useCache) {
fillCache(module);
return delta;
}
IModule m = module[module.length - 1];
ModuleDelegate pm = (ModuleDelegate) m.loadAdapter(ModuleDelegate.class, null);
if (pm == null || (m.getProject() != null && !m.getProject().isAccessible()))
return EMPTY_MODULE_RESOURCE_DELTA;
IModuleResource[] resources2 = null;
try {
resources2 = pm.members();
printModule(resources2, "delta:");
} catch (CoreException ce) {
if (Trace.WARNING) {
Trace.trace(Trace.STRING_WARNING, "Possible failure in getDelta", ce);
}
}
if (resources2 == null)
resources2 = EMPTY_MODULE_RESOURCE;
return ServerPublishInfo.getDelta(getResources(), resources2);
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.servertools by eclipse.
the class ModulePublishInfo method hasDelta.
protected boolean hasDelta(IModule[] module) {
if (module == null)
return false;
if (useCache) {
fillCache(module);
return hasDelta;
}
IModule m = module[module.length - 1];
ModuleDelegate pm = (ModuleDelegate) m.loadAdapter(ModuleDelegate.class, null);
IModuleResource[] resources2 = null;
if (pm == null || (m.getProject() != null && !m.getProject().isAccessible()))
return false;
try {
resources2 = pm.members();
} catch (CoreException ce) {
if (Trace.WARNING) {
Trace.trace(Trace.STRING_WARNING, "Possible failure in hasDelta", ce);
}
}
if (resources2 == null)
resources2 = EMPTY_MODULE_RESOURCE;
return ServerPublishInfo.hasDelta(getResources(), resources2);
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.servertools by eclipse.
the class ModulePublishInfo method printModule.
private void printModule(IModuleResource r, String s) {
if (Trace.RESOURCES) {
Trace.trace(Trace.STRING_RESOURCES, s + r.getName());
}
if (r instanceof IModuleFolder) {
IModuleFolder mf = (IModuleFolder) r;
IModuleResource[] mr = mf.members();
for (IModuleResource mrr : mr) {
printModule(mrr, s + " ");
}
}
}
use of org.eclipse.wst.server.core.model.IModuleResource in project webtools.servertools by eclipse.
the class PublishUtilTestCase method test03PreserveFiles.
public void test03PreserveFiles() throws Exception {
// Publish all resources except the B resources, preserving them them rather than delete them
IModuleResource[] resources = getModuleResources();
IModuleResource[] resources2 = getModuleResources2();
IPath dest = getDestination();
assertNotNull(dest);
IStatus[] result = PublishUtil.publishSmart(resources2, dest, getPreservePaths(), null);
assertNotNull(result);
assertTrue(getResultMessage(result), result.length == 0);
// Verify "A" files are unchanged and "B" files have not been deleted
String contents = getContents(dest.append(resources[0].getModuleRelativePath()));
assertEquals("rootFileA contents", contents);
contents = getContents(dest.append(resources[1].getModuleRelativePath()));
assertEquals("rootFileB contents 2", contents);
IModuleFolder mf = (IModuleFolder) resources[2];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderAFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderAFileB contents 2", contents);
mf = (IModuleFolder) resources[3];
contents = getContents(dest.append(mf.members()[0].getModuleRelativePath()));
assertEquals("folderBFileA contents", contents);
contents = getContents(dest.append(mf.members()[1].getModuleRelativePath()));
assertEquals("folderBFileB contents 2", contents);
}
Aggregations