diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/api/API.java b/src/main/java/ch/ethz/seb/sebserver/gbl/api/API.java index 1560ddf7..2ba1e9d3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/api/API.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/api/API.java @@ -19,6 +19,7 @@ public final class API { public static final String PARAM_LOGO_IMAGE = "logoImageBase64"; public static final String PARAM_INSTITUTION_ID = "institutionId"; public static final String PARAM_MODEL_ID = "modelId"; + public static final String PARAM_MODEL_ID_LIST = "modelIds"; public static final String PARAM_ENTITY_TYPE = "entityType"; public static final String PARAM_BULK_ACTION_TYPE = "bulkActionType"; diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java index 452b0bbb..8765707b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/institution/Institution.java @@ -63,7 +63,7 @@ public final class Institution implements GrantEntity, Activatable { this.name = mapper.getString(INSTITUTION.ATTR_NAME); this.urlSuffix = mapper.getString(INSTITUTION.ATTR_URL_SUFFIX); this.logoImage = mapper.getString(INSTITUTION.ATTR_LOGO_IMAGE); - this.active = mapper.getBooleanObject(INSTITUTION.ATTR_ACTIVE); + this.active = false; } @Override diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/EntityController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/EntityController.java index b5622a4d..74985de1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/EntityController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/EntityController.java @@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.webservice.weblayer.api; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.stream.Collectors; import javax.validation.Valid; @@ -163,7 +164,7 @@ public abstract class EntityController getDependencies( @PathVariable final String modelId, - @RequestParam(API.PARAM_BULK_ACTION_TYPE) final BulkActionType bulkActionType) { + @RequestParam(name = API.PARAM_BULK_ACTION_TYPE, required = true) final BulkActionType bulkActionType) { this.entityDAO .byModelId(modelId) @@ -204,11 +205,11 @@ public abstract class EntityController getForIds(@RequestParam(name = "ids", required = true) final String ids) { + public List getForIds(@RequestParam(name = API.PARAM_MODEL_ID_LIST, required = true) final String modelIds) { return Result.tryCatch(() -> { - return Arrays.asList(StringUtils.split(ids, Constants.LIST_SEPARATOR_CHAR)) + return Arrays.asList(StringUtils.split(modelIds, Constants.LIST_SEPARATOR_CHAR)) .stream() .map(modelId -> new EntityKey(modelId, this.entityDAO.entityType())) .collect(Collectors.toList()); @@ -307,7 +308,7 @@ public abstract class EntityController page = new Page<>(2, 1, "name", Arrays.asList( + new UserInfo("id1", 1L, "user1", "user1", "user1@inst2.none", true, Locale.ENGLISH, DateTimeZone.UTC, + new HashSet<>(Arrays.asList(UserRole.EXAM_ADMIN.name()))), + new UserInfo("id2", 3L, "user2", "user2", "user2@inst2.none", true, Locale.ENGLISH, DateTimeZone.UTC, + new HashSet<>(Arrays.asList(UserRole.EXAM_ADMIN.name()))), + new UserInfo("id3", 4L, "user3", "user3", "user3@inst2.none", false, Locale.GERMAN, DateTimeZone.UTC, + new HashSet<>(Arrays.asList(UserRole.EXAM_ADMIN.name()))))); + + final JSONMapper jsonMapper = new JSONMapper(); + final ObjectWriter writerWithDefaultPrettyPrinter = jsonMapper.writerWithDefaultPrettyPrinter(); + final String json = writerWithDefaultPrettyPrinter.writeValueAsString(page); + assertEquals("{\r\n" + + " \"number_of_pages\" : 2,\r\n" + + " \"page_number\" : 1,\r\n" + + " \"sort\" : \"name\",\r\n" + + " \"content\" : [ {\r\n" + + " \"uuid\" : \"id1\",\r\n" + + " \"institutionId\" : 1,\r\n" + + " \"name\" : \"user1\",\r\n" + + " \"username\" : \"user1\",\r\n" + + " \"email\" : \"user1@inst2.none\",\r\n" + + " \"active\" : true,\r\n" + + " \"language\" : \"en\",\r\n" + + " \"timezone\" : \"UTC\",\r\n" + + " \"userRoles\" : [ \"EXAM_ADMIN\" ]\r\n" + + " }, {\r\n" + + " \"uuid\" : \"id2\",\r\n" + + " \"institutionId\" : 3,\r\n" + + " \"name\" : \"user2\",\r\n" + + " \"username\" : \"user2\",\r\n" + + " \"email\" : \"user2@inst2.none\",\r\n" + + " \"active\" : true,\r\n" + + " \"language\" : \"en\",\r\n" + + " \"timezone\" : \"UTC\",\r\n" + + " \"userRoles\" : [ \"EXAM_ADMIN\" ]\r\n" + + " }, {\r\n" + + " \"uuid\" : \"id3\",\r\n" + + " \"institutionId\" : 4,\r\n" + + " \"name\" : \"user3\",\r\n" + + " \"username\" : \"user3\",\r\n" + + " \"email\" : \"user3@inst2.none\",\r\n" + + " \"active\" : false,\r\n" + + " \"language\" : \"de\",\r\n" + + " \"timezone\" : \"UTC\",\r\n" + + " \"userRoles\" : [ \"EXAM_ADMIN\" ]\r\n" + + " } ],\r\n" + + " \"page_size\" : 3\r\n" + + "}", json); + + } + +} diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/InstitutionAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/InstitutionAPITest.java index dd708395..b7246596 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/InstitutionAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/InstitutionAPITest.java @@ -269,6 +269,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester { + "dependencies=[], " + "errors=[]]", report.toString()); + // get institution = new RestAPITestHelper() .withAccessToken(sebAdminAccess) @@ -349,7 +350,7 @@ public class InstitutionAPITest extends AdministrationAPIIntegrationTester { .withAccessToken(getSebAdminAccess()) .withPath(API.INSTITUTION_ENDPOINT) .withPath(API.LIST_PATH_SEGMENT) - .withAttribute("ids", "1,2,3") + .withAttribute(API.PARAM_MODEL_ID_LIST, "1,2,3") .withExpectedStatus(HttpStatus.OK) .getAsObject(new TypeReference>() { }); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/LmsSetupAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/LmsSetupAPITest.java index 1ecf0c2b..c924a20c 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/LmsSetupAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/LmsSetupAPITest.java @@ -224,7 +224,7 @@ public class LmsSetupAPITest extends AdministrationAPIIntegrationTester { .withAccessToken(getSebAdminAccess()) .withPath(API.LMS_SETUP_ENDPOINT) .withPath(API.LIST_PATH_SEGMENT) - .withAttribute("ids", lmsSetup1.id + "," + lmsSetup2.id) + .withAttribute(API.PARAM_MODEL_ID_LIST, lmsSetup1.id + "," + lmsSetup2.id) .withExpectedStatus(HttpStatus.OK) .getAsObject(new TypeReference>() { }); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java index 37037a2f..49501542 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java @@ -1090,7 +1090,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc .perform( get(this.endpoint + API.USER_ACCOUNT_ENDPOINT - + "/list?ids=user1,user2,user6,user7") + + "/list?modelIds=user1,user2,user6,user7") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .header("Authorization", "Bearer " + sebAdminToken)) .andExpect(status().isOk()) @@ -1108,7 +1108,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc .perform( get(this.endpoint + API.USER_ACCOUNT_ENDPOINT - + "/list?ids=user1,user2,user6,user7") + + "/list?modelIds=user1,user2,user6,user7") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .header("Authorization", "Bearer " + instAdminToken)) .andExpect(status().isOk())