Package org.jnode.net.nfs.nfs2

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


    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


    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

     * @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

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

        NFS2Entry entry =
View Full Code Here

        NFS2Client nfsClient = getNFS2Client();

        CreateFileResult result;
        try {
            result = nfsClient.createFile(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 file " + name + "." + e.getMessage(), e);
        }

        NFS2Entry entry =
View Full Code Here

                            ". It is not directory or file");
                }
            }
            CreateFileResult result =
                    nfsClient.createFile(tempFileHandle, tokenList.get(tokenList.size() - 1),
                            DEFAULT_PERMISSION, uid, gid, 0, new Time(-1, -1), new Time(-1, -1));
            fileHandle = result.getFileHandle();
            fileAttribute = result.getFileAttribute();
        } catch (NFS2Exception e) {
            try {
                mountClient.unmount(mountDirectory);
View Full Code Here

        } catch (PrivilegedActionException e) {
            return;
        }

        for (int i = 0; i < exportEntryList.size(); i++) {
            ExportEntry exportEntry = exportEntryList.get(i);
            if (exportEntry.getDirectory().startsWith(partialDirectory)) {
                completions.addCompletion(hostName + ":" + exportEntry.getDirectory());
            }
        }
    }
View Full Code Here

        } catch (MountException e1) {
            mountClient.close();
            throw new IOException(e1.getMessage());
        }

        ExportEntry exportEntry = null;
        for (ExportEntry e : exportList) {
            if (path.startsWith(e.getDirectory())) {
                if (exportEntry == null) {
                    exportEntry = e;
                } else {
                    if (exportEntry.getDirectory().length() < e.getDirectory().length()) {
                        exportEntry = e;
                    }
                }
            }
        }
        if (exportEntry == null) {
            throw new IOException("The path " + path + " it is not exported");
        }
        mountDirectory = exportEntry.getDirectory();
        MountResult mountResult;
        try {
            mountResult = mountClient.mount(mountDirectory);
        } catch (MountException e) {
            mountClient.close();
            throw new IOException(e.getMessage());
        }

        byte[] tempFileHandle = mountResult.getFileHandle();
        try {
            String filePath = path.substring(exportEntry.getDirectory().length());
            StringTokenizer tokenizer = new StringTokenizer(filePath, "/");
            List<String> tokenList = new ArrayList<String>();
            while (tokenizer.hasMoreElements()) {
                String t = tokenizer.nextToken();
                tokenList.add(t);
View Full Code Here

                // ignore
            }
            throw e;
        }

        ExportEntry exportEntry = null;
        for (ExportEntry e : exportList) {
            if (path.startsWith(e.getDirectory())) {
                if (exportEntry == null) {
                    exportEntry = e;
                } else {
                    if (exportEntry.getDirectory().length() < e.getDirectory().length()) {
                        exportEntry = e;
                    }
                }
            }
        }

        if (exportEntry == null) {
            throw new IOException("The path " + path + " it is not exported");
        }
        mountDirectory = exportEntry.getDirectory();
        MountResult mountResult;
        try {
            mountResult = mountClient.mount(mountDirectory);
        } catch (MountException e) {
            try {
                mountClient.close();
            } catch (IOException e1) {
                // ignore
            }
            throw new IOException(e.getMessage());
        } catch (IOException e) {
            try {
                mountClient.close();
            } catch (IOException e1) {
                // ignore
            }
            throw e;
        }

        byte[] tempFileHandle = mountResult.getFileHandle();

        try {
            String filePath = path.substring(exportEntry.getDirectory().length());
            StringTokenizer tokenizer = new StringTokenizer(filePath, "/");
            while (tokenizer.hasMoreElements()) {
                String t = tokenizer.nextToken();
                LookupResult lookup = nfsClient.lookup(tempFileHandle, t);
                if (lookup.getFileAttribute().getType() == FileAttribute.FILE) {
View Full Code Here

                    // Ignore this
                }
            }
        });

        mountClient = new Mount1Client(device.getHost(), device.getProtocol(), device.getUid(), device.getGid());
        nfsClient = new NFS2Client(device.getHost(), device.getProtocol(), device.getUid(), device.getGid());

        // Mount the file system
        MountResult result;
        FileAttribute fileAttribute;
View Full Code Here

TOP

Related Classes of org.jnode.net.nfs.nfs2.NFS2Client

Copyright © 2018 www.massapicom. 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.