added more type information to RestCall's
This commit is contained in:
parent
718bd74e22
commit
3c42843f13
27 changed files with 245 additions and 56 deletions
|
@ -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<EntityKey> 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<EntityKey> dependencies =
|
||||
restService.<Set<EntityKey>> 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));
|
||||
|
|
|
@ -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<T> {
|
|||
|
||||
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<T> typeRef;
|
||||
protected TypeKey<T> typeKey;
|
||||
protected final HttpMethod httpMethod;
|
||||
protected final MediaType contentType;
|
||||
protected final String path;
|
||||
|
||||
protected RestCall(
|
||||
final TypeReference<T> typeRef,
|
||||
final TypeKey<T> 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<T> {
|
|||
|
||||
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<T> {
|
|||
|
||||
}
|
||||
|
||||
public static final class TypeKey<T> {
|
||||
final CallType callType;
|
||||
final EntityType entityType;
|
||||
private final TypeReference<T> typeRef;
|
||||
|
||||
public TypeKey(
|
||||
final CallType callType,
|
||||
final EntityType entityType,
|
||||
final TypeReference<T> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<T>) this.calls.get(type.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <T> RestCall<T> getRestCall(final EntityType entityType, final CallType callType) {
|
||||
return (RestCall<T>) this.calls.values()
|
||||
.stream()
|
||||
.filter(call -> call.typeKey.callType == callType && call.typeKey.entityType == entityType)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public final <T> RestCall<T>.RestCallBuilder getBuilder(final Class<? extends RestCall<T>> type) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final RestCall<T> restCall = (RestCall<T>) this.calls.get(type.getName());
|
||||
|
@ -75,6 +86,18 @@ public class RestService {
|
|||
return restCall.newBuilder();
|
||||
}
|
||||
|
||||
public final <T> RestCall<T>.RestCallBuilder getBuilder(
|
||||
final EntityType entityType,
|
||||
final CallType callType) {
|
||||
|
||||
final RestCall<T> restCall = getRestCall(entityType, callType);
|
||||
if (restCall == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return restCall.newBuilder();
|
||||
}
|
||||
|
||||
public <T> Action activation(final Action action) {
|
||||
if (action.definition.restCallType == null) {
|
||||
throw new IllegalArgumentException("ActionDefinition needs to define a restCallType to use this action");
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected ActivateInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_ACTIVATE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.PATH_VAR_ACTIVE);
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected DeactivateInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_DEACTIVATE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.PATH_VAR_INACTIVE);
|
||||
|
|
|
@ -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<byte[]> {
|
||||
|
||||
protected ExportSEBConfig() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.UNDEFINED,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<byte[]>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.SEB_CONFIG_EXPORT_ENDPOINT);
|
||||
|
|
|
@ -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<Institution> {
|
||||
|
||||
protected GetInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_SINGLE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Institution>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT);
|
||||
|
|
|
@ -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<Set<EntityKey>> {
|
||||
|
||||
protected GetInstitutionDependency() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_DEPENDENCIES,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Set<EntityKey>>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.DEPENDENCY_PATH_SEGMENT);
|
||||
|
|
|
@ -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<List<EntityName>> {
|
||||
|
||||
protected GetInstitutionNames() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_NAMES,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<List<EntityName>>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.NAMES_PATH_SEGMENT);
|
||||
|
|
|
@ -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<Page<Institution>> {
|
||||
|
||||
protected GetInstitutions() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_PAGE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Page<Institution>>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT);
|
||||
|
|
|
@ -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<Institution> {
|
||||
|
||||
protected NewInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.NEW,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Institution>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT);
|
||||
|
|
|
@ -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<Institution> {
|
||||
|
||||
protected SaveInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.SAVE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Institution>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.PUT,
|
||||
MediaType.APPLICATION_JSON_UTF8,
|
||||
API.INSTITUTION_ENDPOINT);
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected ActivateLmsSetup() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_ACTIVATE,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT + API.PATH_VAR_ACTIVE);
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected DeactivateLmsSetup() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_DEACTIVATE,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT + API.PATH_VAR_INACTIVE);
|
||||
|
|
|
@ -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<LmsSetup> {
|
||||
|
||||
protected GetLmsSetup() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_SINGLE,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<LmsSetup>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT);
|
||||
|
|
|
@ -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<Set<EntityKey>> {
|
||||
|
||||
protected GetLmsSetupDependencies() {
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_DEPENDENCIES,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<Set<EntityKey>>() {
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.DEPENDENCY_PATH_SEGMENT);
|
||||
}
|
||||
}
|
|
@ -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<Page<LmsSetup>> {
|
||||
|
||||
protected GetLmsSetups() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_PAGE,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<Page<LmsSetup>>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT);
|
||||
|
|
|
@ -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<LmsSetup> {
|
||||
|
||||
protected NewLmsSetup() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.NEW,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<LmsSetup>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.LMS_SETUP_ENDPOINT);
|
||||
|
|
|
@ -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<LmsSetup> {
|
||||
|
||||
protected SaveLmsSetup() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.SAVE,
|
||||
EntityType.LMS_SETUP,
|
||||
new TypeReference<LmsSetup>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.PUT,
|
||||
MediaType.APPLICATION_JSON_UTF8,
|
||||
API.LMS_SETUP_ENDPOINT);
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected ActivateUserAccount() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_ACTIVATE,
|
||||
EntityType.USER,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.USER_ACCOUNT_ENDPOINT + API.PATH_VAR_ACTIVE);
|
||||
|
|
|
@ -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<UserInfo> {
|
||||
|
||||
protected ChangePassword() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.UNDEFINED,
|
||||
EntityType.USER,
|
||||
new TypeReference<UserInfo>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.PUT,
|
||||
MediaType.APPLICATION_JSON_UTF8,
|
||||
API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT);
|
||||
|
|
|
@ -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<EntityProcessingReport> {
|
||||
|
||||
protected DeactivateUserAccount() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.ACTIVATION_DEACTIVATE,
|
||||
EntityType.USER,
|
||||
new TypeReference<EntityProcessingReport>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.USER_ACCOUNT_ENDPOINT + API.PATH_VAR_INACTIVE);
|
||||
|
|
|
@ -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<UserInfo> {
|
||||
|
||||
protected GetUserAccount() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_SINGLE,
|
||||
EntityType.USER,
|
||||
new TypeReference<UserInfo>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.USER_ACCOUNT_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT);
|
||||
|
|
|
@ -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<Page<UserInfo>> {
|
||||
|
||||
protected GetUserAccounts() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_PAGE,
|
||||
EntityType.USER,
|
||||
new TypeReference<Page<UserInfo>>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.USER_ACCOUNT_ENDPOINT);
|
||||
|
|
|
@ -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<UserInfo> {
|
||||
|
||||
protected NewUserAccount() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.NEW,
|
||||
EntityType.USER,
|
||||
new TypeReference<UserInfo>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.POST,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.USER_ACCOUNT_ENDPOINT);
|
||||
|
|
|
@ -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<UserInfo> {
|
||||
|
||||
protected SaveUserAccount() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.SAVE,
|
||||
EntityType.USER,
|
||||
new TypeReference<UserInfo>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.PUT,
|
||||
MediaType.APPLICATION_JSON_UTF8,
|
||||
API.USER_ACCOUNT_ENDPOINT);
|
||||
|
|
|
@ -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<Institution> {
|
||||
|
||||
public GetInstitution() {
|
||||
super(
|
||||
super(new TypeKey<>(
|
||||
CallType.GET_SINGLE,
|
||||
EntityType.INSTITUTION,
|
||||
new TypeReference<Institution>() {
|
||||
},
|
||||
}),
|
||||
HttpMethod.GET,
|
||||
MediaType.APPLICATION_FORM_URLENCODED,
|
||||
API.INSTITUTION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT);
|
||||
|
|
Loading…
Reference in a new issue