Index: lams_bb_integration/RELEASE_NOTES.TXT
===================================================================
diff -u -r4c4f5298c4e76f2f9ab805a93be2b3709796e8ae -r16d465ea5a587cce4799b66582fe7a31ed5df95f
--- lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision 4c4f5298c4e76f2f9ab805a93be2b3709796e8ae)
+++ lams_bb_integration/RELEASE_NOTES.TXT (.../RELEASE_NOTES.TXT) (revision 16d465ea5a587cce4799b66582fe7a31ed5df95f)
@@ -114,4 +114,5 @@
====================
* LDEV-3510: Previous releases were opening lessons in a new window due to a change made for LDEV-3510.
Now reverted back to previous behaviour with lesson loading in the same tab.
-* LKC-61: Gradebook syncing change
\ No newline at end of file
+* LKC-61: Gradebook syncing change
+* LDEV-3621: Ability to import and use groups from integrated server
\ No newline at end of file
Index: lams_bb_integration/WEB-INF/web.xml
===================================================================
diff -u -rd40a0d041dc391b87ad266f8186a3592fb7eba7c -r16d465ea5a587cce4799b66582fe7a31ed5df95f
--- lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision d40a0d041dc391b87ad266f8186a3592fb7eba7c)
+++ lams_bb_integration/WEB-INF/web.xml (.../web.xml) (revision 16d465ea5a587cce4799b66582fe7a31ed5df95f)
@@ -10,6 +10,10 @@
org.lamsfoundation.ld.integration.blackboard.UserDataServlet
+ GroupDataServlet
+ org.lamsfoundation.ld.integration.blackboard.GroupDataServlet
+
+
LamsLearningDesignServlet
org.lamsfoundation.ld.integration.blackboard.LamsLearningDesignServlet
@@ -48,6 +52,10 @@
/UserData
+ GroupDataServlet
+ /GroupData
+
+
GradebookServlet
/Gradebook
Index: lams_bb_integration/lib/gson-2.2.4.jar
===================================================================
diff -u
Binary files differ
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java
===================================================================
diff -u -rceb0cd59c019481da796281a115e4d2e61034b25 -r16d465ea5a587cce4799b66582fe7a31ed5df95f
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision ceb0cd59c019481da796281a115e4d2e61034b25)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/Constants.java (.../Constants.java) (revision 16d465ea5a587cce4799b66582fe7a31ed5df95f)
@@ -39,6 +39,7 @@
public static final String PARAM_LEARNING_DESIGN_ID = "ldid";
public static final String PARAM_COURSE_ID = "course_id";
public static final String PARAM_FOLDER_ID = "folderId";
+ public static final String PARAM_IS_USER_DETAILS_REQUIRED = "isUserDetailsRequired";
public static final String SERVLET_LOGIN_REQUEST = "/lams/LoginRequest";
public static final String SERVLET_ACTION_REQUEST = "/LamsActionRequest";
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java
===================================================================
diff -u
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java (revision 0)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/GroupDataServlet.java (revision 16d465ea5a587cce4799b66582fe7a31ed5df95f)
@@ -0,0 +1,172 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.ld.integration.blackboard;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.ld.integration.Constants;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
+import blackboard.base.BbList;
+import blackboard.data.course.Course;
+import blackboard.data.course.Group;
+import blackboard.data.user.User;
+import blackboard.persist.BbPersistenceManager;
+import blackboard.persist.Id;
+import blackboard.persist.PersistenceException;
+import blackboard.persist.course.CourseDbLoader;
+import blackboard.persist.course.GroupDbLoader;
+import blackboard.persist.user.UserDbLoader;
+import blackboard.platform.BbServiceManager;
+
+/**
+ * Fetch groups of the specified course. Serves 2 different types of calls: 1-initial request for group names;
+ * 2-sequential request for selected group users.
+ *
+ * @author Andrey Balan
+ */
+public class GroupDataServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+ private static Logger logger = Logger.getLogger(GroupDataServlet.class);
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+ try {
+
+ // get Parameter values
+ String usernameParam = request.getParameter(Constants.PARAM_USER_ID);
+ String tsParam = request.getParameter(Constants.PARAM_TIMESTAMP);
+ String hashParam = request.getParameter(Constants.PARAM_HASH);
+ String courseIdParam = request.getParameter(Constants.PARAM_COURSE_ID);
+ String[] groupIdsParam = request.getParameterValues("extGroupIds");
+
+ // check paramaeters
+ if (usernameParam == null || tsParam == null || hashParam == null || courseIdParam == null) {
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "missing expected parameters");
+ return;
+ }
+
+ String secretKey = LamsPluginUtil.getSecretKey();
+ String serverId = LamsPluginUtil.getServerId();
+
+ if (!LamsSecurityUtil.sha1(
+ tsParam.toLowerCase() + usernameParam.toLowerCase() + serverId.toLowerCase()
+ + secretKey.toLowerCase()).equals(hashParam)) {
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "authentication failed");
+ return;
+ }
+
+ // get the persistence manager
+ BbPersistenceManager bbPm = BbServiceManager.getPersistenceService().getDbPersistenceManager();
+ CourseDbLoader cLoader = CourseDbLoader.Default.getInstance();
+ GroupDbLoader groupLoader = (GroupDbLoader) bbPm.getLoader(GroupDbLoader.TYPE);
+ UserDbLoader userDbLoader = (UserDbLoader) bbPm.getLoader(UserDbLoader.TYPE);
+// Id courseId = bbPm.generateId(Course.DATA_TYPE, courseIdParam);
+
+ //create JSON objects to return
+ Course course = cLoader.loadByCourseId(courseIdParam);
+ List groups = groupLoader.loadAvailableByCourseId(course.getId());
+ JsonArray jsonGroups = new JsonArray();
+
+ //in case groupIds is supplied - it means we need to provide groups along with all users
+ if (groupIdsParam != null && groupIdsParam.length > 0) {
+
+ for (String groupIdParam : groupIdsParam) {
+ for (Group group : groups) {
+ //only groups with ids requested by LAMS should be processed
+ Id groupId = group.getId();
+ if (!groupId.toExternalString().equals(groupIdParam)) {
+ continue;
+ }
+
+ JsonObject jsonGroup = new JsonObject();
+ jsonGroup.addProperty("groupId", groupId.toExternalString());
+ jsonGroup.addProperty("groupName", group.getTitle());
+ jsonGroups.add(jsonGroup);
+
+ JsonArray jsonUsers = new JsonArray();
+ jsonGroup.add("users", jsonUsers);
+
+ BbList users = userDbLoader.loadByGroupId(groupId, null, true);
+ for (User user : users) {
+ JsonObject jsonUser = new JsonObject();
+ jsonUsers.add(jsonUser);
+
+ jsonUser.addProperty("userName", user.getUserName());
+
+ // The CSV list should be the format below
+ // ,,,,,,
+ // ,,,,
+ // ,,,
+ jsonUser.addProperty("1", user.getTitle());
+ jsonUser.addProperty("2", user.getGivenName());
+ jsonUser.addProperty("3", user.getFamilyName());
+ jsonUser.addProperty("4", user.getStreet1() + user.getStreet2());
+ jsonUser.addProperty("5", user.getCity());
+ jsonUser.addProperty("6", user.getState());
+ jsonUser.addProperty("7", user.getZipCode());
+ jsonUser.addProperty("8", user.getCountry());
+ jsonUser.addProperty("9", user.getHomePhone1());
+ jsonUser.addProperty("10", user.getMobilePhone());
+ jsonUser.addProperty("11", user.getBusinessFax());
+ jsonUser.addProperty("12", user.getEmailAddress());
+ String locale = user.getLocale();
+ String localeLang = LamsSecurityUtil.getLanguage(locale);
+ String localeCountry = LamsSecurityUtil.getCountry(locale);
+ jsonUser.addProperty("13", localeLang);
+ jsonUser.addProperty("14", localeCountry);
+ }
+ }
+ }
+ } else {
+ for (Group group : groups) {
+ Id groupId = group.getId();
+ JsonObject jsonGroup = new JsonObject();
+ jsonGroup.addProperty("groupId", groupId.toExternalString());
+ jsonGroup.addProperty("groupName", group.getTitle());
+ jsonGroup.addProperty("groupSize", group.getGroupMemberships().size());
+ jsonGroups.add(jsonGroup);
+
+ }
+ }
+
+ response.getWriter().write(jsonGroups.toString());
+
+ } catch (PersistenceException e) {
+ throw new ServletException("Failed to fetch course's groups", e);
+ }
+ }
+
+}
+