You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/05/14 21:53:47 UTC

[1/7] incubator-brooklyn git commit: switch docs to kramdown and replace triple backticks with triple tilde

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d78c1725d -> e4f44c88a


switch docs to kramdown and replace triple backticks with triple tilde

tilde is more portable, but apart from that kramdown is more widely used,
and it permits mixing html which we do on the brooklyn landing page
(with redcarpet that didn't render right)


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

Branch: refs/heads/master
Commit: 583185d91931b0038f7b2eacdd9d30e0243d98e4
Parents: 78776ca
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu May 7 10:42:59 2015 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu May 7 10:42:59 2015 +0100

----------------------------------------------------------------------
 docs/_config.yml                |  2 +-
 docs/guide/ops/catalog/index.md | 38 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/583185d9/docs/_config.yml
----------------------------------------------------------------------
diff --git a/docs/_config.yml b/docs/_config.yml
index a24029d..e25b279 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -18,7 +18,7 @@
 #
 
 encoding: utf-8
-markdown: redcarpet
+markdown: kramdown
 
 # where this will publish
 url_root: http://0.0.0.0:4000

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/583185d9/docs/guide/ops/catalog/index.md
----------------------------------------------------------------------
diff --git a/docs/guide/ops/catalog/index.md b/docs/guide/ops/catalog/index.md
index 8477204..074bbf3 100644
--- a/docs/guide/ops/catalog/index.md
+++ b/docs/guide/ops/catalog/index.md
@@ -5,8 +5,8 @@ children:
 - { section: General YAML Schema }
 - { section: Catalog Metadata }
 - { section: Catalog YAML Examples }
-- { section: Adding to the Catalog, title: Adding and Deleting } 
 - { section: Templates and the Add-Application Wizard, title: Templates }
+- { section: Adding to the Catalog, title: Adding and Deleting } 
 - { section: Versioning } 
 ---
 
@@ -25,19 +25,19 @@ specifying the catalog metadata for the items and the actual blueprint or resour
  
 A single catalog item can be defined following this general structure:
 
-```yaml
+~~~ yaml
 brooklyn.catalog:
   <catalog-metadata>
   item:
     <blueprint-or-resource-definition>
-```
+~~~ 
 
 
 To define multiple catalog items in a single YAML,
 where they may share some metadata,
 use the following structure:
 
-```yaml
+~~~ yaml
 brooklyn.catalog:
   <catalog-metadata>
   items:
@@ -47,7 +47,7 @@ brooklyn.catalog:
   - <additional-catalog-metadata>
     item:
       <blueprint-or-resource-definition>
-```
+~~~ 
 
 
 #### Catalog Metadata
@@ -70,10 +70,10 @@ To reference a catalog item in another blueprint, simply reference its ID and op
 For instance, if we've added an item with metadata `{ id: datastore, version: "1.0" }` (such as the example below),
 we could refer to it in another blueprint with: 
 
-```yaml
+~~~ yaml
 services:
 - type: datastore:1.0
-```
+~~~ 
 
 In addition to the above fields, exactly **one** of the following is also required:
 
@@ -128,7 +128,7 @@ with a nice display name, description, and icon.
 It can be referred in other blueprints to as `datastore:1.0`,
 and its implementation will be the Java class `brooklyn.entity.nosql.riak.RiakNode` included with Brooklyn.
 
-```yaml
+~~~ yaml
 brooklyn.catalog:
   id: datastore
   version: 1.0
@@ -139,14 +139,14 @@ brooklyn.catalog:
   item:
     type: brooklyn.entity.nosql.riak.RiakNode
     name: Riak Node
-```
+~~~ 
 
 
 ##### Multiple Items
 
 This YAML will install three items:
 
-```yaml
+~~~ yaml
 brooklyn.catalog:
   version: 1.1
   iconUrl: classpath://brooklyn/entity/nosql/riak/riak.png
@@ -178,7 +178,7 @@ brooklyn.catalog:
             provisioning.properties:
               # you can also define machine specs
               minRam: 8gb
-```
+~~~ 
 
 The items this will install are:
 
@@ -196,11 +196,11 @@ The items this will install are:
 
 The following legacy and experimental syntax is also supported:
 
-```yaml
+~~~ yaml
 <blueprint-definition>
 brooklyn.catalog:
   <catalog-metadata>
-```
+~~~ 
 
 In this format, the `brooklyn.catalog` block is optional;
 and an `id` in the `<blueprint-definition>` will be used to determine the catalog ID. 
@@ -236,9 +236,9 @@ In addition to the GUI, items can be added to the catalog via the REST API
 with a `POST` of the YAML file to `/v1/catalog` endpoint.
 To do this using `curl`:
 
-```bash
+~~~ bash
 curl http://127.0.0.1:8081/v1/catalog --data-binary @/path/to/riak.catalog.bom
-```
+~~~ 
 
 
 
@@ -247,9 +247,9 @@ curl http://127.0.0.1:8081/v1/catalog --data-binary @/path/to/riak.catalog.bom
 You can delete a versioned item from the catalog using the same endpoint as the REST API. 
 For example, to delete the item with id `datastore` and version `1.0` with `curl`:
 
-```bash
+~~~ bash
 curl -X DELETE http://127.0.0.1:8081/v1/catalog/entities/datastore/1.0
-```
+~~~ 
 
 **Note:** Catalog items should not be deleted if there are running apps which were created using the same item. 
 During rebinding the catalog item is used to reconstruct the entity.
@@ -262,9 +262,9 @@ in a future release.
 Deprecation applies to a specific version of a catalog item, so the full
 id including the version number is passed to the REST API as follows:
 
-```bash
+~~~ bash
 curl -X POST http://127.0.0.1:8081/v1/catalog/entities/MySQL:1.0/deprecated/true
-```
+~~~ 
 
 
 ### Versioning


[7/7] incubator-brooklyn git commit: This closes #641

Posted by he...@apache.org.
This closes #641


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

Branch: refs/heads/master
Commit: e4f44c88a3fe34a8e771da53c509df8b7983ad81
Parents: 8026036 702e120
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu May 14 12:52:32 2015 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu May 14 12:52:32 2015 -0700

----------------------------------------------------------------------
 .../brooklyn/util/exceptions/Exceptions.java    | 20 +++---
 .../main/java/brooklyn/util/text/Strings.java   | 68 ++++++++++++++----
 .../java/brooklyn/util/text/StringsTest.java    | 76 +++++++++++---------
 3 files changed, 106 insertions(+), 58 deletions(-)
----------------------------------------------------------------------



[5/7] incubator-brooklyn git commit: Strings.removeAllFromStart/End only call substring() once.

Posted by he...@apache.org.
Strings.removeAllFromStart/End only call substring() once.

Java 7 update 6 changed the cost of String.substring from O(1) to O(n).
This commit changes the two removeAll methods to make one substring calls
rather than one per match.


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

Branch: refs/heads/master
Commit: 28f7c5942fb15e890da1e585d085af81336b0e5c
Parents: 4e78e67
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Tue May 12 20:26:57 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Thu May 14 11:05:31 2015 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/util/text/Strings.java   | 30 +++++++++++++-------
 .../java/brooklyn/util/text/StringsTest.java    |  6 ++++
 2 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/28f7c594/utils/common/src/main/java/brooklyn/util/text/Strings.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/text/Strings.java b/utils/common/src/main/java/brooklyn/util/text/Strings.java
index 5736441..05957c4 100644
--- a/utils/common/src/main/java/brooklyn/util/text/Strings.java
+++ b/utils/common/src/main/java/brooklyn/util/text/Strings.java
@@ -151,20 +151,24 @@ public class Strings {
         return string;
     }
 
-    /** as removeFromEnd, but repeats until all such suffixes are gone */
-    public static String removeAllFromEnd(String string, String ...suffixes) {
+    /**
+     * As removeFromEnd, but repeats until all such suffixes are gone
+     */
+    public static String removeAllFromEnd(String string, String... suffixes) {
+        if (isEmpty(string)) return string;
+        int index = string.length();
         boolean anotherLoopNeeded = true;
         while (anotherLoopNeeded) {
             if (isEmpty(string)) return string;
             anotherLoopNeeded = false;
             for (String suffix : suffixes)
-                if (string.endsWith(suffix)) {
-                    string = string.substring(0, string.length() - suffix.length());
+                if (!isEmpty(suffix) && string.startsWith(suffix, index - suffix.length())) {
+                    index -= suffix.length();
                     anotherLoopNeeded = true;
                     break;
                 }
         }
-        return string;
+        return string.substring(0, index);
     }
 
     /**
@@ -193,20 +197,24 @@ public class Strings {
         return string;
     }
 
-    /** as removeFromStart, but repeats until all such suffixes are gone */
-    public static String removeAllFromStart(String string, String ...prefixes) {
+    /**
+     * As {@link #removeFromStart(String, String)}, repeating until all such prefixes are gone.
+     */
+    public static String removeAllFromStart(String string, String... prefixes) {
+        int index = 0;
         boolean anotherLoopNeeded = true;
         while (anotherLoopNeeded) {
             if (isEmpty(string)) return string;
             anotherLoopNeeded = false;
-            for (String prefix : prefixes)
-                if (string.startsWith(prefix)) {
-                    string = string.substring(prefix.length());
+            for (String prefix : prefixes) {
+                if (!isEmpty(prefix) && string.startsWith(prefix, index)) {
+                    index += prefix.length();
                     anotherLoopNeeded = true;
                     break;
                 }
+            }
         }
-        return string;
+        return string.substring(index);
     }
 
     /** convenience for {@link com.google.common.base.Joiner} */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/28f7c594/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/text/StringsTest.java b/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
index a9780c1..5759c6f 100644
--- a/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
+++ b/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
@@ -108,12 +108,15 @@ public class StringsTest extends FixedLocaleTest {
     public void testRemoveAllFromEnd() {
         assertEquals(Strings.removeAllFromEnd("", "bar"), "");
         assertEquals(Strings.removeAllFromEnd(null, "bar"), null);
+        assertEquals(Strings.removeAllFromEnd("foo", ""), "foo");
 
         assertEquals(Strings.removeAllFromEnd("foobar", "foo", "bar"), "");
         assertEquals(Strings.removeAllFromEnd("foobar", "ar", "car", "b", "o"), "f");
         // test they are applied in order
         assertEquals(Strings.removeAllFromEnd("foobar", "ar", "car", "b", "ob"), "foo");
         assertEquals(Strings.removeAllFromEnd("foobar", "zz", "x"), "foobar");
+        assertEquals(Strings.removeAllFromEnd("foobarbaz", "bar", "baz"), "foo");
+        assertEquals(Strings.removeAllFromEnd("foobarbaz", "baz", "", "foo", "bar", "baz"), "");
     }
 
     public void testRemoveFromStart() {
@@ -129,6 +132,7 @@ public class StringsTest extends FixedLocaleTest {
     public void testRemoveAllFromStart() {
         assertEquals(Strings.removeAllFromStart("", "foo"), "");
         assertEquals(Strings.removeAllFromStart(null, "foo"), null);
+        assertEquals(Strings.removeAllFromStart("foo", ""), "foo");
 
         assertEquals(Strings.removeAllFromStart("foobar", "foo"), "bar");
         assertEquals(Strings.removeAllFromStart("foo", "bar"), "foo");
@@ -138,6 +142,8 @@ public class StringsTest extends FixedLocaleTest {
         assertEquals(Strings.removeAllFromStart("foobar", "ob", "fo", "o"), "ar");
         // test they are applied in order, "ob" doesn't match because "o" eats the o
         assertEquals(Strings.removeAllFromStart("foobar", "o", "fo", "ob"), "bar");
+        assertEquals(Strings.removeAllFromStart("foobarbaz", "bar", "foo"), "baz");
+        assertEquals(Strings.removeAllFromStart("foobarbaz", "baz", "bar", "foo"), "");
     }
 
     public void testRemoveFromStart2() {


[3/7] incubator-brooklyn git commit: assert(actual, expected) in StringsTest

Posted by he...@apache.org.
assert(actual, expected) in StringsTest


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

Branch: refs/heads/master
Commit: c39fec26e13b1de63f043a3afb913ce97f5a4b43
Parents: d78c172
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Tue May 12 19:16:32 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Thu May 14 11:05:27 2015 +0100

----------------------------------------------------------------------
 .../java/brooklyn/util/text/StringsTest.java    | 70 ++++++++++----------
 1 file changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c39fec26/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
----------------------------------------------------------------------
diff --git a/utils/common/src/test/java/brooklyn/util/text/StringsTest.java b/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
index c86c03b..a9780c1 100644
--- a/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
+++ b/utils/common/src/test/java/brooklyn/util/text/StringsTest.java
@@ -80,64 +80,64 @@ public class StringsTest extends FixedLocaleTest {
     }
 
     public void makeValidJavaName() {
-        assertEquals("__null", Strings.makeValidJavaName(null));
-        assertEquals("__empty", Strings.makeValidJavaName(""));
-        assertEquals("abcdef", Strings.makeValidJavaName("abcdef"));
-        assertEquals("abcdef", Strings.makeValidJavaName("a'b'c'd'e'f"));
-        assertEquals("_12345", Strings.makeValidJavaName("12345"));
+        assertEquals(Strings.makeValidJavaName(null), "__null");
+        assertEquals(Strings.makeValidJavaName(""), "__empty");
+        assertEquals(Strings.makeValidJavaName("abcdef"), "abcdef");
+        assertEquals(Strings.makeValidJavaName("a'b'c'd'e'f"), "abcdef");
+        assertEquals(Strings.makeValidJavaName("12345"), "_12345");
     }
 
     public void makeValidUniqueJavaName() {
-        assertEquals("__null", Strings.makeValidUniqueJavaName(null));
-        assertEquals("__empty", Strings.makeValidUniqueJavaName(""));
-        assertEquals("abcdef", Strings.makeValidUniqueJavaName("abcdef"));
-        assertEquals("_12345", Strings.makeValidUniqueJavaName("12345"));
+        assertEquals(Strings.makeValidUniqueJavaName(null), "__null");
+        assertEquals(Strings.makeValidUniqueJavaName(""), "__empty");
+        assertEquals(Strings.makeValidUniqueJavaName("abcdef"), "abcdef");
+        assertEquals(Strings.makeValidUniqueJavaName("12345"), "_12345");
     }
 
     public void testRemoveFromEnd() {
-        assertEquals("", Strings.removeFromEnd("", "bar"));
-        assertEquals(null, Strings.removeFromEnd(null, "bar"));
+        assertEquals(Strings.removeFromEnd("", "bar"), "");
+        assertEquals(Strings.removeFromEnd(null, "bar"), null);
 
-        assertEquals("foo", Strings.removeFromEnd("foobar", "bar"));
-        assertEquals("foo", Strings.removeFromEnd("foo", "bar"));
-        assertEquals("foo", Strings.removeFromEnd("foobar", "foo", "bar"));
+        assertEquals(Strings.removeFromEnd("foobar", "bar"), "foo");
+        assertEquals(Strings.removeFromEnd("foo", "bar"), "foo");
+        assertEquals(Strings.removeFromEnd("foobar", "foo", "bar"), "foo");
         // test they are applied in order
-        assertEquals("foob", Strings.removeFromEnd("foobar", "ar", "bar", "b"));
+        assertEquals(Strings.removeFromEnd("foobar", "ar", "bar", "b"), "foob");
     }
 
     public void testRemoveAllFromEnd() {
-        assertEquals("", Strings.removeAllFromEnd("", "bar"));
-        assertEquals(null, Strings.removeAllFromEnd(null, "bar"));
+        assertEquals(Strings.removeAllFromEnd("", "bar"), "");
+        assertEquals(Strings.removeAllFromEnd(null, "bar"), null);
 
-        assertEquals("", Strings.removeAllFromEnd("foobar", "foo", "bar"));
-        assertEquals("f", Strings.removeAllFromEnd("foobar", "ar", "car", "b", "o"));
+        assertEquals(Strings.removeAllFromEnd("foobar", "foo", "bar"), "");
+        assertEquals(Strings.removeAllFromEnd("foobar", "ar", "car", "b", "o"), "f");
         // test they are applied in order
-        assertEquals("foo", Strings.removeAllFromEnd("foobar", "ar", "car", "b", "ob"));
-        assertEquals("foobar", Strings.removeAllFromEnd("foobar", "zz", "x"));
+        assertEquals(Strings.removeAllFromEnd("foobar", "ar", "car", "b", "ob"), "foo");
+        assertEquals(Strings.removeAllFromEnd("foobar", "zz", "x"), "foobar");
     }
 
     public void testRemoveFromStart() {
-        assertEquals("", Strings.removeFromStart("", "foo"));
-        assertEquals(null, Strings.removeFromStart(null, "foo"));
+        assertEquals(Strings.removeFromStart("", "foo"), "");
+        assertEquals(Strings.removeFromStart(null, "foo"), null);
 
-        assertEquals("bar", Strings.removeFromStart("foobar", "foo"));
-        assertEquals("foo", Strings.removeFromStart("foo", "bar"));
-        assertEquals("bar", Strings.removeFromStart("foobar", "foo", "bar"));
-        assertEquals("obar", Strings.removeFromStart("foobar", "ob", "fo", "foo", "o"));
+        assertEquals(Strings.removeFromStart("foobar", "foo"), "bar");
+        assertEquals(Strings.removeFromStart("foo", "bar"), "foo");
+        assertEquals(Strings.removeFromStart("foobar", "foo", "bar"), "bar");
+        assertEquals(Strings.removeFromStart("foobar", "ob", "fo", "foo", "o"), "obar");
     }
 
     public void testRemoveAllFromStart() {
-        assertEquals("", Strings.removeAllFromStart("", "foo"));
-        assertEquals(null, Strings.removeAllFromStart(null, "foo"));
+        assertEquals(Strings.removeAllFromStart("", "foo"), "");
+        assertEquals(Strings.removeAllFromStart(null, "foo"), null);
 
-        assertEquals("bar", Strings.removeAllFromStart("foobar", "foo"));
-        assertEquals("foo", Strings.removeAllFromStart("foo", "bar"));
-        assertEquals("", Strings.removeAllFromStart("foobar", "foo", "bar"));
+        assertEquals(Strings.removeAllFromStart("foobar", "foo"), "bar");
+        assertEquals(Strings.removeAllFromStart("foo", "bar"), "foo");
+        assertEquals(Strings.removeAllFromStart("foobar", "foo", "bar"), "");
 
-        assertEquals("ar", Strings.removeAllFromStart("foobar", "fo", "ob", "o"));
-        assertEquals("ar", Strings.removeAllFromStart("foobar", "ob", "fo", "o"));
+        assertEquals(Strings.removeAllFromStart("foobar", "fo", "ob", "o"), "ar");
+        assertEquals(Strings.removeAllFromStart("foobar", "ob", "fo", "o"), "ar");
         // test they are applied in order, "ob" doesn't match because "o" eats the o
-        assertEquals("bar", Strings.removeAllFromStart("foobar", "o", "fo", "ob"));
+        assertEquals(Strings.removeAllFromStart("foobar", "o", "fo", "ob"), "bar");
     }
 
     public void testRemoveFromStart2() {


[4/7] incubator-brooklyn git commit: Exceptions.stripBoringPrefixes calls removeAllFromStart once with all prefixes

Posted by he...@apache.org.
Exceptions.stripBoringPrefixes calls removeAllFromStart once with all prefixes


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

Branch: refs/heads/master
Commit: 702e1205811920e9a4c9c00cf79a523bfe200b23
Parents: 28f7c59
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Tue May 12 20:28:48 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Thu May 14 11:05:31 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/util/exceptions/Exceptions.java    | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/702e1205/utils/common/src/main/java/brooklyn/util/exceptions/Exceptions.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/exceptions/Exceptions.java b/utils/common/src/main/java/brooklyn/util/exceptions/Exceptions.java
index 4303e4e..57dbf54 100644
--- a/utils/common/src/main/java/brooklyn/util/exceptions/Exceptions.java
+++ b/utils/common/src/main/java/brooklyn/util/exceptions/Exceptions.java
@@ -24,6 +24,7 @@ import static com.google.common.base.Throwables.getCausalChain;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
@@ -35,6 +36,7 @@ import com.google.common.base.Predicates;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 
 public class Exceptions {
 
@@ -69,14 +71,16 @@ public class Exceptions {
     }
 
     private static String stripBoringPrefixes(String s) {
-        String was;
-        do {
-            was = s;
-            for (Class<? extends Throwable> type: BORING_PREFIX_THROWABLE_EXACT_TYPES) {
-                s = Strings.removeAllFromStart(s, type.getCanonicalName(), type.getName(), type.getSimpleName(), ":", " ");
-            }
-        } while (!was.equals(s));
-        return s;
+        ArrayList<String> prefixes = Lists.newArrayListWithCapacity(2 + BORING_PREFIX_THROWABLE_EXACT_TYPES.size() * 3);
+        for (Class<? extends Throwable> type : BORING_PREFIX_THROWABLE_EXACT_TYPES) {
+            prefixes.add(type.getCanonicalName());
+            prefixes.add(type.getName());
+            prefixes.add(type.getSimpleName());
+        }
+        prefixes.add(":");
+        prefixes.add(" ");
+        String[] ps = prefixes.toArray(new String[prefixes.size()]);
+        return Strings.removeAllFromStart(s, ps);
     }
 
     /**


[2/7] incubator-brooklyn git commit: Deprecates removeFromStart/End(String, String...)

Posted by he...@apache.org.
Deprecates removeFromStart/End(String, String...)

The only uses of Start that give more than one prefix are the method's
tests. There is only one use of End that may as well be removeAllFromEnd.


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

Branch: refs/heads/master
Commit: 4e78e67e4935612049cdfc33fd866de15ee64d71
Parents: c39fec2
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Tue May 12 20:21:11 2015 +0100
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Thu May 14 11:05:27 2015 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/util/text/Strings.java   | 38 +++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4e78e67e/utils/common/src/main/java/brooklyn/util/text/Strings.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/text/Strings.java b/utils/common/src/main/java/brooklyn/util/text/Strings.java
index c619565..5736441 100644
--- a/utils/common/src/main/java/brooklyn/util/text/Strings.java
+++ b/utils/common/src/main/java/brooklyn/util/text/Strings.java
@@ -125,10 +125,25 @@ public class Strings {
         if (isEmpty(s)) throw new IllegalArgumentException(message);
     }
 
+    /**
+     * Removes suffix from the end of the string. Returns string if it does not end with suffix.
+     */
+    public static String removeFromEnd(String string, String suffix) {
+        if (isEmpty(string)) {
+            return string;
+        } else if (!isEmpty(suffix) && string.endsWith(suffix)) {
+            return string.substring(0, string.length() - suffix.length());
+        } else {
+            return string;
+        }
+    }
+
     /** removes the first suffix in the list which is present at the end of string
      * and returns that string; ignores subsequent suffixes if a matching one is found;
      * returns the original string if no suffixes are at the end
+     * @deprecated since 0.7.0 use {@link #removeFromEnd(String, String)} or {@link #removeAllFromEnd(String, String...)}
      */
+    @Deprecated
     public static String removeFromEnd(String string, String ...suffixes) {
         if (isEmpty(string)) return string;
         for (String suffix : suffixes)
@@ -152,10 +167,25 @@ public class Strings {
         return string;
     }
 
+    /**
+     * Removes prefix from the beginning of string. Returns string if it does not begin with prefix.
+     */
+    public static String removeFromStart(String string, String prefix) {
+        if (isEmpty(string)) {
+            return string;
+        } else if (!isEmpty(prefix) && string.startsWith(prefix)) {
+            return string.substring(prefix.length());
+        } else {
+            return string;
+        }
+    }
+
     /** removes the first prefix in the list which is present at the start of string
      * and returns that string; ignores subsequent prefixes if a matching one is found;
      * returns the original string if no prefixes match
+     * @deprecated since 0.7.0 use {@link #removeFromStart(String, String)}
      */
+    @Deprecated
     public static String removeFromStart(String string, String ...prefixes) {
         if (isEmpty(string)) return string;
         for (String prefix : prefixes)
@@ -180,23 +210,23 @@ public class Strings {
     }
 
     /** convenience for {@link com.google.common.base.Joiner} */
-    public static String join(Iterable<? extends Object> list, String seperator) {
+    public static String join(Iterable<? extends Object> list, String separator) {
         if (list==null) return null;
         boolean app = false;
         StringBuilder out = new StringBuilder();
         for (Object s: list) {
-            if (app) out.append(seperator);
+            if (app) out.append(separator);
             out.append(s);
             app = true;
         }
         return out.toString();
     }
     /** convenience for {@link com.google.common.base.Joiner} */
-    public static String join(Object[] list, String seperator) {
+    public static String join(Object[] list, String separator) {
         boolean app = false;
         StringBuilder out = new StringBuilder();
         for (Object s: list) {
-            if (app) out.append(seperator);
+            if (app) out.append(separator);
             out.append(s);
             app = true;
         }


[6/7] incubator-brooklyn git commit: This closes #632

Posted by he...@apache.org.
This closes #632


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

Branch: refs/heads/master
Commit: 8026036d2ebefe29a63672c1d5e1b27d2889a49c
Parents: d78c172 583185d
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu May 14 12:50:08 2015 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu May 14 12:50:08 2015 -0700

----------------------------------------------------------------------
 docs/_config.yml                |  2 +-
 docs/guide/ops/catalog/index.md | 38 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------