diff options
author | Fraser Tweedale <ftweedal@redhat.com> | 2016-01-07 16:11:01 +1100 |
---|---|---|
committer | Fraser Tweedale <ftweedal@redhat.com> | 2016-02-15 14:04:54 +1000 |
commit | 27a38daf9840e4fd9bc031daf25024806d05e943 (patch) | |
tree | 9fc72942f948b5f27ee0f93e63da43eae00618b5 /base/ca/src/org/dogtagpki/server | |
parent | 709457876a6d5e4aea281a35350667492bc34df8 (diff) | |
download | pki-27a38daf9840e4fd9bc031daf25024806d05e943.tar.gz pki-27a38daf9840e4fd9bc031daf25024806d05e943.tar.xz pki-27a38daf9840e4fd9bc031daf25024806d05e943.zip |
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
Diffstat (limited to 'base/ca/src/org/dogtagpki/server')
-rw-r--r-- | base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java | 15 |
1 files 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 807c3f98b..08496f309 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()); @@ -430,7 +431,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 { @@ -482,7 +483,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()); @@ -581,7 +582,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); @@ -690,7 +691,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 @@ -761,7 +762,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>(); @@ -1177,7 +1178,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."); } |