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