Index: lams_central/src/java/org/lamsfoundation/lams/web/controller/LtiController.java
===================================================================
diff -u -r11c16b6288d776bf28308fbabe11a12ce9547335 -re8258c12ef64821f5c4797d12a4d9d4bf99c8804
--- lams_central/src/java/org/lamsfoundation/lams/web/controller/LtiController.java (.../LtiController.java) (revision 11c16b6288d776bf28308fbabe11a12ce9547335)
+++ lams_central/src/java/org/lamsfoundation/lams/web/controller/LtiController.java (.../LtiController.java) (revision e8258c12ef64821f5c4797d12a4d9d4bf99c8804)
@@ -91,6 +91,7 @@
String resourceLinkId = request.getParameter(BasicLTIConstants.RESOURCE_LINK_ID);
String tcGradebookId = request.getParameter(BasicLTIConstants.LIS_RESULT_SOURCEDID);
String extUserId = request.getParameter(BasicLTIConstants.USER_ID);
+ String customContextMembershipUrl = request.getParameter(LtiUtils.CUSTOM_CONTEXT_MEMBERSHIPS_URL);
Long customLessonId = WebUtil.readLongParam(request, "custom_lessonid", true);
boolean isContentItemSelection = WebUtil.readBooleanParam(request, "custom_iscontentitemselection", false);
//parameter containing original resource_link_id, available after course copy (BB only)
@@ -130,7 +131,8 @@
if (isLessonCopyRequired) {
//add users to the course
- integrationService.addUsersUsingMembershipService(extServer, null, extCourseId, resourceLinkId);
+ integrationService.addUsersUsingMembershipService(extServer, null, extCourseId, resourceLinkId,
+ customContextMembershipUrl);
// clone lesson
Integer creatorId = lesson.getUser().getUserId();
@@ -195,6 +197,7 @@
UserAccessDeniedException, RepositoryCheckedException, UserInfoFetchException, UserInfoValidationException {
Integer userId = getUser().getUserID();
String contextId = request.getParameter(BasicLTIConstants.CONTEXT_ID);
+ String customContextMembershipUrl = request.getParameter(LtiUtils.CUSTOM_CONTEXT_MEMBERSHIPS_URL);
String consumerKey = request.getParameter(LtiUtils.OAUTH_CONSUMER_KEY);
String resourceLinkId = request.getParameter(BasicLTIConstants.RESOURCE_LINK_ID);
String resourceLinkTitle = request.getParameter(BasicLTIConstants.RESOURCE_LINK_TITLE);
@@ -216,6 +219,7 @@
request.setAttribute(BasicLTIConstants.RESOURCE_LINK_ID, resourceLinkId);
request.setAttribute(CentralConstants.ATTR_COURSE_ID, organisationId);
request.setAttribute(BasicLTIConstants.CONTEXT_ID, contextId);
+ request.setAttribute(LtiUtils.CUSTOM_CONTEXT_MEMBERSHIPS_URL, customContextMembershipUrl);
request.setAttribute(CentralConstants.PARAM_TITLE, resourceLinkTitle);
request.setAttribute(CentralConstants.PARAM_DESC, resourceLinkDescription);
@@ -257,6 +261,7 @@
String desc = request.getParameter(CentralConstants.PARAM_DESC);
String ldIdStr = request.getParameter(CentralConstants.PARAM_LEARNING_DESIGN_ID);
String extCourseId = request.getParameter(BasicLTIConstants.CONTEXT_ID);
+ String customContextMembershipUrl = request.getParameter(LtiUtils.CUSTOM_CONTEXT_MEMBERSHIPS_URL);
Integer organisationId = WebUtil.readIntParam(request, CentralConstants.ATTR_COURSE_ID);
boolean enableLessonIntro = WebUtil.readBooleanParam(request, "enableLessonIntro", false);
@@ -303,7 +308,8 @@
*/
integrationService.createExtServerLessonMap(lessonId, extServer);
- integrationService.addUsersUsingMembershipService(extServer, lessonId, extCourseId, resourceLinkId);
+ integrationService.addUsersUsingMembershipService(extServer, lessonId, extCourseId, resourceLinkId,
+ customContextMembershipUrl);
//support for ContentItemSelectionRequest
String ltiMessageType = request.getParameter(BasicLTIConstants.LTI_MESSAGE_TYPE);
Index: lams_central/web/lti/addLesson.jsp
===================================================================
diff -u -r4c2d1f37b92435907ec4ce23cb635a7cd9e4161e -re8258c12ef64821f5c4797d12a4d9d4bf99c8804
--- lams_central/web/lti/addLesson.jsp (.../addLesson.jsp) (revision 4c2d1f37b92435907ec4ce23cb635a7cd9e4161e)
+++ lams_central/web/lti/addLesson.jsp (.../addLesson.jsp) (revision e8258c12ef64821f5c4797d12a4d9d4bf99c8804)
@@ -194,6 +194,7 @@
+
<%-- ContentItemSelectionRequest items --%>
Index: lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java
===================================================================
diff -u -r40de3afab4e8d589660daffb6efd6e568e87f8fa -re8258c12ef64821f5c4797d12a4d9d4bf99c8804
--- lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java (.../IIntegrationService.java) (revision 40de3afab4e8d589660daffb6efd6e568e87f8fa)
+++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IIntegrationService.java (.../IIntegrationService.java) (revision e8258c12ef64821f5c4797d12a4d9d4bf99c8804)
@@ -27,11 +27,9 @@
import java.io.UnsupportedEncodingException;
import java.util.List;
-import org.apache.http.client.ClientProtocolException;
-import org.imsglobal.lti.launch.LtiSigningException;
import org.lamsfoundation.lams.integration.ExtCourseClassMap;
-import org.lamsfoundation.lams.integration.ExtServerLessonMap;
import org.lamsfoundation.lams.integration.ExtServer;
+import org.lamsfoundation.lams.integration.ExtServerLessonMap;
import org.lamsfoundation.lams.integration.ExtServerToolAdapterMap;
import org.lamsfoundation.lams.integration.ExtUserUseridMap;
import org.lamsfoundation.lams.integration.UserInfoFetchException;
@@ -57,8 +55,7 @@
String prettyCourseName, String method) throws UserInfoValidationException;
ExtCourseClassMap getExtCourseClassMap(ExtServer extServer, ExtUserUseridMap userMap, String extCourseId,
- String extCourseName, String parentOrgId, String method, Boolean prefix)
- throws UserInfoValidationException;
+ String extCourseName, String parentOrgId, String method, Boolean prefix) throws UserInfoValidationException;
ExtUserUseridMap getExtUserUseridMap(ExtServer extServer, String extUsername, boolean prefix)
throws UserInfoFetchException, UserInfoValidationException;
@@ -98,23 +95,23 @@
/**
* Returns integration server by its automatically-created sid.
- *
+ *
* @param serverId
* @return
*/
ExtServer getExtServer(Integer sid);
/**
* Returns integration server by its human-entered serverId.
- *
+ *
* @param serverId
* @return
*/
ExtServer getExtServer(String serverId);
/**
* Returns ExtServerLessonMap for the LTI Tool Consumer identified by serverId.
- *
+ *
* @param serverId
* @param resourceLinkId
* resource_link_id parameter from LTI request
@@ -154,7 +151,7 @@
/**
* Checks whether user was created via integrations.
- *
+ *
* @param userId
* @return
*/
@@ -187,7 +184,7 @@
/**
* Creates new ExtServerLessonMap object. Method is suitable for creating lessons via integration servers.
- *
+ *
* @param lessonId
* @param extServer
*/
@@ -196,7 +193,7 @@
/**
* Creates new ExtServerLessonMap object. Method is suitable for creating lessons via LTI tool consumers as long as
* they provide resourceLinkId as a parameter and not lessonId.
- *
+ *
* @param lessonId
* @param resourceLinkId
* resource_link_id parameter sent by LTI tool consumer
@@ -205,18 +202,19 @@
ExtServerLessonMap createExtServerLessonMap(Long lessonId, String resourceLinkId, ExtServer extServer);
/**
- * Checks whether the lesson was created from extServer (not an LTI consumer one) and returns lessonFinishCallbackUrl if it's not blank.
+ * Checks whether the lesson was created from extServer (not an LTI consumer one) and returns
+ * lessonFinishCallbackUrl if it's not blank.
*
* @param user
* @param lesson
* @return
* @throws UnsupportedEncodingException
*/
String getLessonFinishCallbackUrl(User user, Lesson lesson) throws UnsupportedEncodingException;
-
+
/**
* Check whether specified lesson was created using LTI consumer, and if so - push user mark to that server
- *
+ *
* @param user
* @param lesson
*/
@@ -232,32 +230,34 @@
*/
boolean isIntegratedServerGroupFetchingAvailable(Long lessonId);
- List getExtGroups(Long lessonId, String[] extGroupIds) throws GroupInfoFetchException, UserInfoValidationException, IOException;
+ List getExtGroups(Long lessonId, String[] extGroupIds)
+ throws GroupInfoFetchException, UserInfoValidationException, IOException;
ExtCourseClassMap getExtCourseClassMap(Integer sid, Long lessonId);
-
+
/**
* Try to get users from ext server using membership service.
- *
- * @param lessonId if supplied, user will be added to the according lesson; and only to the course otherwise
+ *
+ * @param lessonId
+ * if supplied, user will be added to the according lesson; and only to the course otherwise
*/
- void addUsersUsingMembershipService(ExtServer extServer, Long lessonId, String extCourseId, String resourceLinkId)
- throws IOException, UserInfoFetchException, UserInfoValidationException;
-
+ void addUsersUsingMembershipService(ExtServer extServer, Long lessonId, String extCourseId, String resourceLinkId,
+ String customContextMembershipUrl) throws IOException, UserInfoFetchException, UserInfoValidationException;
+
/**
* Adds an external user to the course with specified courseId.
*/
- ExtUserUseridMap addExtUserToCourse(ExtServer extServer, String method, String username, String firstName, String lastName,
- String email, String extCourseId, String countryIsoCode, String langIsoCode)
+ ExtUserUseridMap addExtUserToCourse(ExtServer extServer, String method, String username, String firstName,
+ String lastName, String email, String extCourseId, String countryIsoCode, String langIsoCode)
throws UserInfoFetchException, UserInfoValidationException;
/**
* Add an external user to the course with specified courseId and then adds it the the lesson with specified
* lessonId. (This method makes internal call to addExtUserToCourse()).
*/
- ExtUserUseridMap addExtUserToCourseAndLesson(ExtServer extServer, String method, Long lessonId, String username, String firstName,
- String lastName, String email, String extCourseId, String countryIsoCode, String langIsoCode)
- throws UserInfoFetchException, UserInfoValidationException;
+ ExtUserUseridMap addExtUserToCourseAndLesson(ExtServer extServer, String method, Long lessonId, String username,
+ String firstName, String lastName, String email, String extCourseId, String countryIsoCode,
+ String langIsoCode) throws UserInfoFetchException, UserInfoValidationException;
/**
* Creates an external org and normal org. It does not set roles for the creator.
Index: lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java
===================================================================
diff -u -r058adba867d104c2148e289a3dacda7f22f6ac60 -re8258c12ef64821f5c4797d12a4d9d4bf99c8804
--- lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision 058adba867d104c2148e289a3dacda7f22f6ac60)
+++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision e8258c12ef64821f5c4797d12a4d9d4bf99c8804)
@@ -973,16 +973,23 @@
@Override
public void addUsersUsingMembershipService(ExtServer extServer, Long lessonId, String courseId,
- String resourceLinkId) throws IOException, UserInfoFetchException, UserInfoValidationException {
+ String resourceLinkId, String customContextMembershipUrl)
+ throws IOException, UserInfoFetchException, UserInfoValidationException {
- String membershipUrl = extServer.getMembershipUrl();
- //if tool consumer haven't provided membershipUrl (ToolProxyBinding.memberships.url parameter) we can't add any users
+ String membershipUrl = customContextMembershipUrl;
if (StringUtils.isBlank(membershipUrl)) {
+ membershipUrl = extServer.getMembershipUrl();
+ }
+
+ // if tool consumer haven't provided membershipUrl (ToolProxyBinding.memberships.url parameter) we can't add any users
+ if (StringUtils.isBlank(membershipUrl)) {
return;
}
- membershipUrl += membershipUrl.contains("?") ? "&" : "?";
- membershipUrl += "rlid=" + resourceLinkId;
+ if (StringUtils.isNotBlank(resourceLinkId)) {
+ membershipUrl += membershipUrl.contains("?") ? "&" : "?";
+ membershipUrl += "rlid=" + resourceLinkId;
+ }
log.debug("Make a call to remote membershipUrl:" + membershipUrl);
HttpGet ltiServiceGetRequest = new HttpGet(membershipUrl);
Index: lams_common/src/java/org/lamsfoundation/lams/integration/util/LtiUtils.java
===================================================================
diff -u -r596d49cc53a892734fbc68fe872ab0b618bc0a8c -re8258c12ef64821f5c4797d12a4d9d4bf99c8804
--- lams_common/src/java/org/lamsfoundation/lams/integration/util/LtiUtils.java (.../LtiUtils.java) (revision 596d49cc53a892734fbc68fe872ab0b618bc0a8c)
+++ lams_common/src/java/org/lamsfoundation/lams/integration/util/LtiUtils.java (.../LtiUtils.java) (revision e8258c12ef64821f5c4797d12a4d9d4bf99c8804)
@@ -11,21 +11,22 @@
public static final String OAUTH_CONSUMER_KEY = "oauth_consumer_key";
public static final String LTI_MESSAGE_TYPE_CONTENTITEMSELECTIONREQUEST = "ContentItemSelectionRequest";
public static final String CONTENT_ITEM_RETURN_URL = "content_item_return_url";
-
+ public static final String CUSTOM_CONTEXT_MEMBERSHIPS_URL = "custom_context_memberships_url";
+
/**
* Return true
if the user is an administrator.
* {Method added by LAMS}
*
* @return true
if the user has a role of administrator
*/
public static boolean isAdmin(String roles) {
- List rolesToSearchFor = new LinkedList();
+ List rolesToSearchFor = new LinkedList<>();
rolesToSearchFor.add("urn:lti:role:ims/lis/Administrator");
rolesToSearchFor.add("urn:lti:sysrole:ims/lis/SysAdmin");
rolesToSearchFor.add("urn:lti:sysrole:ims/lis/Administrator");
rolesToSearchFor.add("urn:lti:instrole:ims/lis/Administrator");
-
- return hasRole(roles, rolesToSearchFor);
+
+ return LtiUtils.hasRole(roles, rolesToSearchFor);
}
/**
@@ -35,27 +36,27 @@
* @return true
if the user has a role of instructor, contentdeveloper or teachingassistant
*/
public static boolean isStaff(String roles, ExtServer extServer) {
- List rolesToSearchFor = new LinkedList();
+ List rolesToSearchFor = new LinkedList<>();
rolesToSearchFor.add("urn:lti:role:ims/lis/Instructor");
rolesToSearchFor.add("urn:lti:instrole:ims/lis/Instructor");
rolesToSearchFor.add("urn:lti:role:ims/lis/ContentDeveloper");
rolesToSearchFor.add("urn:lti:role:ims/lis/TeachingAssistant");
-
+
String toolConsumerMonitorRoles = extServer.getLtiToolConsumerMonitorRoles();
if (toolConsumerMonitorRoles != null) {
rolesToSearchFor.addAll(Arrays.asList(toolConsumerMonitorRoles.split(",")));
}
-
- return hasRole(roles, rolesToSearchFor);
+
+ return LtiUtils.hasRole(roles, rolesToSearchFor);
}
-
+
public static boolean isToolConsumerCustomRole(String roles, String toolConsumerCustomRoles) {
if (roles == null || toolConsumerCustomRoles == null) {
return false;
}
-
+
List rolesToSearchFor = Arrays.asList(toolConsumerCustomRoles.split(","));
- return hasRole(roles, rolesToSearchFor);
+ return LtiUtils.hasRole(roles, rolesToSearchFor);
}
/**
@@ -65,24 +66,24 @@
* @return true
if the user has a role of learner
*/
public static boolean isLearner(String roles) {
- List rolesToSearchFor = new LinkedList();
+ List rolesToSearchFor = new LinkedList<>();
rolesToSearchFor.add("urn:lti:role:ims/lis/Learner");
-
- return hasRole(roles, rolesToSearchFor);
+
+ return LtiUtils.hasRole(roles, rolesToSearchFor);
}
/*
* Check whether the user has a specified role name.
* {Method added by LAMS}
*
* @param role
- * Name of role
+ * Name of role
*
* @return true
if the user has the specified role
*/
private static boolean hasRole(String roles, List rolesToSearchFor) {
String[] roleArray = roles.split(",");
-
+
boolean hasRole = false;
for (String role : roleArray) {
for (String roleToSearchFor : rolesToSearchFor) {