Index: lams_build/lib/lams/lams-contentrepository.jar
===================================================================
diff -u -rf48c6873abe00cb898d3a832b9b6a9c95d81a559 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
Binary files differ
Index: lams_build/lib/lams/lams.jar
===================================================================
diff -u -r83e729447a22f145df8450889b6bfecad5382854 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
Binary files differ
Index: lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java
===================================================================
diff -u -rf48c6873abe00cb898d3a832b9b6a9c95d81a559 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
--- lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision f48c6873abe00cb898d3a832b9b6a9c95d81a559)
+++ lams_central/src/java/org/lamsfoundation/lams/web/PortraitSaveAction.java (.../PortraitSaveAction.java) (revision a93d8d1f7b86194a155d41c34874fc83acada0c9)
@@ -111,7 +111,7 @@
if (file!= null && !StringUtils.isEmpty(fileName)) {
try {
//InputStream is = file.getInputStream();
- node = centralToolContentHandler.uploadFile(is, fileName, file.getContentType(), IToolContentHandler.TYPE_ONLINE, user.getUserId());
+ node = centralToolContentHandler.uploadFile(is, fileName, file.getContentType(), IToolContentHandler.TYPE_ONLINE);
is.close();
} catch (Exception e) {
request.setAttribute("errorMessage", e.getMessage());
Index: lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java
===================================================================
diff -u -rf48c6873abe00cb898d3a832b9b6a9c95d81a559 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
--- lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java (.../IWorkspaceManagementService.java) (revision f48c6873abe00cb898d3a832b9b6a9c95d81a559)
+++ lams_central/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java (.../IWorkspaceManagementService.java) (revision a93d8d1f7b86194a155d41c34874fc83acada0c9)
@@ -222,12 +222,11 @@
* holds this content
* @param mimeType The MIME type of the file
* @param path The physical location of the file from where it has to be read
- * @param userID The User
who has requested this opeartion
* @return String The acknowledgement/error message in WDDX format for the
* FLASH client.
* @throws Exception
*/
- public String createWorkspaceFolderContent(Integer contentTypeID, String name, String description, Integer workspaceFolderID, String mimeType, String path, Integer userId) throws Exception;
+ public String createWorkspaceFolderContent(Integer contentTypeID, String name, String description, Integer workspaceFolderID, String mimeType, String path) throws Exception;
/**
* This method updates an existing file(workspaceFolderContet
)
@@ -236,11 +235,10 @@
* @param folderContentID The folder_content_id
of the file
* to be updated
* @param path The physical location of the file from where it has to be read
- * @param userID The User
who has requested this opeartion
* @return String The acknowledgement/error message in WDDX format for FLASH
* @throws Exception
*/
- public String updateWorkspaceFolderContent(Long folderContentID,String path, Integer userId)throws Exception;
+ public String updateWorkspaceFolderContent(Long folderContentID,String path)throws Exception;
/**
* This method is called when the user knows which version of the
@@ -349,4 +347,4 @@
*/
public String getUserOrganisation(Integer userID, Integer organisationId) throws IOException;
-}
\ No newline at end of file
+}
Index: lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java
===================================================================
diff -u -rf48c6873abe00cb898d3a832b9b6a9c95d81a559 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
--- lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java (.../WorkspaceManagementService.java) (revision f48c6873abe00cb898d3a832b9b6a9c95d81a559)
+++ lams_central/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java (.../WorkspaceManagementService.java) (revision a93d8d1f7b86194a155d41c34874fc83acada0c9)
@@ -53,10 +53,10 @@
import org.lamsfoundation.lams.dao.IBaseDAO;
import org.lamsfoundation.lams.learningdesign.LearningDesign;
import org.lamsfoundation.lams.learningdesign.dao.ILearningDesignDAO;
-import org.lamsfoundation.lams.usermanagement.Organisation;
import org.lamsfoundation.lams.usermanagement.OrganisationState;
import org.lamsfoundation.lams.usermanagement.Role;
import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.Organisation;
import org.lamsfoundation.lams.usermanagement.UserOrganisation;
import org.lamsfoundation.lams.usermanagement.UserOrganisationRole;
import org.lamsfoundation.lams.usermanagement.Workspace;
@@ -71,6 +71,7 @@
import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.wddx.FlashMessage;
import org.lamsfoundation.lams.workspace.WorkspaceFolderContent;
+import org.lamsfoundation.lams.workspace.dao.IWorkspaceFolderContentDAO;
import org.lamsfoundation.lams.workspace.dto.FolderContentDTO;
import org.lamsfoundation.lams.workspace.dto.UpdateContentDTO;
@@ -377,6 +378,8 @@
public Integer getPermissions(WorkspaceFolder workspaceFolder, User user){
Integer permission = null;
+ WorkspaceFolder userDefaultFolder = user.getWorkspace().getDefaultFolder();
+
if ( workspaceFolder==null || user==null ) {
permission = WorkspaceFolder.NO_ACCESS;
} else if (workspaceFolder.getUserID().equals(user.getUserId())) {
@@ -388,7 +391,25 @@
}
return permission;
}
-
+ /** This method checks if the given workspaceFolder is a subFolder of the
+ * given rootFolder. Returns false if they are the same folder. */
+ private boolean isSubFolder(WorkspaceFolder workspaceFolder,WorkspaceFolder rootFolder){
+ if ( rootFolder != null ) {
+ // is it the same folder?
+ if ( rootFolder.getWorkspaceFolderId().equals(workspaceFolder.getWorkspaceFolderId()) ) {
+ return false;
+ }
+ // check the parent hierarchy
+ WorkspaceFolder folder = workspaceFolder;
+ while ( folder != null && ! rootFolder.getWorkspaceFolderId().equals(folder.getWorkspaceFolderId()) ) {
+ folder = folder.getParentWorkspaceFolder();
+ }
+ return ( folder != null );
+ }
+ return false;
+
+ }
+
private Vector getFolderContentDTO(List designs, Integer permissions,Vector folderContent){
Iterator iterator = designs.iterator();
while(iterator.hasNext()){
@@ -791,9 +812,9 @@
}
/**
- * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#createWorkspaceFolderContent(java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer)
+ * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#createWorkspaceFolderContent(java.lang.Integer, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String)
*/
- public String createWorkspaceFolderContent(Integer contentTypeID,String name,String description,Integer workspaceFolderID, String mimeType, String path, Integer userId) throws Exception{
+ public String createWorkspaceFolderContent(Integer contentTypeID,String name,String description,Integer workspaceFolderID, String mimeType, String path) throws Exception{
// TODO add some validation so that a non-unique name doesn't result in an index violation
// bit hard for the user to understand.
@@ -808,7 +829,7 @@
try{
InputStream stream = new FileInputStream(path);
- NodeKey nodeKey = addFileToRepository(stream,name,mimeType,userId);
+ NodeKey nodeKey = addFileToRepository(stream,name,mimeType);
workspaceFolderContent.setUuid(nodeKey.getUuid());
workspaceFolderContent.setVersionID(nodeKey.getVersion());
baseDAO.update(workspaceFolderContent);
@@ -871,13 +892,13 @@
/**
* (non-Javadoc)
- * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#updateWorkspaceFolderContent(java.lang.Long, java.io.InputStream, java.lang.Integer)
+ * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#updateWorkspaceFolderContent(java.lang.Long, java.io.InputStream)
*/
- public String updateWorkspaceFolderContent(Long folderContentID,String path, Integer userId)throws Exception{
+ public String updateWorkspaceFolderContent(Long folderContentID,String path)throws Exception{
InputStream stream = new FileInputStream(path);
WorkspaceFolderContent workspaceFolderContent = (WorkspaceFolderContent)baseDAO.find(WorkspaceFolderContent.class,folderContentID);
if(workspaceFolderContent!=null){
- NodeKey nodeKey = updateFileInRepository(workspaceFolderContent,stream, userId);
+ NodeKey nodeKey = updateFileInRepository(workspaceFolderContent,stream);
UpdateContentDTO contentDTO = new UpdateContentDTO(nodeKey.getUuid(), nodeKey.getVersion(),folderContentID);
flashMessage = new FlashMessage(MSG_KEY_UPDATE_WKF_CONTENT,contentDTO);
}else
@@ -895,16 +916,15 @@
* @param stream The InputStream
representing the data to be added
* @param fileName The name of the file being added
* @param mimeType The MIME type of the file (eg. TXT, DOC, GIF etc)
- * @param userId The user who is creating the content
* @return NodeKey Represents the two part key - UUID and Version.
* @throws AccessDeniedException
* @throws FileException
* @throws InvalidParameterException
*/
- private NodeKey addFileToRepository(InputStream stream, String fileName, String mimeType, Integer userId)throws AccessDeniedException,
+ private NodeKey addFileToRepository(InputStream stream, String fileName, String mimeType)throws AccessDeniedException,
FileException,InvalidParameterException{
ITicket ticket = getRepositoryLoginTicket();
- NodeKey nodeKey = repositoryService.addFileItem(ticket,stream,fileName,mimeType,null,userId);
+ NodeKey nodeKey = repositoryService.addFileItem(ticket,stream,fileName,mimeType,null);
return nodeKey;
}
/**
@@ -920,11 +940,11 @@
* @throws Exception
*/
private NodeKey updateFileInRepository(WorkspaceFolderContent workspaceFolderContent,
- InputStream stream, Integer userId)throws Exception{
+ InputStream stream)throws Exception{
ITicket ticket = getRepositoryLoginTicket();
NodeKey nodeKey = repositoryService.updateFileItem(ticket,workspaceFolderContent.getUuid(),
workspaceFolderContent.getName(),
- stream,workspaceFolderContent.getMimeType(),null,userId);
+ stream,workspaceFolderContent.getMimeType(),null);
workspaceFolderContent.setUuid(nodeKey.getUuid());
workspaceFolderContent.setVersionID(nodeKey.getVersion());
baseDAO.update(workspaceFolderContent);
@@ -1362,4 +1382,4 @@
-}
\ No newline at end of file
+}
Index: lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java
===================================================================
diff -u -rf48c6873abe00cb898d3a832b9b6a9c95d81a559 -ra93d8d1f7b86194a155d41c34874fc83acada0c9
--- lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java (.../WorkspaceAction.java) (revision f48c6873abe00cb898d3a832b9b6a9c95d81a559)
+++ lams_central/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java (.../WorkspaceAction.java) (revision a93d8d1f7b86194a155d41c34874fc83acada0c9)
@@ -71,10 +71,10 @@
public static final String ROLE_DELIMITER = ",";
private Integer getUserId(HttpServletRequest request) {
- // return new Integer(WebUtil.readIntParam(request,AttributeNames.PARAM_USER_ID));
- HttpSession ss = SessionManager.getSession();
+ return new Integer(WebUtil.readIntParam(request,AttributeNames.PARAM_USER_ID));
+ /* HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- return user != null ? user.getUserID() : null;
+ return user != null ? user.getUserID() : null; */
}
/**
@@ -394,7 +394,6 @@
Integer workspaceFolderID = new Integer(WebUtil.readIntParam(request,"workspaceFolderID"));
String mimeType = WebUtil.readStrParam(request,"mimeType");
String path = WebUtil.readStrParam(request,"path");
- Integer userId = getUserId(request);
String errorPacket = checkResourceNotDummyValue("createWorkspaceFolderContent", workspaceFolderID, FolderContentDTO.FOLDER);
if ( errorPacket != null)
@@ -405,7 +404,7 @@
IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService();
wddxPacket = workspaceManagementService.createWorkspaceFolderContent(contentTypeID,name,description,
workspaceFolderID,
- mimeType,path,userId);
+ mimeType,path);
} catch (Exception e) {
log.error("createWorkspaceFolderContent: Exception occured. contentTypeID "+contentTypeID+" name "+name+" workspaceFolderID "+workspaceFolderID, e);
FlashMessage flashMessage = FlashMessage.getExceptionOccured(IWorkspaceManagementService.MSG_KEY_CREATE_WKF_CONTENT, e.getMessage());
@@ -431,11 +430,10 @@
HttpServletResponse response)throws ServletException, Exception{
Long folderContentID = new Long(WebUtil.readLongParam(request,"folderContentID"));
String path = WebUtil.readStrParam(request,"path");
- Integer userId = getUserId(request);
String wddxPacket = null;
try {
IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService();
- wddxPacket = workspaceManagementService.updateWorkspaceFolderContent(folderContentID,path,userId);
+ wddxPacket = workspaceManagementService.updateWorkspaceFolderContent(folderContentID,path);
} catch (Exception e) {
log.error("updateWorkspaceFolderContent: Exception occured. path "+path+" folderContentID "+folderContentID, e);
FlashMessage flashMessage = FlashMessage.getExceptionOccured(IWorkspaceManagementService.MSG_KEY_UPDATE_WKF_CONTENT, e.getMessage());