Index: lams_tool_nb/.classpath
===================================================================
diff -u -re59bc835a5ec91886980d67af70c0f05a0f7ae73 -rc21616f59a9c46798f42cc5e9fc758ed824f701a
--- lams_tool_nb/.classpath (.../.classpath) (revision e59bc835a5ec91886980d67af70c0f05a0f7ae73)
+++ lams_tool_nb/.classpath (.../.classpath) (revision c21616f59a9c46798f42cc5e9fc758ed824f701a)
@@ -18,6 +18,11 @@
+
+
+
+
+
Index: lams_tool_scribe/.classpath
===================================================================
diff -u -r9e2dc03fe28e3c80540446ea36654baeb862a888 -rc21616f59a9c46798f42cc5e9fc758ed824f701a
--- lams_tool_scribe/.classpath (.../.classpath) (revision 9e2dc03fe28e3c80540446ea36654baeb862a888)
+++ lams_tool_scribe/.classpath (.../.classpath) (revision c21616f59a9c46798f42cc5e9fc758ed824f701a)
@@ -6,7 +6,7 @@
-
+
@@ -18,5 +18,11 @@
+
+
+
+
+
+
-
+
Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java
===================================================================
diff -u -r40eb54374e84591563d8b6a679ac719dbc85c8f7 -rc21616f59a9c46798f42cc5e9fc758ed824f701a
--- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision 40eb54374e84591563d8b6a679ac719dbc85c8f7)
+++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision c21616f59a9c46798f42cc5e9fc758ed824f701a)
@@ -24,8 +24,6 @@
package org.lamsfoundation.lams.tool.scribe.service;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
@@ -35,27 +33,19 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.struts.upload.FormFile;
-import org.lamsfoundation.lams.contentrepository.AccessDeniedException;
-import org.lamsfoundation.lams.contentrepository.ICredentials;
-import org.lamsfoundation.lams.contentrepository.ITicket;
-import org.lamsfoundation.lams.contentrepository.InvalidParameterException;
-import org.lamsfoundation.lams.contentrepository.LoginException;
-import org.lamsfoundation.lams.contentrepository.NodeKey;
-import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
-import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException;
+import org.apache.tomcat.util.json.JSONArray;
+import org.apache.tomcat.util.json.JSONException;
+import org.apache.tomcat.util.json.JSONObject;
import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
-import org.lamsfoundation.lams.contentrepository.service.IRepositoryService;
-import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials;
import org.lamsfoundation.lams.learning.service.ILearnerService;
import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException;
import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService;
import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.notebook.service.ICoreNotebookService;
+import org.lamsfoundation.lams.rest.ToolRestManager;
import org.lamsfoundation.lams.tool.ToolContentImport102Manager;
import org.lamsfoundation.lams.tool.ToolContentManager;
import org.lamsfoundation.lams.tool.ToolOutput;
@@ -76,11 +66,10 @@
import org.lamsfoundation.lams.tool.scribe.model.ScribeUser;
import org.lamsfoundation.lams.tool.scribe.util.ScribeConstants;
import org.lamsfoundation.lams.tool.scribe.util.ScribeException;
-import org.lamsfoundation.lams.tool.scribe.util.ScribeToolContentHandler;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.util.JsonUtil;
import org.lamsfoundation.lams.util.WebUtil;
-import org.lamsfoundation.lams.util.audit.IAuditService;
import org.lamsfoundation.lams.util.wddx.WDDXProcessor;
import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException;
@@ -90,7 +79,7 @@
* As a requirement, all LAMS tool's service bean must implement ToolContentManager and ToolSessionManager.
*/
-public class ScribeService implements ToolSessionManager, ToolContentManager, ToolContentImport102Manager,
+public class ScribeService implements ToolSessionManager, ToolContentManager, ToolContentImport102Manager, ToolRestManager,
IScribeService {
static Logger logger = Logger.getLogger(ScribeService.class.getName());
@@ -632,4 +621,52 @@
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return null;
}
+
+ // ****************** REST methods *************************
+
+ /** Used by the Rest calls to create content.
+ * Mandatory fields in toolContentJSON: title, instructions, topics.
+ * Topics must contain a JSONArray of JSONObject objects, which have the following mandatory fields: subject, body
+ * There should be at least one topic object in the Topics array.
+ */
+ @Override
+ public void createRestToolContent(Integer userID, Long toolContentID, JSONObject toolContentJSON) throws JSONException {
+
+ Date updateDate = new Date();
+
+ Scribe scribe = new Scribe();
+ scribe.setCreateBy(userID.longValue());
+ scribe.setCreateDate(updateDate);
+ scribe.setUpdateDate(updateDate);
+
+ scribe.setToolContentId(toolContentID);
+ scribe.setContentInUse(false);
+ scribe.setDefineLater(false);
+
+ scribe.setTitle(toolContentJSON.getString("title"));
+ scribe.setInstructions(toolContentJSON.getString("instructions"));
+
+ scribe.setAutoSelectScribe(JsonUtil.opt(toolContentJSON, "autoSelectScribe", Boolean.FALSE));
+ scribe.setLockOnFinished(JsonUtil.opt(toolContentJSON, "lockOnFinished", Boolean.FALSE));
+ scribe.setReflectInstructions((String) JsonUtil.opt(toolContentJSON, "reflectInstructions", null));
+ scribe.setReflectOnActivity(JsonUtil.opt(toolContentJSON, "reflectOnActivity", Boolean.FALSE));
+ scribe.setShowAggregatedReports(JsonUtil.opt(toolContentJSON, "showAggregatedReports", Boolean.FALSE));
+
+ Set headings = scribe.getScribeHeadings();
+ if ( headings == null ) {
+ headings = new HashSet();
+ scribe.setScribeHeadings(headings);
+ }
+ JSONArray headingData = toolContentJSON.getJSONArray("headings");
+ for ( int i=0; i