EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8.compute.suppliers]

COVERAGE SUMMARY FOR SOURCE FILE [VAppTemplatesInOrgs.java]

nameclass, %method, %block, %line, %
VAppTemplatesInOrgs.java0%   (0/2)0%   (0/4)0%   (0/60)0%   (0/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VAppTemplatesInOrgs0%   (0/1)0%   (0/2)0%   (0/39)0%   (0/8)
VAppTemplatesInOrgs (Supplier, Function, ImagesInVCloudExpressOrg): void 0%   (0/1)0%   (0/15)0%   (0/6)
get (): Set 0%   (0/1)0%   (0/24)0%   (0/2)
     
class VAppTemplatesInOrgs$10%   (0/1)0%   (0/2)0%   (0/21)0%   (0/5)
VAppTemplatesInOrgs$1 (VAppTemplatesInOrgs): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Image): Image 0%   (0/1)0%   (0/15)0%   (0/4)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.trmk.vcloud_0_8.compute.suppliers;
20 
21import static com.google.common.collect.Iterables.concat;
22import static com.google.common.collect.Iterables.transform;
23import static com.google.common.collect.Sets.newLinkedHashSet;
24 
25import java.util.Set;
26 
27import javax.annotation.Resource;
28import javax.inject.Inject;
29import javax.inject.Named;
30import javax.inject.Singleton;
31 
32import org.jclouds.collect.Memoized;
33import org.jclouds.compute.domain.Image;
34import org.jclouds.compute.domain.ImageBuilder;
35import org.jclouds.compute.reference.ComputeServiceConstants;
36import org.jclouds.domain.Location;
37import org.jclouds.logging.Logger;
38import org.jclouds.trmk.vcloud_0_8.compute.functions.ImagesInVCloudExpressOrg;
39import org.jclouds.trmk.vcloud_0_8.domain.Org;
40 
41import com.google.common.base.Function;
42import com.google.common.base.Supplier;
43 
44/**
45 * @author Adrian Cole
46 */
47@Singleton
48public class VAppTemplatesInOrgs implements Supplier<Set<? extends Image>> {
49 
50   @Resource
51   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
52   public Logger logger = Logger.NULL;
53 
54   private final Supplier<Set<? extends Location>> locations;
55   private final Function<Iterable<? extends Location>, Iterable<? extends Org>> organizatonsForLocations;
56   private final ImagesInVCloudExpressOrg imagesInOrg;
57 
58   @Inject
59   VAppTemplatesInOrgs(@Memoized Supplier<Set<? extends Location>> locations,
60            Function<Iterable<? extends Location>, Iterable<? extends Org>> organizatonsForLocations,
61            ImagesInVCloudExpressOrg imagesInOrg) {
62      this.locations = locations;
63      this.organizatonsForLocations = organizatonsForLocations;
64      this.imagesInOrg = imagesInOrg;
65   }
66 
67   /**
68    * Terremark does not provide vApp templates in the vDC resourceEntity list. Rather, you must
69    * query the catalog.
70    */
71   @Override
72   public Set<? extends Image> get() {
73      logger.debug(">> providing vAppTemplates");
74      return newLinkedHashSet(transform(
75               concat(transform(organizatonsForLocations.apply(locations.get()), imagesInOrg)),
76               new Function<Image, Image>() {
77 
78                  @Override
79                  public Image apply(Image from) {
80                     ImageBuilder builder = ImageBuilder.fromImage(from);
81                     // the password in the image is the sudo password
82                     // TODO refactor authenticate image logic so that it can populate the
83                     // adminPassword
84                     // value
85                     // independently
86                     if (from.getDefaultCredentials() != null)
87                        builder.adminPassword(from.getDefaultCredentials().credential);
88                     return builder.build();
89                  }
90 
91               }));
92   }
93}

[all classes][org.jclouds.trmk.vcloud_0_8.compute.suppliers]
EMMA 2.0.5312 (C) Vladimir Roubtsov