You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2017/07/10 13:11:50 UTC
[1/4] brooklyn-server git commit: Fix REST API response of methods
with String return type
Repository: brooklyn-server
Updated Branches:
refs/heads/master 463910fdf -> 9caf201d1
Fix REST API response of methods with String return type
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/299c2ab8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/299c2ab8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/299c2ab8
Branch: refs/heads/master
Commit: 299c2ab8f36439212cbd09cf58f67a4d74f13df9
Parents: 3d8675e
Author: Ivana Yovcheva <iv...@gmail.com>
Authored: Tue Jul 4 17:41:48 2017 +0300
Committer: Ivana Yovcheva <iv...@gmail.com>
Committed: Tue Jul 4 18:02:45 2017 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java | 1 +
.../org/apache/brooklyn/rest/resources/PolicyConfigResource.java | 2 +-
.../java/org/apache/brooklyn/rest/resources/ServerResource.java | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/299c2ab8/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java
----------------------------------------------------------------------
diff --git a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java
index 45cd25c..8a2261d 100644
--- a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java
+++ b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java
@@ -75,6 +75,7 @@ public interface ActivityApi {
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Could not find task or stream")
})
+ @Produces(MediaType.TEXT_PLAIN)
public String stream(
@ApiParam(value = "Task ID", required = true) @PathParam("task") String taskId,
@ApiParam(value = "Stream ID", required = true) @PathParam("streamId") String streamId);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/299c2ab8/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
index 6dcdf19..2f6e60d 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
@@ -77,7 +77,7 @@ public class PolicyConfigResource extends AbstractBrooklynRestResource implement
ConfigKey<?> ck = policy.getPolicyType().getConfigKey(configKeyName);
if (ck == null) throw WebResourceUtils.notFound("Cannot find config key '%s' in policy '%s' of entity '%s'", configKeyName, policy, entityToken);
- return getStringValueForDisplay(brooklyn(), policy, policy.getConfig(ck));
+ return (String) WebResourceUtils.getValueForDisplay(mapper(), getStringValueForDisplay(brooklyn(), policy, policy.getConfig(ck)), true, true);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/299c2ab8/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
index 2a6dcbd..20a371a 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
@@ -383,7 +383,7 @@ public class ServerResource extends AbstractBrooklynRestResource implements Serv
throw WebResourceUtils.forbidden("User '%s' is not authorized for this operation", Entitlements.getEntitlementContext().user());
}
ConfigKey<String> config = ConfigKeys.newStringConfigKey(configKey);
- return mgmt().getConfig().getConfig(config);
+ return (String) WebResourceUtils.getValueForDisplay(mapper(), mgmt().getConfig().getConfig(config), true, true);
}
@Override
@@ -446,7 +446,7 @@ public class ServerResource extends AbstractBrooklynRestResource implements Serv
request.getSession();
EntitlementContext entitlementContext = Entitlements.getEntitlementContext();
if (entitlementContext!=null && entitlementContext.user()!=null){
- return entitlementContext.user();
+ return (String) WebResourceUtils.getValueForDisplay(mapper(), entitlementContext.user(), true, true);
} else {
return null; //User can be null if no authentication was requested
}
[2/4] brooklyn-server git commit: Fix
PolicyResourceTest.testGetDefaultValue and ServerResourceTest.testGetConfig
tests to work with the rest api fix
Posted by ge...@apache.org.
Fix PolicyResourceTest.testGetDefaultValue and ServerResourceTest.testGetConfig tests to work with the rest api fix
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/cfb08749
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/cfb08749
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/cfb08749
Branch: refs/heads/master
Commit: cfb0874948b984423b377cac3511747156411d1a
Parents: 299c2ab
Author: Ivana Yovcheva <iv...@gmail.com>
Authored: Tue Jul 4 18:27:02 2017 +0300
Committer: Ivana Yovcheva <iv...@gmail.com>
Committed: Tue Jul 4 18:27:02 2017 +0300
----------------------------------------------------------------------
.../org/apache/brooklyn/rest/resources/PolicyResourceTest.java | 3 ++-
.../org/apache/brooklyn/rest/resources/ServerResourceTest.java | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cfb08749/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
index 3498e00..534173b 100644
--- a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
+++ b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
@@ -28,6 +28,7 @@ import java.util.Set;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.brooklyn.rest.util.WebResourceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
@@ -109,7 +110,7 @@ public class PolicyResourceTest extends BrooklynRestResourceTest {
@Test
public void testGetDefaultValue() throws Exception {
String configName = RestMockSimplePolicy.SAMPLE_CONFIG.getName();
- String expectedVal = RestMockSimplePolicy.SAMPLE_CONFIG.getDefaultValue();
+ String expectedVal = (String) WebResourceUtils.getValueForDisplay(mapper(), RestMockSimplePolicy.SAMPLE_CONFIG.getDefaultValue(), true, true);
String configVal = client().path(ENDPOINT + policyId + "/config/" + configName)
.get(String.class);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/cfb08749/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ServerResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ServerResourceTest.java b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ServerResourceTest.java
index f97b87b..e423951 100644
--- a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ServerResourceTest.java
+++ b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ServerResourceTest.java
@@ -99,7 +99,7 @@ public class ServerResourceTest extends BrooklynRestResourceTest {
void testGetConfig() throws Exception {
((ManagementContextInternal)getManagementContext()).getBrooklynProperties().put("foo.bar.baz", "quux");
try {
- assertEquals(client().path("/server/config/foo.bar.baz").get(String.class), "quux");
+ assertEquals(client().path("/server/config/foo.bar.baz").get(String.class), "\"quux\"");
} finally {
((ManagementContextInternal)getManagementContext()).getBrooklynProperties().remove("foo.bar.baz");
}
[3/4] brooklyn-server git commit: Fix
PolicyResourceTest.testGetConfigValue
Posted by ge...@apache.org.
Fix PolicyResourceTest.testGetConfigValue
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/829e495b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/829e495b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/829e495b
Branch: refs/heads/master
Commit: 829e495bbfeba6bb50a8e5d4ee9214324e6713fd
Parents: cfb0874
Author: Ivana Yovcheva <iv...@gmail.com>
Authored: Wed Jul 5 10:40:32 2017 +0300
Committer: Ivana Yovcheva <iv...@gmail.com>
Committed: Wed Jul 5 10:40:32 2017 +0300
----------------------------------------------------------------------
.../org/apache/brooklyn/rest/resources/PolicyConfigResource.java | 2 +-
.../org/apache/brooklyn/rest/resources/PolicyResourceTest.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829e495b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
index 2f6e60d..b362223 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
@@ -66,7 +66,7 @@ public class PolicyConfigResource extends AbstractBrooklynRestResource implement
((BrooklynObjectInternal)policy).config().getInternalConfigMap().getAllConfigInheritedRawValuesIgnoringErrors() ).getAllConfig();
Map<String, Object> result = Maps.newLinkedHashMap();
for (Map.Entry<String, Object> ek : source.entrySet()) {
- result.put(ek.getKey(), getStringValueForDisplay(brooklyn(), policy, ek.getValue()));
+ result.put(ek.getKey(), WebResourceUtils.getValueForDisplay(mapper(), getStringValueForDisplay(brooklyn(), policy, ek.getValue()), true, true));
}
return result;
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/829e495b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
index 534173b..61f60c5 100644
--- a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
+++ b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/PolicyResourceTest.java
@@ -130,7 +130,7 @@ public class PolicyResourceTest extends BrooklynRestResourceTest {
@Test(dependsOnMethods = "testReconfigureConfig")
public void testGetConfigValue() throws Exception {
String configName = RestMockSimplePolicy.SAMPLE_CONFIG.getName();
- String expectedVal = "newval";
+ String expectedVal = (String) WebResourceUtils.getValueForDisplay(mapper(), "newval", true, true);
Map<String, Object> allState = client().path(ENDPOINT + policyId + "/config/current-state")
.get(new GenericType<Map<String, Object>>() {});
[4/4] brooklyn-server git commit: Closes #754
Posted by ge...@apache.org.
Closes #754
Fix REST API response of methods with String return type
Using the REST API from the GUI used to return `"error": "no response from server"` and return code 0 for methods that return String.
The problem was that the received response was not in json format, while the expected response content type is `application/json`.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/9caf201d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/9caf201d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/9caf201d
Branch: refs/heads/master
Commit: 9caf201d195b2992e39087e980e0934c300fcb7f
Parents: 463910f 829e495
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Mon Jul 10 14:11:36 2017 +0100
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Mon Jul 10 14:11:36 2017 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/brooklyn/rest/api/ActivityApi.java | 1 +
.../apache/brooklyn/rest/resources/PolicyConfigResource.java | 4 ++--
.../java/org/apache/brooklyn/rest/resources/ServerResource.java | 4 ++--
.../org/apache/brooklyn/rest/resources/PolicyResourceTest.java | 5 +++--
.../org/apache/brooklyn/rest/resources/ServerResourceTest.java | 2 +-
5 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------