[1/2] brooklyn-server git commit: Fix external-config for jclouds credentials

2016-02-18 Thread aledsage
Repository: brooklyn-server
Updated Branches:
  refs/heads/master fa19e8f5f -> 8da814a9f


Fix external-config for jclouds credentials

- Adds ResolvingConfigBag, which resolves deferred-supplier on get()
- Use that in jcloudsLocation.getComputeService(ConfigBag)

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/291eb7d2
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/291eb7d2
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/291eb7d2

Branch: refs/heads/master
Commit: 291eb7d2c08fe40b6acd6895a3c126b4455005c0
Parents: a5103bb
Author: Aled Sage 
Authored: Wed Feb 17 14:57:57 2016 +
Committer: Aled Sage 
Committed: Wed Feb 17 14:57:57 2016 +

--
 .../util/core/config/ResolvingConfigBag.java| 122 +++
 .../location/jclouds/JcloudsLocation.java   |  10 +-
 2 files changed, 128 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/291eb7d2/core/src/main/java/org/apache/brooklyn/util/core/config/ResolvingConfigBag.java
--
diff --git 
a/core/src/main/java/org/apache/brooklyn/util/core/config/ResolvingConfigBag.java
 
b/core/src/main/java/org/apache/brooklyn/util/core/config/ResolvingConfigBag.java
new file mode 100644
index 000..5c6c3ad
--- /dev/null
+++ 
b/core/src/main/java/org/apache/brooklyn/util/core/config/ResolvingConfigBag.java
@@ -0,0 +1,122 @@
+/*
+ * 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.core.config;
+
+import java.util.Map;
+
+import org.apache.brooklyn.api.mgmt.ExecutionContext;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.util.core.task.DeferredSupplier;
+import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.guava.Maybe;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+
+/**
+ * As for {@link ConfigBag}, but resolves values that are of type {@link 
DeferredSupplier}.
+ */
+@Beta
+public class ResolvingConfigBag extends ConfigBag {
+
+// Relies on various getters all delegating to a few common methods.
+
+private final ManagementContext mgmt;
+protected final ConfigBag parentBag;
+
+protected transient volatile Function transformer;
+
+
+@Beta
+public static ConfigBag newInstanceExtending(ManagementContext mgmt, 
ConfigBag parentBag) {
+return new ResolvingConfigBag(mgmt, parentBag);
+}
+
+public ResolvingConfigBag(ManagementContext mgmt, ConfigBag parentBag) {
+this.mgmt = mgmt;
+this.parentBag = parentBag;
+copy(parentBag);
+}
+
+protected Function getTransformer() {
+if (transformer == null) {
+transformer = new Function() {
+@Override public Object apply(Object input) {
+if (input instanceof DeferredSupplier) {
+try {
+ExecutionContext exec = 
mgmt.getServerExecutionContext();
+return Tasks.resolveValue(input, Object.class, 
exec);
+} catch (Exception e) {
+throw Exceptions.propagate(e);
+}
+}
+return input;
+}
+};
+}
+return transformer;
+}
+@Override
+public void markUsed(String key) {
+super.markUsed(key);
+if (parentBag!=null)
+parentBag.markUsed(key);
+}
+
+@Override
+public Map getAllConfig() {
+// Lazily transform copy of map
+return Maps.transformValues(super.getAllConfig(), getTransformer());
+}
+
+@Override
+public Map, ?> getAllConfigAsConfigKeyMap() {
+// Lazily transform copy of map
+ 

[2/2] brooklyn-server git commit: This closes #29

2016-02-18 Thread aledsage
This closes #29


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8da814a9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8da814a9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8da814a9

Branch: refs/heads/master
Commit: 8da814a9f8c1c6e7849476ff4c0a3513c1b3c9ce
Parents: fa19e8f 291eb7d
Author: Aled Sage 
Authored: Thu Feb 18 17:28:48 2016 +
Committer: Aled Sage 
Committed: Thu Feb 18 17:28:48 2016 +

--
 .../util/core/config/ResolvingConfigBag.java| 122 +++
 .../location/jclouds/JcloudsLocation.java   |  10 +-
 2 files changed, 128 insertions(+), 4 deletions(-)
--




[14/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ErrorAndToStringUnknownTypeSerializer.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ErrorAndToStringUnknownTypeSerializer.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ErrorAndToStringUnknownTypeSerializer.java
new file mode 100644
index 000..e529ec9
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ErrorAndToStringUnknownTypeSerializer.java
@@ -0,0 +1,123 @@
+/*
+ * 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.util.json;
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import org.apache.brooklyn.util.collections.MutableSet;
+import org.apache.brooklyn.util.javalang.Reflections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonStreamContext;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.impl.UnknownSerializer;
+
+/**
+ * for non-json-serializable classes (quite a lot of them!) simply provide a 
sensible error message and a toString.
+ * TODO maybe we want to attempt to serialize fields instead?  (but being 
careful not to be self-referential!)
+ */
+public class ErrorAndToStringUnknownTypeSerializer extends UnknownSerializer {
+
+private static final Logger log = 
LoggerFactory.getLogger(ErrorAndToStringUnknownTypeSerializer.class);
+private static Set WARNED_CLASSES = 
Collections.synchronizedSet(MutableSet.of());
+
+@Override
+public void serialize(Object value, JsonGenerator jgen, SerializerProvider 
provider) throws IOException {
+if (BidiSerialization.isStrictSerialization())
+throw new JsonMappingException("Cannot serialize object containing 
"+value.getClass().getName()+" when strict serialization requested");
+
+serializeFromError(jgen.getOutputContext(), null, value, jgen, 
provider);
+}
+
+public void serializeFromError(JsonStreamContext ctxt, @Nullable Exception 
error, Object value, JsonGenerator jgen, SerializerProvider 
configurableSerializerProvider) throws IOException {
+if (log.isDebugEnabled())
+log.debug("Recovering from json serialization error, serializing 
"+value+": "+error);
+
+if (BidiSerialization.isStrictSerialization())
+throw new JsonMappingException("Cannot serialize "
++ (ctxt!=null && !ctxt.inRoot() ? "object containing " : "")
++ value.getClass().getName()+" when strict serialization 
requested");
+
+if (WARNED_CLASSES.add(value.getClass().getCanonicalName())) {
+log.warn("Standard serialization not possible for 
"+value.getClass()+" ("+value+")", error);
+}
+JsonStreamContext newCtxt = jgen.getOutputContext();
+
+// very odd, but flush seems necessary when working with large 
objects; presumably a buffer which is allowed to clear itself?
+// without this, when serializing the large (1.5M) Server json object 
from BrooklynJacksonSerializerTest creates invalid json,
+// containing:  "foo":false,"{"error":true,...
+jgen.flush();
+
+boolean createObject = !newCtxt.inObject() || 
newCtxt.getCurrentName()!=null;
+if (createObject) {
+jgen.writeStartObject();
+}
+
+if (allowEmpty(value.getClass())) {
+// write nothing
+} else {
+
+jgen.writeFieldName("error");
+jgen.writeBoolean(true);
+
+jgen.writeFieldName("errorType");
+
jgen.writeString(NotSerializableException.class.getCanonicalName());
+
+jgen.writeFieldName("type");
+jgen.writeString(value.getC

[31/34] brooklyn-server git commit: move common ha filter code to shared class

2016-02-18 Thread heneveld
move common ha filter code to shared class

and ensure classes not in scope aren't referenced


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/3ab00406
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/3ab00406
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/3ab00406

Branch: refs/heads/master
Commit: 3ab00406bc484ec4d8c667d1a068977a25e2aba6
Parents: 7f047ba
Author: Alex Heneveld 
Authored: Thu Feb 18 12:15:08 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 13:28:54 2016 +

--
 .../rest/filter/HaHotCheckHelperAbstract.java   | 82 
 .../rest/filter/HaHotCheckResourceFilter.java   | 72 +
 .../rest/resources/CatalogResourceTest.java |  2 +
 .../rest/filter/HaMasterCheckFilter.java| 35 -
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |  4 -
 5 files changed, 118 insertions(+), 77 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/3ab00406/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckHelperAbstract.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckHelperAbstract.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckHelperAbstract.java
new file mode 100644
index 000..7f183a6
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckHelperAbstract.java
@@ -0,0 +1,82 @@
+/*
+ * 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.filter;
+
+import java.util.Set;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
+import org.apache.brooklyn.rest.domain.ApiError;
+import org.apache.brooklyn.util.guava.Maybe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableSet;
+
+@Beta
+public abstract class HaHotCheckHelperAbstract {
+
+private static final Logger log = 
LoggerFactory.getLogger(HaHotCheckHelperAbstract.class);
+
+public static final String SKIP_CHECK_HEADER = 
"Brooklyn-Allow-Non-Master-Access";
+
+private static final Set HOT_STATES = ImmutableSet.of(
+ManagementNodeState.MASTER, ManagementNodeState.HOT_STANDBY, 
ManagementNodeState.HOT_BACKUP);
+
+/** Returns a string describing the problem if mgmt is null or not 
running; returns absent if no problems */
+public static Maybe 
getProblemMessageIfServerNotRunning(ManagementContext mgmt) {
+if (mgmt==null) return Maybe.of("no management context available");
+if (!mgmt.isRunning()) return Maybe.of("server no longer running");
+if (!mgmt.isStartupComplete()) return Maybe.of("server not in required 
startup-completed state");
+return Maybe.absent();
+}
+
+public Maybe getProblemMessageIfServerNotRunning() {
+return getProblemMessageIfServerNotRunning(mgmt());
+}
+
+public Response disallowResponse(String problem, Object info) {
+log.warn("Disallowing web request as "+problem+": "+info+" (caller 
should set '"+HaHotCheckHelperAbstract.SKIP_CHECK_HEADER+"' to force)");
+return ApiError.builder()
+.message("This request is only permitted against an active master 
Brooklyn server")
+.errorCode(Response.Status.FORBIDDEN).build().asJsonResponse();
+}
+
+public boolean isSkipCheckHeaderSet(String headerValueString) {
+return "true".equalsIgnoreCase(headerValueString);
+}
+
+public boolean isHaHotStatus() {
+ManagementNodeState state = 
mgmt().getHighAvailabilityManager().getNodeState();
+return HOT_STATES.contains(state);
+}
+
+public abstract ManagementContext mgmt();
+
+// Maybe there should be a separate state to indicate that we hav

[27/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
REST API optional Jersey compatibility


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

Branch: refs/heads/master
Commit: abd2d5f3b2a5584c639ca233acd474d2bc972035
Parents: 6f624c7
Author: Svetoslav Neykov 
Authored: Tue Feb 9 19:30:17 2016 +0200
Committer: Svetoslav Neykov 
Committed: Tue Feb 16 11:43:48 2016 +0200

--
 camp/camp-server-jersey/pom.xml | 225 ++
 .../brooklyn/camp/server/RestApiSetup.java  |  53 ++
 .../rest/resource/ApiListingResource.java   | 260 +++
 .../rest/resource/ApidocRestResource.java   |  32 +
 .../src/main/webapp/WEB-INF/web.xml | 142 
 .../brooklyn/camp/server/RestApiSetup.java  |   4 +-
 .../brooklyn/camp/server/rest/CampServer.java   |   2 +-
 .../rest/resource/ApidocRestResource.java   |   2 +-
 camp/pom.xml|   1 +
 launcher/pom.xml|  36 +-
 .../brooklyn/launcher/BrooklynWebServer.java|   8 +-
 .../BrooklynJavascriptGuiLauncherTest.java  |   2 +-
 parent/pom.xml  |  28 +-
 pom.xml |   3 +-
 .../rest/client/BrooklynApiUtilTest.java|   2 +-
 .../brooklyn/rest/resources/ApidocResource.java |   3 +-
 .../rest/util/ManagementContextProvider.java|   6 +-
 .../rest/util/ShutdownHandlerProvider.java  |   6 +-
 .../util/json/BrooklynJacksonJsonProvider.java  |  42 +-
 .../src/main/resources/not-a-jar-file.txt   |  18 -
 .../src/main/resources/reset-catalog.xml|  37 -
 .../src/test/resources/not-a-jar-file.txt   |  18 +
 .../src/test/resources/reset-catalog.xml|  37 +
 rest/rest-server-jersey/pom.xml | 317 +
 .../org/apache/brooklyn/rest/RestApiSetup.java  |  78 +++
 .../rest/filter/HaHotCheckResourceFilter.java   | 163 +
 .../brooklyn/rest/filter/NoCacheFilter.java |  40 ++
 .../brooklyn/rest/filter/SwaggerFilter.java |  79 +++
 .../rest/resources/ApiListingResource.java  | 260 +++
 .../brooklyn/rest/resources/ApidocResource.java |  33 +
 .../brooklyn/rest/util/FormMapProvider.java |  81 +++
 .../main/resources/build-metadata.properties|  18 +
 .../src/main/webapp/WEB-INF/web.xml | 144 
 .../BrooklynPropertiesSecurityFilterTest.java   | 151 
 .../brooklyn/rest/BrooklynRestApiLauncher.java  | 499 +
 .../rest/BrooklynRestApiLauncherTest.java   |  77 ++
 .../BrooklynRestApiLauncherTestFixture.java | 109 +++
 .../apache/brooklyn/rest/HaHotCheckTest.java| 130 
 .../brooklyn/rest/HaMasterCheckFilterTest.java  | 218 ++
 .../rest/domain/AbstractDomainTest.java |  44 ++
 .../brooklyn/rest/domain/ApiErrorTest.java  |  71 ++
 .../rest/domain/ApplicationSpecTest.java|  40 ++
 .../brooklyn/rest/domain/ApplicationTest.java   |  87 +++
 .../rest/domain/EffectorSummaryTest.java|  44 ++
 .../brooklyn/rest/domain/EntitySpecTest.java|  48 ++
 .../brooklyn/rest/domain/EntitySummaryTest.java |  48 ++
 .../brooklyn/rest/domain/LocationSpecTest.java  |  58 ++
 .../rest/domain/LocationSummaryTest.java|  41 ++
 .../brooklyn/rest/domain/SensorSummaryTest.java | 103 +++
 .../rest/domain/VersionSummaryTest.java |  49 ++
 .../AbstractRestApiEntitlementsTest.java| 111 +++
 .../ActivityApiEntitlementsTest.java| 123 
 .../AuthenticateAnyoneSecurityProvider.java |  41 ++
 .../EntityConfigApiEntitlementsTest.java| 103 +++
 .../entitlement/SensorApiEntitlementsTest.java  | 108 +++
 .../entitlement/ServerApiEntitlementsTest.java  |  34 +
 .../StaticDelegatingEntitlementManager.java |  37 +
 .../rest/resources/AccessResourceTest.java  |  68 ++
 .../rest/resources/ApidocResourceTest.java  | 177 +
 .../ApplicationResourceIntegrationTest.java | 133 
 .../rest/resources/ApplicationResourceTest.java | 701 +++
 .../rest/resources/CatalogResetTest.java| 113 +++
 .../rest/resources/CatalogResourceTest.java | 513 ++
 .../rest/resources/DelegatingPrintStream.java   | 183 +
 .../rest/resources/DescendantsTest.java | 130 
 .../resources/EntityConfigResourceTest.java | 172 +
 .../rest/resources/EntityResourceTest.java  | 189 +
 .../rest/resources/ErrorResponseTest.java   |  98 +++
 .../rest/resources/LocationResourceTest.java| 188 +
 .../rest/resources/PolicyResourceTest.java  | 145 
 .../rest/resources/ScriptResourceTest.java  |  54 ++
 .../SensorResourceIntegrationTest.java  |  82 +++
 .../rest/resources/SensorResourceTest.java  | 271 +++
 .../ServerResourc

[2/2] brooklyn-ui git commit: This closes #6

2016-02-18 Thread heneveld
This closes #6


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/68fb2262
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/68fb2262
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/68fb2262

Branch: refs/heads/master
Commit: 68fb22627d4eafd673a926ca81e7e5b6799ff899
Parents: b9ba654 cf1c6a7
Author: Alex Heneveld 
Authored: Thu Feb 18 10:38:57 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 10:38:57 2016 +

--
 src/test/javascript/specs/model/application-spec.js| 10 +-
 src/test/javascript/specs/model/entity-summary-spec.js |  2 +-
 src/test/javascript/specs/model/location-spec.js   |  6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
--




[30/34] brooklyn-server git commit: fix tests which expected a particular result

2016-02-18 Thread heneveld
fix tests which expected a particular result


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/7f047baa
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/7f047baa
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/7f047baa

Branch: refs/heads/master
Commit: 7f047baaa1e029b41977e3316cd990f1cc13eb7e
Parents: 79b98c6
Author: Alex Heneveld 
Authored: Thu Feb 18 11:16:37 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 11:16:37 2016 +

--
 .../apache/brooklyn/rest/resources/ApplicationResourceTest.java | 4 +++-
 .../org/apache/brooklyn/rest/resources/CatalogResourceTest.java | 5 -
 2 files changed, 7 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7f047baa/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
index 6091096..b9a6e9b 100644
--- 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -85,10 +85,12 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
+
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MultivaluedHashMap;
+
 import org.apache.cxf.jaxrs.client.WebClient;
 
 @Test(singleThreaded = true,
@@ -645,7 +647,7 @@ public class ApplicationResourceTest extends 
BrooklynRestResourceTest {
 Response response3 = client().path("/applications")
 .post(Entity.entity(yaml3, "application/x-yaml"));
 HttpAsserts.assertClientErrorStatusCode(response3.getStatus());
-assertTrue(response3.readEntity(String.class).contains("cannot be 
matched"));
+
assertTrue(response3.readEntity(String.class).toLowerCase().contains("unable to 
match"));
 waitForPageNotFoundResponse("/applications/my-app3", 
ApplicationSummary.class);
 
 } finally {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7f047baa/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
index b6a77d5..8d5d017 100644
--- 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
@@ -47,6 +47,7 @@ import 
org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.javalang.Reflections;
 import org.apache.http.HttpHeaders;
 import org.apache.http.entity.ContentType;
+import org.eclipse.jetty.http.HttpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -55,7 +56,9 @@ import org.testng.reporters.Files;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.Iterables;
+
 import java.io.InputStream;
+
 import javax.ws.rs.core.GenericType;
 
 @Test( // by using a different suite name we disallow interleaving other tests 
between the methods of this test class, which wrecks the test fixtures
@@ -501,7 +504,7 @@ public class CatalogResourceTest extends 
BrooklynRestResourceTest {
 Response response = client().path("/catalog")
 .post(yaml);
 
-assertEquals(response.getStatus(), 
Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
+assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400);
 }
 
 private static String ver(String id) {



[11/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
new file mode 100644
index 000..21fd246
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
@@ -0,0 +1,444 @@
+/*
+ * 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.resources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.NoMachinesAvailableException;
+import org.apache.brooklyn.core.mgmt.internal.LocalUsageManager;
+import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest;
+import 
org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.rest.domain.UsageStatistic;
+import org.apache.brooklyn.rest.domain.UsageStatistics;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.time.Time;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import javax.ws.rs.core.GenericType;
+
+@Test( // by using a different suite name we disallow interleaving other tests 
between the methods of this test class, which wrecks the test fixtures
+suiteName = "UsageResourceTest")
+public class UsageResourceTest extends BrooklynRestResourceTest {
+
+@SuppressWarnings("unused")
+private static final Logger LOG = 
LoggerFactory.getLogger(UsageResourceTest.class);
+
+private static final long TIMEOUT_MS = 10*1000;
+
+private Calendar testStartTime;
+
+private final ApplicationSpec simpleSpec = 
ApplicationSpec.builder().name("simple-app").
+entities(ImmutableSet.of(new 
org.apache.brooklyn.rest.domain.EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(.
+locations(ImmutableSet.of("localhost")).
+build();
+
+@BeforeMethod(alwaysRun=true)
+public void setUp() {
+
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.APPLICATION_USAGE_KEY);
+
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.LOCATION_USAGE_KEY);
+testStartTime = new GregorianCalendar();
+}
+
+@Test
+public void testListApplicationUsages() throws Exception {
+// Create an app
+Calendar preStart = new GregorianCalendar();
+String appId = createApp(simpleSpec);
+Calendar postStart = new GregorianCalendar();
+
+// We will retrieve usage from one millisecond after start; this 
guarantees to not be  
+// told about both STARTING+RUNNING, which could otherwise happen if 
they are in the 
+// same milliscond.
+Calendar afterPos

[29/34] brooklyn-server git commit: This closes #15

2016-02-18 Thread heneveld
This closes #15

simple merge conflicts resolved (imports, and extra param/code in places)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/79b98c67
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/79b98c67
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/79b98c67

Branch: refs/heads/master
Commit: 79b98c679b97cd34464abf4a78ddb93cc809b195
Parents: a5103bb abd2d5f
Author: Alex Heneveld 
Authored: Thu Feb 18 10:54:31 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 10:56:30 2016 +

--
 camp/camp-server-jersey/pom.xml | 225 ++
 .../brooklyn/camp/server/RestApiSetup.java  |  53 ++
 .../rest/resource/ApiListingResource.java   | 260 +++
 .../rest/resource/ApidocRestResource.java   |  32 +
 .../src/main/webapp/WEB-INF/web.xml | 142 
 camp/camp-server/pom.xml|  21 +-
 .../brooklyn/camp/server/CampRestApp.java   |  36 +
 .../brooklyn/camp/server/RestApiSetup.java  |  41 ++
 .../brooklyn/camp/server/rest/CampServer.java   |  32 +-
 .../rest/resource/ApidocRestResource.java   |   2 +-
 camp/pom.xml|   1 +
 karaf/apache-brooklyn/pom.xml   |   2 +-
 .../main/resources/etc/org.apache.cxf.osgi.cfg  |  20 +
 karaf/features/src/main/feature/feature.xml |  30 +-
 karaf/itest/pom.xml |  13 +
 .../java/org/apache/brooklyn/AssemblyTest.java  |   4 +-
 launcher/pom.xml|  33 +-
 .../org/apache/brooklyn/launcher/Activator.java |   2 +
 .../brooklyn/launcher/BrooklynWebServer.java|  95 +--
 .../camp/BrooklynCampPlatformLauncher.java  |   1 +
 .../jsgui/BrooklynJavascriptGuiLauncher.java|   2 +-
 .../BrooklynJavascriptGuiLauncherTest.java  |  18 +-
 locations/jclouds/pom.xml   |  12 +
 parent/pom.xml  | 194 +++--
 pom.xml |   8 +-
 rest/rest-api/pom.xml   |  21 +-
 .../org/apache/brooklyn/rest/api/AccessApi.java |   2 +-
 .../apache/brooklyn/rest/api/ActivityApi.java   |   2 +-
 .../brooklyn/rest/api/ApplicationApi.java   |   2 +-
 .../apache/brooklyn/rest/api/CatalogApi.java|  28 +-
 .../apache/brooklyn/rest/api/EffectorApi.java   |   2 +-
 .../org/apache/brooklyn/rest/api/EntityApi.java |   4 +-
 .../brooklyn/rest/api/EntityConfigApi.java  |   4 +-
 .../apache/brooklyn/rest/api/LocationApi.java   |   2 +-
 .../org/apache/brooklyn/rest/api/PolicyApi.java |   2 +-
 .../brooklyn/rest/api/PolicyConfigApi.java  |   2 +-
 .../org/apache/brooklyn/rest/api/ScriptApi.java |   2 +-
 .../org/apache/brooklyn/rest/api/SensorApi.java |   5 +-
 .../org/apache/brooklyn/rest/api/ServerApi.java |   2 +-
 .../org/apache/brooklyn/rest/api/UsageApi.java  |   2 +-
 .../apache/brooklyn/rest/api/VersionApi.java|   4 +-
 rest/rest-api/src/main/webapp/WEB-INF/web.xml   | 121 
 .../rest/domain/ApplicationSpecTest.java|   2 +-
 .../rest/domain/EffectorSummaryTest.java|   2 +-
 .../brooklyn/rest/domain/EntitySummaryTest.java |   8 +-
 .../rest/domain/LocationSummaryTest.java|   2 +-
 .../resources/fixtures/application-list.json|   8 +-
 .../resources/fixtures/application-spec.json|   2 +-
 .../test/resources/fixtures/application.json|   4 +-
 .../fixtures/effector-summary-list.json |  18 +-
 .../resources/fixtures/effector-summary.json|   2 +-
 .../resources/fixtures/entity-summary-list.json |   8 +-
 .../test/resources/fixtures/entity-summary.json |   8 +-
 .../test/resources/fixtures/location-list.json  |   2 +-
 .../resources/fixtures/location-summary.json|   2 +-
 .../resources/fixtures/sensor-summary-list.json |  16 +-
 .../test/resources/fixtures/sensor-summary.json |   2 +-
 rest/rest-client/pom.xml|   7 +
 .../rest/client/BrooklynApiRestClientTest.java  |   3 +-
 .../rest/client/BrooklynApiUtilTest.java|   2 +-
 rest/rest-resources/pom.xml | 220 ++
 .../apache/brooklyn/rest/BrooklynRestApi.java   |  91 +++
 .../apache/brooklyn/rest/BrooklynRestApp.java   |  56 ++
 .../apache/brooklyn/rest/BrooklynWebConfig.java | 164 +
 .../rest/filter/HaHotCheckResourceFilter.java   | 159 +
 .../rest/filter/HaHotStateRequired.java |  38 +
 .../brooklyn/rest/filter/NoCacheFilter.java |  40 ++
 .../resources/AbstractBrooklynRestResource.java | 156 +
 .../brooklyn/rest/resources/AccessResource.java |  46 ++
 .../rest/resources/ActivityResource.java|  99 +++
 .../brooklyn/rest/resources/ApidocResource.java |  34 +
 .../rest/resources/ApplicationResource.java | 474 +
 .../rest/resources/CatalogResource.java | 516 ++
 .../rest/resources/Effec

[02/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
--
diff --git 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
 
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
deleted file mode 100644
index 72392fe..000
--- 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
+++ /dev/null
@@ -1,443 +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.rest.resources;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-import javax.ws.rs.core.Response;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.location.NoMachinesAvailableException;
-import org.apache.brooklyn.core.mgmt.internal.LocalUsageManager;
-import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest;
-import 
org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.rest.domain.ApplicationSpec;
-import org.apache.brooklyn.rest.domain.Status;
-import org.apache.brooklyn.rest.domain.TaskSummary;
-import org.apache.brooklyn.rest.domain.UsageStatistic;
-import org.apache.brooklyn.rest.domain.UsageStatistics;
-import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
-import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
-import org.apache.brooklyn.util.repeat.Repeater;
-import org.apache.brooklyn.util.time.Time;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-
-public class UsageResourceTest extends BrooklynRestResourceTest {
-
-@SuppressWarnings("unused")
-private static final Logger LOG = 
LoggerFactory.getLogger(UsageResourceTest.class);
-
-private static final long TIMEOUT_MS = 10*1000;
-
-private Calendar testStartTime;
-
-private final ApplicationSpec simpleSpec = 
ApplicationSpec.builder().name("simple-app").
-entities(ImmutableSet.of(new 
org.apache.brooklyn.rest.domain.EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(.
-locations(ImmutableSet.of("localhost")).
-build();
-
-@BeforeMethod(alwaysRun=true)
-public void setUpMethod() {
-
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.APPLICATION_USAGE_KEY);
-
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.LOCATION_USAGE_KEY);
-testStartTime = new GregorianCalendar();
-}
-
-@Test
-public void testListApplicationUsages() throws Exception {
-// Create an app
-Calendar preStart = new GregorianCalendar();
-String appId = createApp(simpleSpec);
-Calendar postStart = new GregorianCalendar();
-
-// We will retrieve usage from one millisecond after start; this 
guarantees to not be  
-// told about both STARTING+RUNNING, which could otherwise happen if 
they are in the 
-// same milliscond.
-Calendar afterPostStart = 
Time.newCalendarFromMillisSinceEpochUtc(postStart.getTime().getTime()+1);
-
-// Check that app's usage is retur

[24/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
new file mode 100644
index 000..865b6f7
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceIntegrationTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.resources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.domain.EntitySummary;
+import org.apache.brooklyn.rest.domain.SensorSummary;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.collections.MutableMap;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.GenericType;
+
+@Test(singleThreaded = true)
+public class ApplicationResourceIntegrationTest extends 
BrooklynRestResourceTest {
+
+@SuppressWarnings("unused")
+private static final Logger log = 
LoggerFactory.getLogger(ApplicationResourceIntegrationTest.class);
+
+private final ApplicationSpec redisSpec = 
ApplicationSpec.builder().name("redis-app")
+.entities(ImmutableSet.of(new EntitySpec("redis-ent", 
"org.apache.brooklyn.entity.nosql.redis.RedisStore")))
+.locations(ImmutableSet.of("localhost"))
+.build();
+
+@Test(groups="Integration")
+public void testDeployRedisApplication() throws Exception {
+ClientResponse response = clientDeploy(redisSpec);
+
+assertEquals(response.getStatus(), 201);
+assertEquals(getManagementContext().getApplications().size(), 1);
+
assertTrue(response.getLocation().getPath().startsWith("/v1/applications/"), 
"path="+response.getLocation().getPath()); // path uses id, rather than app name
+
+waitForApplicationToBeRunning(response.getLocation());
+}
+
+@Test(groups="Integration", dependsOnMethods = 
"testDeployRedisApplication")
+public void testListEntities() {
+Set entities = 
client().resource("/v1/applications/redis-app/entities")
+.get(new GenericType>() {});
+
+for (EntitySummary entity : entities) {
+
client().resource(entity.getLinks().get("self")).get(ClientResponse.class);
+// TODO assertions on the above call?
+
+Set children = 
client().resource(entity.getLinks().get("children"))
+.get(new GenericType>() {});
+assertEquals(children.size(), 0);
+}
+}
+
+@Test(groups="Integration", dependsOnMethods = 
"testDeployRedisApplication")
+public void testListSensorsRedis() {
+Set sensors = 
client().resource("/v1/applications/redis-app/entities/redis-ent/sensors")
+.get(new GenericType>() {});
+assertTrue(sensors.size() > 0);
+SensorSummary uptime = Iterables.find(sensors, new 
Predicate() {
+@Override
+public boolean apply(SensorSummary sensorSummary) {
+return sensorSummary.getName().equals("redis.uptime");
+}
+});
+assertEquals(uptime.getT

[05/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/MultimapSerializer.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/MultimapSerializer.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/MultimapSerializer.java
deleted file mode 100644
index c264e22..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/MultimapSerializer.java
+++ /dev/null
@@ -1,62 +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.rest.util.json;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-
-/**
- * Provides a serializer for {@link Multimap} instances.
- * 
- * When Brooklyn's Jackson dependency is updated from 
org.codehaus.jackson:1.9.13 to
- * com.fasterxml.jackson:2.3+ then this class should be replaced with a 
dependency on
- * jackson-datatype-guava and a GuavaModule registered with Brooklyn's 
ObjectMapper.
- */
-@Beta
-public class MultimapSerializer extends StdSerializer> {
-
-@SuppressWarnings({ "unchecked", "rawtypes" })
-protected MultimapSerializer() {
-super((Class>) (Class) Multimap.class);
-}
-
-@Override
-public void serialize(Multimap value, JsonGenerator jgen, 
SerializerProvider provider) throws IOException {
-jgen.writeStartObject();
-writeEntries(value, jgen, provider);
-jgen.writeEndObject();
-}
-
-private void writeEntries(Multimap value, JsonGenerator jgen, 
SerializerProvider provider) throws IOException {
-for (Map.Entry> entry : 
value.asMap().entrySet()) {
-provider.findKeySerializer(provider.constructType(String.class), 
null)
-.serialize(entry.getKey(), jgen, provider);
-
provider.defaultSerializeValue(Lists.newArrayList(entry.getValue()), jgen);
-}
-}
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/PossiblyStrictPreferringFieldsVisibilityChecker.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/PossiblyStrictPreferringFieldsVisibilityChecker.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/PossiblyStrictPreferringFieldsVisibilityChecker.java
deleted file mode 100644
index e474467..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/json/PossiblyStrictPreferringFieldsVisibilityChecker.java
+++ /dev/null
@@ -1,108 +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.rest.util.json;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.introspect.AnnotatedField;
-import c

[17/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/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
new file mode 100644
index 000..c8a7962
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
@@ -0,0 +1,108 @@
+/*
+ * 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.resources;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.policy.Policy;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
+import org.apache.brooklyn.rest.api.PolicyConfigApi;
+import org.apache.brooklyn.rest.domain.PolicyConfigSummary;
+import org.apache.brooklyn.rest.filter.HaHotStateRequired;
+import org.apache.brooklyn.rest.transform.PolicyTransformer;
+import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
+import org.apache.brooklyn.rest.util.WebResourceUtils;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+@HaHotStateRequired
+public class PolicyConfigResource extends AbstractBrooklynRestResource 
implements PolicyConfigApi {
+
+@Override
+public List list(
+final String application, final String entityToken, final String 
policyToken) {
+Entity entity = brooklyn().getEntity(application, entityToken);
+Policy policy = brooklyn().getPolicy(entity, policyToken);
+
+List result = Lists.newArrayList();
+for (ConfigKey key : policy.getPolicyType().getConfigKeys()) {
+result.add(PolicyTransformer.policyConfigSummary(brooklyn(), 
entity, policy, key, ui.getBaseUriBuilder()));
+}
+return result;
+}
+
+// TODO support parameters  ?show=value,summary&name=xxx 
&format={string,json,xml}
+// (and in sensors class)
+@Override
+public Map batchConfigRead(String application, String 
entityToken, String policyToken) {
+// TODO: add test
+Policy policy = brooklyn().getPolicy(application, entityToken, 
policyToken);
+Map source = 
((BrooklynObjectInternal)policy).config().getBag().getAllConfig();
+Map result = Maps.newLinkedHashMap();
+for (Map.Entry ek : source.entrySet()) {
+result.put(ek.getKey(), getStringValueForDisplay(brooklyn(), 
policy, ek.getValue()));
+}
+return result;
+}
+
+@Override
+public String get(String application, String entityToken, String 
policyToken, String configKeyName) {
+Policy policy = brooklyn().getPolicy(application, entityToken, 
policyToken);
+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));
+}
+
+@Override
+@Deprecated
+public Response set(String application, String entityToken, String 
policyToken, String configKeyName, String value) {
+return set(application, entityToken, policyToken, configKeyName, 
(Object) value);
+}
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+@Override
+public Response set(String application, String entityToken, String 
policyToken, String configKeyName, Object value) {
+Entity entity = brooklyn().getEntity(application, entityToken);
+if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.MODIFY_ENTITY, entity)) {
+throw WebResourceUtils.forbidden("User '%s' is not authorized to 
modify entity '%s'",
+E

[12/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
new file mode 100644
index 000..decbcef
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
@@ -0,0 +1,188 @@
+/*
+ * 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.resources;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.http.HttpAsserts;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import javax.ws.rs.core.Response;
+
+@Test(singleThreaded = true,
+// by using a different suite name we disallow interleaving other 
tests between the methods of this test class, which wrecks the test fixtures
+suiteName = "EntityResourceTest")
+public class EntityResourceTest extends BrooklynRestResourceTest {
+
+private static final Logger log = 
LoggerFactory.getLogger(EntityResourceTest.class);
+
+private final ApplicationSpec simpleSpec = ApplicationSpec.builder()
+.name("simple-app")
+.entities(ImmutableSet.of(new EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(
+.locations(ImmutableSet.of("localhost"))
+.build();
+
+private EntityInternal entity;
+
+private static final String entityEndpoint = 
"/applications/simple-app/entities/simple-ent";
+
+@BeforeClass(alwaysRun = true)
+public void setUp() throws Exception {
+// Deploy application
+startServer();
+Response deploy = clientDeploy(simpleSpec);
+waitForApplicationToBeRunning(deploy.getLocation());
+
+// Add tag
+entity = (EntityInternal) 
Iterables.find(getManagementContext().getEntityManager().getEntities(), new 
Predicate() {
+@Override
+public boolean apply(@Nullable Entity input) {
+return 
"RestMockSimpleEntity".equals(input.getEntityType().getSimpleName());
+}
+});
+}
+
+@Test
+public void testTagsSanity() throws Exception {
+entity.tags().addTag("foo");
+
+Response response = client().path(entityEndpoint + "/tags")
+.accept(MediaType.APPLICATION_JSON_TYPE)
+.get();
+String data = response.readEntity(String.class);
+
+try {
+List tags = new ObjectMapper().readValue(data, new 
TypeReference>() {});
+Assert.assertTrue(tags.contains("foo"));
+Assert.assertFalse(tags.contains("bar"));
+} catch (Exception e) {
+Exceptions.propagateIfFatal(e);
+throw new IllegalStateException("Error with deserialization of 
tags list: "+e+"\n"+data, e);
+

[10/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
new file mode 100644
index 000..5c9d4d1
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckResource.java
@@ -0,0 +1,44 @@
+/*
+ * 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.util;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.rest.filter.HaHotStateRequired;
+
+@Path("/ha/method")
+@Produces(MediaType.APPLICATION_JSON)
+public class HaHotStateCheckResource {
+
+@GET
+@Path("ok")
+public String ok() {
+return "OK";
+}
+
+@GET
+@Path("fail")
+@HaHotStateRequired
+public String fail() {
+return "FAIL";
+}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/TestShutdownHandler.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/TestShutdownHandler.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/TestShutdownHandler.java
new file mode 100644
index 000..b5cb218
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/TestShutdownHandler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.util;
+
+public class TestShutdownHandler implements ShutdownHandler {
+private volatile boolean isRequested;
+
+@Override
+public void onShutdownRequest() {
+isRequested = true;
+}
+
+public boolean isRequested() {
+return isRequested;
+}
+
+public void reset() {
+isRequested = false;
+}
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
new file mode 100644
index 000..2dd5ae1
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonSerializerTest.java
@@ -0,0 +1,264 @@
+/*
+ * 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,
+ * softwar

[08/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyResource.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyResource.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyResource.java
deleted file mode 100644
index 7ec0b22..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyResource.java
+++ /dev/null
@@ -1,131 +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.rest.resources;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.policy.Policy;
-import org.apache.brooklyn.api.policy.PolicySpec;
-import org.apache.brooklyn.core.policy.Policies;
-import org.apache.brooklyn.rest.api.PolicyApi;
-import org.apache.brooklyn.rest.domain.PolicySummary;
-import org.apache.brooklyn.rest.domain.Status;
-import org.apache.brooklyn.rest.domain.SummaryComparators;
-import org.apache.brooklyn.rest.filter.HaHotStateRequired;
-import org.apache.brooklyn.rest.transform.ApplicationTransformer;
-import org.apache.brooklyn.rest.transform.PolicyTransformer;
-import org.apache.brooklyn.rest.util.WebResourceUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.Maps;
-
-@HaHotStateRequired
-public class PolicyResource extends AbstractBrooklynRestResource implements 
PolicyApi {
-
-private static final Logger log = 
LoggerFactory.getLogger(PolicyResource.class);
-
-@Override
-public List list( final String application, final String 
entityToken) {
-final Entity entity = brooklyn().getEntity(application, entityToken);
-return FluentIterable.from(entity.policies())
-.transform(new Function() {
-@Override
-public PolicySummary apply(Policy policy) {
-return PolicyTransformer.policySummary(entity, policy);
-}
-})
-.toSortedList(SummaryComparators.nameComparator());
-}
-
-// TODO support parameters  ?show=value,summary&name=xxx
-// (and in sensors class)
-@Override
-public Map batchConfigRead( String application, String 
entityToken) {
-// TODO: add test
-Entity entity = brooklyn().getEntity(application, entityToken);
-Map result = Maps.newLinkedHashMap();
-for (Policy p : entity.policies()) {
-result.put(p.getId(), !p.isSuspended());
-}
-return result;
-}
-
-// TODO would like to make 'config' arg optional but jersey complains if 
we do
-@SuppressWarnings("unchecked")
-@Override
-public PolicySummary addPolicy( String application,String entityToken, 
String policyTypeName,
-Map config) {
-Entity entity = brooklyn().getEntity(application, entityToken);
-Class policyType;
-try {
-policyType = (Class) 
Class.forName(policyTypeName);
-} catch (ClassNotFoundException e) {
-throw WebResourceUtils.badRequest("No policy with type %s found", 
policyTypeName);
-} catch (ClassCastException e) {
-throw WebResourceUtils.badRequest("No policy with type %s found", 
policyTypeName);
-} catch (Exception e) {
-throw Exceptions.propagate(e);
-}
-
-Policy policy = 
entity.policies().add(PolicySpec.create(policyType).configure(config));
-log.debug("REST API added policy " + policy + " to " + entity);
-
-return PolicyTransformer.policySummary(entity, policy);
-}
-
-@Override
-public Status getStatus(String application, String entityToken, String 
policyId) {
-Policy policy = brooklyn().getPolicy(application, entityToken, 
policyId);
-return 
ApplicationTransformer.statusFromLifecycle(Policies.getPolicy

[15/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
new file mode 100644
index 000..3f837a1
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
@@ -0,0 +1,609 @@
+/*
+ * 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.util;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.apache.brooklyn.rest.util.WebResourceUtils.notFound;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.brooklyn.api.catalog.BrooklynCatalog;
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationRegistry;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.policy.Policy;
+import org.apache.brooklyn.api.typereg.RegisteredType;
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
+import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
+import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent.Scope;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.catalog.CatalogPredicates;
+import org.apache.brooklyn.core.catalog.internal.CatalogItemComparator;
+import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
+import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import 
org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
+import org.apache.brooklyn.core.objs.BrooklynTypes;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.enricher.stock.Enrichers;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.collections.MutableSet;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.javalang.Reflections;
+import org.apache.brooklyn.util.net.Urls;
+import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.io.Files;
+
+public class BrooklynRestResourceUtils {
+
+private static final Logger log = 
LoggerFactory.getLogger(BrooklynRestResourceUtils.class);
+
+private final ManagementContext mgmt;
+
+public BrooklynRestResourceUtils(ManagementContext mgmt) {
+Preconditions.checkNotNull(mgmt, "mgmt");
+this.mgmt = mgmt;
+}
+
+public BrooklynCatalog getCatalog() {
+return mgmt.getCatalog();
+}
+
+public Cl

[33/34] brooklyn-server git commit: remove deprecation warnings in launcher

2016-02-18 Thread heneveld
remove deprecation warnings in launcher


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

Branch: refs/heads/master
Commit: bdd502fbd8d858b9051f5a9d9874600c78b6b20c
Parents: 96d804a
Author: Alex Heneveld 
Authored: Thu Feb 18 14:24:33 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 14:24:33 2016 +

--
 .../brooklyn/launcher/BrooklynLauncher.java | 27 
 1 file changed, 17 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/bdd502fb/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynLauncher.java
--
diff --git 
a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynLauncher.java 
b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynLauncher.java
index e5d4c01..1a2224e 100644
--- a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynLauncher.java
+++ b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynLauncher.java
@@ -27,11 +27,11 @@ import java.net.InetAddress;
 import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeoutException;
+
 import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.entity.Application;
@@ -55,7 +55,6 @@ import 
org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
 import org.apache.brooklyn.core.config.ConfigPredicates;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.StartableApplication;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.location.PortRanges;
@@ -135,7 +134,8 @@ public class BrooklynLauncher {
 private final List locations = new ArrayList();
 
 private final List appsToManage = new 
ArrayList();
-private final List appBuildersToManage = new 
ArrayList();
+@SuppressWarnings("deprecation") // TODO convert to EntitySpec; should be 
easy when users not allowed to pass in a builder
+private final 
List 
appBuildersToManage = new 
ArrayList();
 private final List yamlAppsToManage = new ArrayList();
 private final List apps = new ArrayList();
 
@@ -211,9 +211,13 @@ public class BrooklynLauncher {
  * The application will not be started as part of this call (callers can
  * subsequently call {@link #start()} or {@link #getApplications()}.
  * 
- * @see #application(Application)
+ * @see #application(EntitySpec)
+ * 
+ * @deprecated since 0.9.0; instead use {@link #application(String)} for 
YAML apps, or {@link #application(EntitySpec)}.
+ * Note that apps are now auto-managed on construction through 
EntitySpec/YAML.
  */
-public BrooklynLauncher application(ApplicationBuilder appBuilder) {
+public BrooklynLauncher 
application(org.apache.brooklyn.core.entity.factory.ApplicationBuilder 
appBuilder) {
+LOG.warn("Caller supplied ApplicationBuilder; convert to EntitySpec as 
this style builder may not be supported in future.");
 appBuildersToManage.add(checkNotNull(appBuilder, "appBuilder"));
 return this;
 }
@@ -226,8 +230,9 @@ public class BrooklynLauncher {
  * 
  * @see #application(Application)
  */
+@SuppressWarnings("deprecation")  // when appsToManage is EntitySpec this 
will no longer be needed
 public BrooklynLauncher application(EntitySpec appSpec) {
-appBuildersToManage.add(new ApplicationBuilder(checkNotNull(appSpec, 
"appSpec")) {
+appBuildersToManage.add(new 
org.apache.brooklyn.core.entity.factory.ApplicationBuilder(checkNotNull(appSpec,
 "appSpec")) {
 @Override protected void doBuild() {
 }});
 return this;
@@ -802,7 +807,7 @@ public class BrooklynLauncher {
 BrooklynWebConfig.SECURITY_PROVIDER_INSTANCE,
 new 
BrooklynUserWithRandomPasswordSecurityProvider(managementContext));
 } else {
-LOG.debug("Starting Brooklyn using security properties: 
"+brooklynProperties.submap(ConfigPredicates.startingWith(BrooklynWebConfig.BASE_NAME_SECURITY)).asMapWithStringKeys());
+LOG.debug("Starting Brooklyn using security properties: 
"+brooklynProperties.submap(ConfigPredicates.nameStartsWith(BrooklynWebConfig.BASE_NAME_SECURITY)).asMapWithStringKeys

[26/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
--
diff --git 
a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
 
b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
new file mode 100644
index 000..c65c78f
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/filter/HaHotCheckResourceFilter.java
@@ -0,0 +1,163 @@
+/*
+ * 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.filter;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ContextResolver;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
+import org.apache.brooklyn.rest.domain.ApiError;
+import org.apache.brooklyn.util.text.Strings;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
+import com.sun.jersey.api.model.AbstractMethod;
+import com.sun.jersey.spi.container.ContainerRequest;
+import com.sun.jersey.spi.container.ContainerRequestFilter;
+import com.sun.jersey.spi.container.ContainerResponseFilter;
+import com.sun.jersey.spi.container.ResourceFilter;
+import com.sun.jersey.spi.container.ResourceFilterFactory;
+
+/** 
+ * Checks that if the method or resource class corresponding to a request
+ * has a {@link HaHotStateRequired} annotation,
+ * that the server is in that state (and up). 
+ * Requests with {@link #SKIP_CHECK_HEADER} set as a header skip this check.
+ * 
+ * This follows a different pattern to {@link HaMasterCheckFilter} 
+ * as this needs to know the method being invoked. 
+ */
+public class HaHotCheckResourceFilter implements ResourceFilterFactory {
+public static final String SKIP_CHECK_HEADER = 
"Brooklyn-Allow-Non-Master-Access";
+
+private static final Logger log = 
LoggerFactory.getLogger(HaHotCheckResourceFilter.class);
+
+private static final Set HOT_STATES = ImmutableSet.of(
+ManagementNodeState.MASTER, ManagementNodeState.HOT_STANDBY, 
ManagementNodeState.HOT_BACKUP);
+
+@Context
+private ContextResolver mgmt;
+
+public HaHotCheckResourceFilter() {}
+
+@VisibleForTesting
+public HaHotCheckResourceFilter(ContextResolver mgmt) {
+this.mgmt = mgmt;
+}
+
+private ManagementContext mgmt() {
+return mgmt.getContext(ManagementContext.class);
+}
+
+private static class MethodFilter implements ResourceFilter, 
ContainerRequestFilter {
+
+private AbstractMethod am;
+private ManagementContext mgmt;
+
+public MethodFilter(AbstractMethod am, ManagementContext mgmt) {
+this.am = am;
+this.mgmt = mgmt;
+}
+
+@Override
+public ContainerRequestFilter getRequestFilter() {
+return this;
+}
+
+@Override
+public ContainerResponseFilter getResponseFilter() {
+return null;
+}
+
+private String lookForProblem(ContainerRequest request) {
+if (isSkipCheckHeaderSet(request)) 
+return null;
+
+if (!isHaHotStateRequired(request))
+return null;
+
+String problem = lookForProblemIfServerNotRunning(mgmt);
+if (Strings.isNonBlank(problem)) 
+return problem;
+
+if (!isHaHotStatus())
+return "server not in required HA hot state";
+if (isStateNotYetValid())
+return "server not yet completed loading data for required HA 
hot state";
+
+return null;
+}
+
+@Override
+public ContainerRequest filter(ContainerRequest request) {
+String 

[04/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
--
diff --git 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
 
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
deleted file mode 100644
index 8b49763..000
--- 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
+++ /dev/null
@@ -1,701 +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.rest.resources;
-
-import static com.google.common.collect.Iterables.find;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeoutException;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.EntityFunctions;
-import org.apache.brooklyn.core.entity.EntityPredicates;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.location.AbstractLocation;
-import org.apache.brooklyn.core.location.LocationConfigKeys;
-import org.apache.brooklyn.core.location.geo.HostGeoInfo;
-import org.apache.brooklyn.core.location.internal.LocationInternal;
-import org.apache.brooklyn.entity.stock.BasicApplication;
-import org.apache.brooklyn.entity.stock.BasicEntity;
-import org.apache.brooklyn.rest.domain.ApiError;
-import org.apache.brooklyn.rest.domain.ApplicationSpec;
-import org.apache.brooklyn.rest.domain.ApplicationSummary;
-import org.apache.brooklyn.rest.domain.CatalogEntitySummary;
-import org.apache.brooklyn.rest.domain.CatalogItemSummary;
-import org.apache.brooklyn.rest.domain.EffectorSummary;
-import org.apache.brooklyn.rest.domain.EntityConfigSummary;
-import org.apache.brooklyn.rest.domain.EntitySpec;
-import org.apache.brooklyn.rest.domain.EntitySummary;
-import org.apache.brooklyn.rest.domain.PolicySummary;
-import org.apache.brooklyn.rest.domain.SensorSummary;
-import org.apache.brooklyn.rest.domain.Status;
-import org.apache.brooklyn.rest.domain.TaskSummary;
-import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
-import org.apache.brooklyn.rest.testing.mocks.CapitalizePolicy;
-import org.apache.brooklyn.rest.testing.mocks.NameMatcherGroup;
-import org.apache.brooklyn.rest.testing.mocks.RestMockApp;
-import org.apache.brooklyn.rest.testing.mocks.RestMockAppBuilder;
-import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.util.collections.CollectionFunctionals;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.http.HttpAsserts;
-import org.apache.brooklyn.util.text.Strings;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.http.HttpHeaders;
-import org.apache.http.entity.ContentType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-
-@Test(singleThreaded = true)
-public class ApplicationResourceTest extends BrooklynRestResourceTest {
-
-/*
- * In simpleS

[20/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
[BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

Changes:

* Replace Jersey dependency (JAX-RS 1.1) implementation with CXF (JAX-RS 2.0)
* Use relative paths for REST resource paths

Move the context root at /v1, and use paths relative to that in resource
annotations.

* Add CXF REST resources to karaf features
* Remove /v1 prefix from brooklyn-rest-api resources
* Move CXF servlet context to /v1

In order to preserve compatibility with the existing brooklyn REST API
we need to expose resources at path /v1 instead of /cxf/v1.

For now move the whole CXF servlet at /v1, and with resources mounted at
/ we get the historical path /v1/ for the REST API. We'll need to make
the JSGUI configurable with the base REST API path in the future though.

Also add appropriate providers to the OSGi CXF service blueprint.

* Use relative paths when referring REST resources

Don't use absolute paths based on the assumption that the REST API is
deployed at /v1.

Instead use an UriBuilder provided by JAX-RS as a context-injected
UriInfo object, which should work with any root context path.

Also drop the /v1 prefix from REST API tests and test fixtures.

* Fix usage of resources in CXF unit tests

Use HTTP transport instead of local transport so we can have a ServletContext 
to get/setAttribute.
Allow CXF to use BrooklynJacksonJsonProvider for message formatting and parsing.
Inject the ManagementContext in resources and providers.
Add request/response logging during tests.

* Pull up common implementation of configureCXF

All tests ended up using the same configuration of the REST API, so it
makes sense to move that into the base class

This had the side effect of worsening the interleaving of test methods
by testng, so each resource test was separated into its own suite.

* Fix DeployBlueprintTest

Also change getEndpointAddress() to use template method instead of
setter/getter.

* Wait for CXF resources to start in karaf itest

* Remove CatalogApi's multipart/form-data create method

There is no standard JAX-RS way to process multipart/form-data contents,
so this service was removed from the API for the purpose of unifying the
CXF and Jersey API.

* Adjust OSGi package import directives to allow a version range of 1.1 to
2.0 of JAX-RS directives.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/6f624c78
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/6f624c78
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/6f624c78

Branch: refs/heads/master
Commit: 6f624c78b1e7fe72c6df1ecd297b922721b2c023
Parents: 495b1d3
Author: Ciprian Ciubotariu 
Authored: Tue Feb 9 19:23:20 2016 +0200
Committer: Svetoslav Neykov 
Committed: Mon Feb 15 16:43:57 2016 +0200

--
 camp/camp-server/pom.xml|  21 +-
 .../brooklyn/camp/server/CampRestApp.java   |  36 +
 .../brooklyn/camp/server/RestApiSetup.java  |  43 ++
 .../brooklyn/camp/server/rest/CampServer.java   |  32 +-
 karaf/apache-brooklyn/pom.xml   |   2 +-
 .../main/resources/etc/org.apache.cxf.osgi.cfg  |  20 +
 karaf/features/src/main/feature/feature.xml |  30 +-
 karaf/itest/pom.xml |  13 +
 .../java/org/apache/brooklyn/AssemblyTest.java  |   4 +-
 launcher/pom.xml|  19 +-
 .../org/apache/brooklyn/launcher/Activator.java |   2 +
 .../brooklyn/launcher/BrooklynWebServer.java|  99 +--
 .../camp/BrooklynCampPlatformLauncher.java  |   1 +
 .../jsgui/BrooklynJavascriptGuiLauncher.java|   2 +-
 .../BrooklynJavascriptGuiLauncherTest.java  |  18 +-
 locations/jclouds/pom.xml   |  12 +
 parent/pom.xml  | 182 +++--
 pom.xml |   7 +-
 rest/rest-api/pom.xml   |  21 +-
 .../org/apache/brooklyn/rest/api/AccessApi.java |   2 +-
 .../apache/brooklyn/rest/api/ActivityApi.java   |   2 +-
 .../brooklyn/rest/api/ApplicationApi.java   |   2 +-
 .../apache/brooklyn/rest/api/CatalogApi.java|  28 +-
 .../apache/brooklyn/rest/api/EffectorApi.java   |   2 +-
 .../org/apache/brooklyn/rest/api/EntityApi.java |   4 +-
 .../brooklyn/rest/api/EntityConfigApi.java  |   4 +-
 .../apache/brooklyn/rest/api/LocationApi.java   |   2 +-
 .../org/apache/brooklyn/rest/api/PolicyApi.java |   2 +-
 .../brooklyn/rest/api/PolicyConfigApi.java  |   2 +-
 .../org/apache/brooklyn/rest/api/ScriptApi.java |   2 +-
 .../org/apache/brooklyn/rest/api/SensorApi.java |   5 +-
 .../org/apache/brooklyn/rest/api/ServerApi.java |   2 +-
 .../org/apache/brooklyn/rest/api/UsageApi.java  |   2 +-
 .../apache/brooklyn/rest/api/VersionApi.java|   4 +-
 rest/rest-api/src/main/webapp/WEB-INF/web.xml   | 121 
 .../rest/domain/ApplicationSpecTest.java|   2 +-
 .../rest/domain/EffectorS

[1/2] brooklyn-ui git commit: Remove /v1 prefix from REST API

2016-02-18 Thread heneveld
Repository: brooklyn-ui
Updated Branches:
  refs/heads/master b9ba6544d -> 68fb22627


Remove /v1 prefix from REST API


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

Branch: refs/heads/master
Commit: cf1c6a7fbe9264ba44c3d518fd92427f233e6bf5
Parents: 72d57e1
Author: Svetoslav Neykov 
Authored: Mon Feb 15 17:17:19 2016 +0200
Committer: Svetoslav Neykov 
Committed: Mon Feb 15 17:17:19 2016 +0200

--
 src/test/javascript/specs/model/application-spec.js| 10 +-
 src/test/javascript/specs/model/entity-summary-spec.js |  2 +-
 src/test/javascript/specs/model/location-spec.js   |  6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cf1c6a7f/src/test/javascript/specs/model/application-spec.js
--
diff --git a/src/test/javascript/specs/model/application-spec.js 
b/src/test/javascript/specs/model/application-spec.js
index 1b76e3b..b03531d 100644
--- a/src/test/javascript/specs/model/application-spec.js
+++ b/src/test/javascript/specs/model/application-spec.js
@@ -31,7 +31,7 @@ define([
 
 it('loads all model properties defined in fixtures/application.json', 
function () {
 expect(application.get("status")).toEqual('STARTING')
-
expect(application.getLinkByName('self')).toEqual('/v1/applications/myapp')
+
expect(application.getLinkByName('self')).toEqual('/applications/myapp')
 
expect(application.getLinkByName('entities')).toEqual('fixtures/entity-summary-list.json')
 })
 
@@ -40,7 +40,7 @@ define([
 entity = new Entity.Model(applicationSpec.get("entities")[0])
 
 expect(applicationSpec.get("name")).toEqual('myapp')
-
expect(applicationSpec.get("locations")[0]).toEqual('/v1/locations/1')
+expect(applicationSpec.get("locations")[0]).toEqual('/locations/1')
 expect(entity.get("name")).toEqual('Vanilla Java App')
 })
 
@@ -55,7 +55,7 @@ define([
 
 beforeEach(function () {
 spec = new Application.Spec
-location = "/v1/locations/2"
+location = "/locations/2"
 entity = new Entity.Model({name:'test'})
 
 spec.url = 'fixtures/application-spec.json'
@@ -64,7 +64,7 @@ define([
 
 it('loads the properties from fixtures/application-spec.json', 
function () {
 expect(spec.get("name")).toEqual('myapp')
-expect(spec.get("locations")[0]).toEqual('/v1/locations/1')
+expect(spec.get("locations")[0]).toEqual('/locations/1')
 expect(spec.get("entities").length).toBe(1)
 })
 
@@ -87,7 +87,7 @@ define([
 spec.addLocation(location)
 spyOn(spec, "trigger").andCallThrough()
 
-spec.removeLocation('/v1/invalid/location')
+spec.removeLocation('/invalid/location')
 expect(spec.trigger).not.toHaveBeenCalled()
 spec.removeLocation(location)
 expect(spec.trigger).toHaveBeenCalled()

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cf1c6a7f/src/test/javascript/specs/model/entity-summary-spec.js
--
diff --git a/src/test/javascript/specs/model/entity-summary-spec.js 
b/src/test/javascript/specs/model/entity-summary-spec.js
index 230b331..a2748c8 100644
--- a/src/test/javascript/specs/model/entity-summary-spec.js
+++ b/src/test/javascript/specs/model/entity-summary-spec.js
@@ -28,7 +28,7 @@ define(
 
 it('the collection element must be of type TomcatServer and have 
expected properties', function () {
 expect(eSummary.getLinkByName('catalog'))
-
.toBe('/v1/catalog/entities/org.apache.brooklyn.entity.webapp.tomcat.TomcatServer')
+
.toBe('/catalog/entities/org.apache.brooklyn.entity.webapp.tomcat.TomcatServer')
 
expect(eSummary.get("type")).toBe('org.apache.brooklyn.entity.webapp.tomcat.TomcatServer')
 
expect(eSummary.getLinkByName('sensors')).toBe('fixtures/sensor-summary-list.json')
 expect(eSummary.getDisplayName()).toBe('TomcatServer:zQsqdXzi')

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/cf1c6a7f/src/test/javascript/specs/model/location-spec.js
--
diff --git a/src/test/javascript/specs/model/location-spec.js 
b/src/test/javascript/specs/model/location-spec.js
index f72fc8c..3294e53 100644
--- a/src/test/javascript/specs/

[22/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
new file mode 100644
index 000..72392fe
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/UsageResourceTest.java
@@ -0,0 +1,443 @@
+/*
+ * 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.resources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.location.NoMachinesAvailableException;
+import org.apache.brooklyn.core.mgmt.internal.LocalUsageManager;
+import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest;
+import 
org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.rest.domain.UsageStatistic;
+import org.apache.brooklyn.rest.domain.UsageStatistics;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+import org.apache.brooklyn.util.repeat.Repeater;
+import org.apache.brooklyn.util.time.Time;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.GenericType;
+
+public class UsageResourceTest extends BrooklynRestResourceTest {
+
+@SuppressWarnings("unused")
+private static final Logger LOG = 
LoggerFactory.getLogger(UsageResourceTest.class);
+
+private static final long TIMEOUT_MS = 10*1000;
+
+private Calendar testStartTime;
+
+private final ApplicationSpec simpleSpec = 
ApplicationSpec.builder().name("simple-app").
+entities(ImmutableSet.of(new 
org.apache.brooklyn.rest.domain.EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(.
+locations(ImmutableSet.of("localhost")).
+build();
+
+@BeforeMethod(alwaysRun=true)
+public void setUpMethod() {
+
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.APPLICATION_USAGE_KEY);
+
((ManagementContextInternal)getManagementContext()).getStorage().remove(LocalUsageManager.LOCATION_USAGE_KEY);
+testStartTime = new GregorianCalendar();
+}
+
+@Test
+public void testListApplicationUsages() throws Exception {
+// Create an app
+Calendar preStart = new GregorianCalendar();
+String appId = createApp(simpleSpec);
+Calendar postStart = new GregorianCalendar();
+
+// We will retrieve usage from one millisecond after start; this 
guarantees to not be  
+// told about both STARTING+RUNNING, which could otherwise happen if 
they are in the 
+// same milliscond.
+Calendar afterPostStart = 
Time.newCalendarFromMillisSinceEpochUtc(postStart.getTime().getTime()+1);
+
+// Check t

[28/34] brooklyn-server git commit: This closes #15

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/79b98c67/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/WebResourceUtils.java
--
diff --cc 
rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/WebResourceUtils.java
index 000,5894700..238e277
mode 00,100644..100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/WebResourceUtils.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/WebResourceUtils.java
@@@ -1,0 -1,197 +1,231 @@@
+ /*
+  * 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.util;
+ 
+ import java.io.IOException;
+ import java.util.Map;
+ 
+ import javax.servlet.ServletContext;
+ import javax.servlet.http.HttpServletResponse;
+ import javax.ws.rs.WebApplicationException;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.Response;
+ 
 -import org.slf4j.Logger;
 -import org.slf4j.LoggerFactory;
+ import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
+ import org.apache.brooklyn.rest.domain.ApiError;
+ import org.apache.brooklyn.rest.util.json.BrooklynJacksonJsonProvider;
+ import org.apache.brooklyn.util.exceptions.Exceptions;
++import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
+ import org.apache.brooklyn.util.net.Urls;
+ import org.apache.brooklyn.util.text.StringEscapes.JavaStringEscapes;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
+ 
+ import com.fasterxml.jackson.databind.ObjectMapper;
+ import com.google.common.collect.ImmutableMap;
+ import javax.ws.rs.core.UriBuilder;
+ 
+ public class WebResourceUtils {
+ 
+ private static final Logger log = 
LoggerFactory.getLogger(WebResourceUtils.class);
+ 
+ /** @throws WebApplicationException with an ApiError as its body and the 
given status as its response code. */
+ public static WebApplicationException 
throwWebApplicationException(Response.Status status, String format, Object... 
args) {
 -String msg = String.format(format, args);
++return throwWebApplicationException(status, null, format, args);
++}
++
++/** @throws WebApplicationException with an ApiError as its body and the 
given status as its response code. */
++public static WebApplicationException 
throwWebApplicationException(Response.Status status, Throwable exception) {
++return throwWebApplicationException(status, exception, null);
++}
++
++/** @throws WebApplicationException with an ApiError as its body and the 
given status as its response code.
++ * Exception and/or format can be null, and will be filled in / prefixed 
as appropriate. */
++public static WebApplicationException 
throwWebApplicationException(Response.Status status, Throwable exception, 
String format, Object... args) {
++String suppliedMsg = format==null ? null : String.format(format, 
args);
++String fullMsg = suppliedMsg;
++if (exception!=null) {
++if (fullMsg==null) fullMsg = Exceptions.collapseText(exception);
++else fullMsg = suppliedMsg + ": 
"+Exceptions.collapseText(exception);
++}
+ if (log.isDebugEnabled()) {
+ log.debug("responding {} {} ({})",
 -new Object[]{status.getStatusCode(), 
status.getReasonPhrase(), msg});
++new Object[]{status.getStatusCode(), 
status.getReasonPhrase(), fullMsg});
+ }
 -ApiError apiError = 
ApiError.builder().message(msg).errorCode(status).build();
++ApiError apiError = 
++(exception != null ? 
ApiError.builderFromThrowable(exception).prefixMessage(suppliedMsg) 
++: ApiError.builder().message(fullMsg==null ? "" : fullMsg))
++.errorCode(status).build();
+ // including a Throwable is the only way to include a message with 
the WebApplicationException - ugly!
 -throw new WebApplicationException(new Throwable(apiError.toString()), 
apiError.asJsonResponse());
++throw new WebApplicationException(
++exception==null ? new Throwable(apiError.toString()) :
++supplie

[23/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/EntityConfigResourceTest.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/EntityConfigResourceTest.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/EntityConfigResourceTest.java
new file mode 100644
index 000..014053f
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/resources/EntityConfigResourceTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.resources;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.core.entity.EntityInternal;
+import org.apache.brooklyn.core.entity.EntityPredicates;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.EntityConfigSummary;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+import org.apache.brooklyn.util.collections.MutableMap;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.GenericType;
+
+@Test(singleThreaded = true)
+public class EntityConfigResourceTest extends BrooklynRestResourceTest {
+
+private final static Logger log = 
LoggerFactory.getLogger(EntityConfigResourceTest.class);
+private URI applicationUri;
+private EntityInternal entity;
+
+@BeforeClass(alwaysRun = true)
+@Override
+public void setUp() throws Exception {
+super.setUp(); // We require that the superclass setup is done first, 
as we will be calling out to Jersey
+
+// Deploy an application that we'll use to read the configuration of
+final ApplicationSpec simpleSpec = 
ApplicationSpec.builder().name("simple-app").
+  entities(ImmutableSet.of(new EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(), ImmutableMap.of("install.version", 
"1.0.0".
+  locations(ImmutableSet.of("localhost")).
+  build();
+
+ClientResponse response = clientDeploy(simpleSpec);
+int status = response.getStatus();
+assertTrue(status >= 200 && status <= 299, "expected HTTP Response of 
2xx but got " + status);
+applicationUri = response.getLocation();
+log.debug("Built app: application");
+waitForApplicationToBeRunning(applicationUri);
+
+entity = (EntityInternal) 
Iterables.find(getManagementContext().getEntityManager().getEntities(), 
EntityPredicates.displayNameEqualTo("simple-ent"));
+}
+
+@Test
+public void testList() throws Exception {
+List entityConfigSummaries = client().resource(
+
URI.create("/v1/applications/simple-app/entities/simple-ent/config"))
+.get(new GenericType>() {
+});
+
+// Default entities have over a dozen config entries, but it's 
unnecessary to test them all; just pick one
+// representative config key
+Optional configKeyOptional = 
Iterables.tryFind(entityConfigSummaries, new Predicate() {
+@Override
+public boolean apply(@Nullable EntityConfigSummary input) {
+return input != null && 
"install.version".equals(input.getNa

[25/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/HaMasterCheckFilterTest.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/HaMasterCheckFilterTest.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/HaMasterCheckFilterTest.java
new file mode 100644
index 000..424c0c1
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/HaMasterCheckFilterTest.java
@@ -0,0 +1,218 @@
+/*
+ * 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;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+import java.net.URI;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.mgmt.EntityManager;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
+import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherNoServer;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.eclipse.jetty.server.Server;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.http.HttpTool;
+import org.apache.brooklyn.util.http.HttpToolResponse;
+import org.apache.brooklyn.util.os.Os;
+import org.apache.brooklyn.util.time.Duration;
+
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+
+public class HaMasterCheckFilterTest extends 
BrooklynRestApiLauncherTestFixture {
+private static final Duration TIMEOUT = Duration.THIRTY_SECONDS;
+
+private File mementoDir;
+private ManagementContext writeMgmt;
+private ManagementContext readMgmt;
+private String appId;
+private Server server;
+private HttpClient client;
+
+@AfterMethod(alwaysRun=true)
+public void tearDown() throws Exception {
+System.err.println("TEAR DOWN");
+server.stop();
+Entities.destroyAll(writeMgmt);
+Entities.destroyAll(readMgmt);
+Os.deleteRecursively(mementoDir);
+}
+
+@Test(groups = "Integration")
+public void testEntitiesExistOnDisabledHA() throws Exception {
+initHaCluster(HighAvailabilityMode.DISABLED, 
HighAvailabilityMode.DISABLED);
+assertReadIsMaster();
+assertEntityExists(new ReturnCodeCheck());
+}
+
+@Test(groups = "Integration")
+public void testEntitiesExistOnMasterPromotion() throws Exception {
+initHaCluster(HighAvailabilityMode.AUTO, HighAvailabilityMode.AUTO);
+stopWriteNode();
+assertEntityExists(new ReturnCodeCheck());
+assertReadIsMaster();
+}
+
+@Test(groups = "Integration")
+public void testEntitiesExistOnHotStandbyAndPromotion() throws Exception {
+initHaCluster(HighAvailabilityMode.AUTO, 
HighAvailabilityMode.HOT_STANDBY);
+assertEntityExists(new ReturnCodeCheck());
+stopWriteNode();
+assertEntityExists(new ReturnCodeAndNodeState());
+assertReadIsMaster();
+}
+
+@Test(groups = "Integration")
+public void testEntitiesExistOnHotBackup() throws Exception {
+initHaCluster(HighAvailabilityMode.AUTO, 
HighAvailabilityMode.HOT_BACKUP);
+Asserts.continually(
+ImmutableMap.of(
+"timeout", Duration.THIRTY_SECONDS,
+"period", Duration.ZERO),
+new ReturnCodeSupplier(),
+Predicates.or(Predicates.equalTo(200), 
Predicates.equalTo(403)));
+}
+
+private HttpClient g

[03/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
--
diff --git 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
 
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
deleted file mode 100644
index 1c091da..000
--- 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/resources/EntityResourceTest.java
+++ /dev/null
@@ -1,189 +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.rest.resources;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.entity.stock.BasicApplication;
-import org.apache.brooklyn.rest.domain.ApplicationSpec;
-import org.apache.brooklyn.rest.domain.EntitySpec;
-import org.apache.brooklyn.rest.domain.TaskSummary;
-import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
-import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.http.HttpAsserts;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.sun.jersey.api.client.ClientResponse;
-
-@Test(singleThreaded = true)
-public class EntityResourceTest extends BrooklynRestResourceTest {
-
-private static final Logger log = 
LoggerFactory.getLogger(EntityResourceTest.class);
-
-private final ApplicationSpec simpleSpec = ApplicationSpec.builder()
-.name("simple-app")
-.entities(ImmutableSet.of(new EntitySpec("simple-ent", 
RestMockSimpleEntity.class.getName(
-.locations(ImmutableSet.of("localhost"))
-.build();
-
-private EntityInternal entity;
-
-private static final String entityEndpoint = 
"/v1/applications/simple-app/entities/simple-ent";
-
-@BeforeClass(alwaysRun = true)
-@Override
-public void setUp() throws Exception {
-super.setUp();
-
-// Deploy application
-ClientResponse deploy = clientDeploy(simpleSpec);
-waitForApplicationToBeRunning(deploy.getLocation());
-
-// Add tag
-entity = (EntityInternal) 
Iterables.find(getManagementContext().getEntityManager().getEntities(), new 
Predicate() {
-@Override
-public boolean apply(@Nullable Entity input) {
-return 
"RestMockSimpleEntity".equals(input.getEntityType().getSimpleName());
-}
-});
-}
-
-@Test
-public void testTagsSanity() throws Exception {
-entity.tags().addTag("foo");
-
-ClientResponse response = client().resource(entityEndpoint + "/tags")
-.accept(MediaType.APPLICATION_JSON_TYPE)
-.get(ClientResponse.class);
-String data = response.getEntity(String.class);
-
-try {
-List tags = new ObjectMapper().readValue(data, new 
TypeReference>() {});
-Assert.assertTrue(tags.contains("foo"));
-Assert.assertFalse(tags.contains("bar"));
-} catch (Exception e) {
-Exceptions.propagateIfFatal(e);
-throw new IllegalStateException("Error with deserialization of 
tags list: "+e+"\n"+data, e);
-}
-}
-
-@Test
-public void testRename() throws Exception {
-try {
-ClientResponse response = clien

[06/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
deleted file mode 100644
index 829b7cb..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
+++ /dev/null
@@ -1,608 +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.rest.util;
-
-import static com.google.common.collect.Iterables.transform;
-import static org.apache.brooklyn.rest.util.WebResourceUtils.notFound;
-
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.concurrent.Future;
-
-import javax.ws.rs.core.MediaType;
-
-import org.apache.brooklyn.api.catalog.BrooklynCatalog;
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationRegistry;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.api.policy.Policy;
-import org.apache.brooklyn.api.typereg.RegisteredType;
-import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
-import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
-import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent.Scope;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.catalog.CatalogPredicates;
-import org.apache.brooklyn.core.catalog.internal.CatalogItemComparator;
-import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
-import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
-import 
org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
-import org.apache.brooklyn.core.objs.BrooklynTypes;
-import org.apache.brooklyn.core.typereg.RegisteredTypes;
-import org.apache.brooklyn.enricher.stock.Enrichers;
-import org.apache.brooklyn.entity.stock.BasicApplication;
-import org.apache.brooklyn.rest.domain.ApplicationSpec;
-import org.apache.brooklyn.rest.domain.EntitySpec;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.collections.MutableSet;
-import org.apache.brooklyn.util.core.flags.TypeCoercions;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.javalang.Reflections;
-import org.apache.brooklyn.util.net.Urls;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Files;
-
-public class BrooklynRestResourceUtils {
-
-private static final Logger log = 
LoggerFactory.getLogger(BrooklynRestResourceUtils.class);
-
-private final ManagementContext mgmt;
-
-public BrooklynRestResourceUtils(ManagementContext mgmt) {
-Preconditions.checkNotNull(mgmt, "mgmt");
-this.mgmt = mgmt;
-}
-
-public BrooklynCatalog getCatalog() {
-return mgmt.getCatalog();
-}
-
-public ClassLoade

[19/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-api/src/main/webapp/WEB-INF/web.xml
--
diff --git a/rest/rest-api/src/main/webapp/WEB-INF/web.xml 
b/rest/rest-api/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index bab259b..000
--- a/rest/rest-api/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-http://java.sun.com/dtd/web-app_2_3.dtd"; >
-
-
-Brooklyn REST API v1
-
-
-Brooklyn Request Tagging Filter
-
org.apache.brooklyn.rest.filter.RequestTaggingFilter
-
-
-Brooklyn Request Tagging Filter
-/*
-
-
-
-Brooklyn Properties Authentication Filter
-
org.apache.brooklyn.rest.filter.BrooklynPropertiesSecurityFilter
-
-
-Brooklyn Properties Authentication Filter
-/*
-
-
-
-Brooklyn Logging Filter
-
org.apache.brooklyn.rest.filter.LoggingFilter
-
-
-Brooklyn Logging Filter
-/*
-
-
-
-Brooklyn HA Master Filter
-
org.apache.brooklyn.rest.filter.HaMasterCheckFilter
-
-
-Brooklyn HA Master Filter
-/*
-
-
-Brooklyn Swagger Bootstrap
-
org.apache.brooklyn.rest.filter.SwaggerFilter
-
-
-Brooklyn Swagger Bootstrap
-/*
-
-
-
-
-Brooklyn REST API v1 Filter
-
com.sun.jersey.spi.container.servlet.ServletContainer
-
-
-
-com.sun.jersey.config.property.packages
-
io.swagger.jaxrs.listing;com.fasterxml.jackson.jaxrs;org.apache.brooklyn.rest.resources;org.apache.brooklyn.rest.util
-
-
-
-  
-com.sun.jersey.config.property.classnames
-
com.fasterxml.jackson.jaxrs.JacksonJsonProvider
-
-
-com.sun.jersey.api.json.POJOMappingFeature
-true
-
-
- 
-
-com.sun.jersey.config.feature.DisableWADL
-true
-
-
-
-
-Brooklyn REST API v1 Filter
-/*
-
-
-
-

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
--
diff --git 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
 
b/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
index b2690d6..82bbb43 100644
--- 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
+++ 
b/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
@@ -33,7 +33,7 @@ public class ApplicationSpecTest extends AbstractDomainTest {
 EntitySpec entitySpec = new EntitySpec("Vanilla Java App", 
"org.apache.brooklyn.entity.java.VanillaJavaApp",
 ImmutableMap.of("initialSize", "1", "creationScriptUrl", 
"http://my.brooklyn.io/storage/foo.sql";));
 return ApplicationSpec.builder().name("myapp")
-
.entities(ImmutableSet.of(entitySpec)).locations(ImmutableSet.of("/v1/locations/1"))
+
.entities(ImmutableSet.of(entitySpec)).locations(ImmutableSet.of("/locations/1"))
 .build();
 }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EffectorSummaryTest.java
--
diff --git 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EffectorSummaryTest.java
 
b/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EffectorSummaryTest.java
index 71cb64d..f71399c 100644
--- 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EffectorSummaryTest.java
+++ 
b/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EffectorSummaryTest.java
@@ -38,7 +38,7 @@ public class EffectorSummaryTest extends AbstractDomainTest {
 ImmutableSet.>of(),
 "Effector description",
 ImmutableMap.of(
-"self", 
URI.create("/v1/applications/redis-app/entities/redis-ent/effectors/stop")));
+"self", 
URI.create("/applications/redis-app/entities/redis-ent/effectors/stop")));
 }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySummaryTest.java
--
diff --git 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySummaryTest.java
 
b/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySummaryTest.java
index 2d39cc9..6eb38c8 100644
--- 
a/rest/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySummaryTest.java
+++ 
b/res

[34/34] brooklyn-server git commit: Merge remote-tracking branch 'apache-git/master' into osgi

2016-02-18 Thread heneveld
Merge remote-tracking branch 'apache-git/master' into osgi


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

Branch: refs/heads/master
Commit: fa19e8f5f6c4bfe2967b87d5e0f3efcbcc1f8304
Parents: bdd502f a2820e5
Author: Alex Heneveld 
Authored: Thu Feb 18 15:45:02 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 15:45:02 2016 +

--
 .../spi/dsl/methods/BrooklynDslCommon.java  | 73 
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 56 +++
 2 files changed, 129 insertions(+)
--




[21/34] brooklyn-server git commit: REST API optional Jersey compatibility

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
new file mode 100644
index 000..f0c65e4
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/EntityLocationUtilsTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.util;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.location.AbstractLocation;
+import org.apache.brooklyn.core.location.geo.HostGeoInfo;
+import org.apache.brooklyn.core.location.internal.LocationInternal;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+
+import com.google.common.collect.ImmutableList;
+
+public class EntityLocationUtilsTest extends BrooklynAppUnitTestSupport {
+
+private static final Logger log = 
LoggerFactory.getLogger(EntityLocationUtilsTest.class);
+
+private Location loc;
+
+@BeforeMethod(alwaysRun=true)
+@Override
+public void setUp() throws Exception {
+super.setUp();
+loc = mgmt.getLocationRegistry().resolve("localhost");
+((AbstractLocation)loc).setHostGeoInfo(new HostGeoInfo("localhost", 
"localhost", 50, 0));
+}
+
+@Test
+public void testCount() {
+@SuppressWarnings("unused")
+SoftwareProcess r1 = 
app.createAndManageChild(EntitySpec.create(SoftwareProcess.class, 
RestMockSimpleEntity.class));
+SoftwareProcess r2 = 
app.createAndManageChild(EntitySpec.create(SoftwareProcess.class, 
RestMockSimpleEntity.class));
+Entities.start(app, Arrays.asList(loc));
+
+Entities.dumpInfo(app);
+
+log.info("r2loc: "+r2.getLocations());
+log.info("props: 
"+((LocationInternal)r2.getLocations().iterator().next()).config().getBag().getAllConfig());
+
+Map counts = new 
EntityLocationUtils(mgmt).countLeafEntitiesByLocatedLocations();
+log.info("count: "+counts);
+assertEquals(ImmutableList.copyOf(counts.values()), 
ImmutableList.of(2), "counts="+counts);
+}
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
--
diff --git 
a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
new file mode 100644
index 000..80e9c46
--- /dev/null
+++ 
b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/util/HaHotStateCheckClassResource.java
@@ -0,0 +1,38 @@
+/*
+ * 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

[07/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
deleted file mode 100644
index d3636e9..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
+++ /dev/null
@@ -1,132 +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.rest.security.provider;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.InitialDirContext;
-import javax.servlet.http.HttpSession;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.CharMatcher;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.config.StringConfigMap;
-import org.apache.brooklyn.rest.BrooklynWebConfig;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Strings;
-
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A {@link SecurityProvider} implementation that relies on LDAP to 
authenticate.
- *
- * @author Peter Veentjer.
- */
-public class LdapSecurityProvider extends AbstractSecurityProvider implements 
SecurityProvider {
-
-public static final Logger LOG = 
LoggerFactory.getLogger(LdapSecurityProvider.class);
-
-public static final String LDAP_CONTEXT_FACTORY = 
"com.sun.jndi.ldap.LdapCtxFactory";
-
-private final String ldapUrl;
-private final String ldapRealm;
-private final String organizationUnit;
-
-public LdapSecurityProvider(ManagementContext mgmt) {
-StringConfigMap properties = mgmt.getConfig();
-ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL);
-Strings.checkNonEmpty(ldapUrl, "LDAP security provider configuration 
missing required property "+BrooklynWebConfig.LDAP_URL);
-ldapRealm = 
CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_REALM));
-Strings.checkNonEmpty(ldapRealm, "LDAP security provider configuration 
missing required property "+BrooklynWebConfig.LDAP_REALM);
-
-if(Strings.isBlank(properties.getConfig(BrooklynWebConfig.LDAP_OU))) {
-LOG.info("Setting LDAP ou attribute to: Users");
-organizationUnit = "Users";
-} else {
-organizationUnit = 
CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_OU));
-}
-Strings.checkNonEmpty(ldapRealm, "LDAP security provider configuration 
missing required property "+BrooklynWebConfig.LDAP_OU);
-}
-
-public LdapSecurityProvider(String ldapUrl, String ldapRealm, String 
organizationUnit) {
-this.ldapUrl = ldapUrl;
-this.ldapRealm = ldapRealm;
-this.organizationUnit = organizationUnit;
-}
-
-@SuppressWarnings({ "rawtypes", "unchecked" })
-@Override
-public boolean authenticate(HttpSession session, String user, String 
password) {
-if (session==null || user==null) return false;
-checkCanLoad();
-
-Hashtable env = new Hashtable();
-env.put(Context.INITIAL_CONTEXT_FACTORY, 
"com.sun.jndi.ldap.LdapCtxFactory");
-env.put(Context.PROVIDER_URL, ldapUrl);
-env.put(Context.SECURITY_AUTHENTICATION, "simple");
-env.put(Context.SECURITY_PRINCIPAL, getUserDN(user));
-env.put(Context.SECURITY_CREDENTIALS, password);
-
-try {
-new InitialDirContext(env);
-return allow(session, user);
-} catch (NamingException e) {
-return false;
-}
-}
-
-/**
- * Returns the LDAP path for the user
- *
- * @param user
- * @return String
- */
-protected String getUserDN(S

[09/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
--
diff --git 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
 
b/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
deleted file mode 100644
index 1dbf1a8..000
--- 
a/rest/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
+++ /dev/null
@@ -1,449 +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.rest.resources;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.api.objs.BrooklynObject;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.api.sensor.Sensor;
-import org.apache.brooklyn.api.typereg.RegisteredType;
-import org.apache.brooklyn.core.config.ConstraintViolationException;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.EntityPredicates;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.mgmt.EntityManagementUtils;
-import org.apache.brooklyn.core.mgmt.EntityManagementUtils.CreationResult;
-import org.apache.brooklyn.core.mgmt.entitlement.EntitlementPredicates;
-import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
-import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.EntityAndItem;
-import 
org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.core.typereg.RegisteredTypeLoadingContexts;
-import org.apache.brooklyn.core.typereg.RegisteredTypes;
-import org.apache.brooklyn.entity.group.AbstractGroup;
-import org.apache.brooklyn.rest.api.ApplicationApi;
-import org.apache.brooklyn.rest.domain.ApplicationSpec;
-import org.apache.brooklyn.rest.domain.ApplicationSummary;
-import org.apache.brooklyn.rest.domain.EntityDetail;
-import org.apache.brooklyn.rest.domain.EntitySummary;
-import org.apache.brooklyn.rest.domain.TaskSummary;
-import org.apache.brooklyn.rest.filter.HaHotStateRequired;
-import org.apache.brooklyn.rest.transform.ApplicationTransformer;
-import org.apache.brooklyn.rest.transform.EntityTransformer;
-import org.apache.brooklyn.rest.transform.TaskTransformer;
-import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
-import org.apache.brooklyn.rest.util.WebResourceUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.UserFacingException;
-import org.apache.brooklyn.util.guava.Maybe;
-import org.apache.brooklyn.util.javalang.JavaClassNames;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.ACCEPTED;
-import static javax.ws.rs.core.Response.created;
-import static javax.ws.rs.core.Response.status;
-
-@HaHotStateRequired
-public class ApplicationResource extends AbstractBrooklynRestResource 
impl

[32/34] brooklyn-server git commit: clarify when /v1/ is or is not required, fixing many integration tests

2016-02-18 Thread heneveld
clarify when /v1/ is or is not required, fixing many integration tests

and remove warnings


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/96d804a7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/96d804a7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/96d804a7

Branch: refs/heads/master
Commit: 96d804a75a660a618e0083fe1863006056406703
Parents: 3ab0040
Author: Alex Heneveld 
Authored: Thu Feb 18 13:40:15 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 13:40:15 2016 +

--
 .../rest/transform/CatalogTransformer.java  |  5 ++
 .../util/json/BrooklynJacksonJsonProvider.java  |  2 +-
 .../json/ConfigurableSerializerProvider.java|  1 +
 .../rest/resources/ApplicationResourceTest.java |  4 +-
 .../SensorResourceIntegrationTest.java  |  6 +--
 .../rest/resources/ServerShutdownTest.java  |  2 +-
 .../brooklynnode/DeployBlueprintTest.java   |  8 +--
 .../rest/testing/mocks/RestMockAppBuilder.java  |  1 +
 .../testing/mocks/RestMockSimpleEntity.java |  8 +--
 .../BrooklynPropertiesSecurityFilterTest.java   | 12 ++---
 .../rest/BrooklynRestApiLauncherTest.java   |  8 +--
 .../BrooklynRestApiLauncherTestFixture.java | 19 ++--
 .../brooklyn/rest/HaMasterCheckFilterTest.java  | 51 ++--
 .../AbstractRestApiEntitlementsTest.java|  8 +--
 .../ServerResourceIntegrationTest.java  |  8 +--
 .../java/org/apache/brooklyn/test/Asserts.java  |  4 +-
 16 files changed, 84 insertions(+), 63 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/96d804a7/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
index e584a9a..7e0d8bc 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
@@ -56,14 +56,19 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
+
 import javax.ws.rs.core.UriBuilder;
+
 import org.apache.brooklyn.rest.api.CatalogApi;
+
 import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
 
+@SuppressWarnings("deprecation")
 public class CatalogTransformer {
 
 private static final org.slf4j.Logger log = 
LoggerFactory.getLogger(CatalogTransformer.class);
 
+@SuppressWarnings({ "unchecked", "rawtypes" })
 public static  CatalogEntitySummary 
catalogEntitySummary(BrooklynRestResourceUtils b, CatalogItem> item, UriBuilder ub) {
 Set config = Sets.newLinkedHashSet();
 Set sensors = 
Sets.newTreeSet(SummaryComparators.nameComparator());

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/96d804a7/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
index 9c6704d..7083eb6 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
@@ -158,7 +158,7 @@ public class BrooklynJacksonJsonProvider extends 
JacksonJsonProvider implements
 mapper.setSerializerProvider(sp);
 mapper.setVisibilityChecker(new 
PossiblyStrictPreferringFieldsVisibilityChecker());
 
-SimpleModule mapperModule = new SimpleModule("Brooklyn", new 
Version(0, 0, 0, "ignored"));
+SimpleModule mapperModule = new SimpleModule("Brooklyn", new 
Version(0, 0, 0, "ignored", null, null));
 
 new 
BidiSerialization.ManagementContextSerialization(mgmt).install(mapperModule);
 new BidiSerialization.EntitySerialization(mgmt).install(mapperModule);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/96d804a7/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ConfigurableSerializerProvider.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/ConfigurableSerializerProvider.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/

[01/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
Repository: brooklyn-server
Updated Branches:
  refs/heads/master a2820e5f6 -> fa19e8f5f


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
--
diff --git 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
 
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
deleted file mode 100644
index 7a24f31..000
--- 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullHttpServletRequestProvider.java
+++ /dev/null
@@ -1,46 +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.rest.util;
-
-import java.lang.reflect.Type;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.ext.Provider;
-
-import com.sun.jersey.core.spi.component.ComponentContext;
-import com.sun.jersey.core.spi.component.ComponentScope;
-import com.sun.jersey.spi.inject.Injectable;
-import com.sun.jersey.spi.inject.InjectableProvider;
-
-@Provider
-public class NullHttpServletRequestProvider implements 
InjectableProvider { 
-public Injectable getInjectable(ComponentContext ic, 
-Context a, Type c) { 
-if (HttpServletRequest.class == c) { 
-return new Injectable() {
-public HttpServletRequest getValue() { return null; }
-}; 
-} else 
-return null; 
-} 
-public ComponentScope getScope() { 
-return ComponentScope.Singleton; 
-} 
-} 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
--
diff --git 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
 
b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
deleted file mode 100644
index 106780d..000
--- 
a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/util/NullServletConfigProvider.java
+++ /dev/null
@@ -1,51 +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.rest.util;
-
-import java.lang.reflect.Type;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.ext.Provider;
-
-import com.sun.jersey.core.spi.component.ComponentContext;
-import com.sun.jersey.core.spi.component.ComponentScope;
-import com.sun.jersey.spi.container.servlet.WebConfig;
-import com.sun.jersey.spi.inject.Injectable;
-import com.sun.jersey.spi.inject.InjectableProvider;
-
-@Provider
-public class NullServletConfigProvider implements InjectableProvider { 
-public Injectable getInjectable(ComponentContext ic, 
-Context a, Type c) { 
-if (ServletContext.class == c) { 
-return new Injectable() {
-public ServletContext getValue() { return null; }
-}; 
-} else if (WebConfig.class == c) {
-return new Injectable() {
-public ServletContext getValue() { return null; }
-}; 
-} else 
-return null; 
-} 
-public ComponentScope getScope() { 
-return Componen

[13/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
--
diff --git 
a/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
new file mode 100644
index 000..6091096
--- /dev/null
+++ 
b/rest/rest-resources/src/test/java/org/apache/brooklyn/rest/resources/ApplicationResourceTest.java
@@ -0,0 +1,697 @@
+/*
+ * 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.resources;
+
+import static com.google.common.collect.Iterables.find;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeoutException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityFunctions;
+import org.apache.brooklyn.core.entity.EntityPredicates;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.location.AbstractLocation;
+import org.apache.brooklyn.core.location.LocationConfigKeys;
+import org.apache.brooklyn.core.location.geo.HostGeoInfo;
+import org.apache.brooklyn.core.location.internal.LocationInternal;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.brooklyn.entity.stock.BasicEntity;
+import org.apache.brooklyn.rest.domain.ApiError;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.CatalogEntitySummary;
+import org.apache.brooklyn.rest.domain.CatalogItemSummary;
+import org.apache.brooklyn.rest.domain.EffectorSummary;
+import org.apache.brooklyn.rest.domain.EntityConfigSummary;
+import org.apache.brooklyn.rest.domain.EntitySpec;
+import org.apache.brooklyn.rest.domain.EntitySummary;
+import org.apache.brooklyn.rest.domain.PolicySummary;
+import org.apache.brooklyn.rest.domain.SensorSummary;
+import org.apache.brooklyn.rest.domain.Status;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
+import org.apache.brooklyn.rest.testing.mocks.CapitalizePolicy;
+import org.apache.brooklyn.rest.testing.mocks.NameMatcherGroup;
+import org.apache.brooklyn.rest.testing.mocks.RestMockApp;
+import org.apache.brooklyn.rest.testing.mocks.RestMockAppBuilder;
+import org.apache.brooklyn.rest.testing.mocks.RestMockSimpleEntity;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.collections.CollectionFunctionals;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.http.HttpAsserts;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.brooklyn.util.time.Duration;
+import org.apache.http.HttpHeaders;
+import org.apache.http.entity.ContentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import org.apache.cxf.jaxrs.client.WebClient;
+
+@Test(singleThreaded = true,
+// by using a different suite name we disallow interleaving other 
tests between the methods of this test class, which wrecks the te

[18/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
new file mode 100644
index 000..986855e
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
@@ -0,0 +1,451 @@
+/*
+ * 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.resources;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.ws.rs.core.Response.created;
+import static javax.ws.rs.core.Response.status;
+import static javax.ws.rs.core.Response.Status.ACCEPTED;
+import static 
org.apache.brooklyn.rest.util.WebResourceUtils.serviceAbsoluteUriBuilder;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.entity.Group;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.objs.BrooklynObject;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.api.sensor.Sensor;
+import org.apache.brooklyn.api.typereg.RegisteredType;
+import org.apache.brooklyn.core.config.ConstraintViolationException;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.EntityPredicates;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.mgmt.EntityManagementUtils;
+import org.apache.brooklyn.core.mgmt.EntityManagementUtils.CreationResult;
+import org.apache.brooklyn.core.mgmt.entitlement.EntitlementPredicates;
+import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.EntityAndItem;
+import 
org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.typereg.RegisteredTypeLoadingContexts;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.entity.group.AbstractGroup;
+import org.apache.brooklyn.rest.api.ApplicationApi;
+import org.apache.brooklyn.rest.domain.ApplicationSpec;
+import org.apache.brooklyn.rest.domain.ApplicationSummary;
+import org.apache.brooklyn.rest.domain.EntityDetail;
+import org.apache.brooklyn.rest.domain.EntitySummary;
+import org.apache.brooklyn.rest.domain.TaskSummary;
+import org.apache.brooklyn.rest.filter.HaHotStateRequired;
+import org.apache.brooklyn.rest.transform.ApplicationTransformer;
+import org.apache.brooklyn.rest.transform.EntityTransformer;
+import org.apache.brooklyn.rest.transform.TaskTransformer;
+import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
+import org.apache.brooklyn.rest.util.WebResourceUtils;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.exceptions.UserFacingException;
+import org.apache.brooklyn.util.guava.Maybe;
+import org.apache.brooklyn.util.javalang.JavaClassNames;
+import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.List

[16/34] brooklyn-server git commit: [BROOKLYN-183] REST API using CXF JAX-RS 2.0 implementation

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6f624c78/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/ExplicitUsersSecurityProvider.java
--
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/ExplicitUsersSecurityProvider.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/ExplicitUsersSecurityProvider.java
new file mode 100644
index 000..a0795cb
--- /dev/null
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/ExplicitUsersSecurityProvider.java
@@ -0,0 +1,117 @@
+/*
+ * 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.security.provider;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.config.StringConfigMap;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.rest.BrooklynWebConfig;
+import org.apache.brooklyn.rest.security.PasswordHasher;
+
+/**
+ * Security provider which validates users against passwords according to 
property keys,
+ * as set in {@link BrooklynWebConfig#USERS} and {@link 
BrooklynWebConfig#PASSWORD_FOR_USER(String)}
+ */
+public class ExplicitUsersSecurityProvider extends AbstractSecurityProvider 
implements SecurityProvider {
+
+public static final Logger LOG = 
LoggerFactory.getLogger(ExplicitUsersSecurityProvider.class);
+
+protected final ManagementContext mgmt;
+private boolean allowAnyUserWithValidPass;
+private Set allowedUsers = null;
+
+public ExplicitUsersSecurityProvider(ManagementContext mgmt) {
+this.mgmt = mgmt;
+initialize();
+}
+
+private synchronized void initialize() {
+if (allowedUsers != null) return;
+
+StringConfigMap properties = mgmt.getConfig();
+
+allowedUsers = new LinkedHashSet();
+String users = properties.getConfig(BrooklynWebConfig.USERS);
+if (users == null) {
+LOG.warn("REST has no users configured; no one will be able to log 
in!");
+} else if ("*".equals(users)) {
+LOG.info("REST allowing any user (so long as valid password is 
set)");
+allowAnyUserWithValidPass = true;
+} else {
+StringTokenizer t = new StringTokenizer(users, ",");
+while (t.hasMoreElements()) {
+allowedUsers.add(("" + t.nextElement()).trim());
+}
+LOG.info("REST allowing users: " + allowedUsers);
+}
+}
+
+@Override
+public boolean authenticate(HttpSession session, String user, String 
password) {
+if (session==null || user==null) return false;
+
+if (!allowAnyUserWithValidPass) {
+if (!allowedUsers.contains(user)) {
+LOG.debug("REST rejecting unknown user "+user);
+return false;
+}
+}
+
+if (checkExplicitUserPassword(mgmt, user, password)) {
+return allow(session, user);
+}
+return false;
+}
+
+/** checks the supplied candidate user and password against the
+ * expect password (or SHA-256 + SALT thereof) defined as brooklyn 
properties.
+ */
+public static boolean checkExplicitUserPassword(ManagementContext mgmt, 
String user, String password) {
+BrooklynProperties properties = (BrooklynProperties) mgmt.getConfig();
+String expectedPassword = 
properties.getConfig(BrooklynWebConfig.PASSWORD_FOR_USER(user));
+String salt = 
properties.getConfig(BrooklynWebConfig.SALT_FOR_USER(user));
+String expectedSha256 = 
properties.getConfig(BrooklynWebConfig.SHA256_FOR_USER(user));
+
+return checkPassword(password, expectedPassword, expectedSha256, salt);
+}
+/** 
+ * checks a candidate password against the expected credential defined for 
a given user.
+ * the expected credential

[04/27] brooklyn-ui git commit: can go from catalog item to open in composer

2016-02-18 Thread heneveld
can go from catalog item to open in composer


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/0554b079
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/0554b079
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/0554b079

Branch: refs/heads/master
Commit: 0554b0796f9886d99f50a98ef8246d8e5c8a3e55
Parents: f49de1c
Author: Alex Heneveld 
Authored: Thu Feb 11 03:05:41 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 src/main/webapp/assets/js/view/catalog.js  | 6 ++
 src/main/webapp/assets/tpl/catalog/details-entity.html | 1 +
 2 files changed, 7 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/0554b079/src/main/webapp/assets/js/view/catalog.js
--
diff --git a/src/main/webapp/assets/js/view/catalog.js 
b/src/main/webapp/assets/js/view/catalog.js
index eb9effd..5c3e2ce 100644
--- a/src/main/webapp/assets/js/view/catalog.js
+++ b/src/main/webapp/assets/js/view/catalog.js
@@ -43,6 +43,7 @@ define([
 var CatalogItemDetailsView = Backbone.View.extend({
 
 events: {
+"click .composer": "composeItem",
 "click .delete": "deleteItem"
 },
 
@@ -109,6 +110,11 @@ define([
 return this;
 },
 
+composeItem: function(event) {
+// TODO could make this a catalog item
+Backbone.history.navigate("/v1/editor/app/"+ 
encodeURIComponent($(event.currentTarget).data("name")),
+{trigger: true});
+},
 deleteItem: function(event) {
 // Could use wait flag to block removal of model from collection
 // until server confirms deletion and success handler to perform

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/0554b079/src/main/webapp/assets/tpl/catalog/details-entity.html
--
diff --git a/src/main/webapp/assets/tpl/catalog/details-entity.html 
b/src/main/webapp/assets/tpl/catalog/details-entity.html
index 2e43fe5..02f3fe9 100644
--- a/src/main/webapp/assets/tpl/catalog/details-entity.html
+++ b/src/main/webapp/assets/tpl/catalog/details-entity.html
@@ -20,6 +20,7 @@ under the License.
 
 
 
+Open in 
Composer
 Delete
 
 



[02/27] brooklyn-ui git commit: a bunch more buttons for the composer

2016-02-18 Thread heneveld
a bunch more buttons for the composer


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

Branch: refs/heads/master
Commit: d67739c82e62025fed2a3d170fe254b4b744d89e
Parents: 6120199
Author: Alex Heneveld 
Authored: Thu Feb 11 16:03:42 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 src/main/webapp/assets/js/view/editor.js| 106 ---
 src/main/webapp/assets/tpl/editor/page.html |   8 +-
 2 files changed, 99 insertions(+), 15 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d67739c8/src/main/webapp/assets/js/view/editor.js
--
diff --git a/src/main/webapp/assets/js/view/editor.js 
b/src/main/webapp/assets/js/view/editor.js
index fa893fc..1b4dce3 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -60,6 +60,9 @@ define([
 events: {
 'click #button-run':'runBlueprint',
 'click #button-delete':'removeBlueprint',
+'click #button-convert':'convertBlueprint',
+'click #button-switch':'switchMode',
+'click #button-example':'populateExampleBlueprint',
 },
 editorTemplate:_.template(EditorHtml),
 
@@ -79,7 +82,7 @@ define([
 this.options.catalog.fetch({
 data: $.param({allVersions: true}),
 success: function () {
-vm.refreshEditor();
+vm.initializeEditor();
 }
 });
 },
@@ -97,11 +100,41 @@ define([
 refresh: function() {
 $("#button-run", this.$el).html(this.mode==MODE_CATALOG ? "Add to 
Catalog" : "Deploy");
 $("#button-delete", this.$el).html("Clear");
+$("#button-example", this.$el).html(this.mode==MODE_CATALOG ? 
"Insert Catalog Example" : "Insert Blueprint Example");
+$("#button-switch", this.$el).html(this.mode==MODE_CATALOG ? 
"Switch to Application Blueprint Mode" : "Switch to Catalog Mode");
+this.refreshOnMinorChange();
 },
-refreshEditor: function() {
+refreshOnMinorChange: function() {
+var yaml = this.editor && this.editor.getValue();
+var parse = this.parse();
+
+if (!yaml || parse.problem || this.mode==MODE_CATALOG) {
+$("#button-convert", this.$el).hide();
+} else {
+$("#button-convert", this.$el).html("Convert to Catalog Item");
+$("#button-convert", this.$el).show();
+}
+
+if (!yaml) {
+// no yaml
+$("#button-run", this.$el).attr('disabled','disabled');
+$("#button-delete", this.$el).hide();
+// example and switch mode only shown when empty
+$("#button-example", this.$el).show();
+$("#button-switch", this.$el).show();
+} else {
+$("#button-run", this.$el).attr('disabled','false');
+// we have yaml
+$("#button-run", this.$el).show();
+$("#button-delete", this.$el).show();
+$("#button-example", this.$el).hide();
+$("#button-switch", this.$el).hide();
+}
+},
+initializeEditor: function() {
 var cm = this.editor;
 if (typeof(cm) !== "undefined") {
-var itemText;
+var itemText = "";
 if (this.options.typeId === '_') {
 // _ indicates a literal is being supplied
 itemText = this.options.content;
@@ -119,14 +152,10 @@ define([
 }
 }
 }
+cm.getDoc().setValue(itemText);
 if (!itemText) {
-if (this.options.type === 'catalog') {
-itemText = _DEFAULT_CATALOG;
-} else {
-itemText = _DEFAULT_BLUEPRINT;
-}
+// could populateExampleBlueprint -- but now that is 
opt-in
 }
-cm.getDoc().setValue(itemText);
 //better not to focus as focussing puts the cursor at the 
beginning which is odd
 //and cmd-shift-[ and tab are intercepted so user can't 
navigate
 // cm.focus();
@@ -144,20 +173,65 @@ define([
 globalVars: true
 }
 

[27/27] brooklyn-ui git commit: apply code review to ui #7 codemirror yaml-parse and completion

2016-02-18 Thread heneveld
apply code review to ui #7 codemirror yaml-parse and completion

and some styling tweaks so highlight is correct


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

Branch: refs/heads/master
Commit: b9ba6544dd0a4a8fec6519ab6b3145f7956ad578
Parents: e1646d7
Author: Alex Heneveld 
Authored: Thu Feb 18 10:36:23 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 10:36:23 2016 +

--
 .../webapp/assets/css/codemirror-brooklyn.css   | 21 ++--
 .../brooklyn-yaml-completion-proposals.js   | 16 ++-
 .../js/util/code-complete/js-yaml-parser.js |  5 +
 src/main/webapp/index.html  |  2 +-
 4 files changed, 32 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/css/codemirror-brooklyn.css
--
diff --git a/src/main/webapp/assets/css/codemirror-brooklyn.css 
b/src/main/webapp/assets/css/codemirror-brooklyn.css
index b1b2c54..e751df3 100644
--- a/src/main/webapp/assets/css/codemirror-brooklyn.css
+++ b/src/main/webapp/assets/css/codemirror-brooklyn.css
@@ -28,16 +28,25 @@
 .CodeMirror .CodeMirror-gutter.CodeMirror-linenumbers {
 }
 
+ul.CodeMirror-hints {
+  overflow: scroll;
+  width: 320px;
+}
 li.CodeMirror-hint {
   max-width: inherit;
   overflow: visible;
+  /* nice trick: table has stretchability based on content (line inline) but 
otherwise acts like div 
+   * (following content is not on same line). this causes wide (overflow) 
content to get the right background when active;
+   * otherwise with div the content is shown but background only applies to 
non-overflow part. */
+  display: table;
+  /* but width of table defaults to ignoring padding so we have to fix it to 
be parent's less padding */ 
+  min-width: 312px;
 }
-ul.CodeMirror-hints {
-  overflow: scroll;
-  max-width: 30em;
-}
-
 .CodeMirror-hints .CodeMirror-hint.summary {
   font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
   font-style: italic;
-}
\ No newline at end of file
+}
+li.CodeMirror-hint-active {
+  /* override show-hint to have roughly brooklyn colors instead of blue */
+  background: #549e2b;
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
--
diff --git 
a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
index 3dfecd7..e183411 100644
--- 
a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
+++ 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
@@ -56,14 +56,20 @@ define([
 
 if (n.result === null) {
 n.type = 'null';
-} else if (typeof n.result === 'object') {
+} else if (n.kind == 'sequence') {
+if (typeof n.result.length === 'undefined') {
+console.log("WARN: mismatch expected list but had no length", 
n);
+}
+n.type = 'list';
+} else if (n.kind == 'mapping') {
 if (typeof n.result.length !== 'undefined') {
-// ^^^ messy way to check is parent a list
-n.type = 'list';
-} else {
-n.type = 'map';
+console.log("WARN: mismatch expected map but had length", n);
 }
+n.type = 'map';
 } else {
+if (n.kind != 'scalar') {
+console.log("WARN: mismatch expected scalar/primitive", n);
+}
 n.type = 'primitive';
 }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
--
diff --git a/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js 
b/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
index 98092f0..b95ebe0 100644
--- a/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
+++ b/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
@@ -18,8 +18,13 @@ define([
 }
 
 function closeYamlNode(node, state) {
+// character offset where this block ends, i.e. 1 means after the 
first character
+// NB: if parser unsure may contain additional whitespace
 node.end = state.position;
+// the actual parsed object
  

[18/27] brooklyn-ui git commit: add font awesome

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.ttf
--
diff --git 
a/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.ttf 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.ttf
new file mode 100644
index 000..26dea79
Binary files /dev/null and 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.ttf 
differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff
--
diff --git 
a/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff
new file mode 100644
index 000..dc35ce3
Binary files /dev/null and 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff 
differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff2
--
diff --git 
a/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff2 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff2
new file mode 100644
index 000..500e517
Binary files /dev/null and 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.woff2 
differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/less/animated.less
--
diff --git a/src/main/webapp/assets/js/libs/font-awesome/less/animated.less 
b/src/main/webapp/assets/js/libs/font-awesome/less/animated.less
new file mode 100644
index 000..66ad52a
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/less/animated.less
@@ -0,0 +1,34 @@
+// Animated Icons
+// --
+
+.@{fa-css-prefix}-spin {
+  -webkit-animation: fa-spin 2s infinite linear;
+  animation: fa-spin 2s infinite linear;
+}
+
+.@{fa-css-prefix}-pulse {
+  -webkit-animation: fa-spin 1s infinite steps(8);
+  animation: fa-spin 1s infinite steps(8);
+}
+
+@-webkit-keyframes fa-spin {
+  0% {
+-webkit-transform: rotate(0deg);
+transform: rotate(0deg);
+  }
+  100% {
+-webkit-transform: rotate(359deg);
+transform: rotate(359deg);
+  }
+}
+
+@keyframes fa-spin {
+  0% {
+-webkit-transform: rotate(0deg);
+transform: rotate(0deg);
+  }
+  100% {
+-webkit-transform: rotate(359deg);
+transform: rotate(359deg);
+  }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/less/bordered-pulled.less
--
diff --git 
a/src/main/webapp/assets/js/libs/font-awesome/less/bordered-pulled.less 
b/src/main/webapp/assets/js/libs/font-awesome/less/bordered-pulled.less
new file mode 100644
index 000..f1c8ad7
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/less/bordered-pulled.less
@@ -0,0 +1,25 @@
+// Bordered & Pulled
+// -
+
+.@{fa-css-prefix}-border {
+  padding: .2em .25em .15em;
+  border: solid .08em @fa-border-color;
+  border-radius: .1em;
+}
+
+.@{fa-css-prefix}-pull-left { float: left; }
+.@{fa-css-prefix}-pull-right { float: right; }
+
+.@{fa-css-prefix} {
+  &.@{fa-css-prefix}-pull-left { margin-right: .3em; }
+  &.@{fa-css-prefix}-pull-right { margin-left: .3em; }
+}
+
+/* Deprecated as of 4.4.0 */
+.pull-right { float: right; }
+.pull-left { float: left; }
+
+.@{fa-css-prefix} {
+  &.pull-left { margin-right: .3em; }
+  &.pull-right { margin-left: .3em; }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/less/core.less
--
diff --git a/src/main/webapp/assets/js/libs/font-awesome/less/core.less 
b/src/main/webapp/assets/js/libs/font-awesome/less/core.less
new file mode 100644
index 000..c577ac8
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/less/core.less
@@ -0,0 +1,12 @@
+// Base Class Definition
+// -
+
+.@{fa-css-prefix} {
+  display: inline-block;
+  font: normal normal normal @fa-font-size-base/@fa-line-height-base 
FontAwesome; // shortening font declaration
+  font-size: inherit; // can't have font-size inherit on line above, so need 
to override
+  text-rendering: auto; // optimizelegibility throws things off #1094
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/f

[10/27] brooklyn-ui git commit: call buttons "Open in Composer" and "Deploy" rather than "Preview" / "Finish"

2016-02-18 Thread heneveld
call buttons "Open in Composer" and "Deploy" rather than "Preview" / "Finish"

and the "Open in Composer" button is highlighted if you pick a template


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/9d3d9bb3
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/9d3d9bb3
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/9d3d9bb3

Branch: refs/heads/master
Commit: 9d3d9bb3f8346f62028fdad1df43ec60d94e73d8
Parents: 2d75ed5
Author: Alex Heneveld 
Authored: Thu Feb 11 01:50:58 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 .../assets/js/view/application-add-wizard.js| 91 +++-
 .../assets/tpl/app-add-wizard/modal-wizard.html |  4 +-
 2 files changed, 50 insertions(+), 45 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9d3d9bb3/src/main/webapp/assets/js/view/application-add-wizard.js
--
diff --git a/src/main/webapp/assets/js/view/application-add-wizard.js 
b/src/main/webapp/assets/js/view/application-add-wizard.js
index ffdee6d..62d4db2 100644
--- a/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -166,12 +166,39 @@ define([
 
 setVisibility(this.$("#prev_step"), (this.currentStep > 0))
 
+this.isTemplate = false;
+{
+var yaml = (this.currentView && 
this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml);
+if (yaml) {
+try {
+yaml = JsYaml.safeLoad(yaml);
+hasLocation = yaml.location || yaml.locations;
+if (!hasLocation) {
+  // look for locations defined in locations
+  svcs = yaml.services;
+  if (svcs) {
+for (svcI in svcs) {
+  if (svcs[svcI].location || svcs[svcI].locations) 
{
+hasLocation = true;
+break;
+  }
+}
+  }
+}
+this.isTemplate = (hasLocation ? true : false);
+} catch (e) {
+log("Warning: could not parse yaml template of 
selected item")
+log(yaml);
+}
+}
+}
+
 // next shown for first step, but not for yaml
-var nextVisible = (this.currentStep < 1) && (this.model.mode != 
"yaml")
+var nextVisible = (this.currentStep < 1) && (this.model.mode != 
"yaml") && (!this.isTemplate);
 setVisibility(this.$("#next_step"), nextVisible)
 
-// previous shown for step 2 (but again, not yaml)
-var previewVisible = (this.currentStep == 1) && (this.model.mode 
!= "yaml")
+// preview (aka "Open in Composer") shown for step 2 or for 
template (but again, not yaml)
+var previewVisible = (((this.currentStep < 1) && this.isTemplate) 
|| (this.currentStep == 1)) && (this.model.mode != "yaml")
 setVisibility(this.$("#preview_step"), previewVisible)
 
 // now set next/preview enablement
@@ -266,38 +293,9 @@ define([
 nextStep:function () {
 if (this.currentStep == 0) {
 if (this.currentView.validate()) {
-this.isTemplate = false;
-var yaml = (this.currentView && 
this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml);
-if (yaml) {
-try {
-yaml = JsYaml.safeLoad(yaml);
-hasLocation = yaml.location || yaml.locations;
-if (!hasLocation) {
-  // look for locations defined in locations
-  svcs = yaml.services;
-  if (svcs) {
-for (svcI in svcs) {
-  if (svcs[svcI].location || 
svcs[svcI].locations) {
-hasLocation = true;
-break;
-  }
-}
-  }
-}
-this.isTemplate = (hasLocation ? true : false);
-} catch (e) {
-log("Warning: could not parse yaml template")
- 

[06/27] brooklyn-ui git commit: use location identifier spec/name, not a random id, in app-add-wizard

2016-02-18 Thread heneveld
use location identifier spec/name, not a random id, in app-add-wizard


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

Branch: refs/heads/master
Commit: f49de1ca782ea158f511d80ba450e5e990e578da
Parents: 9c6c06c
Author: Alex Heneveld 
Authored: Thu Feb 11 02:57:32 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 src/main/webapp/assets/js/view/application-add-wizard.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/f49de1ca/src/main/webapp/assets/js/view/application-add-wizard.js
--
diff --git a/src/main/webapp/assets/js/view/application-add-wizard.js 
b/src/main/webapp/assets/js/view/application-add-wizard.js
index 1174c5e..1436eea 100644
--- a/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -595,7 +595,7 @@ define([
 var $locationOptions = container.find('.select-location');
 var templated = this.locations.map(function(aLocation) {
 return optionTemplate({
-id: aLocation.id || "",
+id: aLocation.getIdentifierName() || aLocation.id || "",
 name: aLocation.getPrettyName()
 });
 });
@@ -647,7 +647,7 @@ define([
 },
 addLocation:function () {
 if (this.locations.models.length>0) {
-this.model.spec.addLocation(this.locations.models[0].get("id"))
+
this.model.spec.addLocation(this.locations.models[0].getIdentifierName())
 } else {
 // i.e. No location
 this.model.spec.addLocation(undefined);
@@ -702,7 +702,7 @@ define([
 var loc_id = $(event.currentTarget).val(),
 isNoneLocation = loc_id === NO_LOCATION_INDICATOR;
 var locationValid = isNoneLocation || this.locations.find(function 
(candidate) {
-return candidate.get("id")==loc_id;
+return candidate.getIdentifierName()==loc_id;
 });
 if (!locationValid) {
 log("invalid location "+loc_id);



[17/27] brooklyn-ui git commit: add font awesome

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/scss/_icons.scss
--
diff --git a/src/main/webapp/assets/js/libs/font-awesome/scss/_icons.scss 
b/src/main/webapp/assets/js/libs/font-awesome/scss/_icons.scss
new file mode 100644
index 000..6f93759
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/scss/_icons.scss
@@ -0,0 +1,697 @@
+/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen
+   readers do not read off random characters that represent icons */
+
+.#{$fa-css-prefix}-glass:before { content: $fa-var-glass; }
+.#{$fa-css-prefix}-music:before { content: $fa-var-music; }
+.#{$fa-css-prefix}-search:before { content: $fa-var-search; }
+.#{$fa-css-prefix}-envelope-o:before { content: $fa-var-envelope-o; }
+.#{$fa-css-prefix}-heart:before { content: $fa-var-heart; }
+.#{$fa-css-prefix}-star:before { content: $fa-var-star; }
+.#{$fa-css-prefix}-star-o:before { content: $fa-var-star-o; }
+.#{$fa-css-prefix}-user:before { content: $fa-var-user; }
+.#{$fa-css-prefix}-film:before { content: $fa-var-film; }
+.#{$fa-css-prefix}-th-large:before { content: $fa-var-th-large; }
+.#{$fa-css-prefix}-th:before { content: $fa-var-th; }
+.#{$fa-css-prefix}-th-list:before { content: $fa-var-th-list; }
+.#{$fa-css-prefix}-check:before { content: $fa-var-check; }
+.#{$fa-css-prefix}-remove:before,
+.#{$fa-css-prefix}-close:before,
+.#{$fa-css-prefix}-times:before { content: $fa-var-times; }
+.#{$fa-css-prefix}-search-plus:before { content: $fa-var-search-plus; }
+.#{$fa-css-prefix}-search-minus:before { content: $fa-var-search-minus; }
+.#{$fa-css-prefix}-power-off:before { content: $fa-var-power-off; }
+.#{$fa-css-prefix}-signal:before { content: $fa-var-signal; }
+.#{$fa-css-prefix}-gear:before,
+.#{$fa-css-prefix}-cog:before { content: $fa-var-cog; }
+.#{$fa-css-prefix}-trash-o:before { content: $fa-var-trash-o; }
+.#{$fa-css-prefix}-home:before { content: $fa-var-home; }
+.#{$fa-css-prefix}-file-o:before { content: $fa-var-file-o; }
+.#{$fa-css-prefix}-clock-o:before { content: $fa-var-clock-o; }
+.#{$fa-css-prefix}-road:before { content: $fa-var-road; }
+.#{$fa-css-prefix}-download:before { content: $fa-var-download; }
+.#{$fa-css-prefix}-arrow-circle-o-down:before { content: 
$fa-var-arrow-circle-o-down; }
+.#{$fa-css-prefix}-arrow-circle-o-up:before { content: 
$fa-var-arrow-circle-o-up; }
+.#{$fa-css-prefix}-inbox:before { content: $fa-var-inbox; }
+.#{$fa-css-prefix}-play-circle-o:before { content: $fa-var-play-circle-o; }
+.#{$fa-css-prefix}-rotate-right:before,
+.#{$fa-css-prefix}-repeat:before { content: $fa-var-repeat; }
+.#{$fa-css-prefix}-refresh:before { content: $fa-var-refresh; }
+.#{$fa-css-prefix}-list-alt:before { content: $fa-var-list-alt; }
+.#{$fa-css-prefix}-lock:before { content: $fa-var-lock; }
+.#{$fa-css-prefix}-flag:before { content: $fa-var-flag; }
+.#{$fa-css-prefix}-headphones:before { content: $fa-var-headphones; }
+.#{$fa-css-prefix}-volume-off:before { content: $fa-var-volume-off; }
+.#{$fa-css-prefix}-volume-down:before { content: $fa-var-volume-down; }
+.#{$fa-css-prefix}-volume-up:before { content: $fa-var-volume-up; }
+.#{$fa-css-prefix}-qrcode:before { content: $fa-var-qrcode; }
+.#{$fa-css-prefix}-barcode:before { content: $fa-var-barcode; }
+.#{$fa-css-prefix}-tag:before { content: $fa-var-tag; }
+.#{$fa-css-prefix}-tags:before { content: $fa-var-tags; }
+.#{$fa-css-prefix}-book:before { content: $fa-var-book; }
+.#{$fa-css-prefix}-bookmark:before { content: $fa-var-bookmark; }
+.#{$fa-css-prefix}-print:before { content: $fa-var-print; }
+.#{$fa-css-prefix}-camera:before { content: $fa-var-camera; }
+.#{$fa-css-prefix}-font:before { content: $fa-var-font; }
+.#{$fa-css-prefix}-bold:before { content: $fa-var-bold; }
+.#{$fa-css-prefix}-italic:before { content: $fa-var-italic; }
+.#{$fa-css-prefix}-text-height:before { content: $fa-var-text-height; }
+.#{$fa-css-prefix}-text-width:before { content: $fa-var-text-width; }
+.#{$fa-css-prefix}-align-left:before { content: $fa-var-align-left; }
+.#{$fa-css-prefix}-align-center:before { content: $fa-var-align-center; }
+.#{$fa-css-prefix}-align-right:before { content: $fa-var-align-right; }
+.#{$fa-css-prefix}-align-justify:before { content: $fa-var-align-justify; }
+.#{$fa-css-prefix}-list:before { content: $fa-var-list; }
+.#{$fa-css-prefix}-dedent:before,
+.#{$fa-css-prefix}-outdent:before { content: $fa-var-outdent; }
+.#{$fa-css-prefix}-indent:before { content: $fa-var-indent; }
+.#{$fa-css-prefix}-video-camera:before { content: $fa-var-video-camera; }
+.#{$fa-css-prefix}-photo:before,
+.#{$fa-css-prefix}-image:before,
+.#{$fa-css-prefix}-picture-o:before { content: $fa-var-picture-o; }
+.#{$fa-css-prefix}-pencil:before { content: $fa-var-pencil; }
+.#{$fa-css-prefix}-map-marker:before { content: $fa-var-map-marker; }
+.#{$fa-css-prefix}-adjust:before { content: $fa-var-adju

[16/27] brooklyn-ui git commit: simple but effective code completion

2016-02-18 Thread heneveld
simple but effective code completion

does not attempt to cover everything or do a perfect parse tree,
as that is much harder, but does simple heuristics which give a lot of help 
without too much work

it would be great to offer something much sounder, basing e.g. on json-schema,
but that is a lot more work as well


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/1058fa7a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/1058fa7a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/1058fa7a

Branch: refs/heads/master
Commit: 1058fa7a1328bb1926dc1f0f68e580dc323dd588
Parents: d19e315
Author: Alex Heneveld 
Authored: Fri Feb 12 15:55:30 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 02:08:31 2016 +

--
 .../webapp/assets/css/codemirror-brooklyn.css   |  14 +
 src/main/webapp/assets/js/config.js |   2 +
 .../brooklyn-yaml-completion-proposals.js   | 374 +++
 .../js/util/code-complete/js-yaml-parser.js |  48 +++
 src/main/webapp/assets/js/view/editor.js|  25 +-
 src/test/javascript/config.txt  |   2 +
 6 files changed, 463 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/1058fa7a/src/main/webapp/assets/css/codemirror-brooklyn.css
--
diff --git a/src/main/webapp/assets/css/codemirror-brooklyn.css 
b/src/main/webapp/assets/css/codemirror-brooklyn.css
index c293ed4..b1b2c54 100644
--- a/src/main/webapp/assets/css/codemirror-brooklyn.css
+++ b/src/main/webapp/assets/css/codemirror-brooklyn.css
@@ -27,3 +27,17 @@
 }
 .CodeMirror .CodeMirror-gutter.CodeMirror-linenumbers {
 }
+
+li.CodeMirror-hint {
+  max-width: inherit;
+  overflow: visible;
+}
+ul.CodeMirror-hints {
+  overflow: scroll;
+  max-width: 30em;
+}
+
+.CodeMirror-hints .CodeMirror-hint.summary {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+  font-style: italic;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/1058fa7a/src/main/webapp/assets/js/config.js
--
diff --git a/src/main/webapp/assets/js/config.js 
b/src/main/webapp/assets/js/config.js
index 05afbb6..94d6385 100644
--- a/src/main/webapp/assets/js/config.js
+++ b/src/main/webapp/assets/js/config.js
@@ -49,6 +49,8 @@ require.config({
 "uri":"libs/URI",
 "zeroclipboard":"libs/ZeroClipboard",
 "js-yaml":"libs/js-yaml",
+"js-yaml-parser":"util/code-complete/js-yaml-parser",
+
"brooklyn-yaml-completion-proposals":"util/code-complete/brooklyn-yaml-completion-proposals",
 
 "codemirror":"libs/codemirror",
 "codemirror-mode-yaml":"libs/codemirror/mode/yaml/yaml",

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/1058fa7a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
--
diff --git 
a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
new file mode 100644
index 000..032f0d6
--- /dev/null
+++ 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
@@ -0,0 +1,374 @@
+
+define([
+"backbone", "js-yaml-parser", "underscore"
+], function (Backbone, JsYamlParser, _) {
+
+var BrooklynYamlCompletionProposals = {};
+
+var Catalog = Backbone.Collection.extend({
+initialize: function(models, options) {
+this.name = options["name"];
+var that = this; 
+var model = this.model.extend({
+  url: function() {
+return "/v1/" + that.name + "/" + this.id.split(":").join("/");
+  }
+});
+_.bindAll(this);
+this.model = model;
+},
+url: function() {
+return "/v1/" + this.name;
+}
+});
+// currently populates catalog on startup, then refreshes on each search
+// (but only renders later)
+// ideally should be shared model refreshed periodically in background
+var catalogE = new Catalog(undefined, { name: "catalog/entities" });
+var catalogA = new Catalog(undefined, { name: "catalog/applications" });
+var catalogL = new Catalog(undefined, { name: "locations" });
+catalogA.fetch();
+catalogE.fetch();
+catalogL.fetch();
+
+function findParseNodeAt(parse, position) {
+  if (parse.start<=position && parse.end>=position) {
+for (var ci in parse.children) {
+  var c = parse.children[ci];
+  var result = findParseNodeAt(c, position);
+  i

[23/27] brooklyn-ui git commit: make span12 (composer) line up with other pages

2016-02-18 Thread heneveld
make span12 (composer) line up with other pages

and remove debug js logging just introduced


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/2414c144
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/2414c144
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/2414c144

Branch: refs/heads/master
Commit: 2414c1443bd5433e0ff5598ba79604f82cd43f7e
Parents: 500b5fa
Author: Alex Heneveld 
Authored: Tue Feb 16 20:51:38 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 20:51:38 2016 +

--
 src/main/webapp/assets/css/brooklyn.css   | 10 +-
 .../code-complete/brooklyn-yaml-completion-proposals.js   |  4 +---
 2 files changed, 10 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/2414c144/src/main/webapp/assets/css/brooklyn.css
--
diff --git a/src/main/webapp/assets/css/brooklyn.css 
b/src/main/webapp/assets/css/brooklyn.css
index c2ad673..ec4aa90 100644
--- a/src/main/webapp/assets/css/brooklyn.css
+++ b/src/main/webapp/assets/css/brooklyn.css
@@ -136,6 +136,13 @@ textarea {
 margin-top: 10px !important
 }
 
+.row-fluid .span12 {
+margin-left: 34px !important;
+margin-right: -26px !important;
+margin-top: 10px !important;
+width: 927px !important;
+}
+
 .navbar_top {
 background-color: #f0f0f0 !important;
 -webkit-border-radius: 13px 13px 0 0 !important;
@@ -145,8 +152,9 @@ textarea {
 border-bottom: none;
 }
 
-.navbar_top  h3 {
+.navbar_top h3 {
 line-height: 24px !important;
+margin-top: 6px;
 }
 
 .navbar_main_wrapper {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/2414c144/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
--
diff --git 
a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
index 032f0d6..3dfecd7 100644
--- 
a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
+++ 
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
@@ -27,6 +27,7 @@ define([
 var catalogE = new Catalog(undefined, { name: "catalog/entities" });
 var catalogA = new Catalog(undefined, { name: "catalog/applications" });
 var catalogL = new Catalog(undefined, { name: "locations" });
+// if browser opened while server is starting this will fail on first 
completion
 catalogA.fetch();
 catalogE.fetch();
 catalogL.fetch();
@@ -178,7 +179,6 @@ define([
 
 getServiceTypes: function(n) {
 var result = [];
-console.log(catalogE);
 catalogE.fetch();
 catalogA.fetch();
 result = result.concat(_.map(catalogE.models, function(m) { return 
m.get('symbolicName'); })); 
@@ -284,7 +284,6 @@ define([
 try {
 parse = JsYamlParser.parse(text);
 if (typeof parse.result == 'string') {
-console.log("prim");
 throw "primitive not supported, parse as empty and let 
completion apply";
 }
 } catch (e) {
@@ -332,7 +331,6 @@ define([
 }
 result = _.compact(_.map(result, function(proposal) {
 var proposalObj;
-
console.log("considering",proposal,"wrt",wordSoFar,"/",lineSoFar);
 if (typeof proposal === 'object') {
 proposalObj = proposal;
 proposal = proposalObj.text;



[11/27] brooklyn-ui git commit: minor bug fixes

2016-02-18 Thread heneveld
minor bug fixes


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/438132fc
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/438132fc
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/438132fc

Branch: refs/heads/master
Commit: 438132fcf49e7c97fafc6c334cfcdbe00a40cea7
Parents: 4cd4fea
Author: Alex Heneveld 
Authored: Thu Feb 11 18:03:26 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 18:03:26 2016 +

--
 .../assets/js/view/application-add-wizard.js| 41 ++--
 src/main/webapp/assets/js/view/editor.js|  3 --
 2 files changed, 21 insertions(+), 23 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/438132fc/src/main/webapp/assets/js/view/application-add-wizard.js
--
diff --git a/src/main/webapp/assets/js/view/application-add-wizard.js 
b/src/main/webapp/assets/js/view/application-add-wizard.js
index 1436eea..f57023a 100644
--- a/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -97,6 +97,20 @@ define([
 return value;
 }
 }
+
+function redirectToEditorTabToDeployId(catalogId){
+redirectTo("/v1/editor/app/"+ (typeof catalogId === 'string' ? 
catalogId : '')); 
+}
+function redirectToEditorTabToDeployYaml(yaml){
+redirectTo("/v1/editor/app/_/"+encodeURIComponent(yaml));
+}
+function redirectTo(url){
+var $modal = $('.add-app #modal-container .modal');
+$modal.modal('hide');
+$modal.fadeTo(500,1);
+Backbone.history.navigate(url, {trigger: true});
+}
+
 
 var ModalWizard = Backbone.View.extend({
 tagName:'div',
@@ -206,7 +220,8 @@ define([
 var nextEnabled = true;
 if (this.currentStep==0 && currentStepObj && currentStepObj.view) {
 // disable if nothing is selected in template (app lozenge 
list) view
-if (! currentStepObj.view.selectedTemplate)
+// or if it is a template with a location
+if (!currentStepObj.view.selectedTemplate || 
isTemplateWithLocation)
 nextEnabled = false;
 }
 
@@ -291,9 +306,9 @@ define([
 if (this.currentStep==0) {
 // from first step, composer should load yaml from the catalog 
item
 if (this.currentView.selectedTemplate && 
this.currentView.selectedTemplate.id) {
-
this.redirectToEditorTabToDeployId(this.currentView.selectedTemplate.id);
+
redirectToEditorTabToDeployId(this.currentView.selectedTemplate.id);
 } else {
-this.redirectToEditorTabToDeployId();
+redirectToEditorTabToDeployId();
 }
 } else {
 // on second step we generate yaml
@@ -301,7 +316,7 @@ define([
 this.model.spec.pruneLocations();
 var yaml = 
JsYaml.safeDump(oldSpecToCamp(this.model.spec.toJSON()));
 
-this.redirectToEditorTabToDeployYaml(yaml);
+redirectToEditorTabToDeployYaml(yaml);
 }
 },
 finishStep:function () {
@@ -311,19 +326,6 @@ define([
 // call to validate should showFailure
 }
 },
-
-redirectToEditorTabToDeployId: function(catalogId){
-this.redirectTo("/v1/editor/app/"+ (typeof catalogId === 'string' 
? catalogId : '')); 
-},
-redirectToEditorTabToDeployYaml: function(yaml){
-this.redirectTo("/v1/editor/app/_/"+encodeURIComponent(yaml));
-},
-redirectTo: function(url){
-var $modal = $('.add-app #modal-container .modal');
-$modal.modal('hide');
-$modal.fadeTo(500,1);
-Backbone.history.navigate(url, {trigger: true});
-},
 })
 
 // Note: this does not restore values on a back click; setting type and 
entity type+name is easy,
@@ -368,7 +370,6 @@ define([
 self.addTemplateLozenges();
 } else {
 $('#catalog-applications-empty').show();
-self.showYamlTab();
 }
 }
 });
@@ -405,8 +406,8 @@ define([
 $modal.modal('hide');
 window.location.href="#v1/catalog/new";
 },
-redirectToEditorTab: function() {
-this.redirectToEditorTabToDeployId();
+redirectToEditorTab: function () {
+redirectToEditorTabToDeployId();
 },
 applyFilter: function(e) {
 var f

[25/27] brooklyn-ui git commit: This closes #5

2016-02-18 Thread heneveld
This closes #5


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

Branch: refs/heads/master
Commit: b7954f13d70b66af3a9a1ab2edaa0ceb1897cbe0
Parents: c2e374e 438132f
Author: Alex Heneveld 
Authored: Thu Feb 18 09:12:05 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 09:12:05 2016 +

--
 .../webapp/assets/css/codemirror-brooklyn.css   |   29 +
 src/main/webapp/assets/js/libs/js-yaml.js   | 5703 +-
 .../assets/js/model/catalog-application.js  |1 -
 src/main/webapp/assets/js/router.js |8 +-
 .../assets/js/view/application-add-wizard.js|  290 +-
 src/main/webapp/assets/js/view/catalog.js   |9 +-
 src/main/webapp/assets/js/view/editor.js|  193 +-
 .../tpl/app-add-wizard/create-entity-entry.html |   64 -
 .../assets/tpl/app-add-wizard/create.html   |   46 +-
 .../assets/tpl/app-add-wizard/modal-wizard.html |4 +-
 .../assets/tpl/catalog/details-entity.html  |1 +
 src/main/webapp/assets/tpl/editor/page.html |   39 +-
 src/main/webapp/index.html  |1 +
 13 files changed, 3132 insertions(+), 3256 deletions(-)
--




[07/27] brooklyn-ui git commit: update js-yaml to latest (snapshot) version

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/1e17eeef/src/main/webapp/assets/js/libs/js-yaml.js
--
diff --git a/src/main/webapp/assets/js/libs/js-yaml.js 
b/src/main/webapp/assets/js/libs/js-yaml.js
index fbc53e6..25bf133 100644
--- a/src/main/webapp/assets/js/libs/js-yaml.js
+++ b/src/main/webapp/assets/js/libs/js-yaml.js
@@ -1,492 +1,471 @@
-/* js-yaml 3.5.2 https://github.com/nodeca/js-yaml */(function(f){if(typeof 
exports==="object"&&typeof module!=="undefined"){module.exports=f()}else 
if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof 
window!=="undefined"){g=window}else if(typeof 
global!=="undefined"){g=global}else if(typeof 
self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var 
define,module,exports;return (function e(t,n,r){function 
s(o,u){if(!n[o]){if(!t[o]){var a=typeof 
require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var 
f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var 
l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return 
s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof 
require=="function"&&require;for(var o=0;ohttps://github.com/nodeca/js-yaml */
+(function(f){if(typeof exports==="object"&&typeof 
module!=="undefined"){module.exports=f()}else if(typeof 
define==="function"&&define.amd){define([],f)}else{var g;if(typeof 
window!=="undefined"){g=window}else if(typeof 
global!=="undefined"){g=global}else if(typeof 
self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var 
define,module,exports;return (function e(t,n,r){function 
s(o,u){if(!n[o]){if(!t[o]){var a=typeof 
require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var 
f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var 
l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return 
s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof 
require=="function"&&require;for(var o=0;o */
-  var CHAR_QUESTION = 0x3F; /* ? */
-  var CHAR_COMMERCIAL_AT= 0x40; /* @ */
-  var CHAR_LEFT_SQUARE_BRACKET  = 0x5B; /* [ */
-  var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
-  var CHAR_GRAVE_ACCENT = 0x60; /* ` */
-  var CHAR_LEFT_CURLY_BRACKET   = 0x7B; /* { */
-  var CHAR_VERTICAL_LINE= 0x7C; /* | */
-  var CHAR_RIGHT_CURLY_BRACKET  = 0x7D; /* } */
-
-  var ESCAPE_SEQUENCES = {};
-
-  ESCAPE_SEQUENCES[0x00]   = '\\0';
-  ESCAPE_SEQUENCES[0x07]   = '\\a';
-  ESCAPE_SEQUENCES[0x08]   = '\\b';
-  ESCAPE_SEQUENCES[0x09]   = '\\t';
-  ESCAPE_SEQUENCES[0x0A]   = '\\n';
-  ESCAPE_SEQUENCES[0x0B]   = '\\v';
-  ESCAPE_SEQUENCES[0x0C]   = '\\f';
-  ESCAPE_SEQUENCES[0x0D]   = '\\r';
-  ESCAPE_SEQUENCES[0x1B]   = '\\e';
-  ESCAPE_SEQUENCES[0x22]   = '\\"';
-  ESCAPE_SEQUENCES[0x5C]   = '';
-  ESCAPE_SEQUENCES[0x85]   = '\\N';
-  ESCAPE_SEQUENCES[0xA0]   = '\\_';
-  ESCAPE_SEQUENCES[0x2028] = '\\L';
-  ESCAPE_SEQUENCES[0x2029] = '\\P';
-
-  var DEPRECATED_BOOLEANS_SYNTAX = [
-'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
-'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
-  ];
-
-  function compileStyleMap(schema, map) {
-var result, keys, index, length, tag, style, type;
-
-if (null === map) {
-  return {};
-}
-
-result = {};
-keys = Object.keys(map);
-
-for (index = 0, length = keys.length; index < length; index += 1) {
-  tag = keys[index];
-  style = String(map[tag]);
-
-  if ('!!' === tag.slice(0, 2)) {
-tag = 'tag:yaml.org,2002:' + tag.slice(2);
-  }
+  for (cycle = 0; cycle < count; cycle += 1) {
+result += string;
+  }
 
-  type = schema.compiledTypeMap[tag];
+  return result;
+}
 
-  if (type && _hasOwnProperty.call(type.styleAliases, style)) {
-style = type.styleAliases[style];
-  }
 
-  result[tag] = style;
-}
+function isNegativeZero(number) {
+  return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
+}
 
-return result;
-  }
 
-  function encodeHex(character) {
-var string, handle, length;
+module.exports.isNothing  = isNothing;
+module.exports.isObject   = isObject;
+module.exports.toArray= toArray;
+module.exports.repeat = repeat;
+module.exports.isNegativeZero = isNegativeZero;
+module.exports.extend = extend;
 
-string = character.toString(16).toUpperCase();
+},{}],3:[function(require,module,exports){
+'use strict';
+
+/*eslint-disable no-use-before-define*/
+
+var common  = require('./common');
+var YAMLException   = require('./exception');
+var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
+var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
+
+var _toString   = Object.prototype.toString;
+var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+var CHAR_TAB  = 0x09; /* Tab */
+var CHAR_LINE_FEED

[13/27] brooklyn-ui git commit: move codemirror libraries to the usual places

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/libs/codemirror.js
--
diff --git a/src/main/webapp/assets/js/libs/codemirror.js 
b/src/main/webapp/assets/js/libs/codemirror.js
new file mode 100644
index 000..c6f9af8
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/codemirror.js
@@ -0,0 +1,8835 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// This is CodeMirror (http://codemirror.net), a code editor
+// implemented in JavaScript on top of the browser's DOM.
+//
+// You can find some technical background for some of the code below
+// at http://marijnhaverbeke.nl/blog/#cm-internals .
+
+(function(mod) {
+  if (typeof exports == "object" && typeof module == "object") // CommonJS
+module.exports = mod();
+  else if (typeof define == "function" && define.amd) // AMD
+return define([], mod);
+  else // Plain browser env
+this.CodeMirror = mod();
+})(function() {
+  "use strict";
+
+  // BROWSER SNIFFING
+
+  // Kludges for bugs and behavior differences that can't be feature
+  // detected are enabled based on userAgent etc sniffing.
+
+  var gecko = /gecko\/\d/i.test(navigator.userAgent);
+  var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
+  var ie_11up = 
/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
+  var ie = ie_upto10 || ie_11up;
+  var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
+  var webkit = /WebKit\//.test(navigator.userAgent);
+  var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
+  var chrome = /Chrome\//.test(navigator.userAgent);
+  var presto = /Opera\//.test(navigator.userAgent);
+  var safari = /Apple Computer/.test(navigator.vendor);
+  var mac_geMountainLion = /Mac OS X 
1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
+  var phantom = /PhantomJS/.test(navigator.userAgent);
+
+  var ios = /AppleWebKit/.test(navigator.userAgent) && 
/Mobile\/\w+/.test(navigator.userAgent);
+  // This is woefully incomplete. Suggestions for alternative methods welcome.
+  var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera 
Mobi|IEMobile/i.test(navigator.userAgent);
+  var mac = ios || /Mac/.test(navigator.platform);
+  var windows = /win/i.test(navigator.platform);
+
+  var presto_version = presto && 
navigator.userAgent.match(/Version\/(\d*\.\d*)/);
+  if (presto_version) presto_version = Number(presto_version[1]);
+  if (presto_version && presto_version >= 15) { presto = false; webkit = true; 
}
+  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
+  var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || 
presto_version < 12.11));
+  var captureRightClick = gecko || (ie && ie_version >= 9);
+
+  // Optimize some code when these features are not used.
+  var sawReadOnlySpans = false, sawCollapsedSpans = false;
+
+  // EDITOR CONSTRUCTOR
+
+  // A CodeMirror instance represents an editor. This is the object
+  // that user code is usually dealing with.
+
+  function CodeMirror(place, options) {
+if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
+
+this.options = options = options ? copyObj(options) : {};
+// Determine effective options based on given values and defaults.
+copyObj(defaults, options, false);
+setGuttersForLineNumbers(options);
+
+var doc = options.value;
+if (typeof doc == "string") doc = new Doc(doc, options.mode, null, 
options.lineSeparator);
+this.doc = doc;
+
+var input = new CodeMirror.inputStyles[options.inputStyle](this);
+var display = this.display = new Display(place, doc, input);
+display.wrapper.CodeMirror = this;
+updateGutters(this);
+themeChanged(this);
+if (options.lineWrapping)
+  this.display.wrapper.className += " CodeMirror-wrap";
+if (options.autofocus && !mobile) display.input.focus();
+initScrollbars(this);
+
+this.state = {
+  keyMaps: [],  // stores maps added by addKeyMap
+  overlays: [], // highlighting overlays, as added by addOverlay
+  modeGen: 0,   // bumped when mode/overlay changes, used to invalidate 
highlighting info
+  overwrite: false,
+  delayingBlurEvent: false,
+  focused: false,
+  suppressEdits: false, // used to disable editing during key handlers 
when in readOnly mode
+  pasteIncoming: false, cutIncoming: false, // help recognize paste/cut 
edits in input.poll
+  selectingText: false,
+  draggingText: false,
+  highlight: new Delayed(), // stores highlight worker timeout
+  keySeq: null,  // Unfinished key sequence
+  specialChars: null
+};
+
+var cm = this;
+
+// Override magic textarea content restore that IE sometimes does
+// on our hidden textarea on reload
+if (ie && ie_version < 11) setTimeout(function() { 
cm.display.input.reset(true); }, 2

[22/27] brooklyn-ui git commit: tell people about code completion.

2016-02-18 Thread heneveld
tell people about code completion.


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/500b5fa8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/500b5fa8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/500b5fa8

Branch: refs/heads/master
Commit: 500b5fa8eba2e9fd4d4c665bd73380362cd163f6
Parents: d4d88aa
Author: Alex Heneveld 
Authored: Tue Feb 16 17:49:16 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 17:49:16 2016 +

--
 src/main/webapp/assets/tpl/editor/page.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/500b5fa8/src/main/webapp/assets/tpl/editor/page.html
--
diff --git a/src/main/webapp/assets/tpl/editor/page.html 
b/src/main/webapp/assets/tpl/editor/page.html
index 05b62db..c0c4338 100644
--- a/src/main/webapp/assets/tpl/editor/page.html
+++ b/src/main/webapp/assets/tpl/editor/page.html
@@ -57,7 +57,7 @@ under the License.
 
 
 
-
+
 
 
 



[08/27] brooklyn-ui git commit: update js-yaml to latest (snapshot) version

2016-02-18 Thread heneveld
update js-yaml to latest (snapshot) version

from commit 50c82bccf70a19fd4add99542dfdf06a60280da8 (today) with parse 
listener enhancement https://github.com/nodeca/js-yaml/pull/249


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/1e17eeef
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/1e17eeef
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/1e17eeef

Branch: refs/heads/master
Commit: 1e17eeef6b1f7123552cccd4ec5ecd47c6d5d5c6
Parents: c2e374e
Author: Alex Heneveld 
Authored: Thu Feb 11 00:37:52 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 src/main/webapp/assets/js/libs/js-yaml.js | 5703 
 1 file changed, 2784 insertions(+), 2919 deletions(-)
--




[05/27] brooklyn-ui git commit: composer allows blueprints to be passed, and app-add-wizard preview button takes you to composer

2016-02-18 Thread heneveld
composer allows blueprints to be passed, and app-add-wizard preview button 
takes you to composer

previously "preview" button just reset the dialog;
this also gives slightly more interesting examples


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/2d75ed5c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/2d75ed5c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/2d75ed5c

Branch: refs/heads/master
Commit: 2d75ed5cdfae618af20d1a87246ea989ccca5289
Parents: 1e17eee
Author: Alex Heneveld 
Authored: Thu Feb 11 01:38:25 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 .../assets/js/model/catalog-application.js  |  1 -
 src/main/webapp/assets/js/router.js |  8 +--
 .../assets/js/view/application-add-wizard.js| 46 +--
 src/main/webapp/assets/js/view/catalog.js   |  3 +-
 src/main/webapp/assets/js/view/editor.js| 60 
 src/main/webapp/assets/tpl/editor/page.html |  2 +-
 6 files changed, 87 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/2d75ed5c/src/main/webapp/assets/js/model/catalog-application.js
--
diff --git a/src/main/webapp/assets/js/model/catalog-application.js 
b/src/main/webapp/assets/js/model/catalog-application.js
index f1a15eb..43f28b4 100644
--- a/src/main/webapp/assets/js/model/catalog-application.js
+++ b/src/main/webapp/assets/js/model/catalog-application.js
@@ -51,7 +51,6 @@ define(["underscore", "backbone"], function (_, Backbone) {
 },
 getId: function(id){
 return this.find(function(model) {
-console.info("model", model, model.get('id') === id);
 return model.get('id') === id;
 });
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/2d75ed5c/src/main/webapp/assets/js/router.js
--
diff --git a/src/main/webapp/assets/js/router.js 
b/src/main/webapp/assets/js/router.js
index 54874a9..1d6dae4 100644
--- a/src/main/webapp/assets/js/router.js
+++ b/src/main/webapp/assets/js/router.js
@@ -123,7 +123,7 @@ define([
 routes:{
 'v1/home/*trail':'homePage',
 //'v1/editor/*trail':'editorPage',
-'v1/editor(/)(:type)(/)(:typeId)':'editorPage',
+'v1/editor(/)(:type)(/)(:typeId)(/:content)':'editorPage',
 'v1/applications/:app/entities/*trail':'applicationsPage',
 'v1/applications/*trail':'applicationsPage',
 'v1/applications':'applicationsPage',
@@ -179,13 +179,13 @@ define([
 }
 }, error: render});
 },
-editorPage: function (type, typeId) {
-console.log("editorPage", type, typeId);
+editorPage: function (type, typeId, content) {
 var editorView = new EditorView({
 collection: this.applications,
 appRouter: this,
 type: type,
-typeId: typeId
+typeId: typeId,
+content: content
 });
 this.showView("#application-content", editorView);
 $(".nav1").removeClass("active");

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/2d75ed5c/src/main/webapp/assets/js/view/application-add-wizard.js
--
diff --git a/src/main/webapp/assets/js/view/application-add-wizard.js 
b/src/main/webapp/assets/js/view/application-add-wizard.js
index 344d6a0..ffdee6d 100644
--- a/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -266,6 +266,7 @@ define([
 nextStep:function () {
 if (this.currentStep == 0) {
 if (this.currentView.validate()) {
+this.isTemplate = false;
 var yaml = (this.currentView && 
this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml);
 if (yaml) {
 try {
@@ -283,16 +284,15 @@ define([
 }
   }
 }
-yaml = (hasLocation ? true : false);
+this.isTemplate = (hasLocation ? true : false);
 } catch (e) {
 log("Warning: could not parse yaml template")
 log(yaml);
-yaml = false;
 }
 }
-if (yaml) {
-// it's a yaml ca

[24/27] brooklyn-ui git commit: use apache brooklyn logo w feather

2016-02-18 Thread heneveld
use apache brooklyn logo w feather

and add various brooklyn logo files


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

Branch: refs/heads/master
Commit: dfc2d21b8da4df8524b7d2a0a3c5f6345352b7db
Parents: 2414c14
Author: Alex Heneveld 
Authored: Tue Feb 16 23:21:26 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 23:27:47 2016 +

--
 src/main/webapp/assets/css/brooklyn.css|  11 ++-
 .../assets/img/Apache-Brooklyn-Logo-200px-wide.png | Bin 0 -> 4256 bytes
 .../assets/img/Apache-Brooklyn-Logo-300px-wide.png | Bin 0 -> 6068 bytes
 .../assets/img/Apache-Brooklyn-Logo_highres.png| Bin 0 -> 42890 bytes
 .../img/apache-brooklyn-feather-atop-720px.png | Bin 0 -> 72926 bytes
 5 files changed, 6 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/dfc2d21b/src/main/webapp/assets/css/brooklyn.css
--
diff --git a/src/main/webapp/assets/css/brooklyn.css 
b/src/main/webapp/assets/css/brooklyn.css
index ec4aa90..2121837 100644
--- a/src/main/webapp/assets/css/brooklyn.css
+++ b/src/main/webapp/assets/css/brooklyn.css
@@ -29,11 +29,12 @@ textarea {
 
 /* HEADER  */
 .logo {
-height: 44px !important;
-width: 195px !important;
-background: url(../images/brooklyn-logo.png) no-repeat;
-margin-top: 50px;
-margin-left: 40px;
+height: 86px !important;
+width: 240px !important;
+margin-top: 16px;
+background: url(../img/apache-brooklyn-feather-atop-720px.png) no-repeat;
+background-size: contain;
+margin-left: 15px;
 }
 
 .navbar-inner {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/dfc2d21b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-200px-wide.png
--
diff --git a/src/main/webapp/assets/img/Apache-Brooklyn-Logo-200px-wide.png 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-200px-wide.png
new file mode 100755
index 000..f8447a2
Binary files /dev/null and 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-200px-wide.png differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/dfc2d21b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-300px-wide.png
--
diff --git a/src/main/webapp/assets/img/Apache-Brooklyn-Logo-300px-wide.png 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-300px-wide.png
new file mode 100755
index 000..936c129
Binary files /dev/null and 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo-300px-wide.png differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/dfc2d21b/src/main/webapp/assets/img/Apache-Brooklyn-Logo_highres.png
--
diff --git a/src/main/webapp/assets/img/Apache-Brooklyn-Logo_highres.png 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo_highres.png
new file mode 100755
index 000..3fa68b4
Binary files /dev/null and 
b/src/main/webapp/assets/img/Apache-Brooklyn-Logo_highres.png differ

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/dfc2d21b/src/main/webapp/assets/img/apache-brooklyn-feather-atop-720px.png
--
diff --git a/src/main/webapp/assets/img/apache-brooklyn-feather-atop-720px.png 
b/src/main/webapp/assets/img/apache-brooklyn-feather-atop-720px.png
new file mode 100644
index 000..b097aa4
Binary files /dev/null and 
b/src/main/webapp/assets/img/apache-brooklyn-feather-atop-720px.png differ



[15/27] brooklyn-ui git commit: move codemirror libraries to the usual places

2016-02-18 Thread heneveld
move codemirror libraries to the usual places


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

Branch: refs/heads/master
Commit: d19e315616dcf837bb4117aee9ace0d4c5cc9a20
Parents: 438132f
Author: Alex Heneveld 
Authored: Fri Feb 12 15:53:28 2016 +
Committer: Alex Heneveld 
Committed: Fri Feb 12 15:56:51 2016 +

--
 .../assets/js/addon/display/placeholder.js  |   60 -
 .../webapp/assets/js/addon/hint/anyword-hint.js |   41 -
 .../webapp/assets/js/addon/hint/show-hint.js|  386 -
 src/main/webapp/assets/js/config.js |   14 +-
 src/main/webapp/assets/js/lib/codemirror.js | 8835 --
 src/main/webapp/assets/js/libs/codemirror.js| 8835 ++
 .../codemirror/addon/display/placeholder.js |   60 +
 .../libs/codemirror/addon/hint/anyword-hint.js  |   41 +
 .../js/libs/codemirror/addon/hint/show-hint.js  |  386 +
 .../assets/js/libs/codemirror/mode/yaml/yaml.js |  117 +
 src/main/webapp/assets/js/mode/yaml/yaml.js |  117 -
 src/test/javascript/config.txt  |6 +-
 12 files changed, 9449 insertions(+), 9449 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/addon/display/placeholder.js
--
diff --git a/src/main/webapp/assets/js/addon/display/placeholder.js 
b/src/main/webapp/assets/js/addon/display/placeholder.js
deleted file mode 100644
index ba6c096..000
--- a/src/main/webapp/assets/js/addon/display/placeholder.js
+++ /dev/null
@@ -1,60 +0,0 @@
-// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: http://codemirror.net/LICENSE
-
-(function(mod) {
-  if (typeof exports == "object" && typeof module == "object") // CommonJS
-mod(require("codemirror"));
-  else if (typeof define == "function" && define.amd) // AMD
-define(["codemirror"], mod);
-  else // Plain browser env
-mod(CodeMirror);
-})(function(CodeMirror) {
-  CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
-var prev = old && old != CodeMirror.Init;
-if (val && !prev) {
-  cm.on("blur", onBlur);
-  cm.on("change", onChange);
-  onChange(cm);
-} else if (!val && prev) {
-  cm.off("blur", onBlur);
-  cm.off("change", onChange);
-  clearPlaceholder(cm);
-  var wrapper = cm.getWrapperElement();
-  wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
-}
-
-if (val && !cm.hasFocus()) onBlur(cm);
-  });
-
-  function clearPlaceholder(cm) {
-if (cm.state.placeholder) {
-  cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
-  cm.state.placeholder = null;
-}
-  }
-  function setPlaceholder(cm) {
-clearPlaceholder(cm);
-var elt = cm.state.placeholder = document.createElement("pre");
-elt.style.cssText = "height: 0; overflow: visible";
-elt.className = "CodeMirror-placeholder";
-var placeHolder = cm.getOption("placeholder")
-if (typeof placeHolder == "string") placeHolder = 
document.createTextNode(placeHolder)
-elt.appendChild(placeHolder)
-cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
-  }
-
-  function onBlur(cm) {
-if (isEmpty(cm)) setPlaceholder(cm);
-  }
-  function onChange(cm) {
-var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
-wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + 
(empty ? " CodeMirror-empty" : "");
-
-if (empty) setPlaceholder(cm);
-else clearPlaceholder(cm);
-  }
-
-  function isEmpty(cm) {
-return (cm.lineCount() === 1) && (cm.getLine(0) === "");
-  }
-});

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/addon/hint/anyword-hint.js
--
diff --git a/src/main/webapp/assets/js/addon/hint/anyword-hint.js 
b/src/main/webapp/assets/js/addon/hint/anyword-hint.js
deleted file mode 100644
index ade4274..000
--- a/src/main/webapp/assets/js/addon/hint/anyword-hint.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: http://codemirror.net/LICENSE
-
-(function(mod) {
-  if (typeof exports == "object" && typeof module == "object") // CommonJS
-mod(require("codemirror"));
-  else if (typeof define == "function" && define.amd) // AMD
-define(["codemirror"], mod);
-  else // Plain browser env
-mod(CodeMirror);
-})(function(CodeMirror) {
-  "use strict";
-
-  var WORD = /[\w$]+/, RANGE = 500;
-
-

[14/27] brooklyn-ui git commit: move codemirror libraries to the usual places

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/lib/codemirror.js
--
diff --git a/src/main/webapp/assets/js/lib/codemirror.js 
b/src/main/webapp/assets/js/lib/codemirror.js
deleted file mode 100644
index c6f9af8..000
--- a/src/main/webapp/assets/js/lib/codemirror.js
+++ /dev/null
@@ -1,8835 +0,0 @@
-// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: http://codemirror.net/LICENSE
-
-// This is CodeMirror (http://codemirror.net), a code editor
-// implemented in JavaScript on top of the browser's DOM.
-//
-// You can find some technical background for some of the code below
-// at http://marijnhaverbeke.nl/blog/#cm-internals .
-
-(function(mod) {
-  if (typeof exports == "object" && typeof module == "object") // CommonJS
-module.exports = mod();
-  else if (typeof define == "function" && define.amd) // AMD
-return define([], mod);
-  else // Plain browser env
-this.CodeMirror = mod();
-})(function() {
-  "use strict";
-
-  // BROWSER SNIFFING
-
-  // Kludges for bugs and behavior differences that can't be feature
-  // detected are enabled based on userAgent etc sniffing.
-
-  var gecko = /gecko\/\d/i.test(navigator.userAgent);
-  var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
-  var ie_11up = 
/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
-  var ie = ie_upto10 || ie_11up;
-  var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
-  var webkit = /WebKit\//.test(navigator.userAgent);
-  var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
-  var chrome = /Chrome\//.test(navigator.userAgent);
-  var presto = /Opera\//.test(navigator.userAgent);
-  var safari = /Apple Computer/.test(navigator.vendor);
-  var mac_geMountainLion = /Mac OS X 
1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
-  var phantom = /PhantomJS/.test(navigator.userAgent);
-
-  var ios = /AppleWebKit/.test(navigator.userAgent) && 
/Mobile\/\w+/.test(navigator.userAgent);
-  // This is woefully incomplete. Suggestions for alternative methods welcome.
-  var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera 
Mobi|IEMobile/i.test(navigator.userAgent);
-  var mac = ios || /Mac/.test(navigator.platform);
-  var windows = /win/i.test(navigator.platform);
-
-  var presto_version = presto && 
navigator.userAgent.match(/Version\/(\d*\.\d*)/);
-  if (presto_version) presto_version = Number(presto_version[1]);
-  if (presto_version && presto_version >= 15) { presto = false; webkit = true; 
}
-  // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
-  var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || 
presto_version < 12.11));
-  var captureRightClick = gecko || (ie && ie_version >= 9);
-
-  // Optimize some code when these features are not used.
-  var sawReadOnlySpans = false, sawCollapsedSpans = false;
-
-  // EDITOR CONSTRUCTOR
-
-  // A CodeMirror instance represents an editor. This is the object
-  // that user code is usually dealing with.
-
-  function CodeMirror(place, options) {
-if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
-
-this.options = options = options ? copyObj(options) : {};
-// Determine effective options based on given values and defaults.
-copyObj(defaults, options, false);
-setGuttersForLineNumbers(options);
-
-var doc = options.value;
-if (typeof doc == "string") doc = new Doc(doc, options.mode, null, 
options.lineSeparator);
-this.doc = doc;
-
-var input = new CodeMirror.inputStyles[options.inputStyle](this);
-var display = this.display = new Display(place, doc, input);
-display.wrapper.CodeMirror = this;
-updateGutters(this);
-themeChanged(this);
-if (options.lineWrapping)
-  this.display.wrapper.className += " CodeMirror-wrap";
-if (options.autofocus && !mobile) display.input.focus();
-initScrollbars(this);
-
-this.state = {
-  keyMaps: [],  // stores maps added by addKeyMap
-  overlays: [], // highlighting overlays, as added by addOverlay
-  modeGen: 0,   // bumped when mode/overlay changes, used to invalidate 
highlighting info
-  overwrite: false,
-  delayingBlurEvent: false,
-  focused: false,
-  suppressEdits: false, // used to disable editing during key handlers 
when in readOnly mode
-  pasteIncoming: false, cutIncoming: false, // help recognize paste/cut 
edits in input.poll
-  selectingText: false,
-  draggingText: false,
-  highlight: new Delayed(), // stores highlight worker timeout
-  keySeq: null,  // Unfinished key sequence
-  specialChars: null
-};
-
-var cm = this;
-
-// Override magic textarea content restore that IE sometimes does
-// on our hidden textarea on reload
-if (ie && ie_version < 11) setTimeout(function() { 
cm.display.input.reset(true); }, 2

[19/27] brooklyn-ui git commit: add font awesome

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.svg
--
diff --git 
a/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.svg 
b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.svg
new file mode 100644
index 000..d05688e
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/fonts/fontawesome-webfont.svg
@@ -0,0 +1,655 @@
+
+http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"; >
+http://www.w3.org/2000/svg";>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[26/27] brooklyn-ui git commit: This closes #7

2016-02-18 Thread heneveld
This closes #7


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

Branch: refs/heads/master
Commit: e1646d733aaa0be281da891c56f999b2bb24fc9f
Parents: b7954f1 dfc2d21
Author: Alex Heneveld 
Authored: Thu Feb 18 09:12:08 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 09:12:08 2016 +

--
 src/main/license/source-inclusions.yaml |3 +
 src/main/webapp/assets/css/brooklyn.css |   21 +-
 .../webapp/assets/css/codemirror-brooklyn.css   |   14 +
 .../img/Apache-Brooklyn-Logo-200px-wide.png |  Bin 0 -> 4256 bytes
 .../img/Apache-Brooklyn-Logo-300px-wide.png |  Bin 0 -> 6068 bytes
 .../assets/img/Apache-Brooklyn-Logo_highres.png |  Bin 0 -> 42890 bytes
 .../img/apache-brooklyn-feather-atop-720px.png  |  Bin 0 -> 72926 bytes
 .../assets/js/addon/display/placeholder.js  |   60 -
 .../webapp/assets/js/addon/hint/anyword-hint.js |   41 -
 .../webapp/assets/js/addon/hint/show-hint.js|  386 -
 src/main/webapp/assets/js/config.js |   16 +-
 src/main/webapp/assets/js/lib/codemirror.js | 8835 --
 src/main/webapp/assets/js/libs/codemirror.js| 8835 ++
 .../codemirror/addon/display/placeholder.js |   60 +
 .../libs/codemirror/addon/hint/anyword-hint.js  |   41 +
 .../js/libs/codemirror/addon/hint/show-hint.js  |  386 +
 .../assets/js/libs/codemirror/mode/yaml/yaml.js |  117 +
 .../assets/js/libs/font-awesome/HELP-US-OUT.txt |7 +
 .../js/libs/font-awesome/css/font-awesome.css   | 2086 +
 .../libs/font-awesome/css/font-awesome.min.css  |4 +
 .../js/libs/font-awesome/fonts/FontAwesome.otf  |  Bin 0 -> 109688 bytes
 .../font-awesome/fonts/fontawesome-webfont.eot  |  Bin 0 -> 70807 bytes
 .../font-awesome/fonts/fontawesome-webfont.svg  |  655 ++
 .../font-awesome/fonts/fontawesome-webfont.ttf  |  Bin 0 -> 142072 bytes
 .../font-awesome/fonts/fontawesome-webfont.woff |  Bin 0 -> 83588 bytes
 .../fonts/fontawesome-webfont.woff2 |  Bin 0 -> 66624 bytes
 .../js/libs/font-awesome/less/animated.less |   34 +
 .../libs/font-awesome/less/bordered-pulled.less |   25 +
 .../assets/js/libs/font-awesome/less/core.less  |   12 +
 .../js/libs/font-awesome/less/fixed-width.less  |6 +
 .../js/libs/font-awesome/less/font-awesome.less |   17 +
 .../assets/js/libs/font-awesome/less/icons.less |  697 ++
 .../js/libs/font-awesome/less/larger.less   |   13 +
 .../assets/js/libs/font-awesome/less/list.less  |   19 +
 .../js/libs/font-awesome/less/mixins.less   |   26 +
 .../assets/js/libs/font-awesome/less/path.less  |   15 +
 .../libs/font-awesome/less/rotated-flipped.less |   20 +
 .../js/libs/font-awesome/less/stacked.less  |   20 +
 .../js/libs/font-awesome/less/variables.less|  708 ++
 .../js/libs/font-awesome/scss/_animated.scss|   34 +
 .../font-awesome/scss/_bordered-pulled.scss |   25 +
 .../assets/js/libs/font-awesome/scss/_core.scss |   12 +
 .../js/libs/font-awesome/scss/_fixed-width.scss |6 +
 .../js/libs/font-awesome/scss/_icons.scss   |  697 ++
 .../js/libs/font-awesome/scss/_larger.scss  |   13 +
 .../assets/js/libs/font-awesome/scss/_list.scss |   19 +
 .../js/libs/font-awesome/scss/_mixins.scss  |   26 +
 .../assets/js/libs/font-awesome/scss/_path.scss |   15 +
 .../font-awesome/scss/_rotated-flipped.scss |   20 +
 .../js/libs/font-awesome/scss/_stacked.scss |   20 +
 .../js/libs/font-awesome/scss/_variables.scss   |  708 ++
 .../js/libs/font-awesome/scss/font-awesome.scss |   17 +
 src/main/webapp/assets/js/mode/yaml/yaml.js |  117 -
 .../brooklyn-yaml-completion-proposals.js   |  372 +
 .../js/util/code-complete/js-yaml-parser.js |   48 +
 src/main/webapp/assets/js/view/editor.js|   29 +-
 src/main/webapp/assets/tpl/editor/page.html |8 +-
 src/main/webapp/index.html  |1 +
 src/test/javascript/config.txt  |8 +-
 59 files changed, 15915 insertions(+), 9459 deletions(-)
--




[01/27] brooklyn-ui git commit: tweak buttons for composer, following @tbouron and @hellberg suggestions

2016-02-18 Thread heneveld
Repository: brooklyn-ui
Updated Branches:
  refs/heads/master c2e374eb8 -> b9ba6544d


tweak buttons for composer, following @tbouron and @hellberg suggestions

also adjust height w custom codemirror styling


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/4cd4fead
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/4cd4fead
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/4cd4fead

Branch: refs/heads/master
Commit: 4cd4fead9ee387768e9e6a017a351eaef094d135
Parents: d67739c
Author: Alex Heneveld 
Authored: Thu Feb 11 17:35:41 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 .../webapp/assets/css/codemirror-brooklyn.css   | 29 
 src/main/webapp/assets/js/view/editor.js| 78 
 src/main/webapp/assets/tpl/editor/page.html | 36 +++--
 src/main/webapp/index.html  |  1 +
 4 files changed, 108 insertions(+), 36 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/4cd4fead/src/main/webapp/assets/css/codemirror-brooklyn.css
--
diff --git a/src/main/webapp/assets/css/codemirror-brooklyn.css 
b/src/main/webapp/assets/css/codemirror-brooklyn.css
new file mode 100644
index 000..c293ed4
--- /dev/null
+++ b/src/main/webapp/assets/css/codemirror-brooklyn.css
@@ -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.
+*/
+
+/* overrides for brooklyn */
+
+.CodeMirror {
+  height: auto;
+}
+.CodeMirror-scroll {
+  min-height: 480px;
+}
+.CodeMirror .CodeMirror-gutter.CodeMirror-linenumbers {
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/4cd4fead/src/main/webapp/assets/js/view/editor.js
--
diff --git a/src/main/webapp/assets/js/view/editor.js 
b/src/main/webapp/assets/js/view/editor.js
index 1b4dce3..f9ce5b6 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -60,8 +60,8 @@ define([
 events: {
 'click #button-run':'runBlueprint',
 'click #button-delete':'removeBlueprint',
-'click #button-convert':'convertBlueprint',
-'click #button-switch':'switchMode',
+'click #button-switch-app':'switchModeApp',
+'click #button-switch-catalog':'switchModeCatalog',
 'click #button-example':'populateExampleBlueprint',
 },
 editorTemplate:_.template(EditorHtml),
@@ -99,36 +99,39 @@ define([
 },
 refresh: function() {
 $("#button-run", this.$el).html(this.mode==MODE_CATALOG ? "Add to 
Catalog" : "Deploy");
-$("#button-delete", this.$el).html("Clear");
-$("#button-example", this.$el).html(this.mode==MODE_CATALOG ? 
"Insert Catalog Example" : "Insert Blueprint Example");
-$("#button-switch", this.$el).html(this.mode==MODE_CATALOG ? 
"Switch to Application Blueprint Mode" : "Switch to Catalog Mode");
+if (this.mode==MODE_CATALOG) {
+$("#button-switch-catalog", this.$el).addClass('active')
+$("#button-switch-app", this.$el).removeClass('active')
+} else {
+$("#button-switch-app", this.$el).addClass('active')
+$("#button-switch-catalog", this.$el).removeClass('active')
+}
 this.refreshOnMinorChange();
 },
 refreshOnMinorChange: function() {
 var yaml = this.editor && this.editor.getValue();
 var parse = this.parse();
 
-if (!yaml || parse.problem || this.mode==MODE_CATALOG) {
-$("#button-convert", this.$el).hide();
+// fine to switch to catalog
+/* always enable the switch to app button -- worst case it's 
invalid
+if (this.mode==MODE_CATALOG && yaml && (parse.problem || 
parse.result['brooklyn.catalog']) {
+$("#button-swi

[03/27] brooklyn-ui git commit: composer is aware whether it is catalog or blueprint mode

2016-02-18 Thread heneveld
composer is aware whether it is catalog or blueprint mode


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

Branch: refs/heads/master
Commit: 61201998b3b8177d62461e433052c94208adbcac
Parents: 0554b07
Author: Alex Heneveld 
Authored: Thu Feb 11 14:09:18 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 src/main/webapp/assets/js/view/editor.js| 24 +++-
 src/main/webapp/assets/tpl/editor/page.html |  9 +
 2 files changed, 28 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/61201998/src/main/webapp/assets/js/view/editor.js
--
diff --git a/src/main/webapp/assets/js/view/editor.js 
b/src/main/webapp/assets/js/view/editor.js
index baf534f..fa893fc 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -49,6 +49,10 @@ define([
 '  services:\n'+
 '  - type: \n'+
 '  location: \n';
+
+// is the user working on an app blueprint or a catalog item
+var MODE_APP = "app";
+var MODE_CATALOG = "catalog";
 
 var EditorView = Backbone.View.extend({
 tagName:"div",
@@ -63,6 +67,14 @@ define([
 
 initialize:function () {
 var vm = this;
+if (!this.options.type || this.options.type === MODE_APP) {
+this.setMode(MODE_APP);
+} else if (this.options.type === MODE_CATALOG) {
+this.setMode(MODE_CATALOG);
+} else {
+console.log("unknown mode '"+this.option.type+"'; using 
'"+MODE_APP+"'");
+this.setMode(MODE_APP);
+}
 this.options.catalog = new CatalogApplication.Collection();
 this.options.catalog.fetch({
 data: $.param({allVersions: true}),
@@ -71,11 +83,21 @@ define([
 }
 });
 },
+setMode: function(mode) {
+if (this.mode === mode) return;
+this.mode = mode;
+this.refresh();
+},
 render:function (eventName) {
 this.$el.html(_.template(EditorHtml, {}));
 this.loadEditor();
+this.refresh();
 return this;
 },
+refresh: function() {
+$("#button-run", this.$el).html(this.mode==MODE_CATALOG ? "Add to 
Catalog" : "Deploy");
+$("#button-delete", this.$el).html("Clear");
+},
 refreshEditor: function() {
 var cm = this.editor;
 if (typeof(cm) !== "undefined") {
@@ -138,7 +160,7 @@ define([
 },
 runBlueprint: function() {
 if (this.validate()){
-if(this.editor.getValue().slice(0,16) === 'brooklyn.catalog'){
+if (this.mode === MODE_CATALOG) {
 this.submitCatalog();
 }else{
 this.submitApplication();

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/61201998/src/main/webapp/assets/tpl/editor/page.html
--
diff --git a/src/main/webapp/assets/tpl/editor/page.html 
b/src/main/webapp/assets/tpl/editor/page.html
index 9a37fe0..727b4d4 100644
--- a/src/main/webapp/assets/tpl/editor/page.html
+++ b/src/main/webapp/assets/tpl/editor/page.html
@@ -20,10 +20,11 @@ under the License.
 
 
 
-YAML Composer
-
-Create
-Reset
+Blueprint Composer
+
+
+Run
+Clear
 
 
 



[21/27] brooklyn-ui git commit: use icons for example and docs link

2016-02-18 Thread heneveld
use icons for example and docs link


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

Branch: refs/heads/master
Commit: d4d88aab92794cf4b2e16cc429ae4dfaac518a94
Parents: 631292f
Author: Alex Heneveld 
Authored: Tue Feb 16 16:57:57 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 16:57:57 2016 +

--
 src/main/webapp/assets/js/view/editor.js| 4 
 src/main/webapp/assets/tpl/editor/page.html | 6 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d4d88aab/src/main/webapp/assets/js/view/editor.js
--
diff --git a/src/main/webapp/assets/js/view/editor.js 
b/src/main/webapp/assets/js/view/editor.js
index 19e4378..07f68c0 100644
--- a/src/main/webapp/assets/js/view/editor.js
+++ b/src/main/webapp/assets/js/view/editor.js
@@ -63,6 +63,7 @@ define([
 'click #button-switch-app':'switchModeApp',
 'click #button-switch-catalog':'switchModeCatalog',
 'click #button-example':'populateExampleBlueprint',
+'click #button-docs':'openDocumentation',
 },
 editorTemplate:_.template(EditorHtml),
 
@@ -286,6 +287,9 @@ define([
 populateExampleBlueprint: function() {
 this.editor.setValue(this.mode==MODE_CATALOG ? _DEFAULT_CATALOG : 
_DEFAULT_BLUEPRINT);
 },
+openDocumentation: function() {
+window.open(this.mode==MODE_CATALOG ? 
"https://brooklyn.apache.org/v/latest/ops/catalog/"; : 
"https://brooklyn.apache.org/v/latest/yaml/yaml-reference.html";, "_blank");
+},
 
 onSubmissionComplete: function(succeeded, data, type) {
 var that = this;

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d4d88aab/src/main/webapp/assets/tpl/editor/page.html
--
diff --git a/src/main/webapp/assets/tpl/editor/page.html 
b/src/main/webapp/assets/tpl/editor/page.html
index 67bb09c..05b62db 100644
--- a/src/main/webapp/assets/tpl/editor/page.html
+++ b/src/main/webapp/assets/tpl/editor/page.html
@@ -23,7 +23,11 @@ under the License.
 Blueprint Composer
 
 
-Insert Example
+
+
+
+
+
 
 
 

[12/27] brooklyn-ui git commit: move codemirror libraries to the usual places

2016-02-18 Thread heneveld
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/libs/codemirror/addon/display/placeholder.js
--
diff --git 
a/src/main/webapp/assets/js/libs/codemirror/addon/display/placeholder.js 
b/src/main/webapp/assets/js/libs/codemirror/addon/display/placeholder.js
new file mode 100644
index 000..ba6c096
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/codemirror/addon/display/placeholder.js
@@ -0,0 +1,60 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+  if (typeof exports == "object" && typeof module == "object") // CommonJS
+mod(require("codemirror"));
+  else if (typeof define == "function" && define.amd) // AMD
+define(["codemirror"], mod);
+  else // Plain browser env
+mod(CodeMirror);
+})(function(CodeMirror) {
+  CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
+var prev = old && old != CodeMirror.Init;
+if (val && !prev) {
+  cm.on("blur", onBlur);
+  cm.on("change", onChange);
+  onChange(cm);
+} else if (!val && prev) {
+  cm.off("blur", onBlur);
+  cm.off("change", onChange);
+  clearPlaceholder(cm);
+  var wrapper = cm.getWrapperElement();
+  wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
+}
+
+if (val && !cm.hasFocus()) onBlur(cm);
+  });
+
+  function clearPlaceholder(cm) {
+if (cm.state.placeholder) {
+  cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
+  cm.state.placeholder = null;
+}
+  }
+  function setPlaceholder(cm) {
+clearPlaceholder(cm);
+var elt = cm.state.placeholder = document.createElement("pre");
+elt.style.cssText = "height: 0; overflow: visible";
+elt.className = "CodeMirror-placeholder";
+var placeHolder = cm.getOption("placeholder")
+if (typeof placeHolder == "string") placeHolder = 
document.createTextNode(placeHolder)
+elt.appendChild(placeHolder)
+cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
+  }
+
+  function onBlur(cm) {
+if (isEmpty(cm)) setPlaceholder(cm);
+  }
+  function onChange(cm) {
+var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
+wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + 
(empty ? " CodeMirror-empty" : "");
+
+if (empty) setPlaceholder(cm);
+else clearPlaceholder(cm);
+  }
+
+  function isEmpty(cm) {
+return (cm.lineCount() === 1) && (cm.getLine(0) === "");
+  }
+});

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/libs/codemirror/addon/hint/anyword-hint.js
--
diff --git 
a/src/main/webapp/assets/js/libs/codemirror/addon/hint/anyword-hint.js 
b/src/main/webapp/assets/js/libs/codemirror/addon/hint/anyword-hint.js
new file mode 100644
index 000..ade4274
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/codemirror/addon/hint/anyword-hint.js
@@ -0,0 +1,41 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+  if (typeof exports == "object" && typeof module == "object") // CommonJS
+mod(require("codemirror"));
+  else if (typeof define == "function" && define.amd) // AMD
+define(["codemirror"], mod);
+  else // Plain browser env
+mod(CodeMirror);
+})(function(CodeMirror) {
+  "use strict";
+
+  var WORD = /[\w$]+/, RANGE = 500;
+
+  CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
+var word = options && options.word || WORD;
+var range = options && options.range || RANGE;
+var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
+var end = cur.ch, start = end;
+while (start && word.test(curLine.charAt(start - 1))) --start;
+var curWord = start != end && curLine.slice(start, end);
+
+var list = options && options.list || [], seen = {};
+var re = new RegExp(word.source, "g");
+for (var dir = -1; dir <= 1; dir += 2) {
+  var line = cur.line, endLine = Math.min(Math.max(line + dir * range, 
editor.firstLine()), editor.lastLine()) + dir;
+  for (; line != endLine; line += dir) {
+var text = editor.getLine(line), m;
+while (m = re.exec(text)) {
+  if (line == cur.line && m[0] === curWord) continue;
+  if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && 
!Object.prototype.hasOwnProperty.call(seen, m[0])) {
+seen[m[0]] = true;
+list.push(m[0]);
+  }
+}
+  }
+}
+return {list: list, from: CodeMirror.Pos(cur.line, start), to: 
CodeMirror.Pos(cur.line, end)};
+  });
+});

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/d19e3156/src/main/webapp/assets/js/libs/codemirror/addon/hint/show-hint.js
--

[20/27] brooklyn-ui git commit: add font awesome

2016-02-18 Thread heneveld
add font awesome


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/631292f7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/631292f7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/631292f7

Branch: refs/heads/master
Commit: 631292f73e3924b703410195af19465c2c114a69
Parents: 1058fa7
Author: Alex Heneveld 
Authored: Tue Feb 16 16:57:46 2016 +
Committer: Alex Heneveld 
Committed: Tue Feb 16 16:57:46 2016 +

--
 src/main/license/source-inclusions.yaml |3 +
 .../assets/js/libs/font-awesome/HELP-US-OUT.txt |7 +
 .../js/libs/font-awesome/css/font-awesome.css   | 2086 ++
 .../libs/font-awesome/css/font-awesome.min.css  |4 +
 .../js/libs/font-awesome/fonts/FontAwesome.otf  |  Bin 0 -> 109688 bytes
 .../font-awesome/fonts/fontawesome-webfont.eot  |  Bin 0 -> 70807 bytes
 .../font-awesome/fonts/fontawesome-webfont.svg  |  655 ++
 .../font-awesome/fonts/fontawesome-webfont.ttf  |  Bin 0 -> 142072 bytes
 .../font-awesome/fonts/fontawesome-webfont.woff |  Bin 0 -> 83588 bytes
 .../fonts/fontawesome-webfont.woff2 |  Bin 0 -> 66624 bytes
 .../js/libs/font-awesome/less/animated.less |   34 +
 .../libs/font-awesome/less/bordered-pulled.less |   25 +
 .../assets/js/libs/font-awesome/less/core.less  |   12 +
 .../js/libs/font-awesome/less/fixed-width.less  |6 +
 .../js/libs/font-awesome/less/font-awesome.less |   17 +
 .../assets/js/libs/font-awesome/less/icons.less |  697 ++
 .../js/libs/font-awesome/less/larger.less   |   13 +
 .../assets/js/libs/font-awesome/less/list.less  |   19 +
 .../js/libs/font-awesome/less/mixins.less   |   26 +
 .../assets/js/libs/font-awesome/less/path.less  |   15 +
 .../libs/font-awesome/less/rotated-flipped.less |   20 +
 .../js/libs/font-awesome/less/stacked.less  |   20 +
 .../js/libs/font-awesome/less/variables.less|  708 ++
 .../js/libs/font-awesome/scss/_animated.scss|   34 +
 .../font-awesome/scss/_bordered-pulled.scss |   25 +
 .../assets/js/libs/font-awesome/scss/_core.scss |   12 +
 .../js/libs/font-awesome/scss/_fixed-width.scss |6 +
 .../js/libs/font-awesome/scss/_icons.scss   |  697 ++
 .../js/libs/font-awesome/scss/_larger.scss  |   13 +
 .../assets/js/libs/font-awesome/scss/_list.scss |   19 +
 .../js/libs/font-awesome/scss/_mixins.scss  |   26 +
 .../assets/js/libs/font-awesome/scss/_path.scss |   15 +
 .../font-awesome/scss/_rotated-flipped.scss |   20 +
 .../js/libs/font-awesome/scss/_stacked.scss |   20 +
 .../js/libs/font-awesome/scss/_variables.scss   |  708 ++
 .../js/libs/font-awesome/scss/font-awesome.scss |   17 +
 src/main/webapp/index.html  |1 +
 37 files changed, 5980 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/license/source-inclusions.yaml
--
diff --git a/src/main/license/source-inclusions.yaml 
b/src/main/license/source-inclusions.yaml
index d1bb072..d61d6d6 100644
--- a/src/main/license/source-inclusions.yaml
+++ b/src/main/license/source-inclusions.yaml
@@ -41,3 +41,6 @@
 - id: jquery.form.js
 - id: marked.js
 - id: codemirror.js
+- id: font-awesome-fonts
+- id: font-awesome-code
+

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/HELP-US-OUT.txt
--
diff --git a/src/main/webapp/assets/js/libs/font-awesome/HELP-US-OUT.txt 
b/src/main/webapp/assets/js/libs/font-awesome/HELP-US-OUT.txt
new file mode 100644
index 000..cfd9d9f
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/HELP-US-OUT.txt
@@ -0,0 +1,7 @@
+I hope you love Font Awesome. If you've found it useful, please do me a favor 
and check out my latest project,
+Fonticons (https://fonticons.com). It makes it easy to put the perfect icons 
on your website. Choose from our awesome,
+comprehensive icon sets or copy and paste your own.
+
+Please. Check it out.
+
+-Dave Gandy

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/631292f7/src/main/webapp/assets/js/libs/font-awesome/css/font-awesome.css
--
diff --git a/src/main/webapp/assets/js/libs/font-awesome/css/font-awesome.css 
b/src/main/webapp/assets/js/libs/font-awesome/css/font-awesome.css
new file mode 100644
index 000..b2a5fe2
--- /dev/null
+++ b/src/main/webapp/assets/js/libs/font-awesome/css/font-awesome.css
@@ -0,0 +1,2086 @@
+/*!
+ *  Font Awesome 4.5.0 by @davegandy - http://fontawesome.io - @fontawesome
+ *  License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT 
License)
+ */
+/* FONT PATH
+ * ---

[09/27] brooklyn-ui git commit: app-add-wizard - remove tabs and a whole lot of code to support that, and allow "Open in Composer" for normal items, not just templates

2016-02-18 Thread heneveld
app-add-wizard - remove tabs and a whole lot of code to support that,
and allow "Open in Composer" for normal items, not just templates


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/9c6c06c9
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/9c6c06c9
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/9c6c06c9

Branch: refs/heads/master
Commit: 9c6c06c94212faaaf1d456a974820941ae08f353
Parents: 9d3d9bb
Author: Alex Heneveld 
Authored: Thu Feb 11 02:09:59 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 11 17:44:11 2016 +

--
 .../assets/js/view/application-add-wizard.js| 204 ---
 .../tpl/app-add-wizard/create-entity-entry.html |  64 --
 .../assets/tpl/app-add-wizard/create.html   |  46 +
 .../assets/tpl/app-add-wizard/modal-wizard.html |   2 +-
 4 files changed, 42 insertions(+), 274 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9c6c06c9/src/main/webapp/assets/js/view/application-add-wizard.js
--
diff --git a/src/main/webapp/assets/js/view/application-add-wizard.js 
b/src/main/webapp/assets/js/view/application-add-wizard.js
index 62d4db2..1174c5e 100644
--- a/src/main/webapp/assets/js/view/application-add-wizard.js
+++ b/src/main/webapp/assets/js/view/application-add-wizard.js
@@ -16,17 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
 */
+
 /**
- * Builds a Twitter Bootstrap modal as the framework for a Wizard.
- * Also creates an empty Application model.
+ * Supplies a modal (wizardy) with a list of apps a user can pick.
+ * Templates (items with yaml and with a location) go to composer, 
+ * other items (java, or yaml without a location) go to next *or* open in 
composer. 
  */
+ 
 define([
 "underscore", "jquery", "backbone", "brooklyn-utils", "js-yaml", 
"codemirror",
 "model/entity", "model/application", "model/location", 
"model/catalog-application",
 "text!tpl/app-add-wizard/modal-wizard.html",
 "text!tpl/app-add-wizard/create.html",
 "text!tpl/app-add-wizard/create-step-template-entry.html", 
-"text!tpl/app-add-wizard/create-entity-entry.html", 
 "text!tpl/app-add-wizard/required-config-entry.html",
 "text!tpl/app-add-wizard/edit-config-entry.html",
 "text!tpl/app-add-wizard/deploy.html",
@@ -40,7 +42,7 @@ define([
 "codemirror-addon-display-placeholder",
 "bootstrap"
 ], function (_, $, Backbone, Util, JsYaml, CodeMirror, Entity, Application, 
Location, CatalogApplication,
- ModalHtml, CreateHtml, CreateStepTemplateEntryHtml, 
CreateEntityEntryHtml,
+ ModalHtml, CreateHtml, CreateStepTemplateEntryHtml, 
  RequiredConfigEntryHtml, EditConfigEntryHtml, DeployHtml,
  DeployVersionOptionHtml, DeployLocationRowHtml, 
DeployLocationOptionHtml
 ) {
@@ -112,7 +114,6 @@ define([
 this.model = {}
 this.model.spec = new Application.Spec;
 this.model.yaml = "";
-this.model.mode = "template";  // or "yaml" or "other"
 this.currentStep = 0;
 this.steps = [
   {
@@ -166,7 +167,7 @@ define([
 
 setVisibility(this.$("#prev_step"), (this.currentStep > 0))
 
-this.isTemplate = false;
+var isTemplateWithLocation = false;
 {
 var yaml = (this.currentView && 
this.currentView.selectedTemplate && this.currentView.selectedTemplate.yaml);
 if (yaml) {
@@ -185,7 +186,7 @@ define([
 }
   }
 }
-this.isTemplate = (hasLocation ? true : false);
+isTemplateWithLocation = (hasLocation ? true : false);
 } catch (e) {
 log("Warning: could not parse yaml template of 
selected item")
 log(yaml);
@@ -193,41 +194,27 @@ define([
 }
 }
 
-// next shown for first step, but not for yaml
-var nextVisible = (this.currentStep < 1) && (this.model.mode != 
"yaml") && (!this.isTemplate);
-setVisibility(this.$("#next_step"), nextVisible)
+// preview (aka "Open in Composer") enabled and shown always
+setVisibility(this.$("#preview_step"), true);
+setEnablement(this.$("#preview_step"), true)
 
-// preview (aka "Open in Composer") shown for step 2 or for 
template (but again, not yaml)
-var previewVisible = (((this.currentStep < 1) && this.isTemplate) 
|| (this.currentStep == 1)) && (this.model.mode != "yaml")
-   

[1/2] brooklyn-server git commit: Adds equals and hashcode to DslComponent and related classes

2016-02-18 Thread aledsage
Repository: brooklyn-server
Updated Branches:
  refs/heads/master a5103bba5 -> a2820e5f6


Adds equals and hashcode to DslComponent and related classes


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

Branch: refs/heads/master
Commit: a721273c6eac9f969752babba86d249d97611fac
Parents: 0a5f3e1
Author: Martin Harris 
Authored: Fri Feb 12 16:51:22 2016 +
Committer: Martin Harris 
Committed: Wed Feb 17 12:25:33 2016 +

--
 .../spi/dsl/methods/BrooklynDslCommon.java  | 73 
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 56 +++
 2 files changed, 129 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a721273c/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
--
diff --git 
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
 
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
index 88a1f1d..48ea03f 100644
--- 
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
+++ 
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
@@ -58,6 +58,7 @@ import org.apache.brooklyn.util.text.Strings;
 import org.apache.commons.beanutils.BeanUtils;
 
 import com.google.common.base.Function;
+import com.google.common.base.Objects;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
@@ -231,6 +232,20 @@ public class BrooklynDslCommon {
 }
 
 @Override
+public int hashCode() {
+return Objects.hashCode(pattern, args);
+}
+
+@Override
+public boolean equals(Object obj) {
+if (this == obj) return true;
+if (obj == null || getClass() != obj.getClass()) return false;
+DslFormatString that = DslFormatString.class.cast(obj);
+return Objects.equal(this.pattern, that.pattern) &&
+Arrays.deepEquals(this.args, that.args);
+}
+
+@Override
 public String toString() {
 return "$brooklyn:formatString("+
 JavaStringEscapes.wrapJavaString(pattern)+
@@ -258,6 +273,21 @@ public class BrooklynDslCommon {
 }
 
 @Override
+public int hashCode() {
+return Objects.hashCode(source, pattern, replacement);
+}
+
+@Override
+public boolean equals(Object obj) {
+if (this == obj) return true;
+if (obj == null || getClass() != obj.getClass()) return false;
+DslRegexReplacement that = DslRegexReplacement.class.cast(obj);
+return Objects.equal(this.pattern, that.pattern) &&
+Objects.equal(this.replacement, that.replacement) &&
+Objects.equal(this.source, that.source);
+}
+
+@Override
 public String toString() {
 return String.format("$brooklyn:regexReplace(%s:%s:%s)",source, 
pattern, replacement);
 }
@@ -344,6 +374,21 @@ public class BrooklynDslCommon {
 }
 
 @Override
+public int hashCode() {
+return Objects.hashCode(type, fields, config);
+}
+
+@Override
+public boolean equals(Object obj) {
+if (this == obj) return true;
+if (obj == null || getClass() != obj.getClass()) return false;
+DslObject that = DslObject.class.cast(obj);
+return Objects.equal(this.type, that.type) &&
+Objects.equal(this.fields, that.fields) &&
+Objects.equal(this.config, that.config);
+}
+
+@Override
 public String toString() {
 return "$brooklyn:object(\""+type.getName()+"\")";
 }
@@ -383,6 +428,20 @@ public class BrooklynDslCommon {
 }
 
 @Override
+public int hashCode() {
+return Objects.hashCode(providerName, key);
+}
+
+@Override
+public boolean equals(Object obj) {
+if (this == obj) return true;
+if (obj == null || getClass() != obj.getClass()) return false;
+DslExternal that = DslExternal.class.cast(obj);
+return Objects.equal(this.providerName, that.providerName) &&
+Objects.equal(this.key, that.key);
+}
+
+@Override
 public String toString() {
 

[2/2] brooklyn-server git commit: This closes #24

2016-02-18 Thread aledsage
This closes #24


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

Branch: refs/heads/master
Commit: a2820e5f63439ee942f527898140414c3da38b09
Parents: a5103bb a721273
Author: Aled Sage 
Authored: Thu Feb 18 09:45:10 2016 +
Committer: Aled Sage 
Committed: Thu Feb 18 09:45:10 2016 +

--
 .../spi/dsl/methods/BrooklynDslCommon.java  | 73 
 .../brooklyn/spi/dsl/methods/DslComponent.java  | 56 +++
 2 files changed, 129 insertions(+)
--




[2/2] brooklyn-dist git commit: This closes #7

2016-02-18 Thread heneveld
This closes #7


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/006a31ee
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/006a31ee
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/006a31ee

Branch: refs/heads/master
Commit: 006a31eeaca9d44edc92d0c63308f9bc4de676ec
Parents: 00248bc 96660a0
Author: Alex Heneveld 
Authored: Thu Feb 18 09:10:27 2016 +
Committer: Alex Heneveld 
Committed: Thu Feb 18 09:10:27 2016 +

--
 vagrant/src/main/vagrant/servers.yaml | 1 +
 1 file changed, 1 insertion(+)
--




[1/2] brooklyn-dist git commit: Update servers.yaml

2016-02-18 Thread heneveld
Repository: brooklyn-dist
Updated Branches:
  refs/heads/master 00248bc51 -> 006a31eea


Update servers.yaml

added missing execute command on install_brooklyn.sh to fix permission denied 
error

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/commit/96660a07
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/tree/96660a07
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-dist/diff/96660a07

Branch: refs/heads/master
Commit: 96660a07e598e12e5ca229a962987a3e2a563736
Parents: 00248bc
Author: Murdo Aird 
Authored: Tue Feb 16 20:57:11 2016 +
Committer: Murdo Aird 
Committed: Tue Feb 16 20:57:11 2016 +

--
 vagrant/src/main/vagrant/servers.yaml | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/96660a07/vagrant/src/main/vagrant/servers.yaml
--
diff --git a/vagrant/src/main/vagrant/servers.yaml 
b/vagrant/src/main/vagrant/servers.yaml
index 3959fff..8c0c45e 100644
--- a/vagrant/src/main/vagrant/servers.yaml
+++ b/vagrant/src/main/vagrant/servers.yaml
@@ -47,6 +47,7 @@ servers:
 BROOKLYN_VERSION: 0.9.0-SNAPSHOT
 INSTALL_FROM_LOCAL_DIST: false
   cmd:
+- chmod a+x /vagrant/files/install_brooklyn.sh  
 - /vagrant/files/install_brooklyn.sh -v ${BROOKLYN_VERSION} -l 
${INSTALL_FROM_LOCAL_DIST}
 - sudo systemctl start brooklyn
 - sudo systemctl enable brooklyn