Package org.sd_network.vfs.db

Examples of org.sd_network.vfs.db.VfsFile


            printUsage(e.getMessage());
            return;
        }

        String dirName = commandLine.getArgs()[0];
        VfsFile parent = session.getCurrentDirectory();

        try {
            VfsFile targetFile = null;
            if (dirName.equals("..")) {
                if (parent.getParentID().equals("-1"))
                    return;
                targetFile = vfsService.getVfsFile(
                        sessionID, parent.getParentID());
            } else {
                targetFile = vfsService.getVfsFile(
                        sessionID, parent.getID(), 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;
            }
            session.setCurrentDirectory(targetFile);
View Full Code Here


        try {
            VfsService vfsService = VfsContext.getService();
            session.setSessionID(vfsService.login(loginName, password));
            String sessionID = session.getSessionID();
            VfsFile home = vfsService.getVfsFile(sessionID, "-1", "Home");
            if (home == null)
                throw new IllegalStateException(
                        "User home directory not found.");
            session.setCurrentDirectory(home);
            System.out.println("SessionID = " + session.getSessionID());
View Full Code Here

        } 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

        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

        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

        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

        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

        // 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

        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

        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

TOP

Related Classes of org.sd_network.vfs.db.VfsFile

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.