You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2013/02/02 00:27:32 UTC

[1/50] [abbrv] git commit: refs/heads/master - forget to check in code

forget to check in code


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/cb25eed3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/cb25eed3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/cb25eed3

Branch: refs/heads/master
Commit: cb25eed37ac97fc83b7ab799ebebc701db1d68f1
Parents: df5c4c3
Author: Edison Su <ed...@citrix.com>
Authored: Fri Jan 25 00:24:08 2013 -0800
Committer: Edison Su <ed...@citrix.com>
Committed: Fri Jan 25 00:25:14 2013 -0800

----------------------------------------------------------------------
 .../utils/storage/encoding/DecodedDataObject.java  |   58 ++++++++++++
 .../com/cloud/utils/storage/encoding/Decoder.java  |   68 ++++++++++++++
 .../utils/storage/encoding/EncodedDataStore.java   |   73 +++++++++++++++
 .../cloud/utils/storage/encoding/EncodingType.java |   31 ++++++
 4 files changed, 230 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cb25eed3/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
new file mode 100644
index 0000000..a046459
--- /dev/null
+++ b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
@@ -0,0 +1,58 @@
+/*
+ * 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 com.cloud.utils.storage.encoding;
+
+public class DecodedDataObject {
+    private String objType;
+    private Long size;
+    private String name;
+    private String path;
+    private EncodedDataStore store;
+    
+    public DecodedDataObject(String objType,
+            Long size,
+            String name,
+            String path,
+            EncodedDataStore store) {
+        this.objType = objType;
+        this.size = size;
+        this.path = path;
+        this.store = store;
+    }
+    
+    public String getObjType() {
+        return this.objType;
+    }
+    
+    public Long getSize() {
+        return this.size;
+    }
+    
+    public String getName() {
+        return this.name;
+    }
+    
+    public String getPath() {
+        return this.path;
+    }
+    
+    public EncodedDataStore getStore() {
+        return this.store;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cb25eed3/utils/src/com/cloud/utils/storage/encoding/Decoder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/Decoder.java b/utils/src/com/cloud/utils/storage/encoding/Decoder.java
new file mode 100644
index 0000000..1c89d4b
--- /dev/null
+++ b/utils/src/com/cloud/utils/storage/encoding/Decoder.java
@@ -0,0 +1,68 @@
+/*
+ * 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 com.cloud.utils.storage.encoding;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+public class Decoder {
+    private static Map<String, String> getParameters(URI uri) {
+        String parameters = uri.getQuery();
+        Map<String, String> params = new HashMap<String, String>();
+        List<String> paraLists = Arrays.asList(parameters.split("&"));
+        for (String para : paraLists) {
+            String[] pair = para.split("=");
+            if (!pair[1].equalsIgnoreCase("null")) {
+                params.put(pair[0], pair[1]);
+            }
+            
+        }
+        return params;
+    }
+    public static DecodedDataObject decode(String url) throws URISyntaxException {
+        URI uri = new URI(url);
+        Map<String, String> params = getParameters(uri);
+        EncodedDataStore store = new EncodedDataStore(params.get(EncodingType.ROLE.toString()),
+                params.get(EncodingType.STOREUUID.toString()),
+                params.get(EncodingType.PROVIDERNAME.toString()),
+                uri.getScheme(),
+                uri.getScheme() + uri.getHost() + uri.getPath(),
+                uri.getHost(),
+                uri.getPath());
+        
+        Long size = null;
+        try {
+            size = Long.parseLong(params.get(EncodingType.SIZE.toString()));
+        } catch (NumberFormatException e) {
+            
+        }
+        DecodedDataObject obj = new DecodedDataObject(params.get(EncodingType.OBJTYPE.toString()),
+                size,
+                params.get(EncodingType.NAME.toString()),
+                params.get(EncodingType.PATH.toString()),
+                store
+                );
+        return obj;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cb25eed3/utils/src/com/cloud/utils/storage/encoding/EncodedDataStore.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/EncodedDataStore.java b/utils/src/com/cloud/utils/storage/encoding/EncodedDataStore.java
new file mode 100644
index 0000000..30668d8
--- /dev/null
+++ b/utils/src/com/cloud/utils/storage/encoding/EncodedDataStore.java
@@ -0,0 +1,73 @@
+/*
+ * 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 com.cloud.utils.storage.encoding;
+
+public class EncodedDataStore {
+    private final String role;
+    private final String uuid;
+    private final String providerName;
+    private final String scheme;
+    private final String url;
+    private final String server;
+    private final String path;
+    
+    public EncodedDataStore(String role,
+            String uuid,
+            String providerName,
+            String scheme,
+            String url,
+            String server,
+            String path) {
+        this.role = role;
+        this.uuid = uuid;
+        this.providerName = providerName;
+        this.scheme = scheme;
+        this.url = url;
+        this.server = server;
+        this.path = path;
+    }
+    
+    public String getRole() {
+        return this.role;
+    }
+    
+    public String getUuid() {
+        return this.uuid;
+    }
+    
+    public String getProviderName() {
+        return this.providerName;
+    }
+    
+    public String getScheme() {
+        return this.scheme;
+    }
+    
+    public String getUrl() {
+        return this.url;
+    }
+    
+    public String getServer() {
+        return this.server;
+    }
+    
+    public String getPath() {
+        return this.path;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cb25eed3/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/EncodingType.java b/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
new file mode 100644
index 0000000..5b99bc1
--- /dev/null
+++ b/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
@@ -0,0 +1,31 @@
+/*
+ * 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 com.cloud.utils.storage.encoding;
+
+public enum EncodingType {
+    //object
+    OBJTYPE,
+    SIZE,
+    NAME,
+    PATH,
+    //dataStore
+    ROLE,
+    STOREUUID,
+    PROVIDERNAME
+}