Examples of NFS2Client


Examples of org.jnode.net.nfs.nfs2.NFS2Client

    public void setLastChanged(long lastChanged) throws IOException {
        // TODO: The setAttribute API appears to have no way to do this.
    }

    public void setLastModified(long lastModified) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(getFileHandle(), -1, -1, -1, -1,
                new Time(-1, -1), new Time(lastModified));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

            throw new IOException(e.getMessage(), e);
        }
    }

    public void setLastAccessed(long lastAccessed) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(getFileHandle(), -1, -1, -1, -1,
                new Time(lastAccessed), new Time(-1, -1));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

            throw new IOException(e.getMessage(), e);
        }
    }

    public void setName(String newName) throws IOException {
        NFS2Client client = getNFS2Client();
        NFS2Directory parentDirectory = (NFS2Directory) getParent();
        try {
            client.renameFile(
                parentDirectory.getNFS2Entry().getFileHandle(), name,
                parentDirectory.getNFS2Entry().getFileHandle(), newName);
        } catch (NFS2Exception e) {
            throw new IOException("Can not rename ." + e.getMessage(), e);
        }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

     * @param fileOffset
     * @param dest
     * @throws java.io.IOException
     */
    public void read(long fileOffset, ByteBuffer dest) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            int length;
            while (true) {
                length = Math.min(NFS2Client.MAX_DATA, dest.remaining());
                if (length == 0) {
                    return;
                }
                ReadFileResult result =
                        client.readFile(entry.getFileHandle(), (int) fileOffset, length);
                byte[] data = result.getData();
                length = data.length;
                fileOffset += length;
                dest.put(data);
            }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

     *
     * @param length
     * @throws java.io.IOException
     */
    public void setLength(long length) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            client.setAttribute(entry.getFileHandle(), -1, -1, -1, (int) length, new Time(-1, -1),
                    new Time(-1, -1));
        } catch (NFS2Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

     * @param fileOffset
     * @param src
     * @throws java.io.IOException
     */
    public void write(long fileOffset, ByteBuffer src) throws IOException {
        NFS2Client client = getNFS2Client();
        try {
            byte[] data = new byte[NFS2Client.MAX_DATA];
            int count;
            while (src.remaining() > 0) {
                count = Math.min(NFS2Client.MAX_DATA, src.remaining());
                src.get(data, 0, count);
                client.writeFile(entry.getFileHandle(), (int) fileOffset, data, 0, count);
                fileOffset += count;
            }
        } catch (NFS2Exception e) {
            throw new IOException("Error writing file . Reason: " + e.getMessage(), e);
        }
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

        NFS2Entry entry = tableEntry.getEntry(name);
        if (entry != null) {
            return entry;
        }

        NFS2Client nfsClient = getNFS2Client();
        LookupResult lookupResult;
        try {
            lookupResult = nfsClient.lookup(directoryEntry.getFileHandle(), name);
        } catch (NFS2Exception e) {
            throw new IOException("Can not call the rpc method." + e.getMessage(), e);
        }
        entry = new NFS2Entry(
            (NFS2FileSystem) getFileSystem(), this, name,
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

    /**
     * Gets an iterator used to iterate over all the entries of this directory.
     * All elements returned by the iterator must be instanceof FSEntry.
     */
    public Iterator<? extends NFS2Entry> iterator() throws IOException {
        final NFS2Client nfsClient = getNFS2Client();

        @SuppressWarnings("unused")
        FileAttribute fileAttribute;
        try {
            fileAttribute =
                AccessController.doPrivileged(new PrivilegedExceptionAction<FileAttribute>() {
                    public FileAttribute run() throws Exception {
                        return nfsClient.getAttribute(getNFS2Entry().getFileHandle());
                    }
                });

        } catch (PrivilegedActionException e) {
            Exception x = e.getException();
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

        }
        return nfsEntrySet.iterator();
    }

    private Set<NFS2Entry> getNFS2EntrySet() throws IOException {
        final NFS2Client nfsClient = getNFS2Client();
        Set<NFS2Entry> nfsEntrySet;

        try {
            nfsEntrySet =
                AccessController.doPrivileged(new PrivilegedExceptionAction<Set<NFS2Entry>>() {
                    public Set<NFS2Entry> run() throws Exception {
                        Set<Entry> entrySet = new LinkedHashSet<Entry>();
                        boolean eof = false;
                        byte[] cookie = new byte[NFS2Client.COOKIE_SIZE];
                        while (!eof) {
                            ListDirectoryResult result = nfsClient.listDirectory(
                                directoryEntry.getFileHandle(), cookie, 2048);
                            entrySet.addAll(result.getEntryList());
                            if (result.isEof()) {
                                eof = true;
                            } else {
                                // I guess that the list contains at least one entry.
                                cookie = result.getEntryList().get(
                                    result.getEntryList().size() - 1).getCookie();
                            }
                        }

                        if (entrySet.size() == 0) {
                            return new HashSet<NFS2Entry>();
                        }

                        Set<NFS2Entry> nfsEntrySet =
                            new LinkedHashSet<NFS2Entry>(entrySet.size());

                        for (Entry entry : entrySet) {
                            LookupResult lookupResult = nfsClient.lookup(
                                directoryEntry.getFileHandle(), entry.getName());

                            NFS2Entry nfsEntry = new NFS2Entry(
                                (NFS2FileSystem) getFileSystem(),
                                NFS2Directory.this, entry.getName(), lookupResult.getFileHandle(),
View Full Code Here

Examples of org.jnode.net.nfs.nfs2.NFS2Client

    }

    public FSEntry addDirectory(String name) throws IOException {

        NFS2Client nfsClient = getNFS2Client();

        CreateDirectoryResult result;
        try {
            result = nfsClient.createDirectory(directoryEntry.getFileHandle(), name,
                DEFAULT_PERMISSION, -1, -1, -1, new Time(-1, -1), new Time(-1, -1));
        } catch (NFS2Exception e) {
            throw new IOException("Can not create the directory " + name + "." + e.getMessage(), e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.