[Pki-devel] [PATCH] 0065 Profile service: respond 409 on conflicting operations
Fraser Tweedale
ftweedal at redhat.com
Thu Jan 7 05:22:26 UTC 2016
Please review attached patch which fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1257518
Cheers,
Fraser
-------------- next part --------------
From 7f130751766da5b7f5ee1dca634020b17e09ca53 Mon Sep 17 00:00:00 2001
From: Fraser Tweedale <ftweedal at redhat.com>
Date: Thu, 7 Jan 2016 16:11:01 +1100
Subject: [PATCH] Profile service: respond 409 on conflicting operations
The REST profile service current responds 400 on conflicting
operations, indicating that the client sent a bad request when this
not the case. Respond with 409 Conflict instead.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1257518
---
.../src/org/dogtagpki/server/ca/rest/ProfileService.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
index 488dd5ab960fd45fa3dad0dd83398b4317f2cb4f..2bc7904a7d803c5df61daf5bd7478063f0b48838 100644
--- a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
@@ -46,6 +46,7 @@ import org.jboss.resteasy.plugins.providers.atom.Link;
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.base.BadRequestException;
+import com.netscape.certsrv.base.ConflictingOperationException;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.IConfigStore;
import com.netscape.certsrv.base.PKIException;
@@ -415,7 +416,7 @@ public class ProfileService extends PKIService implements ProfileResource {
switch (action) {
case "enable":
if (ps.isProfileEnable(profileId)) {
- throw new BadRequestException("Profile already enabled");
+ throw new ConflictingOperationException("Profile already enabled");
}
try {
ps.enableProfile(profileId, principal.getName());
@@ -429,7 +430,7 @@ public class ProfileService extends PKIService implements ProfileResource {
break;
case "disable":
if (!ps.isProfileEnable(profileId)) {
- throw new BadRequestException("Profile already disabled");
+ throw new ConflictingOperationException("Profile already disabled");
}
String userid = principal.getName();
try {
@@ -479,7 +480,7 @@ public class ProfileService extends PKIService implements ProfileResource {
try {
profile = ps.getProfile(profileId);
if (profile != null) {
- throw new BadRequestException("Profile already exists");
+ throw new ConflictingOperationException("Profile already exists");
}
auditParams.put("class_id", data.getClassId());
@@ -578,7 +579,7 @@ public class ProfileService extends PKIService implements ProfileResource {
IProfile profile = ps.getProfile(profileId);
if (profile != null) {
- throw new BadRequestException("Profile already exists");
+ throw new ConflictingOperationException("Profile already exists");
}
auditParams.put("class_id", classId);
@@ -686,7 +687,7 @@ public class ProfileService extends PKIService implements ProfileResource {
}
if (ps.isProfileEnable(profileId)) {
- throw new BadRequestException("Cannot change profile data. Profile must be disabled");
+ throw new ConflictingOperationException("Cannot change profile data. Profile must be disabled");
}
// First read the data into a Properties to process escaped
@@ -757,7 +758,7 @@ public class ProfileService extends PKIService implements ProfileResource {
throw new PKIException("Error changing profile data. Profile not available.");
}
if (ps.isProfileEnable(profileId)) {
- throw new BadRequestException("Cannot change profile data. Profile must be disabled");
+ throw new ConflictingOperationException("Cannot change profile data. Profile must be disabled");
}
Map<String, String> auditParams = new LinkedHashMap<String, String>();
@@ -1173,7 +1174,7 @@ public class ProfileService extends PKIService implements ProfileResource {
ILogger.FAILURE,
null);
- throw new BadRequestException("Cannot delete profile `" + profileId +
+ throw new ConflictingOperationException("Cannot delete profile `" + profileId +
"`. Profile must be disabled first.");
}
--
2.5.0
More information about the Pki-devel
mailing list