Search in sources :

Example 11 with IModuleResource

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());
        }
    }
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder) TomcatServer(org.eclipse.jst.server.tomcat.core.internal.TomcatServer) IServer(org.eclipse.wst.server.core.IServer) Server(org.eclipse.wst.server.core.internal.Server) File(java.io.File)

Example 12 with IModuleResource

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);
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) ModuleDelegate(org.eclipse.wst.server.core.model.ModuleDelegate)

Example 13 with IModuleResource

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);
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) ModuleDelegate(org.eclipse.wst.server.core.model.ModuleDelegate)

Example 14 with IModuleResource

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 + "  ");
        }
    }
}
Also used : IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource)

Example 15 with IModuleResource

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);
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath)

Aggregations

IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)45 IPath (org.eclipse.core.runtime.IPath)24 IModuleFolder (org.eclipse.wst.server.core.model.IModuleFolder)21 IFile (org.eclipse.core.resources.IFile)17 IStatus (org.eclipse.core.runtime.IStatus)17 IModule (org.eclipse.wst.server.core.IModule)12 File (java.io.File)11 IModuleFile (org.eclipse.wst.server.core.model.IModuleFile)10 ModuleFile (org.eclipse.wst.server.core.util.ModuleFile)9 IProject (org.eclipse.core.resources.IProject)8 CoreException (org.eclipse.core.runtime.CoreException)8 IModuleResourceDelta (org.eclipse.wst.server.core.model.IModuleResourceDelta)8 ArrayList (java.util.ArrayList)7 ModuleFolder (org.eclipse.wst.server.core.util.ModuleFolder)7 ModuleDelegate (org.eclipse.wst.server.core.model.ModuleDelegate)5 IContainer (org.eclipse.core.resources.IContainer)4 Path (org.eclipse.core.runtime.Path)4 Status (org.eclipse.core.runtime.Status)4 IOException (java.io.IOException)3 ProjectModule (org.eclipse.wst.server.core.util.ProjectModule)3