You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/09/06 11:54:49 UTC
[07/10] brooklyn-server git commit: Addressing PR comments
Addressing PR comments
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2903a55a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2903a55a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2903a55a
Branch: refs/heads/master
Commit: 2903a55ad3405993158ce66fcf0d81dbe379040f
Parents: a22d622
Author: Yavor Yanchev <ya...@yanchev.com>
Authored: Fri Sep 2 20:40:39 2016 +0300
Committer: Yavor Yanchev <ya...@yanchev.com>
Committed: Fri Sep 2 20:40:39 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/brooklyn/feed/http/HttpFeed.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2903a55a/core/src/main/java/org/apache/brooklyn/feed/http/HttpFeed.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/feed/http/HttpFeed.java b/core/src/main/java/org/apache/brooklyn/feed/http/HttpFeed.java
index b0d4383..8480b4c 100644
--- a/core/src/main/java/org/apache/brooklyn/feed/http/HttpFeed.java
+++ b/core/src/main/java/org/apache/brooklyn/feed/http/HttpFeed.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.MachineLocation;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.entity.Entities;
@@ -301,7 +302,7 @@ public class HttpFeed extends AbstractFeed {
} else {
HttpExecutorFactory httpExecutorFactory = null;
Collection<? extends Location> locations = Locations.getLocationsCheckingAncestors(builder.entity.getLocations(), builder.entity);
- Maybe<Location> location = Machines.findUniqueElement(locations, Location.class);
+ Maybe<MachineLocation> location = Machines.findUniqueElement(locations, MachineLocation.class);
if (location.isPresent() && location.get().hasExtension(HttpExecutorFactory.class)) {
httpExecutorFactory = location.get().getExtension(HttpExecutorFactory.class);
Map<String, Object> httpExecutorProps = location.get().getAllConfig(true);
@@ -402,7 +403,15 @@ public class HttpFeed extends AbstractFeed {
@SuppressWarnings("unchecked")
private HttpToolResponse createHttpToolRespose(HttpResponse response) throws IOException {
int responseCode = response.code();
- if (responseCode == 400) { // Unprocessable Entity - https://stackoverflow.com/questions/6123425/rest-response-code-for-invalid-data
+
+ /* From https://tools.ietf.org/html/rfc4918#section-11.2
+ The 422 (Unprocessable Entity) status code means the server
+ understands the content type of the request entity (hence a
+ 415(Unsupported Media Type) status code is inappropriate), and the
+ syntax of the request entity is correct (thus a 400 (Bad Request)
+ status code is inappropriate) but was unable to process the contained
+ instructions. */
+ if (responseCode == 422) {
throw new IOException(" Unprocessable Entity: " + response.reasonPhrase());
}
Map<String,? extends List<String>> headers = (Map<String, List<String>>) (Map<?, ?>) response.headers().asMap();