You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/18 17:03:57 UTC

[48/64] [abbrv] incubator-brooklyn git commit: update leftover rest items

update leftover rest items


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

Branch: refs/heads/master
Commit: 207ffa89478eaf7f6c09821f22ca9eec961caeae
Parents: bec0b9c
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Aug 18 12:56:27 2015 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Aug 18 14:51:55 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/rest/client/BrooklynApi.java       |  3 +-
 .../util/http/BuiltResponsePreservingError.java | 78 ++++++++++++++++++++
 .../util/http/BuiltResponsePreservingError.java | 78 --------------------
 3 files changed, 80 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/207ffa89/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java b/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
index 416958f..4b3ef43 100644
--- a/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
+++ b/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/BrooklynApi.java
@@ -61,8 +61,9 @@ import org.apache.brooklyn.rest.api.SensorApi;
 import org.apache.brooklyn.rest.api.ServerApi;
 import org.apache.brooklyn.rest.api.UsageApi;
 import org.apache.brooklyn.rest.api.VersionApi;
+import org.apache.brooklyn.rest.client.util.http.BuiltResponsePreservingError;
+
 import brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.http.BuiltResponsePreservingError;
 
 import com.wordnik.swagger.core.ApiOperation;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/207ffa89/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java b/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
new file mode 100644
index 0000000..bfaee57
--- /dev/null
+++ b/usage/rest-client/src/main/java/org/apache/brooklyn/rest/client/util/http/BuiltResponsePreservingError.java
@@ -0,0 +1,78 @@
+/*
+ * 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.apache.brooklyn.rest.client.util.http;
+
+import java.lang.annotation.Annotation;
+
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.client.core.BaseClientResponse;
+import org.jboss.resteasy.core.Headers;
+import org.jboss.resteasy.specimpl.BuiltResponse;
+
+import brooklyn.util.exceptions.Exceptions;
+
+/** 
+ * Allows wrapping a {@link Response} with the stream fully read and closed so that the client can be re-used.
+ * <p>
+ * The entity may be stored as a string as type info is not available when it is deserialized, 
+ * and that's a relatively convenient common format.
+ *  
+ * TODO It would be nice to support other parsing, storing the byte array.
+ */
+public class BuiltResponsePreservingError extends BuiltResponse {
+
+    private Throwable error;
+
+    public BuiltResponsePreservingError(int status, Headers<Object> headers, Object entity, Annotation[] annotations, Throwable error) {
+        super(status, headers, entity, annotations);
+        this.error = error;
+    }
+    
+    @SuppressWarnings("deprecation")
+    public static <T> Response copyResponseAndClose(Response source, Class<T> type) {
+        int status = -1;
+        Headers<Object> headers = new Headers<Object>();
+        Object entity = null;
+        try {
+            status = source.getStatus();
+            if (source instanceof BaseClientResponse)
+                headers.putAll(((BaseClientResponse<?>)source).getMetadata());
+            if (source instanceof org.jboss.resteasy.client.ClientResponse) {
+                entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type);
+            } else {
+                entity = source.getEntity();
+            }
+            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], null);
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e);
+        } finally {
+            if (source instanceof BaseClientResponse)
+                ((BaseClientResponse<?>)source).close();
+        }
+    }
+    
+    @Override
+    public Object getEntity() {
+        if (error!=null) Exceptions.propagate(error);
+        return super.getEntity();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/207ffa89/usage/rest-client/src/main/java/org/apache/brooklyn/util/http/BuiltResponsePreservingError.java
----------------------------------------------------------------------
diff --git a/usage/rest-client/src/main/java/org/apache/brooklyn/util/http/BuiltResponsePreservingError.java b/usage/rest-client/src/main/java/org/apache/brooklyn/util/http/BuiltResponsePreservingError.java
deleted file mode 100644
index 32a5dfb..0000000
--- a/usage/rest-client/src/main/java/org/apache/brooklyn/util/http/BuiltResponsePreservingError.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.apache.brooklyn.util.http;
-
-import java.lang.annotation.Annotation;
-
-import javax.ws.rs.core.Response;
-
-import org.jboss.resteasy.client.core.BaseClientResponse;
-import org.jboss.resteasy.core.Headers;
-import org.jboss.resteasy.specimpl.BuiltResponse;
-
-import brooklyn.util.exceptions.Exceptions;
-
-/** 
- * Allows wrapping a {@link Response} with the stream fully read and closed so that the client can be re-used.
- * <p>
- * The entity may be stored as a string as type info is not available when it is deserialized, 
- * and that's a relatively convenient common format.
- *  
- * TODO It would be nice to support other parsing, storing the byte array.
- */
-public class BuiltResponsePreservingError extends BuiltResponse {
-
-    private Throwable error;
-
-    public BuiltResponsePreservingError(int status, Headers<Object> headers, Object entity, Annotation[] annotations, Throwable error) {
-        super(status, headers, entity, annotations);
-        this.error = error;
-    }
-    
-    @SuppressWarnings("deprecation")
-    public static <T> Response copyResponseAndClose(Response source, Class<T> type) {
-        int status = -1;
-        Headers<Object> headers = new Headers<Object>();
-        Object entity = null;
-        try {
-            status = source.getStatus();
-            if (source instanceof BaseClientResponse)
-                headers.putAll(((BaseClientResponse<?>)source).getMetadata());
-            if (source instanceof org.jboss.resteasy.client.ClientResponse) {
-                entity = ((org.jboss.resteasy.client.ClientResponse<?>)source).getEntity(type);
-            } else {
-                entity = source.getEntity();
-            }
-            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], null);
-        } catch (Exception e) {
-            Exceptions.propagateIfFatal(e);
-            return new BuiltResponsePreservingError(status, headers, entity, new Annotation[0], e);
-        } finally {
-            if (source instanceof BaseClientResponse)
-                ((BaseClientResponse<?>)source).close();
-        }
-    }
-    
-    @Override
-    public Object getEntity() {
-        if (error!=null) Exceptions.propagate(error);
-        return super.getEntity();
-    }
-
-}