mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +01:00
Merged in bugfix/ci_status_validation (pull request #298)
Bugfix/ci status validation
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
package sonia.scm;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class IllegalIdentifierChangeException extends BadRequestException {
|
||||||
|
|
||||||
|
private static final String CODE = "thbsUFokjk";
|
||||||
|
|
||||||
|
public IllegalIdentifierChangeException(ContextEntry.ContextBuilder context, String message) {
|
||||||
|
super(context.build(), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalIdentifierChangeException(String message) {
|
||||||
|
super(Collections.emptyList(), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCode() {
|
||||||
|
return CODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package sonia.scm.api.v2.resources;
|
|||||||
|
|
||||||
import de.otto.edison.hal.HalRepresentation;
|
import de.otto.edison.hal.HalRepresentation;
|
||||||
import sonia.scm.ConcurrentModificationException;
|
import sonia.scm.ConcurrentModificationException;
|
||||||
|
import sonia.scm.IllegalIdentifierChangeException;
|
||||||
import sonia.scm.Manager;
|
import sonia.scm.Manager;
|
||||||
import sonia.scm.ModelObject;
|
import sonia.scm.ModelObject;
|
||||||
import sonia.scm.NotFoundException;
|
import sonia.scm.NotFoundException;
|
||||||
@@ -11,8 +12,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter from resource http endpoints to managers, for Single resources (e.g. {@code /user/name}).
|
* Adapter from resource http endpoints to managers, for Single resources (e.g. {@code /user/name}).
|
||||||
*
|
*
|
||||||
@@ -55,7 +54,7 @@ class SingleResourceManagerAdapter<MODEL_OBJECT extends ModelObject,
|
|||||||
MODEL_OBJECT existingModelObject = reader.get();
|
MODEL_OBJECT existingModelObject = reader.get();
|
||||||
MODEL_OBJECT changedModelObject = applyChanges.apply(existingModelObject);
|
MODEL_OBJECT changedModelObject = applyChanges.apply(existingModelObject);
|
||||||
if (!hasSameKey.test(changedModelObject)) {
|
if (!hasSameKey.test(changedModelObject)) {
|
||||||
return Response.status(BAD_REQUEST).entity("illegal change of id").build();
|
throw new IllegalIdentifierChangeException("illegal change of id");
|
||||||
}
|
}
|
||||||
else if (modelObjectWasModifiedConcurrently(existingModelObject, changedModelObject)) {
|
else if (modelObjectWasModifiedConcurrently(existingModelObject, changedModelObject)) {
|
||||||
throw new ConcurrentModificationException(type, keyExtractor.apply(existingModelObject));
|
throw new ConcurrentModificationException(type, keyExtractor.apply(existingModelObject));
|
||||||
|
|||||||
Reference in New Issue
Block a user