Merge pull request #1263 from panga/fix_response
Fix wrong response code
This commit is contained in:
commit
9a87b7f196
2 changed files with 9 additions and 11 deletions
|
@ -11,9 +11,7 @@ import javax.ws.rs.core.Response;
|
|||
public class ErrorResponse {
|
||||
|
||||
public static Response exists(String message) {
|
||||
ErrorRepresentation error = new ErrorRepresentation();
|
||||
error.setErrorMessage(message);
|
||||
return Response.status(Response.Status.CONFLICT).entity(error).type(MediaType.APPLICATION_JSON).build();
|
||||
return ErrorResponse.error(message, Response.Status.CONFLICT);
|
||||
}
|
||||
|
||||
public static Response error(String message, Response.Status status) {
|
||||
|
|
|
@ -202,11 +202,11 @@ public class RealmAdminResource {
|
|||
adminEvent.operation(OperationType.UPDATE).resourcePath(uriInfo.getPath()).representation(rep).success();
|
||||
return Response.noContent().build();
|
||||
} catch (PatternSyntaxException e) {
|
||||
return ErrorResponse.exists("Specified regex pattern(s) is invalid.");
|
||||
return ErrorResponse.error("Specified regex pattern(s) is invalid.", Response.Status.BAD_REQUEST);
|
||||
} catch (ModelDuplicateException e) {
|
||||
return ErrorResponse.exists("Realm " + rep.getRealm() + " already exists.");
|
||||
} catch (Exception e) {
|
||||
return ErrorResponse.exists("Failed to update " + rep.getRealm() + " Realm.");
|
||||
return ErrorResponse.error("Failed to update " + rep.getRealm() + " Realm.", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ public class RealmAdminResource {
|
|||
public GlobalRequestResult pushRevocation() {
|
||||
auth.requireManage();
|
||||
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo.getPath()).success();
|
||||
return new ResourceAdminManager(session).pushRealmRevocationPolicy(uriInfo.getRequestUri(), realm);
|
||||
return new ResourceAdminManager(session).pushRealmRevocationPolicy(uriInfo.getRequestUri(), realm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,8 +280,8 @@ public class RealmAdminResource {
|
|||
@POST
|
||||
public GlobalRequestResult logoutAll() {
|
||||
session.sessions().removeUserSessions(realm);
|
||||
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo.getPath()).success();
|
||||
return new ResourceAdminManager(session).logoutAll(uriInfo.getRequestUri(), realm);
|
||||
adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo.getPath()).success();
|
||||
return new ResourceAdminManager(session).logoutAll(uriInfo.getRequestUri(), realm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,10 +294,10 @@ public class RealmAdminResource {
|
|||
@DELETE
|
||||
public void deleteSession(@PathParam("session") String sessionId) {
|
||||
UserSessionModel userSession = session.sessions().getUserSession(realm, sessionId);
|
||||
if (userSession == null) throw new NotFoundException("Sesssion not found");
|
||||
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, connection, headers, true);
|
||||
if (userSession == null) throw new NotFoundException("Sesssion not found");
|
||||
AuthenticationManager.backchannelLogout(session, realm, userSession, uriInfo, connection, headers, true);
|
||||
adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo.getPath()).success();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue