Index: lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java,v diff -u -r1.4 -r1.5 --- lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java 18 Jan 2006 01:03:11 -0000 1.4 +++ lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java 24 Jan 2006 11:35:12 -0000 1.5 @@ -304,6 +304,33 @@ public String getAccessibleWorkspaceFolders(Integer userID)throws IOException; /** + * This method returns a list of workspace folders for which + * the user has "write" access. A user can write/save his content + * in a folder in one of the following cases + *
    + *
  1. He is the OWNER of the given workspace folder
  2. + *
  3. He is a MEMBER of the organisation to which the + * folder belongs and he has one or all of the follwing + * roles (SYSADMIN. ADMIN, AUTHOR, STAFF, TEACHER)
  4. + *
+ * + * The information returned is categorized under 3 main heads + * + * + * This is a modified version which returns FolderContentDTO, rather than UserAccessFoldersDTO + * + * @param userID The user_id of the user for whom the + * folders have to fetched + * @return String The required information in WDDX format + * @throws IOException + */ + public String getAccessibleWorkspaceFoldersNew(Integer userID)throws IOException; + + /** * This method moves a Learning Design from one workspace * folder to another.But before it does that it checks whether * the given User is authorized to do so. Index: lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java,v diff -u -r1.8 -r1.9 --- lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java 19 Jan 2006 22:38:21 -0000 1.8 +++ lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java 24 Jan 2006 11:35:12 -0000 1.9 @@ -1037,7 +1037,54 @@ return flashMessage.serializeMessage(); } + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#getAccessibleWorkspaceFolders(java.lang.Integer) + */ + public String getAccessibleWorkspaceFoldersNew(Integer userID) throws IOException { + User user = userDAO.getUserById(userID); + Hashtable table = new Hashtable(); + Vector workspaces = new Vector(); + + if (user != null) { + //add the user's own folder to the list + WorkspaceFolder privateFolder = user.getWorkspace().getRootFolder(); + Integer permissions = getPermissions(privateFolder,user); + table.put("PRIVATE", new FolderContentDTO(privateFolder, permissions)); + + // Get a list of organisations of which the given user is a member + List userMemberships = userOrganisationDAO.getUserOrganisationsByUser(user); + if (userMemberships != null) { + Iterator memberships = userMemberships.iterator(); + while (memberships.hasNext()) { + UserOrganisation member = (UserOrganisation) memberships.next(); + // Get a list of roles that the user has in this organisation + Set roles = member.getUserOrganisationRoles(); + + /*Check if the user has write access, which is available + * only if the user has an AUTHOR, TEACHER or STAFF role. If + * he has acess add that folder to the list. + */ + if (hasWriteAccess(roles)) { + WorkspaceFolder orgFolder = member.getOrganisation().getWorkspace().getRootFolder(); + workspaces.add(new FolderContentDTO(orgFolder,getPermissions(orgFolder,user))); + } + } + table.put("ORGANISATIONS", workspaces); + flashMessage = new FlashMessage("getAccessibleWorkspaceFolders", table); + }else + flashMessage = new FlashMessage("getAccessibleWorkspaceFolders", + "User with user_id of: " + userID + + " is not a member of any organisation", + FlashMessage.ERROR); + } else + flashMessage = FlashMessage.getNoSuchUserExists("getAccessibleWorkspaceFolders", userID); + + return flashMessage.serializeMessage(); + } + + /** * This a utility method that checks whether user has write access. He can * save his contents to a folder only if he is an AUTHOR,TEACHER or STAFF * Index: lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java,v diff -u -r1.5 -r1.6 --- lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java 18 Jan 2006 01:03:23 -0000 1.5 +++ lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java 24 Jan 2006 11:35:12 -0000 1.6 @@ -359,6 +359,26 @@ * @return ActionForward * @throws IOException */ + public ActionForward getAccessibleWorkspaceFoldersNew(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws IOException{ + Integer userID = new Integer(WebUtil.readIntParam(request,"userID")); + IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService(); + String wddxPacket = workspaceManagementService.getAccessibleWorkspaceFoldersNew(userID); + return outputPacket(mapping, request, response, wddxPacket, "details"); + } + /** + * For details please refer to + * org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService + * + * @param mapping + * @param form + * @param request + * @param response + * @return ActionForward + * @throws IOException + */ public ActionForward moveLearningDesign(ActionMapping mapping, ActionForm form, HttpServletRequest request, Index: lams_central/test/java/org/lamsfoundation/lams/workspace/service/TestWorkspaceManagement.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/test/java/org/lamsfoundation/lams/workspace/service/Attic/TestWorkspaceManagement.java,v diff -u -r1.3 -r1.4 --- lams_central/test/java/org/lamsfoundation/lams/workspace/service/TestWorkspaceManagement.java 6 Oct 2005 06:28:15 -0000 1.3 +++ lams_central/test/java/org/lamsfoundation/lams/workspace/service/TestWorkspaceManagement.java 24 Jan 2006 11:35:12 -0000 1.4 @@ -101,7 +101,6 @@ String name = "testCreateWorkspaceFolderContent"+System.currentTimeMillis(); String message = workspaceManagementService.createWorkspaceFolderContent(WorkspaceFolderContent.CONTENT_TYPE_FILE, name,"Manpreet's Description", - new Date(),new Date(), MELCOE_WORKSPACE_FOLDER, "TXT",testFileString); System.out.println(message); @@ -118,7 +117,6 @@ String message = workspaceManagementService.createWorkspaceFolderContent( WorkspaceFolderContent.CONTENT_TYPE_FILE, name,"This content is to be updated.", - new Date(),new Date(), DOCUMENTS_WORKSPACE_FOLDER, "TXT",testFileString); @@ -171,7 +169,6 @@ String message = workspaceManagementService.createWorkspaceFolderContent( WorkspaceFolderContent.CONTENT_TYPE_FILE, name,"This content is to be deleted.", - new Date(),new Date(), DOCUMENTS_WORKSPACE_FOLDER, "TXT",testFileString);