Package org.sd_network.vfs.db

Examples of org.sd_network.vfs.db.User


        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        if (userSession == null)
            throw new SessionException("Invalid session.");
        User owner = userSession.getUser();

        List<VfsFile> childList =
            VfsFileDB.getChildList(parentFileID, owner.getID());

        VfsFile[] children = new VfsFile[childList.size()];
        for (int idx = 0; idx < childList.size(); idx++) {
            children[idx] = childList.get(idx);
        }
View Full Code Here


        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        if (userSession == null)
            throw new SessionException("Invalid session.");
        User owner = userSession.getUser();

        // retrive target.
        return VfsFileDB.get(parentFileID, fileName, owner.getID());
    }
View Full Code Here

        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        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

        // retrive user from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession session = usm.getUserSession(sessionID);
        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 {
            SectorDriver sectorDriver = SectorDriverManager.getSectorDriver();
            sectorDriver.deleteSectors(fileID);
        } catch (SectorException e) {
            throw new VfsIOException(e.getMessage(), e);
        }

        // delete file entry.
        VfsFileDB.delete(fileID, user.getID());
    }
View Full Code Here

        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();

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

        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        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

        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        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

        // retrive owner from session.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        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

        // check whether logged in user has permission.
        UserSessionManager usm = UserSessionManager.getInstance();
        UserSession userSession = usm.getUserSession(sessionID);
        if (userSession == null)
            throw new SessionException("Invalid session.");
        User user = userSession.getUser();
        if (!user.isAdmin())
            throw new PermissionException(
                    "You have not permission as an Administrator.");

        ConnectionPool pool = ConnectionPool.getInstance("vfs");
        Connection con = pool.engageConnection(10);
        try {
            con.setAutoCommit(false);
            User newUser = UserDB.create(con, loginName, password, isAdmin);

            // If new user is not administrator, create HOME directory of user.
            if (!newUser.isAdmin())
                VfsFileDB.createDirectory(con, "Home", "-1", newUser.getID());
            con.commit();
        } catch (SQLException e) {
            try {
                con.rollback();
            } catch (SQLException e1) {
View Full Code Here

        if (_userSessionMap.size() >= _maxUserSession)
            throw new AuthenticationException(
                    "Session full. Please try again after a wait few minutes.");

        // check whether User exists.
        User user = UserDB.get(loginName, password);
        if (user == null)
            throw new AuthenticationException("User not found.");

        // create session.
        String userSessionID = UUID.randomUUID().toString();
View Full Code Here

TOP

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

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.