Index: lams_bb_integration/RELEASE_NOTES.TXT =================================================================== diff -u -rc42107bc1dd1796f8effeecef9366f0be5795923 -r1ab33003cd3e0467df4e556f45b32a06246856b1 --- lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision c42107bc1dd1796f8effeecef9366f0be5795923) +++ lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision 1ab33003cd3e0467df4e556f45b32a06246856b1) @@ -95,3 +95,8 @@ * LDEV-3513: Transform lineitemId parameter stored in some older versions to the format required now * LDEV-3510: LAMS Lessons always appear at the top of the content list - should able to be moved further down the list. * LDEV-3521: Supporting an alternative URL for LAMS where needed for mixed https/http integrations. + +1.2.13 Release Fixes +==================== +* LDEV-3526: Switch webservice calls to POST. +* LDEV-3456: Adding support for a type field to categorise designs. Index: lams_bb_integration/WEB-INF/bb-manifest.xml =================================================================== diff -u -ra992ac61e8e1ba2366392c77d1783147f48dbc5c -r1ab33003cd3e0467df4e556f45b32a06246856b1 --- lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision a992ac61e8e1ba2366392c77d1783147f48dbc5c) +++ lams_bb_integration/WEB-INF/bb-manifest.xml (.../bb-manifest.xml) (revision 1ab33003cd3e0467df4e556f45b32a06246856b1) @@ -5,7 +5,7 @@ - + Index: lams_bb_integration/build.xml =================================================================== diff -u -ra992ac61e8e1ba2366392c77d1783147f48dbc5c -r1ab33003cd3e0467df4e556f45b32a06246856b1 --- lams_bb_integration/build.xml (.../build.xml) (revision a992ac61e8e1ba2366392c77d1783147f48dbc5c) +++ lams_bb_integration/build.xml (.../build.xml) (revision 1ab33003cd3e0467df4e556f45b32a06246856b1) @@ -2,7 +2,7 @@ - + Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java =================================================================== diff -u -ra992ac61e8e1ba2366392c77d1783147f48dbc5c -r1ab33003cd3e0467df4e556f45b32a06246856b1 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java (.../LamsLearningDesignServlet.java) (revision a992ac61e8e1ba2366392c77d1783147f48dbc5c) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsLearningDesignServlet.java (.../LamsLearningDesignServlet.java) (revision 1ab33003cd3e0467df4e556f45b32a06246856b1) @@ -70,6 +70,7 @@ String sortName = request.getParameter("sortName"); String sortDate = request.getParameter("sortDate"); String search = request.getParameter("search"); + String type = request.getParameter("type"); ContextManager ctxMgr = null; Context ctx = null; @@ -79,7 +80,7 @@ ctx = ctxMgr.setContext(request); String method = usePaging ? "getPagedHomeLearningDesignsJSON" : "getLearningDesignsJSON"; - String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, courseId, folderId, method, search, page, size, sortName, sortDate); + String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, courseId, folderId, method, type, search, page, size, sortName, sortDate); response.setContentType("application/json;charset=UTF-8"); response.getWriter().print(learningDesigns); Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java =================================================================== diff -u -rc42107bc1dd1796f8effeecef9366f0be5795923 -r1ab33003cd3e0467df4e556f45b32a06246856b1 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision c42107bc1dd1796f8effeecef9366f0be5795923) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 1ab33003cd3e0467df4e556f45b32a06246856b1) @@ -33,6 +33,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.nio.charset.Charset; import java.rmi.RemoteException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -226,7 +227,7 @@ * @return a string containing the LAMS workspace tree in tigra format */ public static String getLearningDesigns(Context ctx, String courseId, String folderId) { - return getLearningDesigns(ctx, courseId, folderId,"getLearningDesignsJSON",null,null,null,null,null); + return getLearningDesigns(ctx, courseId, folderId,"getLearningDesignsJSON",null,null,null,null,null,null); } /** @@ -237,14 +238,16 @@ * from LamsLearningDesignServlet. * @param folderId folderID in LAMS. It can be null and then LAMS returns default workspace folders. * @param method which method to call on the LAMS end + * @param type used onlu for method = getLearningDesignsJSON, restricts by type * @param page used only for method = getPagedHomeLearningDesignsJSON * @param size used only for method = getPagedHomeLearningDesignsJSON * @return a string containing the LAMS workspace tree in tigra format (method = getLearningDesignsJSON) or * a string containing the learning designs in JSON (method = getPagedHomeLearningDesignsJSON) */ - public static String getLearningDesigns(Context ctx, String urlCourseId, String folderId, String method, + public static String getLearningDesigns(Context ctx, String urlCourseId, String folderId, String method, String type, String search, String page, String size, String sortName, String sortDate) { - String serverAddr = getServerAddress(); + + String serverAddr = getServerAddress(); String courseId = setupCourseId(ctx, urlCourseId); String serverId = getServerID(); @@ -284,6 +287,11 @@ if (folderId != null ) { serviceURL += "&folderID=" + ( folderId.equalsIgnoreCase("home") ? "-1" : folderId); } + + // The following parameter is only used for getLearningDesignsJSON + if ( type != null && type.length() > 0 ) { + serviceURL += "&type=" +type; + } // The following parameters are only used for getPagedLearningDesignsJSON if (page != null ) { @@ -305,7 +313,7 @@ serviceURL += "&search=" + search; } - InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); // Read/convert response to a String StringWriter writer = new StringWriter(); @@ -375,7 +383,7 @@ + URLEncoder.encode(lastName, "UTF-8") + "&email=" + URLEncoder.encode(email, "UTF-8") + "&learningDesignID="+ldId; - InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); // Read/convert response to a String StringWriter writer = new StringWriter(); @@ -455,7 +463,7 @@ String hash = generateAuthenticationHash(timestamp, username, serverId); String course = courseId != null ? "&courseId=" + URLEncoder.encode(courseId, "UTF8") : ""; - String serviceURL = serverAddr + "/services/xml/LessonManager?" + "&serverId=" + String serviceURL = serverAddr + "/services/xml/LessonManager?" + "serverId=" + URLEncoder.encode(serverId, "utf8") + "&datetime=" + timestamp + "&username=" + URLEncoder.encode(username, "utf8") + "&hashValue=" + hash + course + "&ldId=" + new Long(ldId).toString() + "&country=" @@ -465,7 +473,7 @@ logger.info("LAMS START LESSON Req: " + serviceURL); // InputStream is = url.openConnection().getInputStream(); - InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); // parse xml response DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -618,7 +626,7 @@ logger.info("LAMS Preadd users Req: " + serviceURL); System.out.println("LAMS Preadd users Req: " + serviceURL); - InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); } catch (MalformedURLException e) { throw new RuntimeException("Unable to preadd users to the lesson, bad URL: '" + serverAddr @@ -688,7 +696,7 @@ logger.info("Retirieving learner progress: " + serviceURL); // InputStream is = url.openConnection().getInputStream(); - InputStream is = LamsSecurityUtil.callLamsServer(serviceURL); + InputStream is = LamsSecurityUtil.callLamsServerPost(serviceURL); // parse xml response DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -758,6 +766,56 @@ return is; } + + /** + * Make a call to LAMS server. + * + * @param serviceURL + * @return resulted InputStream + * @throws IOException + */ + private static InputStream callLamsServerPost(String serviceURL) throws IOException { + + String path; + String body; + + int bodyStart = serviceURL.indexOf('?'); + if ( bodyStart < 0 ) { + path = serviceURL; + body = ""; + } else { + path = serviceURL.substring(0,bodyStart); + body = serviceURL.substring(bodyStart+1); + } + + byte[] postData = body.getBytes("UTF-8"); + int postDataLength = postData.length; + + URL url = new URL(path); + URLConnection conn = url.openConnection(); + if (!(conn instanceof HttpURLConnection)) { + throw new IOException("Unable to open connection to: " + serviceURL); + } + + HttpURLConnection httpConn = (HttpURLConnection) conn; + conn.setDoOutput( true ); + httpConn.setRequestMethod("POST"); + conn.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded"); + conn.setRequestProperty( "charset", "utf-8"); + conn.setRequestProperty( "Content-Length", Integer.toString( postDataLength )); + conn.setUseCaches( false ); + + conn.getOutputStream().write(postData); + + if (httpConn.getResponseCode() != HttpURLConnection.HTTP_OK) { + throw new IOException("LAMS server responded with HTTP response code: " + httpConn.getResponseCode() + + ", HTTP response message: " + httpConn.getResponseMessage()); + } + + InputStream is = conn.getInputStream(); + return is; + } + public static String getServerTime() throws IOException, PersistenceException { long now = (new Date()).getTime();