Index: lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java =================================================================== diff -u -r33829c670fd8c90447d62ea3300498a103905e7a -rd416d14c233164ac4787360cbd490f31227694cd --- lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java (.../LaunchLearnerUrlServlet.java) (revision 33829c670fd8c90447d62ea3300498a103905e7a) +++ lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java (.../LaunchLearnerUrlServlet.java) (revision d416d14c233164ac4787360cbd490f31227694cd) @@ -78,7 +78,7 @@ Long lessonId; try { - String decodedLessonId = WebUtil.decodeLessonId(encodedLessonId); + String decodedLessonId = WebUtil.decodeIdForDirectLaunch(encodedLessonId); lessonId = Long.valueOf(decodedLessonId); } catch (IllegalArgumentException e) { Index: lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java =================================================================== diff -u -r53b1f5c6dcfb9e0d74e56c9647da69f07b889a55 -rd416d14c233164ac4787360cbd490f31227694cd --- lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java (.../WebUtil.java) (revision 53b1f5c6dcfb9e0d74e56c9647da69f07b889a55) +++ lams_common/src/java/org/lamsfoundation/lams/util/WebUtil.java (.../WebUtil.java) (revision d416d14c233164ac4787360cbd490f31227694cd) @@ -493,23 +493,23 @@ /** * Converse lessonId into alphabetic sequence for using it in URL shortening * - * @param lessonId + * @param id * @return */ - public static String encodeLessonId(Long lessonId) { - String encodedLessonId = lessonId.toString(); - encodedLessonId = encodedLessonId.replace('0', URL_SHORTENING_CYPHER.charAt(0)); - encodedLessonId = encodedLessonId.replace('1', URL_SHORTENING_CYPHER.charAt(1)); - encodedLessonId = encodedLessonId.replace('2', URL_SHORTENING_CYPHER.charAt(2)); - encodedLessonId = encodedLessonId.replace('3', URL_SHORTENING_CYPHER.charAt(3)); - encodedLessonId = encodedLessonId.replace('4', URL_SHORTENING_CYPHER.charAt(4)); - encodedLessonId = encodedLessonId.replace('5', URL_SHORTENING_CYPHER.charAt(5)); - encodedLessonId = encodedLessonId.replace('6', URL_SHORTENING_CYPHER.charAt(6)); - encodedLessonId = encodedLessonId.replace('7', URL_SHORTENING_CYPHER.charAt(7)); - encodedLessonId = encodedLessonId.replace('8', URL_SHORTENING_CYPHER.charAt(8)); - encodedLessonId = encodedLessonId.replace('9', URL_SHORTENING_CYPHER.charAt(9)); + public static String encodeIdForDirectLaunch(Long id) { + String encodedId = id.toString(); + encodedId = encodedId.replace('0', URL_SHORTENING_CYPHER.charAt(0)); + encodedId = encodedId.replace('1', URL_SHORTENING_CYPHER.charAt(1)); + encodedId = encodedId.replace('2', URL_SHORTENING_CYPHER.charAt(2)); + encodedId = encodedId.replace('3', URL_SHORTENING_CYPHER.charAt(3)); + encodedId = encodedId.replace('4', URL_SHORTENING_CYPHER.charAt(4)); + encodedId = encodedId.replace('5', URL_SHORTENING_CYPHER.charAt(5)); + encodedId = encodedId.replace('6', URL_SHORTENING_CYPHER.charAt(6)); + encodedId = encodedId.replace('7', URL_SHORTENING_CYPHER.charAt(7)); + encodedId = encodedId.replace('8', URL_SHORTENING_CYPHER.charAt(8)); + encodedId = encodedId.replace('9', URL_SHORTENING_CYPHER.charAt(9)); - return encodedLessonId; + return encodedId; } /** @@ -518,26 +518,26 @@ * @param encodedlessonId * @return */ - public static String decodeLessonId(String encodedLessonId) throws IllegalArgumentException { + public static String decodeIdForDirectLaunch(String encodedId) throws IllegalArgumentException { // it should contain only the characters from URL_SHORTENING_CYPHER - if (!encodedLessonId.matches("[" + URL_SHORTENING_CYPHER + "]*")) { - throw new IllegalArgumentException("LessonId: " + encodedLessonId + " has wrong format."); + if (!encodedId.matches("[" + URL_SHORTENING_CYPHER + "]*")) { + throw new IllegalArgumentException("Lesson or course ID: " + encodedId + " has wrong format."); } - String decodedLessonId = encodedLessonId; - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(0), '0'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(1), '1'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(2), '2'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(3), '3'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(4), '4'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(5), '5'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(6), '6'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(7), '7'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(8), '8'); - decodedLessonId = decodedLessonId.replace(URL_SHORTENING_CYPHER.charAt(9), '9'); + String decodedId = encodedId; + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(0), '0'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(1), '1'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(2), '2'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(3), '3'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(4), '4'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(5), '5'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(6), '6'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(7), '7'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(8), '8'); + decodedId = decodedId.replace(URL_SHORTENING_CYPHER.charAt(9), '9'); - return decodedLessonId; + return decodedId; } public static Document getDocument() throws ParserConfigurationException { Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java =================================================================== diff -u -rdbbe9d80bcbeda8f746963fcde183242996fcc68 -rd416d14c233164ac4787360cbd490f31227694cd --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java (.../MonitoringController.java) (revision dbbe9d80bcbeda8f746963fcde183242996fcc68) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java (.../MonitoringController.java) (revision d416d14c233164ac4787360cbd490f31227694cd) @@ -950,7 +950,7 @@ lessonDTO.setCreateDateTimeStr(sfm.format(lessonDTO.getCreateDateTime())); } // prepare encoded lessonId for shortened learner URL - lessonDTO.setEncodedLessonID(WebUtil.encodeLessonId(lessonId)); + lessonDTO.setEncodedLessonID(WebUtil.encodeIdForDirectLaunch(lessonId)); if (!securityService.isLessonMonitor(lessonId, user.getUserID(), "monitor lesson")) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");