Index: lams_common/build.xml =================================================================== diff -u -r67e6bb6752138f9ac416c2119021b9507d7032c6 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/build.xml (.../build.xml) (revision 67e6bb6752138f9ac416c2119021b9507d7032c6) +++ lams_common/build.xml (.../build.xml) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -384,6 +384,8 @@ + + @@ -399,5 +401,31 @@ + + + + + + + + + + + + + + + + + + + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.hbm.xml =================================================================== diff -u -rfc77ed7c05214a99c9d9148a55e160d2d4a455ad -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.hbm.xml (.../WorkspaceFolder.hbm.xml) (revision fc77ed7c05214a99c9d9148a55e160d2d4a455ad) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.hbm.xml (.../WorkspaceFolder.hbm.xml) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -156,6 +156,11 @@ + + + + + Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml =================================================================== diff -u --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml (revision 0) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -0,0 +1,59 @@ + + + + + + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: lams_common/db/model/lams_11.clay =================================================================== diff -u -r96871d90a1687f73bef35cac8e4837325b51e843 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 96871d90a1687f73bef35cac8e4837325b51e843) +++ lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -1,5 +1,5 @@ - + @@ -2707,8 +2707,8 @@ - + @@ -2720,8 +2720,8 @@ - + @@ -4209,6 +4209,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index: lams_common/db/model/lams_tables.clay =================================================================== diff -u -rcc6864f9d0a4e4fa8515e2852cd34a4caa6b313a -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/model/lams_tables.clay (.../lams_tables.clay) (revision cc6864f9d0a4e4fa8515e2852cd34a4caa6b313a) +++ lams_common/db/model/lams_tables.clay (.../lams_tables.clay) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -14,8 +14,8 @@ - + @@ -52,8 +52,8 @@ - + @@ -65,8 +65,8 @@ - + @@ -78,8 +78,8 @@ - + @@ -141,8 +141,8 @@ - + @@ -154,8 +154,8 @@ - + @@ -185,8 +185,8 @@ - + @@ -198,8 +198,8 @@ - + @@ -254,8 +254,8 @@ - + @@ -267,8 +267,8 @@ - + @@ -280,8 +280,8 @@ - + @@ -293,8 +293,8 @@ - + @@ -306,8 +306,8 @@ - + @@ -367,8 +367,8 @@ - + @@ -380,8 +380,8 @@ - + @@ -423,8 +423,8 @@ - + @@ -436,8 +436,8 @@ - + @@ -449,8 +449,8 @@ - + @@ -505,8 +505,8 @@ - + @@ -518,8 +518,8 @@ - + @@ -531,8 +531,8 @@ - + @@ -574,8 +574,8 @@ - + @@ -601,8 +601,8 @@ - + @@ -614,8 +614,8 @@ - + @@ -627,8 +627,8 @@ - + @@ -640,8 +640,8 @@ - + @@ -659,8 +659,8 @@ - + @@ -672,8 +672,8 @@ - + @@ -685,8 +685,8 @@ - + @@ -749,8 +749,8 @@ - + @@ -762,8 +762,8 @@ - + @@ -775,8 +775,8 @@ - + @@ -831,8 +831,8 @@ - + @@ -844,8 +844,8 @@ - + @@ -857,8 +857,8 @@ - + @@ -913,8 +913,8 @@ - + @@ -926,8 +926,8 @@ - + @@ -939,8 +939,8 @@ - + @@ -970,8 +970,8 @@ - + @@ -983,8 +983,8 @@ - + @@ -1032,8 +1032,8 @@ - + @@ -1052,8 +1052,8 @@ - + @@ -1065,8 +1065,8 @@ - + @@ -1078,8 +1078,8 @@ - + @@ -1091,8 +1091,8 @@ - + @@ -1104,8 +1104,8 @@ - + @@ -1117,8 +1117,8 @@ - + @@ -1130,8 +1130,8 @@ - + @@ -1150,8 +1150,8 @@ - + @@ -1163,8 +1163,8 @@ - + @@ -1176,8 +1176,8 @@ - + @@ -1189,8 +1189,8 @@ - + @@ -1308,8 +1308,8 @@ - + @@ -1321,8 +1321,8 @@ - + @@ -1376,8 +1376,8 @@ - + @@ -1435,8 +1435,8 @@ - + @@ -1448,8 +1448,8 @@ - + @@ -1461,8 +1461,8 @@ - + @@ -1525,8 +1525,8 @@ - + @@ -1563,8 +1563,8 @@ - + @@ -1576,8 +1576,8 @@ - + @@ -1589,8 +1589,8 @@ - + @@ -1641,8 +1641,8 @@ - + @@ -1654,8 +1654,8 @@ - + @@ -1674,8 +1674,8 @@ - + @@ -1687,8 +1687,8 @@ - + @@ -1733,8 +1733,8 @@ - + @@ -1746,8 +1746,8 @@ - + @@ -1759,8 +1759,8 @@ - + @@ -1817,8 +1817,8 @@ - + @@ -1830,8 +1830,8 @@ - + @@ -1863,8 +1863,8 @@ - + @@ -1876,8 +1876,8 @@ - + @@ -1889,8 +1889,8 @@ - + @@ -1902,8 +1902,8 @@ - + @@ -1915,8 +1915,8 @@ - + @@ -1928,8 +1928,8 @@ - + @@ -1989,8 +1989,8 @@ - + @@ -2002,8 +2002,8 @@ - + @@ -2040,8 +2040,8 @@ - + @@ -2053,8 +2053,8 @@ - + @@ -2086,8 +2086,8 @@ - + @@ -2125,8 +2125,8 @@ - + @@ -2138,8 +2138,8 @@ - + @@ -2194,8 +2194,8 @@ - + @@ -2207,8 +2207,8 @@ - + @@ -2263,8 +2263,8 @@ - + @@ -2276,8 +2276,8 @@ - + @@ -2289,8 +2289,8 @@ - + @@ -2302,8 +2302,8 @@ - + @@ -2345,8 +2345,8 @@ - + @@ -2358,8 +2358,8 @@ - + @@ -2371,8 +2371,8 @@ - + @@ -2397,8 +2397,8 @@ - + @@ -2410,8 +2410,8 @@ - + @@ -2430,8 +2430,8 @@ - + @@ -2443,8 +2443,8 @@ - + @@ -2463,8 +2463,8 @@ - + @@ -2476,8 +2476,8 @@ - + @@ -2489,8 +2489,8 @@ - + @@ -2545,8 +2545,8 @@ - + @@ -2589,8 +2589,8 @@ - + @@ -2602,8 +2602,8 @@ - + @@ -2628,8 +2628,8 @@ - + @@ -2641,8 +2641,8 @@ - + @@ -2654,8 +2654,8 @@ - + @@ -2667,8 +2667,8 @@ - + @@ -2680,8 +2680,8 @@ - + @@ -2693,8 +2693,8 @@ - + @@ -2736,8 +2736,8 @@ - + @@ -2756,8 +2756,8 @@ - + @@ -2789,8 +2789,8 @@ - + @@ -2802,8 +2802,8 @@ - + @@ -2815,8 +2815,8 @@ - + @@ -2835,8 +2835,8 @@ - + @@ -2848,8 +2848,8 @@ - + @@ -2868,8 +2868,8 @@ - + @@ -2881,8 +2881,8 @@ - + @@ -2894,8 +2894,8 @@ - + @@ -2955,8 +2955,8 @@ - + @@ -2968,8 +2968,8 @@ - + @@ -3001,8 +3001,8 @@ - + @@ -3014,8 +3014,8 @@ - + @@ -3027,8 +3027,8 @@ - + @@ -3040,8 +3040,8 @@ - + @@ -3094,8 +3094,8 @@ - + @@ -3149,8 +3149,8 @@ - + @@ -3180,8 +3180,8 @@ - + @@ -3193,8 +3193,8 @@ - + @@ -3206,8 +3206,8 @@ - + @@ -3233,8 +3233,8 @@ - + @@ -3246,8 +3246,8 @@ - + @@ -3300,8 +3300,8 @@ - + @@ -3313,8 +3313,8 @@ - + @@ -3326,8 +3326,8 @@ - + @@ -3353,8 +3353,8 @@ - + @@ -3366,8 +3366,8 @@ - + @@ -3420,8 +3420,8 @@ - + @@ -3433,8 +3433,8 @@ - + @@ -3460,8 +3460,8 @@ - + @@ -3473,8 +3473,8 @@ - + @@ -3516,8 +3516,8 @@ - + @@ -3529,8 +3529,8 @@ - + @@ -3556,8 +3556,8 @@ - + @@ -3569,8 +3569,8 @@ - + @@ -3600,8 +3600,8 @@ - + @@ -3650,8 +3650,8 @@ - + @@ -3676,8 +3676,8 @@ - + @@ -3711,8 +3711,8 @@ - + @@ -3724,8 +3724,8 @@ - + @@ -3737,8 +3737,8 @@ - + @@ -3789,8 +3789,8 @@ - + @@ -3802,8 +3802,8 @@ - + @@ -3815,8 +3815,8 @@ - + @@ -3867,8 +3867,8 @@ - + @@ -3924,8 +3924,8 @@ - + @@ -3955,8 +3955,8 @@ - + @@ -3996,8 +3996,8 @@ - + @@ -4031,8 +4031,8 @@ - + @@ -4044,8 +4044,8 @@ - + @@ -4057,8 +4057,8 @@ - + @@ -4109,8 +4109,8 @@ - + @@ -4203,8 +4203,8 @@ - + @@ -4256,8 +4256,8 @@ - + @@ -4269,8 +4269,8 @@ - + @@ -4321,8 +4321,8 @@ - + @@ -4334,8 +4334,8 @@ - + @@ -4347,8 +4347,8 @@ - + @@ -4399,8 +4399,8 @@ - + @@ -4426,8 +4426,8 @@ - + @@ -4439,8 +4439,8 @@ - + @@ -4478,8 +4478,8 @@ - + @@ -4491,8 +4491,8 @@ - + @@ -4504,8 +4504,8 @@ - + @@ -4517,8 +4517,8 @@ - + @@ -4530,8 +4530,8 @@ - + @@ -4579,8 +4579,8 @@ - + @@ -4592,8 +4592,8 @@ - + @@ -4637,8 +4637,8 @@ - + Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== diff -u -r96871d90a1687f73bef35cac8e4837325b51e843 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 96871d90a1687f73bef35cac8e4837325b51e843) +++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -673,3 +673,30 @@ REFERENCES lams_learning_design (learning_design_id) ON DELETE NO ACTION ON UPDATE NO ACTION )TYPE=InnoDB; +CREATE TABLE lams_workspace_folder_content_type ( + content_type_id INT(3) NOT NULL AUTO_INCREMENT + , description VARCHAR(64) NOT NULL + , PRIMARY KEY (content_type_id) +)TYPE=InnoDB; + +CREATE TABLE lams_workspace_folder_content ( + folder_content_id BIGINT(20) NOT NULL AUTO_INCREMENT + , content_type_id INT(3) NOT NULL + , name VARCHAR(64) NOT NULL + , description VARCHAR(64) NOT NULL + , create_date_time DATETIME NOT NULL + , last_modified_date DATETIME NOT NULL + , workspace_folder_id BIGINT(20) NOT NULL + , uuid BIGINT(20) + , version_id BIGINT(20) + , mime_type VARCHAR(10)NOT NULL + , UNIQUE unique_content_name (name,workspace_folder_id,mime_type) + , UNIQUE unique_node_version (workspace_folder_id,uuid,version_id) + , PRIMARY KEY (folder_content_id) + , INDEX (workspace_folder_id) + , CONSTRAINT FK_lams_workspace_folder_content_1 FOREIGN KEY (workspace_folder_id) + REFERENCES lams_workspace_folder (workspace_folder_id) + , INDEX (content_type_id) + , CONSTRAINT FK_lams_workspace_folder_content_2 FOREIGN KEY (content_type_id) + REFERENCES lams_workspace_folder_content_type (content_type_id) +)TYPE=InnoDB; \ No newline at end of file Index: lams_common/db/sql/drop_lams_11_tables.sql =================================================================== diff -u -r17f868997f8a8cd76b7af8a98115f3e3c54a829b -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/sql/drop_lams_11_tables.sql (.../drop_lams_11_tables.sql) (revision 17f868997f8a8cd76b7af8a98115f3e3c54a829b) +++ lams_common/db/sql/drop_lams_11_tables.sql (.../drop_lams_11_tables.sql) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -45,7 +45,8 @@ DROP TABLE IF EXISTS lams_workspace; DROP TABLE IF EXISTS lams_workspace_folder; DROP TABLE IF EXISTS lams_workspace_folder_type; +DROP TABLE IF EXISTS lams_workspace_folder_content_type; +DROP TABLE IF EXISTS lams_workspace_folder_content; - SET FOREIGN_KEY_CHECKS=1; Index: lams_common/db/sql/insert_test_data.sql =================================================================== diff -u -rbafdaffb9333f8e4d2f0ab220763262d6c389799 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/sql/insert_test_data.sql (.../insert_test_data.sql) (revision bafdaffb9333f8e4d2f0ab220763262d6c389799) +++ lams_common/db/sql/insert_test_data.sql (.../insert_test_data.sql) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -912,10 +912,16 @@ -- insert the test data for the content repository INSERT INTO lams_cr_credential (credential_id, name, password) VALUES (1, 'atool','atool'); +INSERT INTO lams_cr_credential (credential_id, name, password) VALUES (2, 'workspaceManager','flashClient'); + INSERT INTO lams_cr_workspace (workspace_id, name) VALUES (1, 'atoolWorkspace'); -INSERT INTO lams_cr_workspace_credential (wc_id, workspace_id, credential_id) VALUES (1, 1,1); INSERT INTO lams_cr_workspace (workspace_id, name) VALUES (2, 'atoolWorkspace2'); +INSERT INTO lams_cr_workspace (workspace_id, name) VALUES (3, 'flashClientsWorkspace'); + + +INSERT INTO lams_cr_workspace_credential (wc_id, workspace_id, credential_id) VALUES (1, 1,1); INSERT INTO lams_cr_workspace_credential (wc_id, workspace_id, credential_id) VALUES (2, 2,1); +INSERT INTO lams_cr_workspace_credential (wc_id, workspace_id, credential_id) VALUES (3, 3,2); INSERT INTO lams_cr_node (node_id, workspace_id, type, created_date_time, path, next_version_id) VALUES (1, 1, 'DATANODE', 20050106103100, "/test",3); INSERT INTO lams_cr_node_version (nv_id, node_id, version_id, created_date_time) @@ -936,4 +942,11 @@ INSERT INTO lams_cr_node_version_property( id, nv_id, name, value, type) VALUES (6,3,"FILENAME","nofile.txt",1); INSERT INTO lams_cr_node_version_property( id, nv_id, name, value, type) VALUES (7,3,"MIMETYPE","unknown/unknown",1); +INSERT INTO lams_workspace_folder_content VALUES (1,1,'Document','Test Description','20050101','20050101',2,NULL,NULL,'DOC'); +INSERT INTO lams_workspace_folder_content VALUES (2,1,'Text File','Test Description','20050101','20050101',2,NULL,NULL,'TXT'); +INSERT INTO lams_workspace_folder_content VALUES (3,1,'Text File','Test Description','20050101','20050101',3,NULL,NULL,'TXT'); +INSERT INTO lams_workspace_folder_content VALUES (4,1,'Gif File','Test Description','20050101','20050101',3,NULL,NULL,'GIF'); +INSERT INTO lams_workspace_folder_content VALUES (5,1,'Gif2 File','Test Description','20050101','20050101',3,NULL,NULL,'GIF'); +INSERT INTO lams_workspace_folder_content VALUES (6,1,'Text2 File','Test Description','20050101','20050101',3,NULL,NULL,'TXT'); + SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Index: lams_common/db/sql/insert_types_data.sql =================================================================== diff -u -r1eb71bc810c06d8089316b94d831fd0d8819baca -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 1eb71bc810c06d8089316b94d831fd0d8819baca) +++ lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -81,6 +81,8 @@ INSERT INTO lams_log_event_type VALUES (5, 'LEARNER_ACTIVITY_START'); INSERT INTO lams_log_event_type VALUES (6, 'LEARNER_ACTIVITY_FINISH'); +INSERT INTO lams_workspace_folder_content_type VALUES (1,'FILE'); +INSERT INTO lams_workspace_folder_content_type VALUES (2,'PACKAGE'); Index: lams_common/lib/lams/lams_contentrepository.jar =================================================================== diff -u Binary files differ Index: lams_common/properties.xml =================================================================== diff -u -r3c677ec76c210fd186cc7c4511185b47559a72f5 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/properties.xml (.../properties.xml) (revision 3c677ec76c210fd186cc7c4511185b47559a72f5) +++ lams_common/properties.xml (.../properties.xml) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -19,6 +19,7 @@ + @@ -34,6 +35,8 @@ + + @@ -70,4 +73,6 @@ - \ No newline at end of file + + + \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.java =================================================================== diff -u -re584edf69cf772af93c4bc9444088abecb6f5520 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.java (.../WorkspaceFolder.java) (revision e584edf69cf772af93c4bc9444088abecb6f5520) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/WorkspaceFolder.java (.../WorkspaceFolder.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -24,10 +24,12 @@ import java.io.Serializable; import java.util.Date; +import java.util.HashSet; import java.util.Set; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.workspace.WorkspaceFolderContent; /** * @hibernate.class table="lams_workspace_folder" @@ -89,6 +91,13 @@ * the type of workspace folder. Can be either * NORMAL OR RUN_SEQUENCES */ private Integer workspaceFolderType; + + /** + * A Collection of WorkspaceFolderContent + * objects representing the content of this + * folder. As of now it represents only Files. + */ + private Set folderContent; public WorkspaceFolder(String name, Integer workspaceID, @@ -338,4 +347,25 @@ }else return false; } + /** + * @return Returns the folderContents. + */ + public Set getFolderContent() { + return folderContent; + } + /** + * @param folderContents The folderContents to set. + */ + public void setFolderContent(Set folderContent) { + this.folderContent = folderContent; + } + /** + * @param workspaceFolderContent The content to be added + */ + public void addFolderContent(WorkspaceFolderContent workspaceFolderContent){ + if(this.folderContent==null) + this.folderContent = new HashSet(); + + this.folderContent.add(workspaceFolderContent); + } } Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java =================================================================== diff -u -r79758294f0dfdfd6f805b9232fe3886b1a5b84ae -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 79758294f0dfdfd6f805b9232fe3886b1a5b84ae) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -325,7 +325,7 @@ /** * @param workspaceDAO The workspaceDAO to set. */ - public void setWorkspaceDAO(IWorkspaceDAO workspaceDAO) { + public void setUserManagementWorkspaceDAO(IWorkspaceDAO workspaceDAO) { this.workspaceDAO = workspaceDAO; } /** Index: lams_common/src/java/org/lamsfoundation/lams/util/wddx/FlashMessage.java =================================================================== diff -u -r704c8d12284841f9700e87df5ce6e5d9e97a7a28 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/util/wddx/FlashMessage.java (.../FlashMessage.java) (revision 704c8d12284841f9700e87df5ce6e5d9e97a7a28) +++ lams_common/src/java/org/lamsfoundation/lams/util/wddx/FlashMessage.java (.../FlashMessage.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -139,4 +139,9 @@ "No such Activity with an activity_id of " + activityID +" exists", FlashMessage.ERROR); } + public static FlashMessage getNoSuchWorkspaceFolderContentExsists(String methodName, Long folderContentID){ + return new FlashMessage(methodName, + "No such WorkspaceFolderContent with a folder_content_id of " + folderContentID +" exists", + FlashMessage.ERROR); + } } Index: lams_common/src/java/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/WorkspaceFolderContent.java (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -0,0 +1,244 @@ +/* + * Created on Apr 20, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.workspace; + +import java.io.Serializable; +import java.util.Date; +import java.util.SortedSet; + +import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; +import org.lamsfoundation.lams.workspace.dto.FolderContentDTO; + + +/** + * @author Manpreet Minhas + */ +public class WorkspaceFolderContent implements Serializable{ + + public static final Integer CONTENT_TYPE_FILE = new Integer(1); + public static final Integer CONTENT_TYPE_PACKAGE = new Integer(2); + + /** identifier field */ + private Long folderContentID; + + /** + * non-nullable persistent field + * representing the type of content. + * It can be either CONTENT_TYPE_FILE or + * CONTENT_TYPE_PACKAGE + */ + private Integer contentTypeID; + + /** non-nullable persistent field + * representing the name of the File + **/ + private String name; + + /** non-nullable persistent field + * representing the description of the File + **/ + private String description; + + /** + * non-nullable persistent field + * representing the date the content + * was created. + **/ + private Date createDate; + + /** + * non-nullable persistent field + * representing the date the content + * was last modified. + **/ + private Date lastModified; + + /** + * nullable persistent field. Represents the two + * part key - UUID and version, returned by the + * ContentRepository once the content has been successfully updated. + **/ + private Long uuid; + + /** + * nullable persistent field. Represents the two + * part key - UUID and version, returned by the + * ContentRepository once the content has been successfully updated. + **/ + private Long versionID; + + /** + * non-nullable persistent field + * indicating the type of the file + **/ + private String mimeType; + + /** non-nullable persistent field indicating the + * WorkspaceFolder that contains + * this content + **/ + private WorkspaceFolder workspaceFolder; + + /** Default Constructor*/ + public WorkspaceFolderContent(){ + + } + /** Full Constructor*/ + public WorkspaceFolderContent(Long folderContentID,Integer contentTypeID, + String name, String description, + Date createDate,Date lastModified, + Long uuid, Long versionID, + String mimeType,WorkspaceFolder workspaceFolder) { + super(); + this.folderContentID = folderContentID; + this.contentTypeID = contentTypeID; + this.name = name; + this.description = description; + this.createDate = createDate; + this.lastModified = lastModified; + this.uuid = uuid; + this.versionID = versionID; + this.mimeType = mimeType; + this.workspaceFolder = workspaceFolder; + } + /** Minimal Constructor */ + public WorkspaceFolderContent(Integer contentTypeID, String name, + String description, Date createDate, Date lastModified, + String mimeType, WorkspaceFolder workspaceFolder) { + super(); + this.contentTypeID = contentTypeID; + this.name = name; + this.description = description; + this.createDate = createDate; + this.lastModified = lastModified; + this.mimeType = mimeType; + this.workspaceFolder = workspaceFolder; + } + /** + * @return Returns the contentTypeID. + */ + public Integer getContentTypeID() { + return contentTypeID; + } + /** + * @param contentTypeID The contentTypeID to set. + */ + public void setContentTypeID(Integer contentTypeID) { + this.contentTypeID = contentTypeID; + } + /** + * @return Returns the createDate. + */ + public Date getCreateDate() { + return createDate; + } + /** + * @param createDate The createDate to set. + */ + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description; + } + /** + * @return Returns the folderContentID. + */ + public Long getFolderContentID() { + return folderContentID; + } + /** + * @param folderContentID The folderContentID to set. + */ + public void setFolderContentID(Long folderContentID) { + this.folderContentID = folderContentID; + } + /** + * @return Returns the lastModified. + */ + public Date getLastModified() { + return lastModified; + } + /** + * @param lastModified The lastModified to set. + */ + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + /** + * @return Returns the mimeType. + */ + public String getMimeType() { + return mimeType; + } + /** + * @param mimeType The mimeType to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + /** + * @return Returns the uuid. + */ + public Long getUuid() { + return uuid; + } + /** + * @param uuid The uuid to set. + */ + public void setUuid(Long uuid) { + this.uuid = uuid; + } + /** + * @return Returns the versionID. + */ + public Long getVersionID() { + return versionID; + } + /** + * @param versionID The versionID to set. + */ + public void setVersionID(Long versionID) { + this.versionID = versionID; + } + /** + * @return Returns the workspaceFolder. + */ + public WorkspaceFolder getWorkspaceFolder() { + return workspaceFolder; + } + /** + * @param workspaceFolder The workspaceFolder to set. + */ + public void setWorkspaceFolder(WorkspaceFolder workspaceFolder) { + this.workspaceFolder = workspaceFolder; + } + public FolderContentDTO getFolderContentDTO(SortedSet set, Integer permissions){ + return new FolderContentDTO(permissions,this,set); + } +} Index: lams_common/src/java/org/lamsfoundation/lams/workspace/dao/IWorkspaceFolderContentDAO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/workspace/dao/IWorkspaceFolderContentDAO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/dao/IWorkspaceFolderContentDAO.java (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -0,0 +1,49 @@ +/* + * Created on Apr 20, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.workspace.dao; + +import java.util.List; + +import org.lamsfoundation.lams.learningdesign.dao.IBaseDAO; +import org.lamsfoundation.lams.workspace.WorkspaceFolderContent; + +/** + * @author Manprete Minhas + */ +public interface IWorkspaceFolderContentDAO extends IBaseDAO { + + /** + * This method returns the WorkspaceFolderContent + * corresponding to the given folderContentID + * + * @param folderContentID The folder_content_id of the required object + * @return WorkspaceFolderContent The populated WorkspaceFolderContent object + */ + public WorkspaceFolderContent getWorkspaceFolderContentByID(Long folderContentID); + + /** + * This method returns the content for the given WorkspaceFolder + * with given workspaceFolderID. + * + * @param workspaceFolderID The WorkspaceFolder whose content is requested + * @return List The requested content + */ + public List getContentByWorkspaceFolder(Long workspaceFolderID); + + /** + * This method returns the content of the WorkspaceFolder + * with given workspaceFolderID, which is of requested mimeType + * + * @param workspaceFolderID The WorkspaceFolder whose content is requested + * @param mimeType The mimeType of the requested content + * @return List The requested content + */ + public List getContentByTypeFromWorkspaceFolder(Long workspaceFolderID, String mimeType); + + public int deleteContentWithVersion(Long uuid, Long versionID, Long folderContentID); + +} Index: lams_common/src/java/org/lamsfoundation/lams/workspace/dao/hibernate/WorkspaceFolderContentDAO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/workspace/dao/hibernate/WorkspaceFolderContentDAO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/dao/hibernate/WorkspaceFolderContentDAO.java (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -0,0 +1,75 @@ +/* + * Created on Apr 20, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.workspace.dao.hibernate; + +import java.util.List; + +import net.sf.hibernate.Hibernate; +import net.sf.hibernate.type.Type; + +import org.lamsfoundation.lams.learningdesign.dao.hibernate.BaseDAO; +import org.lamsfoundation.lams.workspace.WorkspaceFolderContent; +import org.lamsfoundation.lams.workspace.dao.IWorkspaceFolderContentDAO; + +/** + * @author Minhas + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class WorkspaceFolderContentDAO extends BaseDAO implements IWorkspaceFolderContentDAO { + + private static final String TABLENAME ="lams_workspace_folder_content"; + + private static final String FIND_BY_FOLDER ="from " + TABLENAME +" in class " + + WorkspaceFolderContent.class.getName() + + " where workspace_folder_id=?"; + + private static final String FIND_BY_TYPE_IN_FOLDER = "from " + TABLENAME +" in class " + + WorkspaceFolderContent.class.getName() + + " where workspace_folder_id=? AND mime_type=?"; + + private static final String DELETE_BY_VERSION = "from " + TABLENAME +" in class " + + WorkspaceFolderContent.class.getName() + + " where folder_content_id=? AND uuid=? AND version_id=?"; + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.dao.IWorkspaceFolderContentDAO#getWorkspaceFolderContentByID(java.lang.Long) + */ + public WorkspaceFolderContent getWorkspaceFolderContentByID(Long folderContentID) { + return (WorkspaceFolderContent) super.find(WorkspaceFolderContent.class, folderContentID); + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.dao.IWorkspaceFolderContentDAO#getContentByWorkspaceFolder(java.lang.Long) + */ + public List getContentByWorkspaceFolder(Long workspaceFolderID) { + return this.getHibernateTemplate().find(FIND_BY_FOLDER,workspaceFolderID); + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.dao.IWorkspaceFolderContentDAO#getContentByTypeFromWorkspaceFolder(java.lang.Long, java.lang.String) + */ + public List getContentByTypeFromWorkspaceFolder(Long workspaceFolderID,String mimeType) { + List list = this.getHibernateTemplate().find(FIND_BY_TYPE_IN_FOLDER, + new Object[]{workspaceFolderID,mimeType}, + new Type[]{Hibernate.LONG,Hibernate.STRING}); + if(list==null||list.size()==0) + return null; + else + return list; + } + public int deleteContentWithVersion(Long uuid, Long versionID, Long folderContentID){ + return this.getHibernateTemplate().delete(DELETE_BY_VERSION, + new Object[]{folderContentID,uuid,versionID}, + new Type[]{Hibernate.LONG,Hibernate.LONG,Hibernate.LONG}); + + } +} Index: lams_common/src/java/org/lamsfoundation/lams/workspace/dto/FolderContentDTO.java =================================================================== diff -u -r79758294f0dfdfd6f805b9232fe3886b1a5b84ae -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/workspace/dto/FolderContentDTO.java (.../FolderContentDTO.java) (revision 79758294f0dfdfd6f805b9232fe3886b1a5b84ae) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/dto/FolderContentDTO.java (.../FolderContentDTO.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -7,30 +7,32 @@ package org.lamsfoundation.lams.workspace.dto; import java.util.Date; +import java.util.SortedSet; +import java.util.Vector; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; import org.lamsfoundation.lams.util.wddx.WDDXTAGS; +import org.lamsfoundation.lams.workspace.WorkspaceFolderContent; /** - * @author Minhas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * @author Manpreet Minhas */ public class FolderContentDTO { - public static final String LESSON ="lesson"; - public static final String DESIGN ="learningDesign"; - public static final String FOLDER ="folder"; + public static final String LESSON ="Lesson"; + public static final String DESIGN ="LearningDesign"; + public static final String FOLDER ="Folder"; + public static final String FILE ="File"; - private String name; - private String description; - private Date creationDateTime; - private Date lastModifiedDateTime; - private String resourceType; - private Long resourceID; - private Integer permissionCode; + public String name; + public String description; + public Date creationDateTime; + public Date lastModifiedDateTime; + public String resourceType; + public Long resourceID; + public Integer permissionCode; + public Vector versionDetails; public FolderContentDTO(){ @@ -47,6 +49,7 @@ this.resourceType = resourceType; this.resourceID = resourceID; this.permissionCode = permissionCode; + this.versionDetails = new Vector(); } public FolderContentDTO(LearningDesign design, Integer permissionCode){ this.name = design.getTitle(); @@ -56,6 +59,7 @@ this.resourceType = DESIGN; this.resourceID = design.getLearningDesignId(); this.permissionCode = permissionCode; + this.versionDetails = new Vector(); } public FolderContentDTO(WorkspaceFolder workspaceFolder, Integer permissionCode){ this.name = workspaceFolder.getName(); @@ -65,7 +69,22 @@ this.resourceType = FOLDER; this.resourceID = new Long(workspaceFolder.getWorkspaceFolderId().intValue()); this.permissionCode = permissionCode; - } + this.versionDetails = new Vector(); + } + public FolderContentDTO(Integer permissionCode, WorkspaceFolderContent workspaceFolderContent,SortedSet details){ + this.name =workspaceFolderContent.getName(); + this.description = workspaceFolderContent.getDescription(); + this.creationDateTime = workspaceFolderContent.getCreateDate(); + this.lastModifiedDateTime = workspaceFolderContent.getLastModified(); + this.resourceID = workspaceFolderContent.getFolderContentID(); + this.permissionCode = permissionCode; + if(workspaceFolderContent.getContentTypeID().equals(WorkspaceFolderContent.CONTENT_TYPE_FILE)) + this.resourceType = FILE; + else + this.resourceType = FOLDER; + this.versionDetails = new Vector(); + versionDetails.addAll(details); + } /** * @return Returns the creationDateTime. */ @@ -108,4 +127,10 @@ public String getResourceType() { return resourceType!=null?resourceType:WDDXTAGS.STRING_NULL_VALUE; } + /** + * @return Returns the versionDetails. + */ + public Vector getVersionDetails() { + return versionDetails; + } } Index: lams_common/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java =================================================================== diff -u -rb5e2e71d176c89c0685d090c662bc303fbc85ea7 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java (.../IWorkspaceManagementService.java) (revision b5e2e71d176c89c0685d090c662bc303fbc85ea7) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/service/IWorkspaceManagementService.java (.../IWorkspaceManagementService.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -1,6 +1,7 @@ package org.lamsfoundation.lams.workspace.service; import java.io.IOException; +import java.util.Date; import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; import org.lamsfoundation.lams.usermanagement.exception.UserException; @@ -11,6 +12,10 @@ */ public interface IWorkspaceManagementService { + public static final String REPOSITORY_USERNAME ="workspaceManager"; + public static final String REPOSITORY_PASSWORD ="flashClient"; + public static final String REPOSITORY_WORKSPACE="FlashClientsWorkspace"; + /** * This method returns the contents of the folder with given * workspaceFolderID depending upon the mode. @@ -21,7 +26,7 @@ *
    *
  • AUTHORING In which case all the Learning Designs in the given * folder are returned OR
  • - *
  • MONITORING In which case only those learning Designs that are + *
  • MONITORING In which case only those Learning Designs that are * valid are returned
  • *
* @@ -51,9 +56,9 @@ * whose contents are requested * @param mode It can be either 1(AUTHORING) or 2(MONITORING) * @return String The required information in WDDX format - * @throws IOException + * @throws Exception */ - public String getFolderContents(Integer userID, Integer workspaceFolderID, Integer mode)throws IOException; + public String getFolderContents(Integer userID, Integer workspaceFolderID, Integer mode)throws Exception; /** * This method creates a new folder under the given parentFolder @@ -167,5 +172,54 @@ * @throws IOException */ public String moveFolder(Integer currentFolderID,Integer targetFolderID,Integer userID)throws IOException; + + /** + * This method is called every time a new content is inserted into the + * given workspaceFolder. The content to be inserted can be either of + * type FILE or PACKAGE, which is indicated by contentTypeID. + * A value of 1 indicates a FILE and a value of 2 indicates PACKAGE. + * + * After updating the database with the corresponding entry of the new content + * this method then updates the Repository as well. + * + * @param contentTypeID The type of content being added.(FILE/PACKAGE) + * @param name The name of the file + * @param description The description of the file + * @param createDateTime The date and time this content was created + * @param lastModifiedDate The date and time this content was last modified + * @param workspaceFolderID The container(workspaceFolder)which + * 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 + * @return String The acknowledgement/error message in WDDX format for the + * FLASH client. + * @throws Exception + */ + public String createWorkspaceFolderContent(Integer contentTypeID,String name, + String description,Date createDateTime, + Date lastModifiedDate,Integer workspaceFolderID, + String mimeType, String path)throws Exception; + + /** + * This method updates an existing file(workspaceFolderContet) + * with new contents in the Reositiory. + * + * @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 + * @return String The acknowledgement/error message in WDDX format for FLASH + * @throws Exception + */ + public String updateWorkspaceFolderContent(Long folderContentID,String path)throws Exception; + + /** + * This method deletes all versions of the given content (FILE/PACKAGE) + * fom the repository. + * + * @param folderContentID The content to be deleted + * @return String Acknowledgement/error message in WDDX format for FLASH + * @throws Exception + */ + public String deleteWorkspaceFolderContent(Long folderContentID)throws Exception; } Index: lams_common/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java =================================================================== diff -u -rb5e2e71d176c89c0685d090c662bc303fbc85ea7 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java (.../WorkspaceManagementService.java) (revision b5e2e71d176c89c0685d090c662bc303fbc85ea7) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/service/WorkspaceManagementService.java (.../WorkspaceManagementService.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -6,14 +6,28 @@ */ package org.lamsfoundation.lams.workspace.service; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Date; import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.SortedSet; import java.util.Vector; +import org.lamsfoundation.lams.contentrepository.LoginException; import org.lamsfoundation.lams.authoring.service.IAuthoringService; +import org.lamsfoundation.lams.contentrepository.AccessDeniedException; +import org.lamsfoundation.lams.contentrepository.FileException; +import org.lamsfoundation.lams.contentrepository.ICredentials; +import org.lamsfoundation.lams.contentrepository.ITicket; +import org.lamsfoundation.lams.contentrepository.InvalidParameterException; +import org.lamsfoundation.lams.contentrepository.NodeKey; +import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; +import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; +import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; +import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.dao.ILearningDesignDAO; import org.lamsfoundation.lams.usermanagement.User; @@ -26,6 +40,8 @@ import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.util.wddx.FlashMessage; import org.lamsfoundation.lams.util.wddx.WDDXTAGS; +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.exception.WorkspaceFolderException; @@ -48,10 +64,20 @@ protected IWorkspaceDAO workspaceDAO; protected IOrganisationDAO organisationDAO; - protected IAuthoringService authoringService; + protected IWorkspaceFolderContentDAO workspaceFolderContentDAO; + protected IAuthoringService authoringService; + protected IRepositoryService repositoryService; + /** + * @param workspaceFolderContentDAO The workspaceFolderContentDAO to set. + */ + public void setWorkspaceFolderContentDAO( + IWorkspaceFolderContentDAO workspaceFolderContentDAO) { + this.workspaceFolderContentDAO = workspaceFolderContentDAO; + } + /** * @param authoringService The authoringService to set. */ public void setAuthoringService(IAuthoringService authoringService) { @@ -145,7 +171,7 @@ * (non-Javadoc) * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#getFolderContents(java.lang.Integer, java.lang.Integer, java.lang.Integer) */ - public String getFolderContents(Integer userID, Integer workspaceFolderID, Integer mode)throws IOException{ + public String getFolderContents(Integer userID, Integer workspaceFolderID, Integer mode)throws Exception{ User user = userDAO.getUserById(userID); WorkspaceFolder workspaceFolder = null; Integer permissions = null; @@ -157,7 +183,10 @@ Vector contentDTO = new Vector(); getFolderContent(workspaceFolder,permissions,mode,contentDTO); if(workspaceFolder.hasSubFolders()) - getSubFolderDetails(workspaceFolder,permissions,contentDTO); + getSubFolderDetails(workspaceFolder,permissions,contentDTO); + Vector repositoryContent = getContentsFromRepository(new Long(workspaceFolderID.intValue()),permissions); + if(repositoryContent!=null) + contentDTO.addAll(repositoryContent); flashMessage = new FlashMessage("getFolderContents",createFolderContentPacket(workspaceFolder,contentDTO)); } else @@ -512,4 +541,222 @@ } return flashMessage.serializeMessage(); } + /** + * This method verifies the credentials of the Workspace Manager + * and gives him the Ticket to login and access the Content Repository. + * A valid ticket is needed in order to access the content from the repository. + * This method would be called evertime the user(Workspace Manager) receives + * a request to get the contents of the Folder or to add/update a file into + * the WorkspaceFodler (Repository). + * + * @return ITicket The ticket for repostory access + */ + private ITicket getRepositoryLoginTicket(){ + repositoryService = RepositoryProxy.getLocalRepositoryService(); + ICredentials credentials = new SimpleCredentials(IWorkspaceManagementService.REPOSITORY_USERNAME, + IWorkspaceManagementService.REPOSITORY_PASSWORD.toCharArray()); + try{ + ITicket ticket = repositoryService.login(credentials,IWorkspaceManagementService.REPOSITORY_WORKSPACE); + return ticket; + }catch(AccessDeniedException ae){ + ae.printStackTrace(); + return null; + }catch(WorkspaceNotFoundException we){ + we.printStackTrace(); + return null; + }catch (LoginException e) { + e.printStackTrace(); + return null; + } + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#createWorkspaceFolderContent(java.lang.Integer, java.lang.String, java.lang.String, java.util.Date, java.util.Date, java.lang.Integer, java.lang.String, java.lang.String) + */ + public String createWorkspaceFolderContent(Integer contentTypeID,String name, + String description,Date createDateTime, + Date lastModifiedDate,Integer workspaceFolderID, + String mimeType, String path)throws Exception{ + WorkspaceFolder workspaceFolder = workspaceFolderDAO.getWorkspaceFolderByID(workspaceFolderID); + if(workspaceFolder!=null){ + WorkspaceFolderContent workspaceFolderContent = new WorkspaceFolderContent(contentTypeID,name,description,createDateTime,lastModifiedDate,mimeType,workspaceFolder); + workspaceFolderContentDAO.insert(workspaceFolderContent); + try{ + InputStream stream = new FileInputStream(path); + NodeKey nodeKey = addFileToRepository(stream,name,mimeType); + workspaceFolderContent.setUuid(nodeKey.getUuid()); + workspaceFolderContent.setVersionID(nodeKey.getUuid()); + workspaceFolderContentDAO.update(workspaceFolderContent); + flashMessage = new FlashMessage("createWorkspaceFolderContent",nodeKey); + }catch(AccessDeniedException ae){ + flashMessage = new FlashMessage("createWorkspaceFolderContent", + "Exception occured while creating workspaceFolderContent: "+ ae.getMessage(), + FlashMessage.CRITICAL_ERROR); + }catch(FileException fe){ + flashMessage = new FlashMessage("createWorkspaceFolderContent", + "Exception occured while creating workspaceFolderContent: "+ fe.getMessage(), + FlashMessage.CRITICAL_ERROR); + + }catch(InvalidParameterException ip){ + flashMessage = new FlashMessage("createWorkspaceFolderContent", + "Exception occured while creating workspaceFolderContent: "+ ip.getMessage(), + FlashMessage.CRITICAL_ERROR); + } + }else + flashMessage = FlashMessage.getNoSuchWorkspaceFolderExsists("createWorkspaceFolderContent",workspaceFolderID); + return flashMessage.serializeMessage(); + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#updateWorkspaceFolderContent(java.lang.Long, java.io.InputStream) + */ + public String updateWorkspaceFolderContent(Long folderContentID,String path)throws Exception{ + InputStream stream = new FileInputStream(path); + WorkspaceFolderContent workspaceFolderContent = workspaceFolderContentDAO.getWorkspaceFolderContentByID(folderContentID); + if(workspaceFolderContent!=null){ + NodeKey nodeKey = updateFileInRepository(workspaceFolderContent,stream); + flashMessage = new FlashMessage("updateWorkspaceFolderContent",nodeKey); + }else + flashMessage = FlashMessage.getNoSuchWorkspaceFolderContentExsists("updateWorkspaceFolderContent",folderContentID); + return flashMessage.serializeMessage(); + } + + /** + * This method is called everytime a new content has to be + * added to the repository. In order to do so first of all + * a valid ticket is obtained from the Repository hence + * authenticating the user(WorkspaceManager) and then + * the corresponding file is added to the repository. + * + * @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) + * @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)throws AccessDeniedException, + FileException,InvalidParameterException{ + ITicket ticket = getRepositoryLoginTicket(); + NodeKey nodeKey = repositoryService.addFileItem(ticket,stream,fileName,mimeType,null); + return nodeKey; + } + /** + * This method is called everytime some content has to be + * updated into the repository. In order to do so first of all + * a valid ticket is obtained from the Repository hence + * authenticating the user(WorkspaceManager) and then + * the corresponding file is updated to the repository. + * + * @param workspaceFolderContent The content to be updated + * @param stream stream The InputStream representing the data to be updated + * @return NodeKey Represents the two part key - UUID and Version. + * @throws Exception + */ + private NodeKey updateFileInRepository(WorkspaceFolderContent workspaceFolderContent, + InputStream stream)throws Exception{ + ITicket ticket = getRepositoryLoginTicket(); + NodeKey nodeKey = repositoryService.updateFileItem(ticket,workspaceFolderContent.getUuid(), + workspaceFolderContent.getName(), + stream,workspaceFolderContent.getMimeType(),null); + workspaceFolderContent.setUuid(nodeKey.getUuid()); + workspaceFolderContent.setVersionID(nodeKey.getVersion()); + workspaceFolderContentDAO.update(workspaceFolderContent); + return nodeKey; + } + + /** + * This method is called when the user knows which version of the + * worksapceFolderContent he wants to delete. + * + * The database (lams_workspace_folder_content) + * stores information only about the latest version of the file. + * So if a user deletes all the versions from the repository + * one by one. there is no way the database would get to know + * about the change.So every time a request is received to + * delete a content from the repository, the database is checked + * against the uuid and version_id + * for the given content.If found that record is also deleted. + * + * @param uuid The uuid of the workspaceFolderContent + * @param versionID The versionID of the workspaceFolderContent + * @param folderContentID The folder_content_id of the content to be deleted + * @return String Acknowledgement/error message in WDDX format for FLASH + * @throws Exception + */ + + public String deleteContentWithVersion(Long uuid, Long versionID,Long folderContentID)throws Exception{ + ITicket ticket = getRepositoryLoginTicket(); + String files[] = repositoryService.deleteVersion(ticket,uuid,versionID); + if(files==null){ + workspaceFolderContentDAO.deleteContentWithVersion(uuid,versionID,folderContentID); + flashMessage = new FlashMessage("deleteContentWithVersion","Content Successfully deleted"); + }else + flashMessage = new FlashMessage("deleteContentWithVersion", + "Following files could not be deleted" + files, + FlashMessage.CRITICAL_ERROR); + + return flashMessage.serializeMessage(); + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService#deleteWorkspaceFolderContent(java.lang.Long, boolean) + */ + public String deleteWorkspaceFolderContent(Long folderContentID)throws Exception{ + WorkspaceFolderContent workspaceFolderContent = workspaceFolderContentDAO.getWorkspaceFolderContentByID(folderContentID); + if(workspaceFolderContent!=null){ + Long uuid = workspaceFolderContent.getUuid(); + Long versionID = workspaceFolderContent.getVersionID(); + ITicket ticket = getRepositoryLoginTicket(); + String files[] = repositoryService.deleteNode(ticket,uuid); + if(files!=null){ + flashMessage = new FlashMessage("deleteWorkspaceFolderContent", + "Follwing files could not be deleted" + files.toString(), + FlashMessage.CRITICAL_ERROR); + }else{ + + flashMessage = new FlashMessage("deleteWorkspaceFolderContent","Content deleted"); + } + }else + flashMessage = FlashMessage.getNoSuchWorkspaceFolderContentExsists("deleteWorkspaceFolderContent",folderContentID); + + return flashMessage.serializeMessage(); + + } + /** + * TODO + * This method returns the contents of the given folder from the + * repository. As of now I am assuming that a folder contains only + * FILES and not PACKAGES. This method would be modified in the near + * future to return a list of PACKAGES contained as well. + * + * For every file contained within the given WorkspaceFolder + * this method also returns a list of all its availabe versions. + * + * @param workspaceFolderID The WorkspaceFolder whose contents have been + * requested from the Repositor + * @param permissions The permissions on this WorkspaceFolder and hence all its contents + * @return Vector A collection of required information. + * @throws Exception + */ + private Vector getContentsFromRepository(Long workspaceFolderID, Integer permissions)throws Exception{ + List content = workspaceFolderContentDAO.getContentByWorkspaceFolder(workspaceFolderID); + if(content.size()==0) + return null; + else{ + ITicket ticket = getRepositoryLoginTicket(); + Vector repositoryContent = new Vector(); + Iterator contentIterator = content.iterator(); + while(contentIterator.hasNext()){ + WorkspaceFolderContent workspaceFolderContent = (WorkspaceFolderContent)contentIterator.next(); + SortedSet set = repositoryService.getVersionHistory(ticket,workspaceFolderContent.getUuid()); + repositoryContent.add(workspaceFolderContent.getFolderContentDTO(set,permissions)); + } + return repositoryContent; + } + } } Index: lams_common/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java =================================================================== diff -u -rb5e2e71d176c89c0685d090c662bc303fbc85ea7 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java (.../WorkspaceAction.java) (revision b5e2e71d176c89c0685d090c662bc303fbc85ea7) +++ lams_common/src/java/org/lamsfoundation/lams/workspace/web/WorkspaceAction.java (.../WorkspaceAction.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -23,6 +23,7 @@ package org.lamsfoundation.lams.workspace.web; import java.io.IOException; +import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -69,7 +70,7 @@ public ActionForward getFolderContents(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response)throws ServletException,IOException{ + HttpServletResponse response)throws ServletException,Exception{ Integer folderID = new Integer(WebUtil.readIntParam(request,"folderID")); Integer mode = new Integer(WebUtil.readIntParam(request,"mode")); Integer userID = new Integer(WebUtil.readIntParam(request,"userID")); @@ -127,6 +128,45 @@ String wddxPacket = workspaceManagementService.moveFolder(currentFolderID,targetFolderID,userID); return mapping.findForward("success"); } + + public ActionForward createWorkspaceFolderContent(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws ServletException, Exception{ + Integer contentTypeID = new Integer(WebUtil.readIntParam(request,"contentType")); + String name = WebUtil.readStrParam(request,"name"); + String description = WebUtil.readStrParam(request,"description"); + Date createDateTime = new Date(WebUtil.readStrParam(request,"createDateTime")); + Date lastModifiedDate = new Date(WebUtil.readStrParam(request,"lastModifiedDateTime")); + Integer workspaceFolderID = new Integer(WebUtil.readIntParam(request,"workspaceFolderID")); + String mimeType = WebUtil.readStrParam(request,"mimeType"); + String path = WebUtil.readStrParam(request,"path"); + + IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService(); + String message = workspaceManagementService.createWorkspaceFolderContent(contentTypeID,name,description, + createDateTime,lastModifiedDate,workspaceFolderID, + mimeType,path); + return mapping.findForward("success"); + } + public ActionForward updateWorkspaceFolderContent(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws ServletException, Exception{ + Long folderContentID = new Long(WebUtil.readLongParam(request,"folderContentID")); + String path = WebUtil.readStrParam(request,"path"); + IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService(); + String message = workspaceManagementService.updateWorkspaceFolderContent(folderContentID,path); + return mapping.findForward("success"); + } + public ActionForward deleteAllVersionsOfContent(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response)throws ServletException, Exception{ + Long folderContentID = new Long(WebUtil.readLongParam(request,"folderContentID")); + IWorkspaceManagementService workspaceManagementService = getWorkspaceManagementService(); + String message = workspaceManagementService.deleteWorkspaceFolderContent(folderContentID); + return mapping.findForward("success"); + } } Index: lams_common/test/java/org/lamsfoundation/lams/learningdesign/TestActivity.java =================================================================== diff -u -r4601ad05006851314d0497b306151ce24447cf22 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/learningdesign/TestActivity.java (.../TestActivity.java) (revision 4601ad05006851314d0497b306151ce24447cf22) +++ lams_common/test/java/org/lamsfoundation/lams/learningdesign/TestActivity.java (.../TestActivity.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -105,16 +105,10 @@ assertNotNull(child); assertEquals("verify id",TEST_CHILD_QNA_ACTIVITY_ID,child.getActivityId().longValue()); } + protected String[] getContextConfigLocation() { + return new String[] {"WEB-INF/spring/applicationContext.xml","WEB-INF/spring/learningDesignApplicationContext.xml"}; + } /** - * @see org.lamsfoundation.lams.AbstractLamsTestCase#getContextConfigLocation() - */ - protected String[] getContextConfigLocation() - { - return new String[] {"/org/lamsfoundation/lams/learningdesign/learningDesignApplicationContext.xml", - "applicationContext.xml"}; - } - - /** * @see org.lamsfoundation.lams.AbstractLamsTestCase#getHibernateSessionFactoryName() */ protected String getHibernateSessionFactoryName() Index: lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestGroupingDAO.java =================================================================== diff -u -r4601ad05006851314d0497b306151ce24447cf22 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestGroupingDAO.java (.../TestGroupingDAO.java) (revision 4601ad05006851314d0497b306151ce24447cf22) +++ lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestGroupingDAO.java (.../TestGroupingDAO.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -79,8 +79,8 @@ */ protected String[] getContextConfigLocation() { - return new String[] {"/org/lamsfoundation/lams/learningdesign/learningDesignApplicationContext.xml", - "applicationContext.xml"}; + return new String[] {"WEB-INF/spring/learningDesignApplicationContext.xml", + "WEB-INF/spring/applicationContext.xml"}; } public void testGetGrouping() Index: lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestLearningDesignDAO.java =================================================================== diff -u -r4a2deb79ebfd327cd6b7444f139de156eeb4434b -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestLearningDesignDAO.java (.../TestLearningDesignDAO.java) (revision 4a2deb79ebfd327cd6b7444f139de156eeb4434b) +++ lams_common/test/java/org/lamsfoundation/lams/learningdesign/dao/TestLearningDesignDAO.java (.../TestLearningDesignDAO.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -48,10 +48,10 @@ userDAO = (UserDAO)context.getBean("userDAO"); } public void testCalculateFirstActivity(){ - learningDesign = learningDesignDAO.getLearningDesignById(new Long(2)); + learningDesign = learningDesignDAO.getLearningDesignById(new Long(1)); Activity activity = learningDesign.calculateFirstActivity(); assertNotNull(activity.getActivityId()); - long x = 27; + long x = 20; assertEquals(activity.getActivityId().longValue(),x); } protected String[] getContextConfigLocation() { @@ -63,7 +63,7 @@ System.out.println("SIZE:"+list.size()); } public void testGetLearningDesignDTO() throws Exception{ - learningDesign = learningDesignDAO.getLearningDesignById(new Long(2)); + learningDesign = learningDesignDAO.getLearningDesignById(new Long(1)); LearningDesignDTO learningDesignDTO = learningDesign.getLearningDesignDTO(); String str = WDDXProcessor.serialize(learningDesignDTO); System.out.println(str); Index: lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java =================================================================== diff -u -r4601ad05006851314d0497b306151ce24447cf22 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision 4601ad05006851314d0497b306151ce24447cf22) +++ lams_common/test/java/org/lamsfoundation/lams/lesson/LessonDataAccessTestCase.java (.../LessonDataAccessTestCase.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -118,16 +118,13 @@ super.tearDown(); } + protected String[] getContextConfigLocation() { + return new String[] {"WEB-INF/spring/applicationContext.xml", + "/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml", + "WEB-INF/spring/learningDesignApplicationContext.xml"}; + } - /** - * @see org.lamsfoundation.lams.AbstractLamsTestCase#getContextConfigLocation() - */ - protected String[] getContextConfigLocation() - { - return new String[] { "/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml", - "/org/lamsfoundation/lams/learningdesign/learningDesignApplicationContext.xml", - "applicationContext.xml"}; - } + //--------------------------------------------------------------------- // Data initialization and finalization methods Index: lams_common/test/java/org/lamsfoundation/lams/tool/ToolDataAccessTestCase.java =================================================================== diff -u -r4601ad05006851314d0497b306151ce24447cf22 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/tool/ToolDataAccessTestCase.java (.../ToolDataAccessTestCase.java) (revision 4601ad05006851314d0497b306151ce24447cf22) +++ lams_common/test/java/org/lamsfoundation/lams/tool/ToolDataAccessTestCase.java (.../ToolDataAccessTestCase.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -116,8 +116,8 @@ { return new String[] { "/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml", "/org/lamsfoundation/lams/tool/toolApplicationContext.xml", - "/org/lamsfoundation/lams/learningdesign/learningDesignApplicationContext.xml", - "applicationContext.xml"}; + "WEB-INF/spring/learningDesignApplicationContext.xml", + "WEB-INF/spring/applicationContext.xml"}; } public void initTestToolSession() Index: lams_common/test/java/org/lamsfoundation/lams/usermanagement/TestUserManagementService.java =================================================================== diff -u -r704c8d12284841f9700e87df5ce6e5d9e97a7a28 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/usermanagement/TestUserManagementService.java (.../TestUserManagementService.java) (revision 704c8d12284841f9700e87df5ce6e5d9e97a7a28) +++ lams_common/test/java/org/lamsfoundation/lams/usermanagement/TestUserManagementService.java (.../TestUserManagementService.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -89,5 +89,9 @@ return "coreSessionFactory"; } + public void testGetWorkspace()throws IOException{ + String str = userManagementService.getWorkspace(new Integer(4)); + System.out.println(str); + } } Index: lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationTypeDAOTest.java =================================================================== diff -u -r19c9010eff6be2e29657beed94349a978088650f -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationTypeDAOTest.java (.../OrganisationTypeDAOTest.java) (revision 19c9010eff6be2e29657beed94349a978088650f) +++ lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/OrganisationTypeDAOTest.java (.../OrganisationTypeDAOTest.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -6,12 +6,11 @@ package org.lamsfoundation.lams.usermanagement.dao.hibernate; import org.springframework.context.ApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; - +import org.lamsfoundation.lams.AbstractLamsTestCase; import org.lamsfoundation.lams.usermanagement.OrganisationType; -import junit.framework.TestCase; + /** * TODO Add description here * @@ -21,15 +20,18 @@ * * @author Fei Yang */ -public class OrganisationTypeDAOTest extends TestCase { +public class OrganisationTypeDAOTest extends AbstractLamsTestCase{ private OrganisationType organisationType = null; private String errorMessage = ""; private OrganisationTypeDAO organisationTypeDAO = null; private ApplicationContext ctx; + public OrganisationTypeDAOTest(String name){ + super(name); + } protected void setUp() throws Exception{ - ctx = new FileSystemXmlApplicationContext("applicationContext.xml"); - organisationTypeDAO = (OrganisationTypeDAO)ctx.getBean("organisationTypeDAO"); + super.setUp(); + organisationTypeDAO = (OrganisationTypeDAO)context.getBean("organisationTypeDAO"); } protected void tearDown() throws Exception{ @@ -41,7 +43,14 @@ organisationTypeDAO.saveOrganisationType(organisationType); assertNotNull(organisationTypeDAO.getOrganisationTypeByName("TEST")); } - + /** + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getContextConfigLocation() + */ + protected String[] getContextConfigLocation() + { + return new String[] {"WEB-INF/spring/learningDesignApplicationContext.xml", + "WEB-INF/spring/applicationContext.xml"}; + } public void testGetOrganisationTypeById(){ errorMessage = "The name of the organisationType gotten by Id 1 is not ROOT ORGANISATION"; organisationType = organisationTypeDAO.getOrganisationTypeById(new Integer(1)); @@ -60,5 +69,12 @@ organisationTypeDAO.deleteOrganisationType(organisationType); assertNull(organisationTypeDAO.getOrganisationTypeByName("TEST")); } + /** + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getHibernateSessionFactoryName() + */ + protected String getHibernateSessionFactoryName() + { + return "coreSessionFactory"; + } } Index: lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/RoleDAOTest.java =================================================================== diff -u -r19c9010eff6be2e29657beed94349a978088650f -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/RoleDAOTest.java (.../RoleDAOTest.java) (revision 19c9010eff6be2e29657beed94349a978088650f) +++ lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/RoleDAOTest.java (.../RoleDAOTest.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -4,13 +4,10 @@ * Last modified on Nov 26, 2004 */ package org.lamsfoundation.lams.usermanagement.dao.hibernate; - import org.springframework.context.ApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; - +import org.lamsfoundation.lams.AbstractLamsTestCase; import org.lamsfoundation.lams.usermanagement.Role; -import junit.framework.TestCase; /** * TODO Add description here @@ -21,24 +18,27 @@ * * @author Fei Yang */ -public class RoleDAOTest extends TestCase { +public class RoleDAOTest extends AbstractLamsTestCase { private Role role = null; private String errorMessage = ""; private RoleDAO roleDAO = null; private ApplicationContext ctx; + public RoleDAOTest(String name){ + super(name); + } protected void setUp() throws Exception{ - ctx = new FileSystemXmlApplicationContext("applicationContext.xml"); - roleDAO = (RoleDAO)ctx.getBean("roleDAO"); + super.setUp(); + roleDAO = (RoleDAO)context.getBean("roleDAO"); } protected void tearDown() throws Exception{ roleDAO = null; } public void testGetAllRoles(){ - assertTrue(roleDAO.getAllRoles().size()==5); + assertTrue(roleDAO.getAllRoles().size()>0); } public void testGetRoleById(){ @@ -52,4 +52,19 @@ role = roleDAO.getRoleByName("SYSADMIN"); assertEquals(errorMessage,new Integer(1),role.getRoleId()); } + /** + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getHibernateSessionFactoryName() + */ + protected String getHibernateSessionFactoryName() + { + return "coreSessionFactory"; + } + /** + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getContextConfigLocation() + */ + protected String[] getContextConfigLocation() + { + return new String[] {"WEB-INF/spring/learningDesignApplicationContext.xml", + "WEB-INF/spring/applicationContext.xml"}; + } } Index: lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/TestWorkspaceDAO.java =================================================================== diff -u -re584edf69cf772af93c4bc9444088abecb6f5520 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/TestWorkspaceDAO.java (.../TestWorkspaceDAO.java) (revision e584edf69cf772af93c4bc9444088abecb6f5520) +++ lams_common/test/java/org/lamsfoundation/lams/usermanagement/dao/hibernate/TestWorkspaceDAO.java (.../TestWorkspaceDAO.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -31,7 +31,7 @@ } protected void setUp() throws Exception{ super.setUp(); - workspaceDAO =(IWorkspaceDAO)context.getBean("workspaceDAO"); + workspaceDAO =(IWorkspaceDAO)context.getBean("userManagementWorkspaceDAO"); } public void testGetWorkspaceByRootFolderID(){ boolean rootFolder = false; @@ -40,6 +40,4 @@ rootFolder=true; assertTrue(rootFolder); } - - } Index: lams_common/test/java/org/lamsfoundation/lams/workspace/TestWorkspaceManagement.java =================================================================== diff -u -rb5e2e71d176c89c0685d090c662bc303fbc85ea7 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/test/java/org/lamsfoundation/lams/workspace/TestWorkspaceManagement.java (.../TestWorkspaceManagement.java) (revision b5e2e71d176c89c0685d090c662bc303fbc85ea7) +++ lams_common/test/java/org/lamsfoundation/lams/workspace/TestWorkspaceManagement.java (.../TestWorkspaceManagement.java) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -7,6 +7,7 @@ package org.lamsfoundation.lams.workspace; import java.io.IOException; +import java.util.Date; import org.lamsfoundation.lams.AbstractLamsTestCase; import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; @@ -41,8 +42,8 @@ protected String getHibernateSessionFactoryName() { return "coreSessionFactory"; } - public void testGetFolderContents()throws IOException{ - String packet = workspaceManagementService.getFolderContents(new Integer(4),new Integer(2),WorkspaceManagementService.AUTHORING); + public void testGetFolderContents()throws Exception{ + String packet = workspaceManagementService.getFolderContents(new Integer(4),new Integer(4),WorkspaceManagementService.AUTHORING); System.out.println(packet); } public void testCopyFolder() throws IOException{ @@ -63,6 +64,20 @@ WorkspaceFolder workspaceFolder = workspaceFolderDAO.getWorkspaceFolderByID(new Integer(6)); assertTrue(workspaceFolder.getParentWorkspaceFolder().getWorkspaceFolderId().equals(new Integer(2))); } - - + public void testCreateWorkspaceFolderContent()throws Exception{ + String message = workspaceManagementService.createWorkspaceFolderContent(new Integer(1), + "Manpreet Minhas","Manpreet's Description", + new Date(),new Date(), + new Integer(3), + "TXT","c:/MMinhas.TXT"); + System.out.println(message); + } + public void testUpdateWorkspaceFolderContent() throws Exception{ + String message = workspaceManagementService.updateWorkspaceFolderContent(new Long(7),"c:/MMinhas2.txt"); + System.out.println(message); + } + public void testDeleteWorkspaceFolderContent() throws Exception{ + String message = workspaceManagementService.deleteWorkspaceFolderContent(new Long(7)); + System.out.println(message); + } } Index: lams_common/test/java/org/lamsfoundation/lams/workspace/dao/TestWorkspaceFolderContentDAO.java =================================================================== diff -u --- lams_common/test/java/org/lamsfoundation/lams/workspace/dao/TestWorkspaceFolderContentDAO.java (revision 0) +++ lams_common/test/java/org/lamsfoundation/lams/workspace/dao/TestWorkspaceFolderContentDAO.java (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -0,0 +1,115 @@ +/* + * Created on Apr 20, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.workspace.dao; + +import java.io.FileInputStream; +import java.util.Date; +import java.util.List; +import org.lamsfoundation.lams.AbstractLamsTestCase; +import org.lamsfoundation.lams.contentrepository.ICredentials; +import org.lamsfoundation.lams.contentrepository.ITicket; +import org.lamsfoundation.lams.contentrepository.NodeKey; +import org.lamsfoundation.lams.contentrepository.SimpleCredentials; +import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; +import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; +import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; +import org.lamsfoundation.lams.usermanagement.dao.IWorkspaceFolderDAO; +import org.lamsfoundation.lams.workspace.WorkspaceFolderContent; + +/** + * @author Manpreet Minhas + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class TestWorkspaceFolderContentDAO extends AbstractLamsTestCase { + + protected IWorkspaceFolderContentDAO workspaceFolderContentDAO; + protected IWorkspaceFolderDAO workspaceFolderDAO; + protected WorkspaceFolder workspaceFolder; + protected IRepositoryService repositoryService; + + protected String workspaceUser = "workspaceManager"; + protected String password = "flashClient"; + protected String workspaceName = "FlashClientsWorkspace"; + + protected ICredentials credentials; + protected ITicket ticket; + + public TestWorkspaceFolderContentDAO(String name){ + super(name); + } + public void setUp()throws Exception{ + super.setUp(); + workspaceFolderContentDAO = (IWorkspaceFolderContentDAO)context.getBean("workspaceFolderContentDAO"); + workspaceFolderDAO = (IWorkspaceFolderDAO)context.getBean("workspaceFolderDAO"); + repositoryService = RepositoryProxy.getLocalRepositoryService(); + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getContextConfigLocation() + */ + protected String[] getContextConfigLocation() { + return new String[] {"WEB-INF/spring/applicationContext.xml", + "org/lamsfoundation/lams/contentrepository/contentRepositoryLocalApplicationContext.xml"}; + } + + /** + * (non-Javadoc) + * @see org.lamsfoundation.lams.AbstractLamsTestCase#getHibernateSessionFactoryName() + */ + protected String getHibernateSessionFactoryName() { + return "coreSessionFactory"; + } + public void testInsertWorkspaceFolderContent(){ + workspaceFolder = workspaceFolderDAO.getWorkspaceFolderByID(new Integer(4)); + WorkspaceFolderContent workspaceFolderContent = new WorkspaceFolderContent(new Integer(1), + "Test File","Test Description", + new Date(), new Date(), + "TXT",workspaceFolder); + workspaceFolderContentDAO.insert(workspaceFolderContent); + assertNotNull(workspaceFolderContent.getFolderContentID()); + } + public void testGetContentByWorkspaceFolder(){ + List list = workspaceFolderContentDAO.getContentByWorkspaceFolder(new Long(3)); + assertEquals(list.size(),4); + } + public void testGetContentByTypeFromWorkspaceFolder(){ + List list = workspaceFolderContentDAO.getContentByTypeFromWorkspaceFolder(new Long(3),"TXT"); + assertEquals(list.size(),2); + } + public void testAddFlashClientWorkspaceCredentials()throws Exception{ + credentials = new SimpleCredentials(workspaceUser,password.toCharArray()); + //repositoryService.createCredentials(credentials); + //repositoryService.addWorkspace(credentials,workspaceName); + ticket = repositoryService.login(credentials,workspaceName); + assertNotNull("Add workspace succeeded - can login to workspace. Ticket is "+ticket, ticket); + testAddFile(ticket); + } + private void testAddFile(ITicket ticket)throws Exception{ + WorkspaceFolderContent workspaceFolderContent = workspaceFolderContentDAO.getWorkspaceFolderContentByID(new Long(7)); + FileInputStream input = new FileInputStream("C:/test/Text File.txt"); + NodeKey nodeKey = repositoryService.addFileItem(ticket,input,workspaceFolderContent.getName(),workspaceFolderContent.getMimeType(),null); + workspaceFolderContent.setUuid(nodeKey.getUuid()); + workspaceFolderContent.setVersionID(nodeKey.getVersion()); + workspaceFolderContentDAO.update(workspaceFolderContent); + assertNotNull(workspaceFolderContent.getUuid()); + } + public void testUpdateFile() throws Exception{ + WorkspaceFolderContent workspaceFolderContent = workspaceFolderContentDAO.getWorkspaceFolderContentByID(new Long(7)); + FileInputStream input = new FileInputStream("C:/test/Text File.txt"); + credentials = new SimpleCredentials(workspaceUser,password.toCharArray()); + ticket = repositoryService.login(credentials,workspaceName); + NodeKey nodeKey = repositoryService.updateFileItem(ticket,workspaceFolderContent.getUuid(),workspaceFolderContent.getName(), + input,workspaceFolderContent.getMimeType(),null); + workspaceFolderContent.setVersionID(nodeKey.getVersion()); + workspaceFolderContent.setUuid(nodeKey.getUuid()); + workspaceFolderContentDAO.update(workspaceFolderContent); + System.out.println(nodeKey.getVersion() + ": " + workspaceFolderContent.getVersionID()); + } +} Index: lams_common/web/WEB-INF/spring/applicationContext.xml =================================================================== diff -u -re6427443b1febeb70f29fb1e7726f976aef23173 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision e6427443b1febeb70f29fb1e7726f976aef23173) +++ lams_common/web/WEB-INF/spring/applicationContext.xml (.../applicationContext.xml) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -68,6 +68,10 @@ org/lamsfoundation/lams/tool/Tool.hbm.xml org/lamsfoundation/lams/tool/ToolContent.hbm.xml org/lamsfoundation/lams/tool/ToolSession.hbm.xml + + + org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml +
@@ -105,7 +109,7 @@ - + @@ -183,11 +187,14 @@ - + + + + Index: lams_common/web/WEB-INF/spring/workspaceApplicationContext.xml =================================================================== diff -u -re6427443b1febeb70f29fb1e7726f976aef23173 -r5ef30da5c8c3f97d81d42ac4abed7430f8261ef3 --- lams_common/web/WEB-INF/spring/workspaceApplicationContext.xml (.../workspaceApplicationContext.xml) (revision e6427443b1febeb70f29fb1e7726f976aef23173) +++ lams_common/web/WEB-INF/spring/workspaceApplicationContext.xml (.../workspaceApplicationContext.xml) (revision 5ef30da5c8c3f97d81d42ac4abed7430f8261ef3) @@ -8,9 +8,10 @@ - + + @@ -26,8 +27,7 @@ PROPAGATION_REQUIRED PROPAGATION_REQUIRED - PROPAGATION_REQUIRED - PROPAGATION_REQUIRED + PROPAGATION_REQUIRED