protected Set<Catalog> getFilteredCatalogList(Metadata metadata) throws CatalogServiceException {
try {
if (metadata.containsKey(CATALOG_ID_MET_KEY)) {
Catalog catalog = this.getCatalog(metadata.getMetadata(CATALOG_ID_MET_KEY));
if (catalog == null)
throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + "' is not managed by this CatalogService");
else
return Collections.singleton(catalog);
}else if (metadata.containsKey(CATALOG_IDS_MET_KEY)) {
HashSet<Catalog> filteredCatalogList = new HashSet<Catalog>();
for (Object catalogUrn : metadata.getAllMetadata(CATALOG_IDS_MET_KEY)) {
Catalog catalog = this.getCatalog((String) catalogUrn);
if (catalog == null)
throw new CatalogServiceException("Catalog '" + metadata.getMetadata(CATALOG_ID_MET_KEY) + "' is not managed by this CatalogService");
else
filteredCatalogList.add(catalog);
}
return filteredCatalogList;
}else {
return new HashSet<Catalog>(this.catalogs);
}
}catch (Exception e) {
throw new CatalogServiceException("Failed to get filtered catalog list : " + e.getMessage(), e);
}
}