Examples of VFSFile


Examples of org.sd_network.vfs.db.VfsFile

        } catch (ParseException e) {
            printUsage(e.getMessage());
            return;
        }

        VfsFile curDir = session.getCurrentDirectory();

        try {
            VfsFile parent = curDir;
            LinkedList<VfsFile> pathList = new LinkedList<VfsFile>();
            while (!parent.getParentID().equals("-1")) {
                pathList.addFirst(parent);
                String parentID = parent.getParentID();
                parent = vfsService.getVfsFile(sessionID, parentID);
                if (parent == null)
                    throw new IllegalStateException(
                            "ERROR: parent directory not found.");
            }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        String dirName = commandLine.getArgs()[0];
        String parentFileID = session.getCurrentDirectory().getID();

        try {
            VfsFile targetFile =
                vfsService.getVfsFile(sessionID, parentFileID, dirName);
            if (targetFile == null) {
                System.out.println("ERROR: [" + dirName + "] not found.");
                return;
            }
            if (targetFile.getType() != VfsFile.FileType.DIRECTORY) {
                System.out.println(
                        "ERROR: [" + dirName + "] is not directory.");
                return;
            }
            vfsService.deleteObject(sessionID, targetFile.getID());
        } catch (VfsIOException e) {
            System.out.println("ERROR: " + e.getMessage());
        } catch (SessionException e) {
            session.clearSessionID();
            System.out.println("ERROR: Session time out.");
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        SystemInfo systemInfo = vfsService.getSystemInfo();
        String parentFileID = session.getCurrentDirectory().getID();
        String fileSessionID = null;
        try {
            VfsFile vfsFile = vfsService.createFile(
                    sessionID, parentFileID, cl.getArgs()[1]);

            if (vfsService.isExistsName(
                        sessionID, vfsFile.getID(), cl.getArgs()[1]))
            {
                System.out.println("ERROR: the vfs_file_name already used.");
                return;
            }

            fileSessionID = vfsService.createFileSession(
                    sessionID, vfsFile.getID(), FileSession.Mode.WRITE);

            byte[] buf = new byte[systemInfo.getBytesPerWrite()];
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(file);
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();

        // retrive target.
        VfsFile target = VfsFileDB.get(targetFileID, user.getID());
        if (target == null)
            return null;

        // retrive parent.
        return VfsFileDB.get(target.getParentID(), user.getID());
    }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        if (session == null)
            throw new SessionException("Invalid session.");
        User user = session.getUser();

        // check whether file exists.
        VfsFile target = VfsFileDB.get(fileID, user.getID());
        if (target == null)
            throw new VfsIOException("The object not found.");

        // check whether target file has child.
        List<VfsFile> childList =
            VfsFileDB.getChildList(target.getID(), user.getID());
        if (childList.size() > 0)
            throw new VfsIOException("The object has child object.");

        // delete sectors related to specified fileID.
        try {
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        // check already exists.
        if (VfsFileDB.get(parentFileID, name, user.getID()) != null)
            throw new VfsIOException("The name is already used.");

        // retrive parent file.
        VfsFile parent = VfsFileDB.get(parentFileID, user.getID());
        if (parent == null)
            throw new VfsIOException("The parent not found.");

        // check child count.
        int childCount = VfsFileDB.countChild(parent.getID(), user.getID());
        if (childCount >= systemInfo.getChildObjectsPerParent())
            throw new VfsIOException("Could not create object any more.");

        return VfsFileDB.createDirectory(name, parent.getID(), user.getID());
    }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();

        // retrive parent object.
        VfsFile parent = VfsFileDB.get(parentFileID, user.getID());
        if (parent == null)
            throw new VfsIOException("The parent not found.");

        // check already exists same name.
        if (VfsFileDB.get(parent.getID(), name, user.getID()) != null)
            throw new VfsIOException("The name is already used.");

        // check number of child object.
        int childCount = VfsFileDB.countChild(parent.getID(), user.getID());
        if (childCount >= systemInfo.getChildObjectsPerParent())
            throw new VfsIOException("Could not create object any more.");

        // create object as a file.
        return VfsFileDB.createFile(name, parent.getID(), 0, user.getID());
    }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();

        // check exists of the file.
        VfsFile targetFile = VfsFileDB.get(fileID, user.getID());
        if (targetFile == null)
            throw new VfsIOException("Invalid fileID.");

        return userSession.newFileSession(targetFile, mode);
    }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();

        // retrive parent object.
        VfsFile parent = VfsFileDB.get(parentFileID, user.getID());
        if (parent == null)
            throw new VfsIOException("The parent not found.");

        // check already exists same name.
        return (VfsFileDB.get(parent.getID(), fileName, user.getID()) != null);
    }
View Full Code Here

Examples of org.sd_network.vfs.db.VfsFile

        SystemInfo systemInfo = vfsService.getSystemInfo();
        String parentFileID = session.getCurrentDirectory().getID();
        String fileSessionID = null;
        try {

            VfsFile vfsFile = vfsService.getVfsFile(
                    sessionID, parentFileID, cl.getArgs()[0]);
            if (vfsFile == null) {
                System.out.println("ERROR: the VfsFile not found.");
                return;
            }
            fileSessionID = vfsService.createFileSession(
                sessionID, vfsFile.getID(), FileSession.Mode.READ);

            byte[] buf = new byte[systemInfo.getBytesPerRead()];
            FileOutputStream fos = null;
            try {
                fos = new FileOutputStream(file);
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.