mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
Migrate NotSupportedFeatureException
This commit is contained in:
@@ -33,17 +33,30 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @version 1.6
|
||||
*/
|
||||
public class NotSupportedFeatureException extends Exception {
|
||||
public class NotSupportedFeatureException extends ExceptionWithContext {
|
||||
|
||||
private static final long serialVersionUID = 256498734456613496L;
|
||||
|
||||
public NotSupportedFeatureException(String message)
|
||||
private static final String CODE = "9SR8G0kmU1";
|
||||
|
||||
public NotSupportedFeatureException(String feature)
|
||||
{
|
||||
super(message);
|
||||
super(Collections.emptyList(),createMessage(feature));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return CODE;
|
||||
}
|
||||
|
||||
private static String createMessage(String feature) {
|
||||
return "feature " + feature + " is not supported by this repository";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +170,7 @@ public abstract class AbstractRepositoryHandler<C extends RepositoryConfig>
|
||||
@Override
|
||||
public ImportHandler getImportHandler() throws NotSupportedFeatureException
|
||||
{
|
||||
throw new NotSupportedFeatureException(
|
||||
"import handler is not supported by this repository handler");
|
||||
throw new NotSupportedFeatureException("import");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package sonia.scm.api.v2;
|
||||
|
||||
import sonia.scm.NotSupportedFeatureException;
|
||||
import sonia.scm.api.rest.ContextualExceptionMapper;
|
||||
import sonia.scm.api.v2.resources.ExceptionWithContextToErrorDtoMapper;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
public class NotSupportedFeatureExceptionMapper extends ContextualExceptionMapper<NotSupportedFeatureException> {
|
||||
@Inject
|
||||
public NotSupportedFeatureExceptionMapper(ExceptionWithContextToErrorDtoMapper mapper) {
|
||||
super(NotSupportedFeatureException.class, Response.Status.BAD_REQUEST, mapper);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import sonia.scm.api.rest.AuthorizationExceptionMapper;
|
||||
import sonia.scm.api.rest.ConcurrentModificationExceptionMapper;
|
||||
import sonia.scm.api.rest.IllegalArgumentExceptionMapper;
|
||||
import sonia.scm.api.v2.NotFoundExceptionMapper;
|
||||
import sonia.scm.api.v2.NotSupportedFeatureExceptionMapper;
|
||||
|
||||
public class DispatcherMock {
|
||||
public static Dispatcher createDispatcher(Object resource) {
|
||||
@@ -21,6 +22,7 @@ public class DispatcherMock {
|
||||
dispatcher.getProviderFactory().register(new ChangePasswordNotAllowedExceptionMapper(mapper));
|
||||
dispatcher.getProviderFactory().register(new InvalidPasswordExceptionMapper(mapper));
|
||||
dispatcher.getProviderFactory().registerProvider(IllegalArgumentExceptionMapper.class);
|
||||
dispatcher.getProviderFactory().register(new NotSupportedFeatureExceptionMapper(mapper));
|
||||
return dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user