You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/07/16 00:12:53 UTC

git commit: JCLOUDS-457: Add JobStatus enum

Repository: jclouds-labs-aws
Updated Branches:
  refs/heads/master 67e8c7211 -> 7165bf46d


JCLOUDS-457: Add JobStatus enum

Now the job status is stored as an enum instead of
a String. This is useful when comparing the status to
check if a job is completed, failed or still in progress.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/7165bf46
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/7165bf46
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/7165bf46

Branch: refs/heads/master
Commit: 7165bf46d0499607e07ba244baf1451c81da6291
Parents: 67e8c72
Author: Roman Coedo <ro...@gmail.com>
Authored: Tue Jul 15 23:08:35 2014 +0200
Committer: Andrew Gaul <ga...@apache.org>
Committed: Tue Jul 15 15:12:13 2014 -0700

----------------------------------------------------------------------
 .../org/jclouds/glacier/domain/JobMetadata.java |  6 ++--
 .../org/jclouds/glacier/domain/JobStatus.java   | 29 ++++++++++++++++++++
 2 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/7165bf46/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
----------------------------------------------------------------------
diff --git a/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java b/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
index 624690d..6dfc5eb 100644
--- a/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
+++ b/glacier/src/main/java/org/jclouds/glacier/domain/JobMetadata.java
@@ -55,7 +55,7 @@ public class JobMetadata {
    @SerializedName("SNSTopic")
    private final String snsTopic;
    @SerializedName("StatusCode")
-   private final String statusCode;
+   private final JobStatus statusCode;
    @SerializedName("StatusMessage")
    private final String statusMessage;
    @SerializedName("VaultARN")
@@ -86,7 +86,7 @@ public class JobMetadata {
       this.retrievalByteRange = retrievalByteRange == null ? null : ContentRange.fromString(retrievalByteRange);
       this.sha256TreeHash = sha256TreeHash;
       this.snsTopic = snsTopic;
-      this.statusCode = checkNotNull(statusCode, "statusCode");
+      this.statusCode = JobStatus.fromString(checkNotNull(statusCode, "statusCode"));
       this.statusMessage = checkNotNull(statusMessage, "statusMessage");
       this.vaultArn = checkNotNull(vaultArn, "vaultArn");
       this.parameters = parameters;
@@ -144,7 +144,7 @@ public class JobMetadata {
       return snsTopic;
    }
 
-   public String getStatusCode() {
+   public JobStatus getStatusCode() {
       return statusCode;
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/7165bf46/glacier/src/main/java/org/jclouds/glacier/domain/JobStatus.java
----------------------------------------------------------------------
diff --git a/glacier/src/main/java/org/jclouds/glacier/domain/JobStatus.java b/glacier/src/main/java/org/jclouds/glacier/domain/JobStatus.java
new file mode 100644
index 0000000..a932161
--- /dev/null
+++ b/glacier/src/main/java/org/jclouds/glacier/domain/JobStatus.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glacier.domain;
+
+import com.google.common.base.CaseFormat;
+
+public enum JobStatus {
+   SUCCEEDED,
+   FAILED,
+   IN_PROGRESS;
+
+   public static JobStatus fromString(String symbol) {
+      return JobStatus.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, symbol));
+   }
+}