diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageUtils.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageUtils.java index 9b7a5645..643a4bab 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageUtils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageUtils.java @@ -21,8 +21,8 @@ import ch.ethz.seb.sebserver.gbl.api.API.BulkActionType; import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall.CallType; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; -import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitutionDependency; public final class PageUtils { @@ -44,11 +44,13 @@ public final class PageUtils { return () -> { try { - final Set dependencies = restService.getBuilder(GetInstitutionDependency.class) - .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(entity.getModelId())) - .withQueryParam(API.PARAM_BULK_ACTION_TYPE, BulkActionType.DEACTIVATE.name()) - .call() - .getOrThrow(); + + final Set dependencies = + restService.> getBuilder(entity.entityType(), CallType.GET_DEPENDENCIES) + .withURIVariable(API.PARAM_MODEL_ID, String.valueOf(entity.getModelId())) + .withQueryParam(API.PARAM_BULK_ACTION_TYPE, BulkActionType.DEACTIVATE.name()) + .call() + .getOrThrow(); final int size = dependencies.size(); if (size > 0) { return new LocTextKey("sebserver.dialog.confirm.deactivation", String.valueOf(size)); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java index bf48db2c..3ce5624a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.APIMessage; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.model.Page; @@ -40,20 +41,32 @@ public abstract class RestCall { private static final Logger log = LoggerFactory.getLogger(RestCall.class); + public enum CallType { + UNDEFINED, + GET_SINGLE, + GET_PAGE, + GET_NAMES, + GET_DEPENDENCIES, + NEW, + SAVE, + ACTIVATION_ACTIVATE, + ACTIVATION_DEACTIVATE + } + protected RestService restService; protected JSONMapper jsonMapper; - protected final TypeReference typeRef; + protected TypeKey typeKey; protected final HttpMethod httpMethod; protected final MediaType contentType; protected final String path; protected RestCall( - final TypeReference typeRef, + final TypeKey typeKey, final HttpMethod httpMethod, final MediaType contentType, final String path) { - this.typeRef = typeRef; + this.typeKey = typeKey; this.httpMethod = httpMethod; this.contentType = contentType; this.path = path; @@ -84,7 +97,7 @@ public abstract class RestCall { return Result.of(RestCall.this.jsonMapper.readValue( responseEntity.getBody(), - RestCall.this.typeRef)); + RestCall.this.typeKey.typeRef)); } else { @@ -255,4 +268,45 @@ public abstract class RestCall { } + public static final class TypeKey { + final CallType callType; + final EntityType entityType; + private final TypeReference typeRef; + + public TypeKey( + final CallType callType, + final EntityType entityType, + final TypeReference typeRef) { + + this.callType = callType; + this.entityType = entityType; + this.typeRef = typeRef; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.callType == null) ? 0 : this.callType.hashCode()); + result = prime * result + ((this.entityType == null) ? 0 : this.entityType.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final TypeKey other = (TypeKey) obj; + if (this.callType != other.callType) + return false; + if (this.entityType != other.entityType) + return false; + return true; + } + } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestService.java index 79e6ce94..7dbf14de 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestService.java @@ -18,10 +18,12 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.page.PageContext.AttributeKeys; import ch.ethz.seb.sebserver.gui.service.page.action.Action; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall.CallType; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.WebserviceURIService; @@ -65,6 +67,15 @@ public class RestService { return (RestCall) this.calls.get(type.getName()); } + @SuppressWarnings("unchecked") + public final RestCall getRestCall(final EntityType entityType, final CallType callType) { + return (RestCall) this.calls.values() + .stream() + .filter(call -> call.typeKey.callType == callType && call.typeKey.entityType == entityType) + .findFirst() + .orElse(null); + } + public final RestCall.RestCallBuilder getBuilder(final Class> type) { @SuppressWarnings("unchecked") final RestCall restCall = (RestCall) this.calls.get(type.getName()); @@ -75,6 +86,18 @@ public class RestService { return restCall.newBuilder(); } + public final RestCall.RestCallBuilder getBuilder( + final EntityType entityType, + final CallType callType) { + + final RestCall restCall = getRestCall(entityType, callType); + if (restCall == null) { + return null; + } + + return restCall.newBuilder(); + } + public Action activation(final Action action) { if (action.definition.restCallType == null) { throw new IllegalArgumentException("ActionDefinition needs to define a restCallType to use this action"); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ActivateInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ActivateInstitution.java index ac0a33a9..2b643164 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ActivateInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ActivateInstitution.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class ActivateInstitution extends RestCall { protected ActivateInstitution() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_ACTIVATE, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.PATH_VAR_ACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/DeactivateInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/DeactivateInstitution.java index 534874c6..fe206130 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/DeactivateInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/DeactivateInstitution.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class DeactivateInstitution extends RestCall { protected DeactivateInstitution() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_DEACTIVATE, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.PATH_VAR_INACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ExportSEBConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ExportSEBConfig.java index c723f7ac..5a380514 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ExportSEBConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/ExportSEBConfig.java @@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gbl.util.Result; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -28,9 +29,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class ExportSEBConfig extends RestCall { protected ExportSEBConfig() { - super( + super(new TypeKey<>( + CallType.UNDEFINED, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.SEB_CONFIG_EXPORT_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitution.java index b9dc3b3c..0db399fb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitution.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetInstitution extends RestCall { protected GetInstitution() { - super( + super(new TypeKey<>( + CallType.GET_SINGLE, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionDependency.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionDependency.java index 31204902..2ec060ff 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionDependency.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionDependency.java @@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -28,9 +29,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetInstitutionDependency extends RestCall> { protected GetInstitutionDependency() { - super( + super(new TypeKey<>( + CallType.GET_DEPENDENCIES, + EntityType.INSTITUTION, new TypeReference>() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.DEPENDENCY_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionNames.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionNames.java index cbbd54ee..e1049342 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionNames.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutionNames.java @@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityName; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -28,9 +29,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetInstitutionNames extends RestCall> { protected GetInstitutionNames() { - super( + super(new TypeKey<>( + CallType.GET_NAMES, + EntityType.INSTITUTION, new TypeReference>() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.NAMES_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutions.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutions.java index eef01ebc..2c085852 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutions.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/GetInstitutions.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; @@ -27,9 +28,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetInstitutions extends RestCall> { protected GetInstitutions() { - super( + super(new TypeKey<>( + CallType.GET_PAGE, + EntityType.INSTITUTION, new TypeReference>() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/NewInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/NewInstitution.java index 30352412..c8d0d1d2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/NewInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/NewInstitution.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class NewInstitution extends RestCall { protected NewInstitution() { - super( + super(new TypeKey<>( + CallType.NEW, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java index d9cc74f5..1f505806 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class SaveInstitution extends RestCall { protected SaveInstitution() { - super( + super(new TypeKey<>( + CallType.SAVE, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.PUT, MediaType.APPLICATION_JSON_UTF8, API.INSTITUTION_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/ActivateLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/ActivateLmsSetup.java index 5be556c2..802850a3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/ActivateLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/ActivateLmsSetup.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class ActivateLmsSetup extends RestCall { protected ActivateLmsSetup() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_ACTIVATE, + EntityType.LMS_SETUP, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.LMS_SETUP_ENDPOINT + API.PATH_VAR_ACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/DeactivateLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/DeactivateLmsSetup.java index 7edc669e..0abf6ad6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/DeactivateLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/DeactivateLmsSetup.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class DeactivateLmsSetup extends RestCall { protected DeactivateLmsSetup() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_DEACTIVATE, + EntityType.LMS_SETUP, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.LMS_SETUP_ENDPOINT + API.PATH_VAR_INACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetup.java index 7a19e3a7..313b2739 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetup.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetLmsSetup extends RestCall { protected GetLmsSetup() { - super( + super(new TypeKey<>( + CallType.GET_SINGLE, + EntityType.LMS_SETUP, new TypeReference() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.LMS_SETUP_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetupDependencies.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetupDependencies.java new file mode 100644 index 00000000..1bea6230 --- /dev/null +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetupDependencies.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.lmssetup; + +import java.util.Set; + +import org.springframework.context.annotation.Lazy; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.type.TypeReference; + +import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; +import ch.ethz.seb.sebserver.gbl.model.EntityKey; +import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; +import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; + +@Lazy +@Component +@GuiProfile +public class GetLmsSetupDependencies extends RestCall> { + + protected GetLmsSetupDependencies() { + super(new TypeKey<>( + CallType.GET_DEPENDENCIES, + EntityType.LMS_SETUP, + new TypeReference>() { + }), + HttpMethod.GET, + MediaType.APPLICATION_FORM_URLENCODED, + API.LMS_SETUP_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.DEPENDENCY_PATH_SEGMENT); + } +} diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetups.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetups.java index 1491b366..f28dc031 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetups.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/GetLmsSetups.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; @@ -27,9 +28,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetLmsSetups extends RestCall> { protected GetLmsSetups() { - super( + super(new TypeKey<>( + CallType.GET_PAGE, + EntityType.LMS_SETUP, new TypeReference>() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.LMS_SETUP_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/NewLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/NewLmsSetup.java index 66079447..9d1379b9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/NewLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/NewLmsSetup.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class NewLmsSetup extends RestCall { protected NewLmsSetup() { - super( + super(new TypeKey<>( + CallType.NEW, + EntityType.LMS_SETUP, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.LMS_SETUP_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java index 12b9aab8..6bbdc247 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class SaveLmsSetup extends RestCall { protected SaveLmsSetup() { - super( + super(new TypeKey<>( + CallType.SAVE, + EntityType.LMS_SETUP, new TypeReference() { - }, + }), HttpMethod.PUT, MediaType.APPLICATION_JSON_UTF8, API.LMS_SETUP_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ActivateUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ActivateUserAccount.java index de8a6251..0df02dec 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ActivateUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ActivateUserAccount.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class ActivateUserAccount extends RestCall { protected ActivateUserAccount() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_ACTIVATE, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.USER_ACCOUNT_ENDPOINT + API.PATH_VAR_ACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java index e90c45e1..627e3450 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class ChangePassword extends RestCall { protected ChangePassword() { - super( + super(new TypeKey<>( + CallType.UNDEFINED, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.PUT, MediaType.APPLICATION_JSON_UTF8, API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/DeactivateUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/DeactivateUserAccount.java index 2cecd59a..547a36a6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/DeactivateUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/DeactivateUserAccount.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class DeactivateUserAccount extends RestCall { protected DeactivateUserAccount() { - super( + super(new TypeKey<>( + CallType.ACTIVATION_DEACTIVATE, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.USER_ACCOUNT_ENDPOINT + API.PATH_VAR_INACTIVE); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccount.java index f9c5aa0d..85a9fe72 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccount.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetUserAccount extends RestCall { protected GetUserAccount() { - super( + super(new TypeKey<>( + CallType.GET_SINGLE, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.USER_ACCOUNT_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccounts.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccounts.java index 66a3b535..2f25a403 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccounts.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/GetUserAccounts.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Page; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; @@ -27,9 +28,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class GetUserAccounts extends RestCall> { protected GetUserAccounts() { - super( + super(new TypeKey<>( + CallType.GET_PAGE, + EntityType.USER, new TypeReference>() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.USER_ACCOUNT_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/NewUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/NewUserAccount.java index 8cc9df3c..de8d59be 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/NewUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/NewUserAccount.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class NewUserAccount extends RestCall { protected NewUserAccount() { - super( + super(new TypeKey<>( + CallType.NEW, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.POST, MediaType.APPLICATION_FORM_URLENCODED, API.USER_ACCOUNT_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java index ce48485f..8b665bde 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.user.UserInfo; import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; @@ -26,9 +27,11 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; public class SaveUserAccount extends RestCall { protected SaveUserAccount() { - super( + super(new TypeKey<>( + CallType.SAVE, + EntityType.USER, new TypeReference() { - }, + }), HttpMethod.PUT, MediaType.APPLICATION_JSON_UTF8, API.USER_ACCOUNT_ENDPOINT); diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/RestServiceTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/RestServiceTest.java index 6b0c56f3..72a6ca8e 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/RestServiceTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/RestServiceTest.java @@ -20,6 +20,7 @@ import org.springframework.http.MediaType; import com.fasterxml.jackson.core.type.TypeReference; import ch.ethz.seb.sebserver.gbl.api.API; +import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.JSONMapper; import ch.ethz.seb.sebserver.gbl.model.institution.Institution; import ch.ethz.seb.sebserver.gbl.util.Result; @@ -50,9 +51,11 @@ public class RestServiceTest extends GuiIntegrationTest { public static class GetInstitution extends RestCall { public GetInstitution() { - super( + super(new TypeKey<>( + CallType.GET_SINGLE, + EntityType.INSTITUTION, new TypeReference() { - }, + }), HttpMethod.GET, MediaType.APPLICATION_FORM_URLENCODED, API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT);