Search in sources :

Example 6 with ModuleFolder

use of org.eclipse.wst.server.core.util.ModuleFolder in project webtools.servertools by eclipse.

the class ModulePublishInfo method loadResource.

/**
 * Used only for reading from WTP 1.x workspaces.
 */
protected IModuleResource[] loadResource(IMemento memento, IPath path) {
    if (memento == null)
        return EMPTY_MODULE_RESOURCE;
    List<IModuleResource> list = new ArrayList<IModuleResource>(10);
    // load files
    IMemento[] children = memento.getChildren(FILE);
    if (children != null) {
        int size = children.length;
        for (int i = 0; i < size; i++) {
            String name2 = children[i].getString(NAME);
            long stamp = Long.parseLong(children[i].getString(STAMP));
            ModuleFile file = new ModuleFile(name2, path, stamp);
            list.add(file);
        }
    }
    // load folders
    children = memento.getChildren(FOLDER);
    if (children != null) {
        int size = children.length;
        for (int i = 0; i < size; i++) {
            String name2 = children[i].getString(NAME);
            ModuleFolder folder = new ModuleFolder(null, name2, path);
            folder.setMembers(loadResource(children[i], path.append(name2)));
            list.add(folder);
        }
    }
    IModuleResource[] resources2 = new IModuleResource[list.size()];
    list.toArray(resources2);
    return resources2;
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModuleFile(org.eclipse.wst.server.core.model.IModuleFile) ModuleFile(org.eclipse.wst.server.core.util.ModuleFile) IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder) ModuleFolder(org.eclipse.wst.server.core.util.ModuleFolder)

Example 7 with ModuleFolder

use of org.eclipse.wst.server.core.util.ModuleFolder in project webtools.servertools by eclipse.

the class ModulePublishInfo method loadResource.

private IModuleResource[] loadResource(DataInput in, IPath path) throws IOException {
    int size = in.readInt();
    if (size > 1000000)
        throw new IOException("Folder capacity limit reached");
    IModuleResource[] resources2 = new IModuleResource[size];
    for (int i = 0; i < size; i++) {
        byte b = in.readByte();
        if (b == 0) {
            String name2 = in.readUTF();
            long stamp = in.readLong();
            resources2[i] = new ModuleFile(name2, path, stamp);
        } else if (b == 1) {
            String name2 = in.readUTF();
            ModuleFolder folder = new ModuleFolder(null, name2, path);
            folder.setMembers(loadResource(in, path.append(name2)));
            resources2[i] = folder;
        }
    }
    return resources2;
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModuleFile(org.eclipse.wst.server.core.model.IModuleFile) ModuleFile(org.eclipse.wst.server.core.util.ModuleFile) IOException(java.io.IOException) IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder) ModuleFolder(org.eclipse.wst.server.core.util.ModuleFolder)

Aggregations

IModuleFolder (org.eclipse.wst.server.core.model.IModuleFolder)7 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)7 ModuleFolder (org.eclipse.wst.server.core.util.ModuleFolder)7 IModuleFile (org.eclipse.wst.server.core.model.IModuleFile)5 IFile (org.eclipse.core.resources.IFile)4 IPath (org.eclipse.core.runtime.IPath)4 ModuleFile (org.eclipse.wst.server.core.util.ModuleFile)4 IContainer (org.eclipse.core.resources.IContainer)3 ArrayList (java.util.ArrayList)2 Path (org.eclipse.core.runtime.Path)2 File (java.io.File)1 IOException (java.io.IOException)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)1 IVirtualContainer (org.eclipse.wst.common.componentcore.resources.IVirtualContainer)1 IVirtualResource (org.eclipse.wst.common.componentcore.resources.IVirtualResource)1