Merge pull request #1458 from jclouds/null-trmk-templates

don't fail horribly on null trmk templates
This commit is contained in:
Adrian Cole 2013-03-25 09:04:10 -07:00
commit de108293c7
2 changed files with 8 additions and 2 deletions

View File

@ -61,6 +61,8 @@ public class ImageForVCloudExpressVAppTemplate implements Function<VAppTemplate,
@Override @Override
public Image apply(VAppTemplate from) { public Image apply(VAppTemplate from) {
if (from == null)
return null;
ImageBuilder builder = new ImageBuilder(); ImageBuilder builder = new ImageBuilder();
builder.ids(from.getHref().toASCIIString()); builder.ids(from.getHref().toASCIIString());
builder.uri(from.getHref()); builder.uri(from.getHref());

View File

@ -18,6 +18,8 @@
*/ */
package org.jclouds.trmk.vcloud_0_8.compute.functions; package org.jclouds.trmk.vcloud_0_8.compute.functions;
import static com.google.common.base.Predicates.notNull;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Provider; import javax.inject.Provider;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -29,7 +31,7 @@ import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
import org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg; import org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.FluentIterable;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -54,7 +56,9 @@ public class ImagesInVCloudExpressOrg implements Function<Org, Iterable<? extend
public Iterable<? extends Image> apply(Org from) { public Iterable<? extends Image> apply(Org from) {
Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from); Iterable<? extends CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs); Iterable<? extends VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(vAppTemplates, imageForVAppTemplateProvider.get().withParent(from)); return FluentIterable.from(vAppTemplates)
.transform(imageForVAppTemplateProvider.get().withParent(from))
.filter(notNull());
} }
} }