EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.scriptbuilder.domain]

COVERAGE SUMMARY FOR SOURCE FILE [SaveHttpResponseTo.java]

nameclass, %method, %block, %line, %
SaveHttpResponseTo.java0%   (0/2)0%   (0/3)0%   (0/71)0%   (0/4)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SaveHttpResponseTo0%   (0/1)0%   (0/1)0%   (0/53)0%   (0/2)
SaveHttpResponseTo (String, String, String, URI, Multimap): void 0%   (0/1)0%   (0/53)0%   (0/2)
     
class SaveHttpResponseTo$10%   (0/1)0%   (0/2)0%   (0/18)0%   (0/2)
SaveHttpResponseTo$1 (): void 0%   (0/1)0%   (0/3)0%   (0/1)
apply (Map$Entry): String 0%   (0/1)0%   (0/15)0%   (0/1)

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.scriptbuilder.domain;
20 
21import java.net.URI;
22import java.util.Map;
23 
24import com.google.common.base.Function;
25import com.google.common.base.Joiner;
26import com.google.common.collect.Iterables;
27import com.google.common.collect.Multimap;
28 
29/**
30 * saves the content of the http response to a file
31 * 
32 * @author Adrian Cole
33 */
34public class SaveHttpResponseTo extends InterpretableStatement {
35   static final String CURL = "curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20";
36 
37   /**
38    * 
39    * @param dir
40    *           location to save file
41    * @param method
42    *           http method: ex GET
43    * @param endpoint
44    *           uri corresponding to the request
45    * @param headers
46    *           request headers to send
47    */
48   public SaveHttpResponseTo(String dir, String file, String method, URI endpoint, Multimap<String, String> headers) {
49      super(String.format("({md} %s && {cd} %s && [ ! -f %s ] && %s -C - -X %s %s %s >%s)\n", dir, dir, file, CURL,
50               method, Joiner.on(' ').join(
51                        Iterables.transform(headers.entries(), new Function<Map.Entry<String, String>, String>() {
52 
53                           @Override
54                           public String apply(Map.Entry<String, String> from) {
55                              return String.format("-H \"%s: %s\"", from.getKey(), from.getValue());
56                           }
57 
58                        })), endpoint.toASCIIString(), file));
59 
60   }
61 
62}

[all classes][org.jclouds.scriptbuilder.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov