Alon Bar-Lev has uploaded a new change for review.

Change subject: utils: pki-resource: cleanup: levarage enum methods for content 
type
......................................................................

utils: pki-resource: cleanup: levarage enum methods for content type

Change-Id: I24da0ff174599ffdeabbf5846eab429bf0d6510d
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/PKIResources.java
1 file changed, 19 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/21073/1

diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/PKIResources.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/PKIResources.java
index 6ed98d0..e6152f7 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/PKIResources.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/PKIResources.java
@@ -25,9 +25,17 @@
     }
 
     public static enum OutputType {
-        X509_PEM_CA,
-        X509_PEM,
-        OPENSSH_PUBKEY
+        X509_PEM_CA("application/x-x509-ca-cert"),
+        X509_PEM("application/x-x509-cert"),
+        OPENSSH_PUBKEY("text/plain");
+
+        String contentType;
+        OutputType(String contentType) {
+            this.contentType = contentType;
+        }
+        public String getContentType() {
+            return contentType;
+        }
     }
 
     private class Details {
@@ -122,24 +130,16 @@
     public String getContentType(Resource resource, OutputType outputType) {
         String ret;
 
-        Details details = resources.get(resource);
-        if (details == null) {
-            throw new IllegalArgumentException("Invalid resource");
+        if (outputType != null) {
+            ret = outputType.getContentType();
         }
+        else {
+            Details details = resources.get(resource);
+            if (details == null) {
+                throw new IllegalArgumentException("Invalid resource");
+            }
 
-        switch (outputType != null ? outputType : details.outputType) {
-            default:
-                throw new RuntimeException("Invalid output type");
-
-            case X509_PEM:
-                ret = "application/x-x509-cert";
-            break;
-            case X509_PEM_CA:
-                ret = "application/x-x509-ca-cert";
-            break;
-            case OPENSSH_PUBKEY:
-                ret = "text/plain";
-            break;
+            ret = details.outputType.getContentType();
         }
 
         return ret;


-- 
To view, visit http://gerrit.ovirt.org/21073
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24da0ff174599ffdeabbf5846eab429bf0d6510d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to