Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java =================================================================== diff -u -ra327993967da9b51f138b3e84530a42ad3874abc -rea63a092873520f86f47c4204c513fbe0c62f5a8 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision a327993967da9b51f138b3e84530a42ad3874abc) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LessonManagerServlet.java (.../LessonManagerServlet.java) (revision ea63a092873520f86f47c4204c513fbe0c62f5a8) @@ -205,16 +205,16 @@ throws InitializationException, BbServiceException, PersistenceException, IOException, ValidationException, ServletException, ParserConfigurationException, SAXException, ParseException { - String courseIdStr = request.getParameter("course_id"); - String contentIdStr = request.getParameter("content_id"); + String _course_id = request.getParameter("course_id"); + String _content_id = request.getParameter("content_id"); // Retrieve the Db persistence manager from the persistence service BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); Container bbContainer = bbPm.getContainer(); // Internal Blackboard IDs for the course and parent content item - Id courseId = bbPm.generateId(Course.DATA_TYPE, courseIdStr); - Id contentId = new PkId( bbContainer, CourseDocument.DATA_TYPE, contentIdStr); + Id courseId = bbPm.generateId(Course.DATA_TYPE, _course_id); + Id contentId = new PkId( bbContainer, CourseDocument.DATA_TYPE, _content_id); // Load the content item ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader( ContentDbLoader.TYPE ); @@ -246,17 +246,16 @@ //if teacher turned Gradecenter option ON (and it was OFF previously) - create lineitem if (!bbContent.getIsDescribed() && isGradecenter) { - - String username = ctx.getUser().getUserName(); - LineitemUtil.createLineitem(bbContent, username); + String username = ctx.getUser().getUserName(); + LineitemUtil.createLineitem(bbContent, username); //if teacher turned Gradecenter option OFF (and it was ON previously) - remove lineitem } else if (bbContent.getIsDescribed() && !isGradecenter) { - LineitemUtil.removeLineitem(contentIdStr, courseIdStr); + LineitemUtil.removeLineitem(_content_id, _course_id); //change existing lineitem's name if lesson name has been changed } else if (isGradecenter && !strTitle.equals(bbContent.getTitle())) { - LineitemUtil.changeLineitemName(contentIdStr, courseIdStr, strTitle); + LineitemUtil.changeLineitemName(_content_id, _course_id, strTitle); } // Set LAMS content data in Blackboard @@ -303,27 +302,27 @@ throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException, ParserConfigurationException, SAXException { //remove Lineitem object from Blackboard DB - String bbContentId = request.getParameter("content_id"); - String courseId = request.getParameter("course_id"); - LineitemUtil.removeLineitem(bbContentId, courseId); + String _content_id = request.getParameter("content_id"); + String _course_id = request.getParameter("course_id"); + LineitemUtil.removeLineitem(_content_id, _course_id); // remove internalContentId -> externalContentId key->value pair (it's used for GradebookServlet) PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, "LamsStorage"); ExtraInfo ei = pei.getExtraInfo(); - ei.clearEntry(bbContentId); + ei.clearEntry(_content_id); PortalUtil.savePortalExtraInfo(pei); //remove lesson from LAMS server BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); Container bbContainer = bbPm.getContainer(); ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance(); - Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, bbContentId); + Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id); Content bbContent = courseDocumentLoader.loadById(contentId); String lsId = bbContent.getLinkRef(); String userName = ctx.getUser().getUserName(); Boolean isDeletedSuccessfully = LamsSecurityUtil.deleteLesson(userName, lsId); - System.out.println("Lesson (bbContentId:" + bbContentId + ") successfully deleted by userName:" + userName); + System.out.println("Lesson (bbContentId:" + _content_id + ") successfully deleted by userName:" + userName); } Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LineitemUtil.java =================================================================== diff -u -r718f1592143790b7e3cc8fd0d6bc2fc62717e7bf -rea63a092873520f86f47c4204c513fbe0c62f5a8 --- lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LineitemUtil.java (.../LineitemUtil.java) (revision 718f1592143790b7e3cc8fd0d6bc2fc62717e7bf) +++ lams_bb_integration/src/org/lamsfoundation/ld/integration/util/LineitemUtil.java (.../LineitemUtil.java) (revision ea63a092873520f86f47c4204c513fbe0c62f5a8) @@ -176,45 +176,51 @@ /** * Removes lineitem. Throws exception if lineitem is not found. * - * @param bbContentId - * @param courseIdStr + * @param _content_id + * @param _course_id * @throws PersistenceException * @throws ServletException */ - public static void removeLineitem(String bbContentId, String courseIdStr) + public static void removeLineitem(String _content_id, String _course_id) throws PersistenceException, ServletException { BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); Container bbContainer = bbPm.getContainer(); ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance(); LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance(); - Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, bbContentId); + Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id); Content bbContent = courseDocumentLoader.loadById(contentId); - //check isGradecenter option is ON (isDescribed field is used for storing isGradecenter parameter) + //check isGradecenter option is ON and thus there should exist associated lineitem object if (!bbContent.getIsDescribed()) { return; } - Id lineitemId = getLineitem(bbContentId, courseIdStr, true); + Id lineitemId = getLineitem(_content_id, _course_id, true); linePersister.deleteById(lineitemId); + + //Remove bbContentId -> lineitemid pair from the storage + PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, LAMS_LINEITEM_STORAGE); + ExtraInfo ei = pei.getExtraInfo(); + ei.clearEntry(_content_id); + PortalUtil.savePortalExtraInfo(pei); } /** * Changes lineitem's name. Throws exception if lineitem is not found. * - * @param bbContentId - * @param courseIdStr + * @param _content_id + * @param _course_id * @param newLineitemName * @throws PersistenceException * @throws ServletException * @throws ValidationException */ - public static void changeLineitemName(String bbContentId, String courseIdStr, String newLineitemName) + public static void changeLineitemName(String _content_id, String _course_id, String newLineitemName) throws PersistenceException, ServletException, ValidationException { LineitemDbLoader lineitemLoader = LineitemDbLoader.Default.getInstance(); LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance(); - Id lineitemId = getLineitem(bbContentId, courseIdStr, true); + Id lineitemId = getLineitem(_content_id, _course_id, true); Lineitem lineitem = lineitemLoader.loadById(lineitemId); lineitem.setName(newLineitemName); linePersister.persist(lineitem);