CatalogResource extends AbstractBrooklynRestResource implements CatalogApi { @Override @Deprecated public void setDisabled(String itemId, boolean disabled) { if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(itemId, "disabled"))) { throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog", Entitlements.getEntitlementContext().user()); } CatalogUtils.setDisabled(mgmt(), itemId, disabled); }  @Override @Beta Response createFromUpload(byte[] item, boolean forceUpdate); @Override @Deprecated Response create(String yaml, boolean forceUpdate); @SuppressWarnings("deprecation") @Override Response createFromYaml(String yaml, boolean forceUpdate); @Override @Beta Response createFromArchive(byte[] zipInput, boolean detail, boolean forceUpdate); @Override @Deprecated void deleteApplication(String symbolicName, String version); @Override @Deprecated void deleteEntity(String symbolicName, String version); @Override @Deprecated void deletePolicy(String policyId, String version); @Override @Deprecated void deleteLocation(String locationId, String version); @Override @Deprecated List<CatalogEntitySummary> listEntities(String regex, String fragment, boolean allVersions); @Override @Deprecated List<CatalogItemSummary> listApplications(String regex, String fragment, boolean allVersions); @Override @Deprecated CatalogEntitySummary getEntity(String symbolicName, String version); @Override @Deprecated CatalogEntitySummary getApplication(String symbolicName, String version); @Override @Deprecated List<CatalogPolicySummary> listPolicies(String regex, String fragment, boolean allVersions); @Override @Deprecated CatalogPolicySummary getPolicy(String policyId, String version); @Override @Deprecated List<CatalogLocationSummary> listLocations(String regex, String fragment, boolean allVersions); @Override @Deprecated CatalogLocationSummary getLocation(String locationId, String version); @Override Response getIcon(String itemId, String version); @Override @Deprecated void setDeprecated(String itemId, boolean deprecated); @Override @Deprecated void setDisabled(String itemId, boolean disabled); @Override @Deprecated List<CatalogEnricherSummary> listEnrichers(@ApiParam(name = "regex", value = "Regular expression to search for") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") @DefaultValue("") String fragment, @ApiParam(name = "allVersions", value = "Include all versions (defaults false, only returning the best version)") @DefaultValue("false") boolean includeAllVersions); @Override @Deprecated CatalogEnricherSummary getEnricher(@ApiParam(name = "enricherId", value = "The ID of the enricher to retrieve", required = true) String enricherId, @ApiParam(name = "version", value = "The version identifier of the enricher to retrieve", required = true) String version); @Override @Deprecated void deleteEnricher(@ApiParam(name = "enricherId", value = "The ID of the enricher to delete", required = true) String enricherId, @ApiParam(name = "version", value = "The version identifier of the enricher to delete", required = true) String version);  }
@Test public void testSetDisabled() { String symbolicName = "my.catalog.item.id.for.disabling"; String serviceType = "org.apache.brooklyn.entity.stock.BasicApplication"; addTestCatalogItem(symbolicName, "template", TEST_VERSION, serviceType); addTestCatalogItem(symbolicName, "template", "2.0", serviceType); try { List<CatalogEntitySummary> applications = client().path("/catalog/applications") .query("fragment", symbolicName).query("allVersions", "true").get(new GenericType<List<CatalogEntitySummary>>() {}); assertEquals(applications.size(), 2); CatalogItemSummary summary0 = applications.get(0); CatalogItemSummary summary1 = applications.get(1); disableCatalogItem(summary0.getSymbolicName(), summary0.getVersion(), true); List<CatalogEntitySummary> applicationsAfterDisabled = client().path("/catalog/applications") .query("fragment", "basicapp").query("allVersions", "true").get(new GenericType<List<CatalogEntitySummary>>() {}); assertEquals(applicationsAfterDisabled.size(), 1); assertTrue(applicationsAfterDisabled.contains(summary1)); disableCatalogItem(summary0.getSymbolicName(), summary0.getVersion(), false); List<CatalogEntitySummary> applicationsAfterUnDisabled = client().path("/catalog/applications") .query("fragment", "basicapp").query("allVersions", "true").get(new GenericType<List<CatalogEntitySummary>>() {}); assertEquals(applications, applicationsAfterUnDisabled); } finally { client().path("/catalog/entities/"+symbolicName+"/"+TEST_VERSION) .delete(); client().path("/catalog/entities/"+symbolicName+"/"+"2.0") .delete(); } }