Index: lams_build/build_base.xml
===================================================================
diff -u -rfd2cfad55c7c517931f69334ce644d509ec28140 -rba30ff8870a09d3979846f37d807a65876717dfc
--- lams_build/build_base.xml (.../build_base.xml) (revision fd2cfad55c7c517931f69334ce644d509ec28140)
+++ lams_build/build_base.xml (.../build_base.xml) (revision ba30ff8870a09d3979846f37d807a65876717dfc)
@@ -50,8 +50,6 @@
-
-
Index: lams_build/conf/j2ee/jboss-deployment-structure.xml
===================================================================
diff -u -rad9302492321e6904e8d8f504a9598ed24ba6cfa -rba30ff8870a09d3979846f37d807a65876717dfc
--- lams_build/conf/j2ee/jboss-deployment-structure.xml (.../jboss-deployment-structure.xml) (revision ad9302492321e6904e8d8f504a9598ed24ba6cfa)
+++ lams_build/conf/j2ee/jboss-deployment-structure.xml (.../jboss-deployment-structure.xml) (revision ba30ff8870a09d3979846f37d807a65876717dfc)
@@ -29,7 +29,6 @@
-
Index: lams_central/.classpath
===================================================================
diff -u -ra03d663fb89c9c0ebafef753314cc5da82f7aaa1 -rba30ff8870a09d3979846f37d807a65876717dfc
--- lams_central/.classpath (.../.classpath) (revision a03d663fb89c9c0ebafef753314cc5da82f7aaa1)
+++ lams_central/.classpath (.../.classpath) (revision ba30ff8870a09d3979846f37d807a65876717dfc)
@@ -29,8 +29,6 @@
-
-
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java
===================================================================
diff -u -r1de0a203f1cc55783cffd95742782070877781cb -rba30ff8870a09d3979846f37d807a65876717dfc
--- lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision 1de0a203f1cc55783cffd95742782070877781cb)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision ba30ff8870a09d3979846f37d807a65876717dfc)
@@ -35,7 +35,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.apache.http.HttpException;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.authoring.service.IAuthoringFullService;
import org.lamsfoundation.lams.authoring.template.Option;
@@ -44,10 +43,12 @@
import org.lamsfoundation.lams.learningdesign.GateActivity;
import org.lamsfoundation.lams.learningdesign.Grouping;
import org.lamsfoundation.lams.learningdesign.LearningDesign;
+import org.lamsfoundation.lams.learningdesign.exception.LearningDesignException;
import org.lamsfoundation.lams.rest.RestTags;
import org.lamsfoundation.lams.rest.ToolRestManager;
import org.lamsfoundation.lams.tool.Tool;
import org.lamsfoundation.lams.tool.dao.IToolDAO;
+import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsCoreToolService;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.AuthoringJsonTags;
@@ -324,7 +325,7 @@
protected ObjectNode saveLearningDesign(String templateCode, String userEnteredTitleString,
String userEnteredDescription, Integer workspaceFolderID, String contentFolderId, Integer maxUIID,
ArrayNode activities, ArrayNode transitions, ArrayNode groupings, ArrayNode branchMappings)
- throws HttpException, IOException {
+ throws IOException {
// fill in required LD data
ObjectNode ldJSON = JsonNodeFactory.instance.objectNode();
@@ -348,9 +349,8 @@
try {
learningDesign = authoringService.saveLearningDesignDetails(ldJSON);
} catch (Exception e) {
- LdTemplateController.log.error("Unable to learning design with details " + ldJSON, e);
- throw new HttpException("Unable to learning design with details " + ldJSON);
-
+ log.error("Unable to save learning design with details " + ldJSON, e);
+ throw new LearningDesignException("Unable to save learning design with details " + ldJSON);
}
ObjectNode responseJSON = JsonNodeFactory.instance.objectNode();
@@ -617,8 +617,7 @@
/* ************************************** Tool related methods ********************************************** */
/** General method to create a tool content. All calls to create tool content should go through this method */
protected Long createToolContent(UserDTO user, String toolSignature, ObjectNode toolContentJSON)
- throws HttpException, IOException {
-
+ throws IOException {
try {
Tool tool = getTool(toolSignature);
Long toolContentID = authoringService.insertToolContentID(tool.getToolId());
@@ -629,15 +628,13 @@
return toolContentID;
} catch (Exception e) {
- LdTemplateController.log.error("Unable to create tool content for " + toolSignature + " with details "
- + toolContentJSON
+ log.error("Unable to create tool content for " + toolSignature + " with details " + toolContentJSON
+ ". \nThe tool probably threw an exception - check the server logs for more details.\n"
+ "If the exception is \"Servlet.service() for servlet ToolContentRestServlet threw exception java.lang.ClassCastException: com.sun.proxy.$ProxyXXX cannot be cast to org.lamsfoundation.lams.rest.ToolRestManager)\""
+ " then the tool doesn't support the LDTemplate service calls (ie has not implemented the ToolRestManager interface / createRestToolContent() method.");
- throw new HttpException(
+ throw new ToolException(
"Unable to create tool content for " + toolSignature + " with details " + toolContentJSON);
}
-
}
/**
@@ -728,8 +725,7 @@
* to be expanded.
*/
protected Long createAssessmentToolContent(UserDTO user, String title, String instructions,
- String reflectionInstructions, boolean selectLeaderToolOutput, ArrayNode questions)
- throws HttpException, IOException {
+ String reflectionInstructions, boolean selectLeaderToolOutput, ArrayNode questions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, null, null,
user);
@@ -766,7 +762,7 @@
* finished and filterKeywords in case it is wanted. The keywords should be a comma deliminated string.
*/
protected Long createChatToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
- String filterKeywords, String reflectionInstructions) throws HttpException, IOException {
+ String filterKeywords, String reflectionInstructions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions,
lockWhenFinished, null, null);
@@ -805,7 +801,7 @@
*/
protected Long createForumToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
boolean allowRichTextEditor, boolean allowNewTopic, boolean allowRateMessages, boolean allowUpload,
- boolean limitedMaxCharacters, Integer maxCharacters, ArrayNode topics) throws HttpException, IOException {
+ boolean limitedMaxCharacters, Integer maxCharacters, ArrayNode topics) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished,
allowRichTextEditor, user);
@@ -837,8 +833,7 @@
* does not support lockWhenFinished.
*/
protected Long createLeaderSelectionToolContent(UserDTO user, String title, String instructions)
- throws HttpException, IOException {
-
+ throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null);
return createToolContent(user, LdTemplateController.LEADER_TOOL_SIGNATURE, toolContentJSON);
}
@@ -861,7 +856,7 @@
* finished and allow rich text editor in case it is wanted.
*/
protected Long createNotebookToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
- boolean allowRichTextEditor) throws HttpException, IOException {
+ boolean allowRichTextEditor) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished,
allowRichTextEditor, null);
@@ -885,7 +880,7 @@
* support a reflection in case it is wanted.
*/
protected Long createNoticeboardToolContent(UserDTO user, String title, String content,
- String reflectionInstructions) throws HttpException, IOException {
+ String reflectionInstructions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, null, reflectionInstructions, null, null, null);
toolContentJSON.put("content", content != null ? content : "");
@@ -910,7 +905,7 @@
*/
protected Long createQAToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
boolean allowRichTextEditor, boolean oneQuestionPerPage, boolean showOtherLearnersAnswers,
- boolean showOtherLearnersNames, ArrayNode questions) throws HttpException, IOException {
+ boolean showOtherLearnersNames, ArrayNode questions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished,
allowRichTextEditor, null);
@@ -938,8 +933,7 @@
* details of questions). Other fields are optional.
*/
protected Long createMCQToolContent(UserDTO user, String title, String instructions,
- boolean useSelectLeaderToolOuput, boolean enableConfidenceLevel, ArrayNode questions)
- throws HttpException, IOException {
+ boolean useSelectLeaderToolOuput, boolean enableConfidenceLevel, ArrayNode questions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null);
toolContentJSON.put(RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, useSelectLeaderToolOuput);
@@ -965,7 +959,7 @@
* Helper method to create a mindmap tool content.
*/
protected Long createMindmapToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
- boolean multiUserMode, String reflectionInstruction) throws HttpException, IOException {
+ boolean multiUserMode, String reflectionInstruction) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, null);
toolContentJSON.put("multiUserMode", multiUserMode);
@@ -994,7 +988,7 @@
protected Long createResourcesToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
boolean runContentAutomatically, boolean allowLearnerAddURL, boolean allowLearnerAddFile,
boolean notifyInstructors, Integer minResourcesToView, String reflectionInstructions, ArrayNode resources)
- throws HttpException, IOException {
+ throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions,
lockWhenFinished, null, user);
@@ -1089,7 +1083,7 @@
*/
protected Long createScratchieToolContent(UserDTO user, String title, String instructions,
boolean useSelectLeaderToolOuput, Integer confidenceLevelsActivityUiid, ArrayNode questions)
- throws HttpException, IOException {
+ throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null);
toolContentJSON.set(RestTags.QUESTIONS, questions);
@@ -1117,7 +1111,7 @@
*/
protected Long createScribeToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
boolean autoSelectScribe, boolean showAggregatedReports, String reflectionInstructions, ArrayNode questions)
- throws HttpException, IOException {
+ throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions,
lockWhenFinished, null, null);
@@ -1146,7 +1140,7 @@
*/
protected Long createSubmitToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
Boolean limitUpload, Integer limitUploadNumber, String reflectionInstructions)
- throws HttpException, IOException {
+ throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions,
lockWhenFinished, null, user);
@@ -1175,7 +1169,7 @@
* first/last names! See the survey implementation for the full field list.
*/
protected Long createSurveyToolContent(UserDTO user, String title, String instructions, Boolean lockWhenFinished,
- ArrayNode questions) throws HttpException, IOException {
+ ArrayNode questions) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, user);
toolContentJSON.set("questions", questions);
@@ -1199,7 +1193,7 @@
* Other fields are optional.
*/
protected Long createVoteToolContent(UserDTO user, String title, String instructions, ArrayNode answers,
- Boolean showResults) throws HttpException, IOException {
+ Boolean showResults) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null);
toolContentJSON.set(RestTags.ANSWERS, answers);
@@ -1223,7 +1217,7 @@
* Helper method to create a wiki tool content.
*/
protected Long createWikiToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished,
- String reflectionInstruction, ArrayNode pages) throws HttpException, IOException {
+ String reflectionInstruction, ArrayNode pages) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, null);
toolContentJSON.set("pages", pages);
@@ -1250,7 +1244,7 @@
* The criterias entry should be ArrayNode as defined in PeerReviewCriters object.
*/
protected Long createPeerReviewToolContent(UserDTO user, String title, String instructions,
- String reflectionInstructions, ArrayNode criterias) throws HttpException, IOException {
+ String reflectionInstructions, ArrayNode criterias) throws IOException {
ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, null, null,
user);
Index: lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestLtiServlet.java
===================================================================
diff -u -r33829c670fd8c90447d62ea3300498a103905e7a -rba30ff8870a09d3979846f37d807a65876717dfc
--- lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestLtiServlet.java (.../LoginRequestLtiServlet.java) (revision 33829c670fd8c90447d62ea3300498a103905e7a)
+++ lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestLtiServlet.java (.../LoginRequestLtiServlet.java) (revision ba30ff8870a09d3979846f37d807a65876717dfc)
@@ -21,7 +21,6 @@
package org.lamsfoundation.lams.web;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Enumeration;
@@ -32,8 +31,6 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.utils.URIBuilder;
import org.apache.log4j.Logger;
import org.imsglobal.lti.BasicLTIConstants;
import org.imsglobal.lti.launch.LtiLaunch;
@@ -48,6 +45,7 @@
import org.lamsfoundation.lams.integration.util.LtiUtils;
import org.lamsfoundation.lams.util.CentralConstants;
import org.lamsfoundation.lams.util.HashUtil;
+import org.lamsfoundation.lams.util.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
@@ -116,7 +114,7 @@
LtiLaunch ltiLaunch = ltiResult.getLtiLaunchResult();
if (!ltiResult.getSuccess()) {
log.warn("Authentication error: " + ltiResult.getMessage());
- response.sendError(HttpStatus.SC_UNAUTHORIZED,
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
"Login Failed - authentication error. " + ltiResult.getMessage());
return;
}
@@ -156,42 +154,38 @@
+ consumerKey.toLowerCase().trim() + secret.toLowerCase().trim();
String hash = HashUtil.sha1(plaintext);
- try {
+ // constructing redirectUrl by getting request.getQueryString() for POST requests
+ String redirectUrl = "lti.do";
+ redirectUrl = WebUtil.appendParameterToURL(redirectUrl, "_" + LoginRequestDispatcher.PARAM_METHOD, method);
+ for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
+ String paramName = e.nextElement();
- // constructing redirectUrl by getting request.getQueryString() for POST requests
- URIBuilder redirectUrl = new URIBuilder("lti.do");
- redirectUrl.addParameter("_" + LoginRequestDispatcher.PARAM_METHOD, method);
- for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
- String paramName = e.nextElement();
-
- //skip parameters starting with oath_
- if (LtiUtils.OAUTH_CONSUMER_KEY.equals(paramName)
- || !paramName.startsWith(BasicLTIConstants.OAUTH_PREFIX)) {
- redirectUrl.addParameter(paramName, request.getParameter(paramName));
- }
+ //skip parameters starting with oath_
+ if (LtiUtils.OAUTH_CONSUMER_KEY.equals(paramName)
+ || !paramName.startsWith(BasicLTIConstants.OAUTH_PREFIX)) {
+ redirectUrl = WebUtil.appendParameterToURL(redirectUrl, paramName, request.getParameter(paramName));
}
-
- URIBuilder url = new URIBuilder("LoginRequest");
- url.addParameter(LoginRequestDispatcher.PARAM_USER_ID, URLEncoder.encode(extUsername, "UTF8"));
- url.addParameter(LoginRequestDispatcher.PARAM_METHOD, method);
- url.addParameter(LoginRequestDispatcher.PARAM_TIMESTAMP, timestamp);
- url.addParameter(LoginRequestDispatcher.PARAM_SERVER_ID, consumerKey);
- url.addParameter(LoginRequestDispatcher.PARAM_HASH, hash);
- url.addParameter(LoginRequestDispatcher.PARAM_COURSE_ID, contextId);
- url.addParameter(CentralConstants.PARAM_COURSE_NAME, contextLabel);
- url.addParameter(LoginRequestDispatcher.PARAM_COUNTRY, countryIsoCode);
- url.addParameter(LoginRequestDispatcher.PARAM_LANGUAGE, langIsoCode);
- url.addParameter(LoginRequestDispatcher.PARAM_FIRST_NAME, firstName);//TODO ?? URLEncoder.encode(queryString, "UTF-8");
- url.addParameter(LoginRequestDispatcher.PARAM_LAST_NAME, lastName);//TODO ?? URLEncoder.encode(queryString, "UTF-8");
- url.addParameter(LoginRequestDispatcher.PARAM_LESSON_ID, lessonId);
- url.addParameter(LoginRequestDispatcher.PARAM_EMAIL, email);
- url.addParameter("redirectURL", redirectUrl.build().toString());
- response.sendRedirect(response.encodeRedirectURL(url.build().toString()));
-
- } catch (URISyntaxException e) {
- throw new ServletException("Error creating URL for LoginRequest", e);
}
+ String url = "LoginRequest";
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_USER_ID,
+ URLEncoder.encode(extUsername, "UTF8"));
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_METHOD, method);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_TIMESTAMP, timestamp);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_SERVER_ID, consumerKey);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_HASH, hash);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_COURSE_ID, contextId);
+ url = WebUtil.appendParameterToURL(url, CentralConstants.PARAM_COURSE_NAME, contextLabel);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_COUNTRY, countryIsoCode);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_LANGUAGE, langIsoCode);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_FIRST_NAME,
+ URLEncoder.encode(firstName, "UTF-8"));
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_LAST_NAME,
+ URLEncoder.encode(lastName, "UTF-8"));
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_LESSON_ID, lessonId);
+ url = WebUtil.appendParameterToURL(url, LoginRequestDispatcher.PARAM_EMAIL, email);
+ url = WebUtil.appendParameterToURL(url, "redirectURL", URLEncoder.encode(redirectUrl, "UTF-8"));
+ response.sendRedirect(response.encodeRedirectURL(url));
}
@Override