brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [07/18] incubator-brooklyn git commit: Catalog versioning - Clean up the CatalogItem interface
Date Thu, 13 Nov 2014 22:23:40 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/catalog/internal/CatalogLoadTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/catalog/internal/CatalogLoadTest.java b/core/src/test/java/brooklyn/catalog/internal/CatalogLoadTest.java
index 976223e..f36d4c9 100644
--- a/core/src/test/java/brooklyn/catalog/internal/CatalogLoadTest.java
+++ b/core/src/test/java/brooklyn/catalog/internal/CatalogLoadTest.java
@@ -56,11 +56,11 @@ public class CatalogLoadTest {
         assertEquals(template.getDisplayName(), "Entity name");
         assertEquals(template.getVersion(), "9.1.3");
         assertEquals(template.getJavaType(), "com.example.ExampleApp");
-        assertEquals(template.getLibraries().getBundles().size(), 2,
-                "Template bundles=" + Joiner.on(", ").join(template.getLibraries().getBundles()));
+        assertEquals(template.getLibraries().size(), 2,
+                "Template bundles=" + Joiner.on(", ").join(template.getLibraries()));
         
         boolean foundBundle1 = false, foundBundle2 = false;
-        for (CatalogBundle bundle : template.getLibraries().getBundles()) {
+        for (CatalogBundle bundle : template.getLibraries()) {
             if (bundle.getUrl().equals("file://path/to/bundle.jar")) {
                 foundBundle1 = true;
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java b/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
index a599755..91372f0 100644
--- a/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
+++ b/core/src/test/java/brooklyn/catalog/internal/CatalogScanTest.java
@@ -99,18 +99,19 @@ public class CatalogScanTest {
         loadAnnotationsOnlyCatalog();
         BrooklynCatalog c = annotsCatalog;
         
-        Iterable<CatalogItem<Object,Object>> bases = c.getCatalogItems(CatalogPredicates.name(Predicates.containsPattern("MyBaseEntity")));
+        Iterable<CatalogItem<Object,Object>> bases = c.getCatalogItems(CatalogPredicates.displayName(Predicates.containsPattern("MyBaseEntity")));
         Assert.assertEquals(Iterables.size(bases), 0, "should have been empty: "+bases);
         
-        Iterable<CatalogItem<Object,Object>> asdfjkls = c.getCatalogItems(CatalogPredicates.name(Predicates.containsPattern("__asdfjkls__shouldnotbefound")));
+        Iterable<CatalogItem<Object,Object>> asdfjkls = c.getCatalogItems(CatalogPredicates.displayName(Predicates.containsPattern("__asdfjkls__shouldnotbefound")));
         Assert.assertEquals(Iterables.size(asdfjkls), 0);
         
-        Iterable<CatalogItem<Object,Object>> silly1 = c.getCatalogItems(CatalogPredicates.name(Predicates.equalTo("MySillyAppTemplate")));
+        Iterable<CatalogItem<Object,Object>> silly1 = c.getCatalogItems(CatalogPredicates.displayName(Predicates.equalTo("MySillyAppTemplate")));
         Iterable<CatalogItem<Object,Object>> silly2 = c.getCatalogItems(CatalogPredicates.javaType(Predicates.equalTo(MySillyAppTemplate.class.getName())));
-        Assert.assertEquals(Iterables.getOnlyElement(silly1), Iterables.getOnlyElement(silly2));
+        CatalogItem<Object, Object> silly1El = Iterables.getOnlyElement(silly1);
+        Assert.assertEquals(silly1El, Iterables.getOnlyElement(silly2));
         
-        CatalogItem<Application,EntitySpec<? extends Application>> s1 = c.getCatalogItem(Application.class, silly1.iterator().next().getId());
-        Assert.assertEquals(s1, Iterables.getOnlyElement(silly1));
+        CatalogItem<Application,EntitySpec<? extends Application>> s1 = c.getCatalogItem(Application.class, silly1El.getSymbolicName(), silly1El.getVersion());
+        Assert.assertEquals(s1, silly1El);
         
         Assert.assertEquals(s1.getDescription(), "Some silly app test");
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/entity/rebind/RebindCatalogItemTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogItemTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogItemTest.java
index a601bb7..8d44e3d 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogItemTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogItemTest.java
@@ -150,7 +150,7 @@ public class RebindCatalogItemTest extends RebindTestFixtureWithApp {
         // persistence window. Because BrooklynMementoPersisterToObjectStore applies writes/deletes
         // asynchronously the winner is down to a race and the test might pass or fail.
         origManagementContext.getRebindManager().forcePersistNow();
-        origManagementContext.getCatalog().deleteCatalogItem(toRemove.getId(), toRemove.getVersion());
+        origManagementContext.getCatalog().deleteCatalogItem(toRemove.getSymbolicName(), toRemove.getVersion());
         assertEquals(Iterables.size(origManagementContext.getCatalog().getCatalogItems()), 0);
         rebindAndAssertCatalogsAreEqual();
         assertEquals(Iterables.size(newManagementContext.getCatalog().getCatalogItems()), 0);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java
index 728126e..8a64e6c 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogWhenCatalogPersistenceDisabledTest.java
@@ -82,7 +82,7 @@ public class RebindCatalogWhenCatalogPersistenceDisabledTest extends RebindTestF
     public void testModificationsToCatalogAreNotPersistedWhenCatalogPersistenceFeatureIsDisabled() throws Exception {
         assertEquals(Iterables.size(origManagementContext.getCatalog().getCatalogItems()), 1);
         CatalogItem<Object, Object> toRemove = Iterables.getOnlyElement(origManagementContext.getCatalog().getCatalogItems());
-        origManagementContext.getCatalog().deleteCatalogItem(toRemove.getId(), toRemove.getVersion());
+        origManagementContext.getCatalog().deleteCatalogItem(toRemove.getSymbolicName(), toRemove.getVersion());
         assertEquals(Iterables.size(origManagementContext.getCatalog().getCatalogItems()), 0);
 
         rebind();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
index 2973276..f97fb85 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindTestFixture.java
@@ -249,11 +249,9 @@ public abstract class RebindTestFixture<T extends StartableApplication> {
     }
 
     private Set<String> getCatalogItemIds(Iterable<CatalogItem<Object, Object>> catalogItems) {
-        Set<String> itemIds = Sets.<String>newHashSet();
-        for (CatalogItem<?, ?> item : catalogItems) {
-            itemIds.add(item.getId() + ":" + item.getVersion());
-        }
-        return itemIds;
+        return FluentIterable.from(catalogItems)
+                .transform(EntityFunctions.id())
+                .copyInto(Sets.<String>newHashSet());
    }
 
     protected void assertCatalogItemsEqual(CatalogItem<?, ?> actual, CatalogItem<?, ?> expected) {
@@ -268,11 +266,7 @@ public abstract class RebindTestFixture<T extends StartableApplication> {
         assertEquals(actual.getCatalogItemJavaType(), expected.getCatalogItemJavaType());
         assertEquals(actual.getCatalogItemType(), expected.getCatalogItemType());
         assertEquals(actual.getSpecType(), expected.getSpecType());
-        assertEquals(actual.getRegisteredTypeName(), expected.getRegisteredTypeName());
-        if (actual.getLibraries() != null && expected.getLibraries() != null) {
-            assertEquals(actual.getLibraries().getBundles(), expected.getLibraries().getBundles());
-        } else {
-            assertEquals(actual.getLibraries(), expected.getLibraries());
-        }
+        assertEquals(actual.getSymbolicName(), expected.getSymbolicName());
+        assertEquals(actual.getLibraries(), expected.getLibraries());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java b/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
index 37c9815..7ae59f6 100644
--- a/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/persister/XmlMementoSerializerTest.java
@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
 
 import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.internal.CatalogItemBuilder;
-import brooklyn.catalog.internal.CatalogLibrariesDto;
+import brooklyn.catalog.internal.CatalogItemDtoAbstract;
 import brooklyn.entity.Entity;
 import brooklyn.entity.Feed;
 import brooklyn.entity.basic.Entities;
@@ -161,12 +161,12 @@ public class XmlMementoSerializerTest {
         final TestApplication app = TestApplication.Factory.newManagedInstanceForTests();
         ManagementContext managementContext = app.getManagementContext();
         try {
-            CatalogItem<?, ?> catalogItem = CatalogItemBuilder.newEntity("registeredtypename", "0.0.1")
+            CatalogItem<?, ?> catalogItem = CatalogItemBuilder.newEntity("symbolicName", "0.0.1")
                     .displayName("test catalog item")
                     .description("description")
                     .plan("yaml plan")
                     .iconUrl("iconUrl")
-                    .libraries(CatalogLibrariesDto.from(ImmutableList.of("library-url")))
+                    .libraries(CatalogItemDtoAbstract.parseLibraries(ImmutableList.of("library-url")))
                     .build();
             serializer.setLookupContext(new LookupContextImpl(managementContext,
                     ImmutableList.<Entity>of(), ImmutableList.<Location>of(), ImmutableList.<Policy>of(),

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
index 92fdb47..84f181b 100644
--- a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
+++ b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
 import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.internal.CatalogEntityItemDto;
 import brooklyn.catalog.internal.CatalogItemBuilder;
-import brooklyn.catalog.internal.CatalogLibrariesDto;
+import brooklyn.catalog.internal.CatalogItemDtoAbstract;
 import brooklyn.catalog.internal.CatalogUtils;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.Entities;
@@ -138,11 +138,11 @@ public class OsgiVersionMoreEntityTest {
         return newCatalogItemWithNameAndType(type, version, type, libraries);
     }
     static CatalogEntityItemDto newCatalogItemWithNameAndType(String symName, String version, String type, String ...libraries) {
+        @SuppressWarnings("deprecation")
         CatalogEntityItemDto c1 = CatalogItemBuilder.newEntity(symName, version)
                 .javaType(type)
-                .libraries(CatalogLibrariesDto.from(Arrays.asList(libraries)))
+                .libraries(CatalogItemDtoAbstract.parseLibraries(Arrays.asList(libraries)))
                 .build();
-        c1.setCatalogItemId(type);
         return c1;
     }
 
@@ -153,7 +153,7 @@ public class OsgiVersionMoreEntityTest {
         // not a great test as we set the ID here; but:
         // YAML test will do better;
         // and we can check that downstream items are loaded correctly
-        spec.catalogItemId(c2.getRegisteredTypeName());
+        spec.catalogItemId(c2.getId());
         Entity me = app.createAndManageChild(spec);
         return me;
     }
@@ -195,7 +195,7 @@ public class OsgiVersionMoreEntityTest {
         
         // test load and instantiate
         Entity me = addItemFromCatalog(c2);
-        Assert.assertEquals(me.getCatalogItemId(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
+        Assert.assertEquals(me.getCatalogItemId(), CatalogUtils.getVersionedId(OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY, TEST_VERSION));
         
         assertV1MethodCall(me);
         assertV1EffectorCall(me);
@@ -204,14 +204,14 @@ public class OsgiVersionMoreEntityTest {
         BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(mgmt, c2);
         @SuppressWarnings({ "unchecked", "rawtypes" })
         Entity me2 = me.addChild(EntitySpec.create( (Class)loader.loadClass(c2.getJavaType()) ));
-        Assert.assertEquals(me2.getCatalogItemId(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
+        Assert.assertEquals(me2.getCatalogItemId(), CatalogUtils.getVersionedId(OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY, TEST_VERSION));
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
     protected PolicySpec<?> getPolicySpec(CatalogItem<?, ?> cp) {
         BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(mgmt, cp);
         PolicySpec spec = PolicySpec.create( (Class)loader.loadClass(cp.getJavaType()) );
-        spec.catalogItemId(cp.getRegisteredTypeName());
+        spec.catalogItemId(cp.getId());
         return spec;
     }
 
@@ -237,7 +237,7 @@ public class OsgiVersionMoreEntityTest {
         Assert.assertNotNull(catalogItemId);
         // must be the actual source bundle
         Assert.assertFalse(catalogItemId.equals(me.getCatalogItemId()), "catalog item id is: "+catalogItemId);
-        Assert.assertTrue(catalogItemId.equals(OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_POLICY), "catalog item id is: "+catalogItemId);
+        Assert.assertTrue(catalogItemId.equals(CatalogUtils.getVersionedId(OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_POLICY, TEST_VERSION)), "catalog item id is: "+catalogItemId);
     }
 
     @Test
@@ -270,7 +270,7 @@ public class OsgiVersionMoreEntityTest {
         
         // test load and instantiate
         Entity me = addItemFromCatalog(c2);
-        Assert.assertEquals(me.getCatalogItemId(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
+        Assert.assertEquals(me.getCatalogItemId(), CatalogUtils.getVersionedId(OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY, TEST_VERSION));
         
         assertV2MethodCall(me);
         assertV2EffectorCall(me);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
index d4b6474..016a83a 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
@@ -45,7 +45,7 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
         Entity moreEntity = Iterables.getOnlyElement(app.getChildren());
         
-        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity");
+        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity:1.0");
         OsgiVersionMoreEntityTest.assertV1EffectorCall(moreEntity);
         OsgiVersionMoreEntityTest.assertV1MethodCall(moreEntity);
     }
@@ -59,12 +59,12 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
         Entity moreEntity = Iterables.getOnlyElement(app.getChildren());
         
-        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity");
+        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity:1.0");
         
         Assert.assertEquals(moreEntity.getPolicies().size(), 1, "wrong policies: "+moreEntity.getPolicies());
         Policy policy = Iterables.getOnlyElement(moreEntity.getPolicies());
         // it was loaded by yaml w ref to catalog, so should have the simple-policy catalog-id
-        Assert.assertEquals(policy.getCatalogItemId(), "simple-policy");
+        Assert.assertEquals(policy.getCatalogItemId(), "simple-policy:1.0");
     }
 
     @Test
@@ -73,20 +73,21 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
         Entity moreEntity = Iterables.getOnlyElement(app.getChildren());
         
-        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity");
+        Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity:1.0");
         OsgiVersionMoreEntityTest.assertV2EffectorCall(moreEntity);
         OsgiVersionMoreEntityTest.assertV2MethodCall(moreEntity);
         
         Assert.assertEquals(moreEntity.getPolicies().size(), 1, "wrong policies: "+moreEntity.getPolicies());
         Policy policy = Iterables.getOnlyElement(moreEntity.getPolicies());
         // it was loaded from the java so should have the base more-entity catalog id
-        Assert.assertEquals(policy.getCatalogItemId(), "more-entity");
+        Assert.assertEquals(policy.getCatalogItemId(), "more-entity:1.0");
     }
 
     @Test
     /** TODO this test works if we assume most recent version wins, but semantics TBC */
     public void testMoreEntityV2ThenV1GivesV1() throws Exception {
         addCatalogItem(getLocalResource("more-entity-v2-osgi-catalog.yaml"));
+        forceCatalogUpdate();
         addCatalogItem(getLocalResource("more-entity-v1-osgi-catalog.yaml"));
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
         Entity moreEntity = Iterables.getOnlyElement(app.getChildren());
@@ -101,6 +102,7 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
     @Test
     public void testMoreEntityV1ThenV2GivesV2() throws Exception {
         addCatalogItem(getLocalResource("more-entity-v1-osgi-catalog.yaml"));
+        forceCatalogUpdate();
         addCatalogItem(getLocalResource("more-entity-v2-osgi-catalog.yaml"));
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
         Entity moreEntity = Iterables.getOnlyElement(app.getChildren());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
index dce7a9b..ab6c7dd 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
@@ -44,12 +44,12 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
 
     @Test
     public void testAddCatalogItem() throws Exception {
-        String registeredTypeName = "my.catalog.app.id.load";
-        addCatalogOSGiEntity(registeredTypeName);
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(registeredTypeName, TEST_VERSION);
-        assertEquals(item.getRegisteredTypeName(), registeredTypeName);
+        String symbolicName = "my.catalog.app.id.load";
+        addCatalogOSGiEntity(symbolicName);
+        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        assertEquals(item.getSymbolicName(), symbolicName);
 
-        deleteCatalogEntity(registeredTypeName);
+        deleteCatalogEntity(symbolicName);
     }
 
     @Test
@@ -68,55 +68,55 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
 
     @Test
     public void testLaunchApplicationReferencingCatalog() throws Exception {
-        String registeredTypeName = "my.catalog.app.id.launch";
-        registerAndLaunchAndAssertSimpleEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
+        String symbolicName = "my.catalog.app.id.launch";
+        registerAndLaunchAndAssertSimpleEntity(symbolicName, SIMPLE_ENTITY_TYPE);
     }
 
     @Test
     public void testLaunchApplicationReferencingUnversionedCatalogFail() throws Exception {
-        String registeredTypeName = "my.catalog.app.id.fail";
-        addCatalogOSGiEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
+        String symbolicName = "my.catalog.app.id.fail";
+        addCatalogOSGiEntity(symbolicName, SIMPLE_ENTITY_TYPE);
         try {
             String yaml = "name: simple-app-yaml\n" +
                           "location: localhost\n" +
                           "services: \n" +
-                          "  - serviceType: " + ver(registeredTypeName);
+                          "  - serviceType: " + ver(symbolicName);
             try {
                 createAndStartApplication(yaml);
             } catch (UnsupportedOperationException e) {
                 assertTrue(e.getMessage().endsWith("cannot be matched"));
             }
         } finally {
-            deleteCatalogEntity(registeredTypeName);
+            deleteCatalogEntity(symbolicName);
         }
     }
 
     @Test
     public void testLaunchApplicationWithCatalogReferencingOtherCatalog() throws Exception {
-        String referencedRegisteredTypeName = "my.catalog.app.id.referenced";
-        String referrerRegisteredTypeName = "my.catalog.app.id.referring";
-        addCatalogOSGiEntity(referencedRegisteredTypeName, SIMPLE_ENTITY_TYPE);
-        addCatalogOSGiEntity(referrerRegisteredTypeName, ver(referencedRegisteredTypeName));
+        String referencedSymbolicName = "my.catalog.app.id.referenced";
+        String referrerSymbolicName = "my.catalog.app.id.referring";
+        addCatalogOSGiEntity(referencedSymbolicName, SIMPLE_ENTITY_TYPE);
+        addCatalogOSGiEntity(referrerSymbolicName, ver(referencedSymbolicName));
 
         String yaml = "name: simple-app-yaml\n" +
                       "location: localhost\n" +
                       "services: \n" +
-                      "  - serviceType: " + ver(referrerRegisteredTypeName);
+                      "  - serviceType: " + ver(referrerSymbolicName);
         Entity app = createAndStartApplication(yaml);
 
         Entity simpleEntity = Iterables.getOnlyElement(app.getChildren());
         assertEquals(simpleEntity.getEntityType().getName(), SIMPLE_ENTITY_TYPE);
 
-        deleteCatalogEntity(referencedRegisteredTypeName);
-        deleteCatalogEntity(referrerRegisteredTypeName);
+        deleteCatalogEntity(referencedSymbolicName);
+        deleteCatalogEntity(referrerSymbolicName);
     }
 
     @Test
     public void testLaunchApplicationChildWithCatalogReferencingOtherCatalog() throws Exception {
-        String referencedRegisteredTypeName = "my.catalog.app.id.child.referenced";
-        String referrerRegisteredTypeName = "my.catalog.app.id.child.referring";
-        addCatalogOSGiEntity(referencedRegisteredTypeName, SIMPLE_ENTITY_TYPE);
-        addCatalogChildOSGiEntity(referrerRegisteredTypeName, ver(referencedRegisteredTypeName));
+        String referencedSymbolicName = "my.catalog.app.id.child.referenced";
+        String referrerSymbolicName = "my.catalog.app.id.child.referring";
+        addCatalogOSGiEntity(referencedSymbolicName, SIMPLE_ENTITY_TYPE);
+        addCatalogChildOSGiEntity(referrerSymbolicName, ver(referencedSymbolicName));
 
         Entity app = createAndStartApplication(
             "name: simple-app-yaml",
@@ -124,7 +124,7 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
             "services:",
             "- serviceType: "+BasicEntity.class.getName(),
             "  brooklyn.children:",
-            "  - type: " + ver(referrerRegisteredTypeName));
+            "  - type: " + ver(referrerSymbolicName));
 
         Collection<Entity> children = app.getChildren();
         assertEquals(children.size(), 1);
@@ -139,32 +139,32 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
         Entity grandGrandChild = Iterables.getOnlyElement(grandGrandChildren);
         assertEquals(grandGrandChild.getEntityType().getName(), SIMPLE_ENTITY_TYPE);
 
-        deleteCatalogEntity(referencedRegisteredTypeName);
-        deleteCatalogEntity(referrerRegisteredTypeName);
+        deleteCatalogEntity(referencedSymbolicName);
+        deleteCatalogEntity(referrerSymbolicName);
     }
 
     @Test
     public void testLaunchApplicationWithTypeUsingJavaColonPrefix() throws Exception {
-        String registeredTypeName = SIMPLE_ENTITY_TYPE;
+        String symbolicName = SIMPLE_ENTITY_TYPE;
         String serviceName = "java:"+SIMPLE_ENTITY_TYPE;
-        registerAndLaunchAndAssertSimpleEntity(registeredTypeName, serviceName);
+        registerAndLaunchAndAssertSimpleEntity(symbolicName, serviceName);
     }
 
     @Test
     public void testLaunchApplicationLoopWithJavaTypeName() throws Exception {
-        String registeredTypeName = SIMPLE_ENTITY_TYPE;
+        String symbolicName = SIMPLE_ENTITY_TYPE;
         String serviceName = SIMPLE_ENTITY_TYPE;
-        registerAndLaunchAndAssertSimpleEntity(registeredTypeName, serviceName);
+        registerAndLaunchAndAssertSimpleEntity(symbolicName, serviceName);
     }
 
     @Test
     public void testLaunchApplicationChildLoopCatalogIdFails() throws Exception {
-        String referrerRegisteredTypeName = "my.catalog.app.id.child.referring";
+        String referrerSymbolicName = "my.catalog.app.id.child.referring";
         try {
-            addCatalogChildOSGiEntity(referrerRegisteredTypeName, ver(referrerRegisteredTypeName));
+            addCatalogChildOSGiEntity(referrerSymbolicName, ver(referrerSymbolicName));
             fail("Expected to throw IllegalStateException");
         } catch (IllegalStateException e) {
-            assertTrue(e.getMessage().contains("Could not find "+referrerRegisteredTypeName));
+            assertTrue(e.getMessage().contains("Could not find "+referrerSymbolicName));
         }
     }
 
@@ -334,28 +334,28 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
         Assert.assertNotNull(spec);
     }
 
-    private void registerAndLaunchAndAssertSimpleEntity(String registeredTypeName, String serviceType) throws Exception {
-        addCatalogOSGiEntity(registeredTypeName, serviceType);
+    private void registerAndLaunchAndAssertSimpleEntity(String symbolicName, String serviceType) throws Exception {
+        addCatalogOSGiEntity(symbolicName, serviceType);
         String yaml = "name: simple-app-yaml\n" +
                       "location: localhost\n" +
                       "services: \n" +
-                      "  - serviceType: "+ver(registeredTypeName);
+                      "  - serviceType: "+ver(symbolicName);
         Entity app = createAndStartApplication(yaml);
 
         Entity simpleEntity = Iterables.getOnlyElement(app.getChildren());
         assertEquals(simpleEntity.getEntityType().getName(), SIMPLE_ENTITY_TYPE);
 
-        deleteCatalogEntity(registeredTypeName);
+        deleteCatalogEntity(symbolicName);
     }
 
-    private void addCatalogOSGiEntity(String registeredTypeName) {
-        addCatalogOSGiEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
+    private void addCatalogOSGiEntity(String symbolicName) {
+        addCatalogOSGiEntity(symbolicName, SIMPLE_ENTITY_TYPE);
     }
 
-    private void addCatalogOSGiEntity(String registeredTypeName, String serviceType) {
+    private void addCatalogOSGiEntity(String symbolicName, String serviceType) {
         addCatalogItem(
             "brooklyn.catalog:",
-            "  id: " + registeredTypeName,
+            "  id: " + symbolicName,
             "  name: My Catalog App",
             "  description: My description",
             "  icon_url: classpath://path/to/myicon.jpg",
@@ -367,10 +367,10 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
             "- type: " + serviceType);
     }
 
-    private void addCatalogChildOSGiEntity(String registeredTypeName, String serviceType) {
+    private void addCatalogChildOSGiEntity(String symbolicName, String serviceType) {
         addCatalogItem(
             "brooklyn.catalog:",
-            "  id: " + registeredTypeName,
+            "  id: " + symbolicName,
             "  name: My Catalog App",
             "  description: My description",
             "  icon_url: classpath://path/to/myicon.jpg",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
index 9ba5bee..8dbc3ab 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
@@ -40,27 +40,27 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
     public void testAddCatalogItem() throws Exception {
         assertEquals(countCatalogPolicies(), 0);
 
-        String registeredTypeName = "my.catalog.policy.id.load";
-        addCatalogOSGiPolicy(registeredTypeName, SIMPLE_POLICY_TYPE);
+        String symbolicName = "my.catalog.policy.id.load";
+        addCatalogOSGiPolicy(symbolicName, SIMPLE_POLICY_TYPE);
 
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(registeredTypeName, TEST_VERSION);
-        assertEquals(item.getRegisteredTypeName(), registeredTypeName);
+        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        assertEquals(item.getSymbolicName(), symbolicName);
         assertEquals(countCatalogPolicies(), 1);
 
-        deleteCatalogEntity(registeredTypeName);
+        deleteCatalogEntity(symbolicName);
     }
 
     @Test
     public void testLaunchApplicationReferencingPolicy() throws Exception {
-        String registeredTypeName = "my.catalog.policy.id.launch";
-        addCatalogOSGiPolicy(registeredTypeName, SIMPLE_POLICY_TYPE);
+        String symbolicName = "my.catalog.policy.id.launch";
+        addCatalogOSGiPolicy(symbolicName, SIMPLE_POLICY_TYPE);
         Entity app = createAndStartApplication(
             "name: simple-app-yaml",
             "location: localhost",
             "services: ",
             "  - type: brooklyn.entity.basic.BasicEntity\n" +
             "    brooklyn.policies:\n" +
-            "    - type: " + ver(registeredTypeName),
+            "    - type: " + ver(symbolicName),
             "      brooklyn.config:",
             "        config2: config2 override",
             "        config3: config3");
@@ -72,18 +72,18 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
         assertEquals(policy.getConfig(new BasicConfigKey<String>(String.class, "config2")), "config2 override");
         assertEquals(policy.getConfig(new BasicConfigKey<String>(String.class, "config3")), "config3");
 
-        deleteCatalogEntity(registeredTypeName);
+        deleteCatalogEntity(symbolicName);
     }
 
     @Test
     public void testLaunchApplicationWithCatalogReferencingOtherCatalog() throws Exception {
-        String referencedRegisteredTypeName = "my.catalog.policy.id.referenced";
-        String referrerRegisteredTypeName = "my.catalog.policy.id.referring";
-        addCatalogOSGiPolicy(referencedRegisteredTypeName, SIMPLE_POLICY_TYPE);
+        String referencedSymbolicName = "my.catalog.policy.id.referenced";
+        String referrerSymbolicName = "my.catalog.policy.id.referring";
+        addCatalogOSGiPolicy(referencedSymbolicName, SIMPLE_POLICY_TYPE);
 
         addCatalogItem(
             "brooklyn.catalog:",
-            "  id: " + referrerRegisteredTypeName,
+            "  id: " + referrerSymbolicName,
             "  name: My Catalog App",
             "  description: My description",
             "  icon_url: classpath://path/to/myicon.jpg",
@@ -94,12 +94,12 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
             "services:",
             "- type: " + SIMPLE_ENTITY_TYPE,
             "  brooklyn.policies:",
-            "  - type: " + ver(referencedRegisteredTypeName));
+            "  - type: " + ver(referencedSymbolicName));
 
         String yaml = "name: simple-app-yaml\n" +
                       "location: localhost\n" +
                       "services: \n" +
-                      "  - serviceType: "+ ver(referrerRegisteredTypeName);
+                      "  - serviceType: "+ ver(referrerSymbolicName);
 
         Entity app = createAndStartApplication(yaml);
 
@@ -107,13 +107,13 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
         Policy policy = Iterables.getOnlyElement(simpleEntity.getPolicies());
         assertEquals(policy.getPolicyType().getName(), SIMPLE_POLICY_TYPE);
 
-        deleteCatalogEntity(referencedRegisteredTypeName);
+        deleteCatalogEntity(referencedSymbolicName);
     }
 
-    private void addCatalogOSGiPolicy(String registeredTypeName, String serviceType) {
+    private void addCatalogOSGiPolicy(String symbolicName, String serviceType) {
         addCatalogItem(
             "brooklyn.catalog:",
-            "  id: " + registeredTypeName,
+            "  id: " + symbolicName,
             "  name: My Catalog Policy",
             "  description: My description",
             "  icon_url: classpath://path/to/myicon.jpg",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/jsgui/src/main/webapp/assets/js/model/entity.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/model/entity.js b/usage/jsgui/src/main/webapp/assets/js/model/entity.js
index 547e329..18e1773 100644
--- a/usage/jsgui/src/main/webapp/assets/js/model/entity.js
+++ b/usage/jsgui/src/main/webapp/assets/js/model/entity.js
@@ -31,7 +31,7 @@ define(["underscore", "backbone"], function (_, Backbone) {
         getVersionedAttr: function(name) {
             var attr = this.get(name);
             var version = this.get('version');
-            if (version && version != '0.0.0') {
+            if (version && version != '0.0.0_SNAPSHOT') {
                 return attr + ':' + version;
             } else {
                 return attr;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/jsgui/src/main/webapp/assets/js/view/catalog.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/catalog.js b/usage/jsgui/src/main/webapp/assets/js/view/catalog.js
index cb83b3b..cf14684 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/catalog.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/catalog.js
@@ -313,17 +313,18 @@ define([
             return this;
         },
 
-        singleItemTempalter: function(name, active, isChild, model, index) {
+        singleItemTemplater: function(isChild, model, index) {
             var args = _.extend({
                     cid: model.cid,
                     isChild: isChild,
-                    extraClasses: (activeDetailsView == name && model.cid == active) ? "active" : ""
+                    extraClasses: (activeDetailsView == this.name && model.cid == this.activeCid) ? "active" : ""
                 }, this.entryTemplateArgs(model));
+            console.log(args);
             return this.template(args);
         },
 
         renderEntries: function() {
-            var elements = this.collection.map(_.partial(this.singleItemTemplater, this.name, this.activeCid, false), this);
+            var elements = this.collection.map(_.partial(this.singleItemTemplater, false), this);
             this.updateContent(elements.join(''));
         },
 
@@ -370,7 +371,7 @@ define([
     
     var AccordionEntityView = AccordionItemView.extend({
         renderEntries: function() {
-            var symbolicNameFn = function(model) {return model.get("symbolicName")};
+            var symbolicNameFn = function(model) {return model.get("type")};
             var groups = this.collection.groupBy(symbolicNameFn);
             var orderedIds = _.uniq(this.collection.map(symbolicNameFn), true);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java
index a0e6017..2933451 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogEntitySummary.java
@@ -34,9 +34,7 @@ public class CatalogEntitySummary extends CatalogItemSummary {
             @JsonProperty("symbolicName") String symbolicName,
             @JsonProperty("version") String version,
             @JsonProperty("name") String name,
-            @JsonProperty("registeredType") String registeredType,
             @JsonProperty("javaType") String javaType,
-            @JsonProperty("type") String type,
             @JsonProperty("planYaml") String planYaml,
             @JsonProperty("description") String description,
             @JsonProperty("iconUrl") String iconUrl,
@@ -45,7 +43,7 @@ public class CatalogEntitySummary extends CatalogItemSummary {
             @JsonProperty("effectors") Set<EffectorSummary> effectors,
             @JsonProperty("links") Map<String, URI> links
         ) {
-        super(symbolicName, version, name, registeredType, javaType, type, planYaml, description, iconUrl, links);
+        super(symbolicName, version, name, javaType, planYaml, description, iconUrl, links);
         this.config = config;
         this.sensors = sensors;
         this.effectors = effectors;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java
index 042e659..553450c 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogItemSummary.java
@@ -33,13 +33,15 @@ import com.google.common.collect.ImmutableMap;
  * see also, subclasses */
 public class CatalogItemSummary implements HasId, HasName {
 
+    private final String id;
     private final String symbolicName;
     private final String version;
-    
-    // TODO too many types, see in CatalogItem
+
+    //needed for backwards compatibility only (json serializer works on fields, not getters)
+    @Deprecated
     private final String type;
+    
     private final String javaType;
-    private final String registeredType;
     
     private final String name;
     @JsonSerialize(include=Inclusion.NON_EMPTY)
@@ -53,21 +55,19 @@ public class CatalogItemSummary implements HasId, HasName {
     public CatalogItemSummary(
             @JsonProperty("symbolicName") String symbolicName,
             @JsonProperty("version") String version,
-            @JsonProperty("name") String name,
-            @JsonProperty("registeredType") String registeredType,
+            @JsonProperty("name") String displayName,
             @JsonProperty("javaType") String javaType,
-            @JsonProperty("type") String highLevelType,
             @JsonProperty("planYaml") String planYaml,
             @JsonProperty("description") String description,
             @JsonProperty("iconUrl") String iconUrl,
             @JsonProperty("links") Map<String, URI> links
         ) {
+        this.id = symbolicName + ":" + version;
         this.symbolicName = symbolicName;
+        this.type = symbolicName;
         this.version = version;
-        this.name = name;
+        this.name = displayName;
         this.javaType = javaType;
-        this.registeredType = registeredType;
-        this.type = highLevelType;
         this.planYaml = planYaml;
         this.description = description;
         this.iconUrl = iconUrl;
@@ -76,7 +76,7 @@ public class CatalogItemSummary implements HasId, HasName {
 
     @Override
     public String getId() {
-        return symbolicName + ":" + version;
+        return id;
     }
 
     public String getSymbolicName() {
@@ -87,22 +87,18 @@ public class CatalogItemSummary implements HasId, HasName {
         return version;
     }
 
-    public String getType() {
-        return type;
-    }
-
     public String getJavaType() {
         return javaType;
     }
 
-    public String getRegisteredType() {
-        return registeredType;
+    public String getType() {
+        return type;
     }
 
     public String getPlanYaml() {
         return planYaml;
     }
-    
+
     @Override
     public String getName() {
         return name;
@@ -130,7 +126,7 @@ public class CatalogItemSummary implements HasId, HasName {
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(symbolicName, version, name, type);
+        return Objects.hashCode(symbolicName, version, name, javaType);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java
index 513cfa0..000bd85 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/CatalogPolicySummary.java
@@ -34,14 +34,14 @@ public class CatalogPolicySummary extends CatalogItemSummary {
             @JsonProperty("symbolicName") String symbolicName,
             @JsonProperty("version") String version,
             @JsonProperty("name") String name,
-            @JsonProperty("type") String type,
+            @JsonProperty("javaType") String javaType,
             @JsonProperty("planYaml") String planYaml,
             @JsonProperty("description") String description,
             @JsonProperty("iconUrl") String iconUrl,
             @JsonProperty("config") Set<PolicyConfigSummary> config,
             @JsonProperty("links") Map<String, URI> links
         ) {
-        super(symbolicName, version, name, type, type, type, planYaml, description, iconUrl, links);
+        super(symbolicName, version, name, javaType, planYaml, description, iconUrl, links);
         // TODO expose config from policies
         this.config = (config == null) ? ImmutableSet.<PolicyConfigSummary>of() : config;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
index 9621e9c..c874e14 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
@@ -112,10 +112,6 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
             return Response.created(URI.create("policies/" + itemId))
                     .entity(CatalogTransformer.catalogPolicySummary(brooklyn(), (CatalogItem<? extends Policy, PolicySpec<?>>) item))
                     .build();
-        case CONFIGURATION:
-            return Response.created(URI.create("configurations/" + itemId))
-                    .entity(CatalogTransformer.catalogEntitySummary(brooklyn(), (CatalogItem<? extends Entity, EntitySpec<?>>) item))
-                    .build();
         default:
             throw new IllegalStateException("Unsupported catalog item type "+item.getCatalogItemType()+": "+item);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java b/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
index 3634868..1bcdf00 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
@@ -70,27 +70,23 @@ public class CatalogTransformer {
         for (Effector<?> x: type.getEffectors())
             effectors.add(EffectorTransformer.effectorSummaryForCatalog(x));
 
-        return new CatalogEntitySummary(item.getId(), item.getVersion(), item.getDisplayName(),
-            item.getRegisteredTypeName(), item.getJavaType(), 
-            item.getRegisteredTypeName(),
-            item.getPlanYaml(),
-                item.getDescription(), tidyIconLink(b, item, item.getIconUrl()),
-                config, sensors, effectors,
-                makeLinks(item));
+        return new CatalogEntitySummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(),
+            item.getJavaType(), item.getPlanYaml(),
+            item.getDescription(), tidyIconLink(b, item, item.getIconUrl()),
+            config, sensors, effectors,
+            makeLinks(item));
     }
 
     public static CatalogItemSummary catalogItemSummary(BrooklynRestResourceUtils b, CatalogItem<?,?> item) {
-        return new CatalogItemSummary(item.getId(), item.getVersion(), item.getDisplayName(), 
-                item.getRegisteredTypeName(), item.getJavaType(), 
-                item.getRegisteredTypeName(),
-                item.getPlanYaml(),
+        return new CatalogItemSummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(),
+                item.getJavaType(), item.getPlanYaml(),
                 item.getDescription(), tidyIconLink(b, item, item.getIconUrl()), makeLinks(item));
     }
 
     public static CatalogPolicySummary catalogPolicySummary(BrooklynRestResourceUtils b, CatalogItem<? extends Policy,PolicySpec<?>> item) {
         Set<PolicyConfigSummary> config = ImmutableSet.of();
-        return new CatalogPolicySummary(item.getId(), item.getVersion(), item.getDisplayName(), item.getRegisteredTypeName(),
-                item.getPlanYaml(),
+        return new CatalogPolicySummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(),
+                item.getJavaType(), item.getPlanYaml(),
                 item.getDescription(), tidyIconLink(b, item, item.getIconUrl()), config,
                 makeLinks(item));
     }
@@ -101,7 +97,7 @@ public class CatalogTransformer {
     
     private static String tidyIconLink(BrooklynRestResourceUtils b, CatalogItem<?,?> item, String iconUrl) {
         if (b.isUrlServerSideAndSafe(iconUrl))
-            return "/v1/catalog/icon/"+item.getId();
+            return "/v1/catalog/icon/"+item.getSymbolicName() + "/" + item.getVersion();
         return iconUrl;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
index 8e33ebb..a610cda 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogResourceTest.java
@@ -74,11 +74,11 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
   @Test
   /** based on CampYamlLiteTest */
   public void testRegisterCustomEntityWithBundleWhereEntityIsFromCoreAndIconFromBundle() {
-    String registeredTypeName = "my.catalog.entity.id";
+    String symbolicName = "my.catalog.entity.id";
     String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
     String yaml =
         "brooklyn.catalog:\n"+
-        "  id: " + registeredTypeName + "\n"+
+        "  id: " + symbolicName + "\n"+
         "  name: My Catalog App\n"+
         "  description: My description\n"+
         "  icon_url: classpath:/brooklyn/osgi/tests/icon.gif\n"+
@@ -94,44 +94,42 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
 
     assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
 
-    CatalogEntitySummary entityItem = client().resource("/v1/catalog/entities/"+registeredTypeName + "/" + TEST_VERSION)
+    CatalogEntitySummary entityItem = client().resource("/v1/catalog/entities/"+symbolicName + "/" + TEST_VERSION)
             .get(CatalogEntitySummary.class);
 
-    assertEquals(entityItem.getRegisteredType(), registeredTypeName);
-    
     Assert.assertNotNull(entityItem.getPlanYaml());
     Assert.assertTrue(entityItem.getPlanYaml().contains("brooklyn.test.entity.TestEntity"));
     
-    assertEquals(entityItem.getId(), ver(registeredTypeName));
-    assertEquals(entityItem.getSymbolicName(), registeredTypeName);
+    assertEquals(entityItem.getId(), ver(symbolicName));
+    assertEquals(entityItem.getSymbolicName(), symbolicName);
     assertEquals(entityItem.getVersion(), TEST_VERSION);
     
     // and internally let's check we have libraries
-    CatalogItem<?, ?> item = getManagementContext().getCatalog().getCatalogItem(registeredTypeName, TEST_VERSION);
+    CatalogItem<?, ?> item = getManagementContext().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
     Assert.assertNotNull(item);
-    Collection<CatalogBundle> libs = item.getLibraries().getBundles();
+    Collection<CatalogBundle> libs = item.getLibraries();
     assertEquals(libs.size(), 1);
     assertEquals(Iterables.getOnlyElement(libs).getUrl(), bundleUrl);
 
     // now let's check other things on the item
     assertEquals(entityItem.getName(), "My Catalog App");
     assertEquals(entityItem.getDescription(), "My description");
-    assertEquals(entityItem.getIconUrl(), "/v1/catalog/icon/" + registeredTypeName);
+    assertEquals(entityItem.getIconUrl(), "/v1/catalog/icon/" + symbolicName + "/" + entityItem.getVersion());
     assertEquals(item.getIconUrl(), "classpath:/brooklyn/osgi/tests/icon.gif");
     
-    byte[] iconData = client().resource("/v1/catalog/icon/"+registeredTypeName + "/" + TEST_VERSION).get(byte[].class);
+    byte[] iconData = client().resource("/v1/catalog/icon/"+symbolicName + "/" + TEST_VERSION).get(byte[].class);
     assertEquals(iconData.length, 43);
   }
 
   @Test
   public void testRegisterOSGiPolicy() {
-    String registeredTypeName = "my.catalog.policy.id";
+    String symbolicName = "my.catalog.policy.id";
     String policyType = "brooklyn.osgi.tests.SimplePolicy";
     String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
 
     String yaml =
         "brooklyn.catalog:\n"+
-        "  id: " + registeredTypeName + "\n"+
+        "  id: " + symbolicName + "\n"+
         "  name: My Catalog App\n"+
         "  description: My description\n"+
         "  version: " + TEST_VERSION + "\n" +
@@ -144,11 +142,10 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
     CatalogPolicySummary entityItem = client().resource("/v1/catalog")
         .post(CatalogPolicySummary.class, yaml);
 
-    assertEquals(entityItem.getRegisteredType(), registeredTypeName);
     Assert.assertNotNull(entityItem.getPlanYaml());
     Assert.assertTrue(entityItem.getPlanYaml().contains(policyType));
-    assertEquals(entityItem.getId(), ver(registeredTypeName));
-    assertEquals(entityItem.getSymbolicName(), registeredTypeName);
+    assertEquals(entityItem.getId(), ver(symbolicName));
+    assertEquals(entityItem.getSymbolicName(), symbolicName);
     assertEquals(entityItem.getVersion(), TEST_VERSION);
   }
 
@@ -241,12 +238,12 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
   
   @Test
   public void testDeleteCustomEntityFromCatalog() {
-    String registeredTypeName = "my.catalog.app.id.to.subsequently.delete";
+    String symbolicName = "my.catalog.app.id.to.subsequently.delete";
     String yaml =
-        "name: "+registeredTypeName+"\n"+
+        "name: "+symbolicName+"\n"+
         // FIXME name above should be unnecessary when brooklyn.catalog below is working
         "brooklyn.catalog:\n"+
-        "  id: " + registeredTypeName + "\n"+
+        "  id: " + symbolicName + "\n"+
         "  name: My Catalog App To Be Deleted\n"+
         "  description: My description\n"+
         "  version: " + TEST_VERSION + "\n"+
@@ -257,12 +254,12 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
     client().resource("/v1/catalog")
             .post(ClientResponse.class, yaml);
     
-    ClientResponse deleteResponse = client().resource("/v1/catalog/entities/"+registeredTypeName+"/"+TEST_VERSION)
+    ClientResponse deleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
             .delete(ClientResponse.class);
 
     assertEquals(deleteResponse.getStatus(), Response.Status.NO_CONTENT.getStatusCode());
 
-    ClientResponse getPostDeleteResponse = client().resource("/v1/catalog/entities/"+registeredTypeName+"/"+TEST_VERSION)
+    ClientResponse getPostDeleteResponse = client().resource("/v1/catalog/entities/"+symbolicName+"/"+TEST_VERSION)
             .get(ClientResponse.class);
     assertEquals(getPostDeleteResponse.getStatus(), Response.Status.NOT_FOUND.getStatusCode());
   }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5661ac49/utils/common/src/main/java/brooklyn/util/io/FileUtil.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/io/FileUtil.java b/utils/common/src/main/java/brooklyn/util/io/FileUtil.java
index 6f816bc..aed8450 100644
--- a/utils/common/src/main/java/brooklyn/util/io/FileUtil.java
+++ b/utils/common/src/main/java/brooklyn/util/io/FileUtil.java
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.commons.io.FileUtils;
 import org.slf4j.Logger;
@@ -44,6 +45,11 @@ public class FileUtil {
 
     private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);
 
+    //Linux allows any characters except /
+    //Windows reserves the following set: < > : " / \ | ? *
+    //Object stores: ???, better be conservative
+    private static final Pattern FILE_NAME_BLACKLIST_CHARACTERS = Pattern.compile("[^\\w\\d \\-_.()\\[\\]$!]");
+
     private static boolean loggedSetFilePermissionsWarning = false;
     
     // When we move to java 7, we can use Files.setPosixFilePermissions
@@ -197,4 +203,8 @@ public class FileUtil {
             Streams.closeQuietly(errgobbler);
         }
     }
+
+    public static String getSafeFileName(String str) {
+        return FILE_NAME_BLACKLIST_CHARACTERS.matcher(str).replaceAll("_");
+    }
 }


Mime
View raw message