You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/11/23 23:11:13 UTC

[08/11] jclouds-chef git commit: Removed all code after promoting, to avoid confusion

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/filters/SignedHeaderAuth.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/filters/SignedHeaderAuth.java b/core/src/main/java/org/jclouds/chef/filters/SignedHeaderAuth.java
deleted file mode 100644
index 50d26a1..0000000
--- a/core/src/main/java/org/jclouds/chef/filters/SignedHeaderAuth.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.filters;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.hash.Hashing.sha1;
-import static com.google.common.io.BaseEncoding.base64;
-
-import java.io.IOException;
-import java.security.PrivateKey;
-import java.util.NoSuchElementException;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
-import org.jclouds.Constants;
-import org.jclouds.crypto.Crypto;
-import org.jclouds.date.TimeStamp;
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.HttpException;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpRequestFilter;
-import org.jclouds.http.HttpUtils;
-import org.jclouds.http.internal.SignatureWire;
-import org.jclouds.io.ByteStreams2;
-import org.jclouds.io.Payload;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.MultipartForm;
-import org.jclouds.io.payloads.Part;
-import org.jclouds.io.payloads.RSAEncryptingPayload;
-import org.jclouds.logging.Logger;
-import org.jclouds.util.Strings2;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
-import com.google.common.base.Splitter;
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Multimap;
-import com.google.common.io.ByteSource;
-
-/**
- * Ported from mixlib-authentication in order to sign Chef requests.
- * 
- * @see <a href= "http://github.com/opscode/mixlib-authentication" />
- */
-@Singleton
-public class SignedHeaderAuth implements HttpRequestFilter {
-   public static final String SIGNING_DESCRIPTION = "version=1.0";
-
-   private final SignatureWire signatureWire;
-   private final Supplier<Credentials> creds;
-   private final Supplier<PrivateKey> supplyKey;
-   private final Provider<String> timeStampProvider;
-   private final String emptyStringHash;
-   private final HttpUtils utils;
-   private final Crypto crypto;
-
-   @Resource
-   @Named(Constants.LOGGER_SIGNATURE)
-   Logger signatureLog = Logger.NULL;
-
-   @Inject
-   public SignedHeaderAuth(SignatureWire signatureWire, @org.jclouds.location.Provider Supplier<Credentials> creds,
-         Supplier<PrivateKey> supplyKey, @TimeStamp Provider<String> timeStampProvider, HttpUtils utils, Crypto crypto) {
-      this.signatureWire = checkNotNull(signatureWire, "signatureWire");
-      this.creds = checkNotNull(creds, "creds");
-      this.supplyKey = checkNotNull(supplyKey, "supplyKey");
-      this.timeStampProvider = checkNotNull(timeStampProvider, "timeStampProvider");
-      this.emptyStringHash = hashBody(Payloads.newStringPayload(""));
-      this.utils = checkNotNull(utils, "utils");
-      this.crypto = checkNotNull(crypto, "crypto");
-   }
-
-   public HttpRequest filter(HttpRequest input) throws HttpException {
-      HttpRequest request = input.toBuilder().endpoint(input.getEndpoint().toString().replace("%3F", "?")).build();
-      String contentHash = hashBody(request.getPayload());
-      Multimap<String, String> headers = ArrayListMultimap.create();
-      headers.put("X-Ops-Content-Hash", contentHash);
-      String timestamp = timeStampProvider.get();
-      String toSign = createStringToSign(request.getMethod(), hashPath(request.getEndpoint().getPath()), contentHash,
-            timestamp);
-      headers.put("X-Ops-Userid", creds.get().identity);
-      headers.put("X-Ops-Sign", SIGNING_DESCRIPTION);
-      request = calculateAndReplaceAuthorizationHeaders(request, toSign);
-      headers.put("X-Ops-Timestamp", timestamp);
-      utils.logRequest(signatureLog, request, "<<");
-
-      return request.toBuilder().replaceHeaders(headers).build();
-   }
-
-   @VisibleForTesting
-   HttpRequest calculateAndReplaceAuthorizationHeaders(HttpRequest request, String toSign) throws HttpException {
-      String signature = sign(toSign);
-      if (signatureWire.enabled())
-         signatureWire.input(Strings2.toInputStream(signature));
-      String[] signatureLines = Iterables.toArray(Splitter.fixedLength(60).split(signature), String.class);
-
-      Multimap<String, String> headers = ArrayListMultimap.create();
-      for (int i = 0; i < signatureLines.length; i++) {
-         headers.put("X-Ops-Authorization-" + (i + 1), signatureLines[i]);
-      }
-      return request.toBuilder().replaceHeaders(headers).build();
-   }
-
-   public String createStringToSign(String request, String hashedPath, String contentHash, String timestamp) {
-
-      return new StringBuilder().append("Method:").append(request).append("\n").append("Hashed Path:")
-            .append(hashedPath).append("\n").append("X-Ops-Content-Hash:").append(contentHash).append("\n")
-            .append("X-Ops-Timestamp:").append(timestamp).append("\n").append("X-Ops-UserId:")
-            .append(creds.get().identity).toString();
-
-   }
-
-   @VisibleForTesting
-   String hashPath(String path) {
-      try {
-         return base64().encode(ByteSource.wrap(canonicalPath(path).getBytes(UTF_8)).hash(sha1()).asBytes());
-      } catch (Exception e) {
-         Throwables.propagateIfPossible(e);
-         throw new HttpException("error creating sigature for path: " + path, e);
-      }
-   }
-
-   /**
-    * Build the canonicalized path, which collapses multiple slashes (/) and
-    * removes a trailing slash unless the path is only "/"
-    */
-   @VisibleForTesting
-   String canonicalPath(String path) {
-      path = path.replaceAll("\\/+", "/");
-      return path.endsWith("/") && path.length() > 1 ? path.substring(0, path.length() - 1) : path;
-   }
-
-   @VisibleForTesting
-   String hashBody(Payload payload) {
-      if (payload == null)
-         return emptyStringHash;
-      payload = useTheFilePartIfForm(payload);
-      checkArgument(payload != null, "payload was null");
-      checkArgument(payload.isRepeatable(), "payload must be repeatable: " + payload);
-      try {
-         return base64().encode(ByteStreams2.hashAndClose(payload.getInput(), sha1()).asBytes());
-      } catch (Exception e) {
-         Throwables.propagateIfPossible(e);
-         throw new HttpException("error creating sigature for payload: " + payload, e);
-      }
-   }
-
-   private Payload useTheFilePartIfForm(Payload payload) {
-      if (payload instanceof MultipartForm) {
-         Iterable<? extends Part> parts = MultipartForm.class.cast(payload).getRawContent();
-         try {
-            payload = Iterables.find(parts, new Predicate<Part>() {
-
-               @Override
-               public boolean apply(Part input) {
-                  return "file".equals(input.getName());
-               }
-
-            });
-         } catch (NoSuchElementException e) {
-
-         }
-      }
-      return payload;
-   }
-
-   public String sign(String toSign) {
-      try {
-         byte[] encrypted = ByteStreams2.toByteArrayAndClose(new RSAEncryptingPayload(crypto, Payloads.newStringPayload(toSign), supplyKey.get()).openStream());
-         return base64().encode(encrypted);
-      } catch (IOException e) {
-         throw new HttpException("error signing request", e);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/BootstrapConfigForGroup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/BootstrapConfigForGroup.java b/core/src/main/java/org/jclouds/chef/functions/BootstrapConfigForGroup.java
deleted file mode 100644
index ec75e47..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/BootstrapConfigForGroup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.domain.JsonBall;
-
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
-
-/**
- * 
- * Retrieves the bootstrap configuration for a specific group
- */
-@Singleton
-public class BootstrapConfigForGroup implements Function<String, DatabagItem> {
-   public static final Type BOOTSTRAP_CONFIG_TYPE = new TypeLiteral<Map<String, JsonBall>>() {
-   }.getType();
-   private final ChefApi api;
-   private final String databag;
-
-   @Inject
-   public BootstrapConfigForGroup(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefApi api) {
-      this.databag = checkNotNull(databag, "databag");
-      this.api = checkNotNull(api, "api");
-   }
-
-   @Override
-   public DatabagItem apply(String from) {
-      DatabagItem bootstrapConfig = api.getDatabagItem(databag, from);
-      checkState(bootstrapConfig != null, "databag item %s/%s not found", databag, from);
-      return bootstrapConfig;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ClientForGroup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ClientForGroup.java b/core/src/main/java/org/jclouds/chef/functions/ClientForGroup.java
deleted file mode 100644
index d1a9250..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ClientForGroup.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Sets.newHashSet;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.domain.Client;
-
-import com.google.common.base.Function;
-
-/**
- * 
- * Generates a client relevant for a particular group
- */
-@Singleton
-public class ClientForGroup implements Function<String, Client> {
-   private final ChefApi chefApi;
-
-   @Inject
-   public ClientForGroup(ChefApi chefApi) {
-      this.chefApi = checkNotNull(chefApi, "chefApi");
-   }
-
-   @Override
-   public Client apply(String from) {
-      String clientName = findNextClientName(chefApi.listClients(), from + "-client-%02d");
-      Client client = chefApi.createClient(clientName);
-      // response from create only includes the key
-      return Client.builder() //
-            .clientname(clientName) //
-            .name(clientName) //
-            .isValidator(false) //
-            .privateKey(client.getPrivateKey()) //
-            .build();
-   }
-
-   private static String findNextClientName(Set<String> clients, String pattern) {
-      String clientName;
-      Set<String> names = newHashSet(clients);
-      int index = 0;
-      while (true) {
-         clientName = String.format(pattern, index++);
-         if (!names.contains(clientName))
-            break;
-      }
-      return clientName;
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/GroupToBootScript.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/GroupToBootScript.java b/core/src/main/java/org/jclouds/chef/functions/GroupToBootScript.java
deleted file mode 100644
index 516d9f9..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/GroupToBootScript.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.scriptbuilder.domain.Statements.appendFile;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-import static org.jclouds.scriptbuilder.domain.Statements.newStatementList;
-
-import java.lang.reflect.Type;
-import java.net.URI;
-import java.security.PrivateKey;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.config.InstallChef;
-import org.jclouds.chef.config.Validator;
-import org.jclouds.crypto.Pems;
-import org.jclouds.domain.JsonBall;
-import org.jclouds.json.Json;
-import org.jclouds.location.Provider;
-import org.jclouds.scriptbuilder.ExitInsteadOfReturn;
-import org.jclouds.scriptbuilder.domain.Statement;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.base.Splitter;
-import com.google.common.base.Supplier;
-import com.google.common.cache.CacheLoader;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.TypeLiteral;
-
-/**
- * 
- * Generates a bootstrap script relevant for a particular group
- */
-@Singleton
-public class GroupToBootScript implements Function<String, Statement> {
-   private static final Pattern newLinePattern = Pattern.compile("(\\r\\n)|(\\n)");
-   
-   @VisibleForTesting
-   static final Type RUN_LIST_TYPE = new TypeLiteral<Map<String, List<String>>>() {
-   }.getType();
-   private final Supplier<URI> endpoint;
-   private final Json json;
-   private final CacheLoader<String, ? extends JsonBall> bootstrapConfigForGroup;
-   private final Statement installChef;
-   private final Optional<String> validatorName;
-   private final Optional<PrivateKey> validatorCredential;
-
-   @Inject
-   public GroupToBootScript(@Provider Supplier<URI> endpoint, Json json,
-         CacheLoader<String, ? extends JsonBall> bootstrapConfigForGroup,
-         @InstallChef Statement installChef, @Validator Optional<String> validatorName,
-         @Validator Optional<PrivateKey> validatorCredential) {
-      this.endpoint = checkNotNull(endpoint, "endpoint");
-      this.json = checkNotNull(json, "json");
-      this.bootstrapConfigForGroup = checkNotNull(bootstrapConfigForGroup, "bootstrapConfigForGroup");
-      this.installChef = checkNotNull(installChef, "installChef");
-      this.validatorName = checkNotNull(validatorName, "validatorName");
-      this.validatorCredential = checkNotNull(validatorCredential, validatorCredential);
-   }
-
-   @Override
-   public Statement apply(String group) {
-      checkNotNull(group, "group");
-      String validatorClientName = validatorName.get();
-      PrivateKey validatorKey = validatorCredential.get();
-
-      JsonBall bootstrapConfig = null;
-      try {
-         bootstrapConfig = bootstrapConfigForGroup.load(group);
-      } catch (Exception e) {
-         throw propagate(e);
-      }
-
-      Map<String, JsonBall> config = json.fromJson(bootstrapConfig.toString(),
-            BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
-      Optional<JsonBall> environment = Optional.fromNullable(config.get("environment"));
-
-      String chefConfigDir = "{root}etc{fs}chef";
-      Statement createChefConfigDir = exec("{md} " + chefConfigDir);
-      Statement createClientRb = appendFile(chefConfigDir + "{fs}client.rb", ImmutableList.of("require 'rubygems'",
-            "require 'ohai'", "o = Ohai::System.new", "o.all_plugins",
-            String.format("node_name \"%s-\" + o[:ipaddress]", group), "log_level :info", "log_location STDOUT",
-            String.format("validation_client_name \"%s\"", validatorClientName),
-            String.format("chef_server_url \"%s\"", endpoint.get())));
-
-      Statement createValidationPem = appendFile(chefConfigDir + "{fs}validation.pem",
-            Splitter.on(newLinePattern).split(Pems.pem(validatorKey)));
-
-      String chefBootFile = chefConfigDir + "{fs}first-boot.json";
-      Statement createFirstBoot = appendFile(chefBootFile, Collections.singleton(json.toJson(bootstrapConfig)));
-
-      ImmutableMap.Builder<String, String> options = ImmutableMap.builder();
-      options.put("-j", chefBootFile);
-      if (environment.isPresent()) {
-         options.put("-E", environment.get().toString());
-      }
-      String strOptions = Joiner.on(' ').withKeyValueSeparator(" ").join(options.build());
-      Statement runChef = exec("chef-client " + strOptions);
-
-      return newStatementList(new ExitInsteadOfReturn(installChef), createChefConfigDir, createClientRb, createValidationPem,
-            createFirstBoot, runChef);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
deleted file mode 100644
index ffb4201..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.config.CookbookParser;
-import org.jclouds.http.HttpResponse;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-
-/**
- * Parses a cookbook definition from a Json response, taking care of using the
- * appropriate parser.
- */
-@Singleton
-public class ParseCookbookDefinitionCheckingChefVersion implements Function<HttpResponse, Set<String>> {
-
-   @VisibleForTesting
-   final Function<HttpResponse, Set<String>> parser;
-
-   @Inject
-   ParseCookbookDefinitionCheckingChefVersion(@CookbookParser Function<HttpResponse, Set<String>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      return parser.apply(response);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
deleted file mode 100644
index 3e172e4..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-
-/**
- * Parses a cookbook definition from a Json response, assuming a Chef Server >=
- * 0.10.8.
- */
-@Singleton
-public class ParseCookbookDefinitionFromJson implements Function<HttpResponse, Set<String>> {
-
-   /** Parser for responses from chef server >= 0.10.8 */
-   private final ParseJson<Map<String, CookbookDefinition>> parser;
-
-   @Inject
-   ParseCookbookDefinitionFromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      return parser.apply(response).keySet();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
deleted file mode 100644
index 692d969..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import java.util.Map;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookDefinitionFromJsonv10 implements Function<HttpResponse, CookbookDefinition> {
-
-   /** Parser for responses from chef server >= 0.10.8 */
-   private final ParseJson<Map<String, CookbookDefinition>> parser;
-
-   @Inject
-   ParseCookbookDefinitionFromJsonv10(ParseJson<Map<String, CookbookDefinition>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public CookbookDefinition apply(HttpResponse response) {
-      Map<String, CookbookDefinition> result = parser.apply(response);
-      String cookbookName = result.keySet().iterator().next();
-      CookbookDefinition def = result.values().iterator().next();
-      return CookbookDefinition.builder() //
-             .from(def) //
-             .name(cookbookName) //
-             .build();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
deleted file mode 100644
index 5da0797..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.collect.Iterables.transform;
-import static com.google.common.collect.Sets.newLinkedHashSet;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookDefinitionListFromJsonv10 implements Function<HttpResponse, Set<CookbookDefinition>> {
-
-   /**
-    * Parser for responses from chef server >= 0.10.8
-    */
-   private final ParseJson<Map<String, CookbookDefinition>> parser;
-
-   @Inject
-   ParseCookbookDefinitionListFromJsonv10(ParseJson<Map<String, CookbookDefinition>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public Set<CookbookDefinition> apply(HttpResponse response) {
-      Set<Map.Entry<String, CookbookDefinition>> result = parser.apply(response).entrySet();
-      return newLinkedHashSet(transform(result, new Function<Map.Entry<String, CookbookDefinition>, CookbookDefinition>() {
-         @Override
-         public CookbookDefinition apply(Map.Entry<String, CookbookDefinition> input) {
-            String cookbookName = input.getKey();
-            CookbookDefinition def = input.getValue();
-            return CookbookDefinition.builder() //
-                   .from(def) //              
-                   .name(cookbookName) //
-                   .build();
-         }
-      }));
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
deleted file mode 100644
index f82a900..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.config.CookbookVersionsParser;
-import org.jclouds.http.HttpResponse;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-
-/**
- * Parses a cookbook versions from a Json response, taking care of using the
- * appropriate parser.
- */
-@Singleton
-public class ParseCookbookVersionsCheckingChefVersion implements Function<HttpResponse, Set<String>> {
-
-   @VisibleForTesting
-   final Function<HttpResponse, Set<String>> parser;
-
-   @Inject
-   ParseCookbookVersionsCheckingChefVersion(@CookbookVersionsParser Function<HttpResponse, Set<String>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      return parser.apply(response);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
deleted file mode 100644
index 4421b3e..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-import static com.google.common.collect.Iterables.getFirst;
-
-/**
- * Parses the cookbook versions in a Chef Server <= 0.9.8.
- */
-@Singleton
-public class ParseCookbookVersionsV09FromJson implements Function<HttpResponse, Set<String>> {
-
-   private final ParseJson<Map<String, Set<String>>> json;
-
-   @Inject
-   ParseCookbookVersionsV09FromJson(ParseJson<Map<String, Set<String>>> json) {
-      this.json = json;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      return getFirst(json.apply(response).values(), null);
-
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
deleted file mode 100644
index 1a25ac0..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.chef.domain.CookbookDefinition.Version;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-import static com.google.common.collect.Iterables.getFirst;
-import static com.google.common.collect.Iterables.transform;
-import static com.google.common.collect.Sets.newLinkedHashSet;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookVersionsV10FromJson implements Function<HttpResponse, Set<String>> {
-
-   /** Parser for responses from chef server >= 0.10.8 */
-   private final ParseJson<Map<String, CookbookDefinition>> parser;
-
-   @Inject
-   ParseCookbookVersionsV10FromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
-      this.parser = parser;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      CookbookDefinition def = getFirst(parser.apply(response).values(), null);
-      return newLinkedHashSet(transform(def.getVersions(), new Function<Version, String>() {
-         @Override
-         public String apply(Version input) {
-            return input.getVersion();
-         }
-      }));
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseErrorFromJsonOrReturnBody.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseErrorFromJsonOrReturnBody.java b/core/src/main/java/org/jclouds/chef/functions/ParseErrorFromJsonOrReturnBody.java
deleted file mode 100644
index 6440409..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseErrorFromJsonOrReturnBody.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ReturnStringIf2xx;
-
-import com.google.common.base.Function;
-
-@Singleton
-public class ParseErrorFromJsonOrReturnBody implements Function<HttpResponse, String> {
-   Pattern pattern = Pattern.compile(".*\\[\"([^\"]+)\"\\].*");
-   private final ReturnStringIf2xx returnStringIf200;
-
-   @Inject
-   ParseErrorFromJsonOrReturnBody(ReturnStringIf2xx returnStringIf200) {
-      this.returnStringIf200 = returnStringIf200;
-   }
-
-   @Override
-   public String apply(HttpResponse response) {
-      String content = returnStringIf200.apply(response);
-      if (content == null)
-         return null;
-      return parse(content);
-   }
-
-   public String parse(String in) {
-      Matcher matcher = pattern.matcher(in);
-      if (matcher.find()) {
-         return matcher.group(1);
-      }
-      return in;
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseKeySetFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseKeySetFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseKeySetFromJson.java
deleted file mode 100644
index 963c19b..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseKeySetFromJson.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-
-@Singleton
-public class ParseKeySetFromJson implements Function<HttpResponse, Set<String>> {
-
-   private final ParseJson<Map<String, String>> json;
-
-   @Inject
-   ParseKeySetFromJson(ParseJson<Map<String, String>> json) {
-      this.json = json;
-   }
-
-   @Override
-   public Set<String> apply(HttpResponse response) {
-      return json.apply(response).keySet();
-
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchClientsFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchClientsFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchClientsFromJson.java
deleted file mode 100644
index 18ecbfa..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchClientsFromJson.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.Client;
-import org.jclouds.http.functions.ParseJson;
-
-@Singleton
-public class ParseSearchClientsFromJson extends ParseSearchResultFromJson<Client> {
-
-   // TODO add generic json parser detector
-
-   @Inject
-   ParseSearchClientsFromJson(ParseJson<Response<Client>> json) {
-      super(json);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchDatabagFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchDatabagFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchDatabagFromJson.java
deleted file mode 100644
index c2c58ef..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchDatabagFromJson.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.chef.domain.SearchResult;
-import org.jclouds.domain.JsonBall;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.json.Json;
-
-import com.google.common.base.Function;
-import com.google.gson.annotations.SerializedName;
-import static com.google.common.collect.Iterables.transform;
-
-/**
- * Parses the search result into a {@link DatabagItem} object.
- * <p>
- * When searching databags, the items are contained inside the
- * <code>raw_data</code> list.
- */
-@Singleton
-public class ParseSearchDatabagFromJson implements Function<HttpResponse, SearchResult<DatabagItem>> {
-
-   private final ParseJson<Response> responseParser;
-
-   private final Json json;
-
-   static class Row {
-      @SerializedName("raw_data")
-      JsonBall rawData;
-   }
-
-   static class Response {
-      long start;
-      List<Row> rows;
-   }
-
-   @Inject
-   ParseSearchDatabagFromJson(ParseJson<Response> responseParser, Json json) {
-      this.responseParser = responseParser;
-      this.json = json;
-   }
-
-   @Override
-   public SearchResult<DatabagItem> apply(HttpResponse response) {
-      Response returnVal = responseParser.apply(response);
-      Iterable<DatabagItem> items = transform(returnVal.rows, new Function<Row, DatabagItem>() {
-         @Override
-         public DatabagItem apply(Row input) {
-            return json.fromJson(input.rawData.toString(), DatabagItem.class);
-         }
-      });
-
-      return new SearchResult<DatabagItem>(returnVal.start, items);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchEnvironmentsFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchEnvironmentsFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchEnvironmentsFromJson.java
deleted file mode 100644
index 852e0f3..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchEnvironmentsFromJson.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import org.jclouds.chef.domain.Environment;
-import org.jclouds.http.functions.ParseJson;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-@Singleton
-public class ParseSearchEnvironmentsFromJson extends ParseSearchResultFromJson<Environment> {
-
-   // TODO add generic json parser detector
-
-   @Inject
-   ParseSearchEnvironmentsFromJson(ParseJson<Response<Environment>> json) {
-      super(json);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchNodesFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchNodesFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchNodesFromJson.java
deleted file mode 100644
index 6d34575..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchNodesFromJson.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.Node;
-import org.jclouds.http.functions.ParseJson;
-
-@Singleton
-public class ParseSearchNodesFromJson extends ParseSearchResultFromJson<Node> {
-
-   // TODO add generic json parser detector
-
-   @Inject
-   ParseSearchNodesFromJson(ParseJson<Response<Node>> json) {
-      super(json);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchResultFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchResultFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchResultFromJson.java
deleted file mode 100644
index 6c9bd84..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchResultFromJson.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.SearchResult;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-
-@Singleton
-public class ParseSearchResultFromJson<T> implements Function<HttpResponse, SearchResult<T>> {
-
-   private final ParseJson<Response<T>> json;
-
-   static class Response<T> {
-      long start;
-      List<T> rows;
-   }
-
-   @Inject
-   ParseSearchResultFromJson(ParseJson<Response<T>> json) {
-      this.json = json;
-   }
-
-   @Override
-   public SearchResult<T> apply(HttpResponse response) {
-      Response<T> returnVal = json.apply(response);
-      return new SearchResult<T>(returnVal.start, returnVal.rows);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/ParseSearchRolesFromJson.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/ParseSearchRolesFromJson.java b/core/src/main/java/org/jclouds/chef/functions/ParseSearchRolesFromJson.java
deleted file mode 100644
index 42ba797..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/ParseSearchRolesFromJson.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.Role;
-import org.jclouds.http.functions.ParseJson;
-
-@Singleton
-public class ParseSearchRolesFromJson extends ParseSearchResultFromJson<Role> {
-
-   // TODO add generic json parser detector
-
-   @Inject
-   ParseSearchRolesFromJson(ParseJson<Response<Role>> json) {
-      super(json);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/RunListForGroup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/RunListForGroup.java b/core/src/main/java/org/jclouds/chef/functions/RunListForGroup.java
deleted file mode 100644
index b14ae71..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/RunListForGroup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.domain.JsonBall;
-import org.jclouds.json.Json;
-
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
-
-/**
- * Retrieves the run-list for a specific group
- */
-@Singleton
-public class RunListForGroup implements Function<String, List<String>> {
-   public static final Type RUN_LIST_TYPE = new TypeLiteral<List<String>>() {
-   }.getType();
-   private final BootstrapConfigForGroup bootstrapConfigForGroup;
-
-   private final Json json;
-
-   @Inject
-   public RunListForGroup(BootstrapConfigForGroup bootstrapConfigForGroup, Json json) {
-      this.bootstrapConfigForGroup = checkNotNull(bootstrapConfigForGroup, "bootstrapConfigForGroup");
-      this.json = checkNotNull(json, "json");
-   }
-
-   @Override
-   public List<String> apply(String from) {
-      DatabagItem bootstrapConfig = bootstrapConfigForGroup.apply(from);
-      Map<String, JsonBall> config = json.fromJson(bootstrapConfig.toString(),
-            BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
-      JsonBall runlist = config.get("run_list");
-      return json.fromJson(runlist.toString(), RUN_LIST_TYPE);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/functions/UriForResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/functions/UriForResource.java b/core/src/main/java/org/jclouds/chef/functions/UriForResource.java
deleted file mode 100644
index d5d0810..0000000
--- a/core/src/main/java/org/jclouds/chef/functions/UriForResource.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.functions;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.Resource;
-
-import com.google.common.base.Function;
-
-/**
- * Extracts the uri field of the given {@link Resource}.
- */
-@Singleton
-public class UriForResource implements Function<Object, URI> {
-
-   @Override
-   public URI apply(Object input) {
-      checkArgument(checkNotNull(input, "input") instanceof Resource,
-            "This function can only be applied to Resource objects");
-      return ((Resource) input).getUrl();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/handlers/ChefApiErrorRetryHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/handlers/ChefApiErrorRetryHandler.java b/core/src/main/java/org/jclouds/chef/handlers/ChefApiErrorRetryHandler.java
deleted file mode 100644
index 3b4da4a..0000000
--- a/core/src/main/java/org/jclouds/chef/handlers/ChefApiErrorRetryHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.handlers;
-
-import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
-
-import javax.annotation.Resource;
-import javax.inject.Named;
-
-import org.jclouds.Constants;
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpRetryHandler;
-import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
-import org.jclouds.logging.Logger;
-
-import com.google.inject.Inject;
-
-/**
- * Allow for eventual consistency on sandbox requests.
- */
-public class ChefApiErrorRetryHandler implements HttpRetryHandler {
-
-   @Inject(optional = true)
-   @Named(Constants.PROPERTY_MAX_RETRIES)
-   private int retryCountLimit = 5;
-
-   @Resource
-   protected Logger logger = Logger.NULL;
-
-   private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
-
-   @Inject
-   ChefApiErrorRetryHandler(BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
-      this.backoffLimitedRetryHandler = backoffLimitedRetryHandler;
-   }
-
-   public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) {
-      if (command.getFailureCount() > retryCountLimit)
-         return false;
-      if (response.getStatusCode() == 400 && command.getCurrentRequest().getMethod().equals("PUT")
-            && command.getCurrentRequest().getEndpoint().getPath().indexOf("sandboxes") != -1) {
-         if (response.getPayload() != null) {
-            String error = new String(closeClientButKeepContentStream(response));
-            if (error != null && error.indexOf("was not uploaded") != -1) {
-               return backoffLimitedRetryHandler.shouldRetryRequest(command, response);
-            }
-         }
-      }
-      return false;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/handlers/ChefErrorHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/handlers/ChefErrorHandler.java b/core/src/main/java/org/jclouds/chef/handlers/ChefErrorHandler.java
deleted file mode 100644
index 85f9129..0000000
--- a/core/src/main/java/org/jclouds/chef/handlers/ChefErrorHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.handlers;
-
-import static org.jclouds.util.Closeables2.closeQuietly;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.functions.ParseErrorFromJsonOrReturnBody;
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.logging.Logger;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-
-/**
- * This will parse and set an appropriate exception on the command object.
- */
-@Singleton
-public class ChefErrorHandler implements HttpErrorHandler {
-   @Resource
-   protected Logger logger = Logger.NULL;
-   private final ParseErrorFromJsonOrReturnBody errorParser;
-
-   @Inject
-   ChefErrorHandler(ParseErrorFromJsonOrReturnBody errorParser) {
-      this.errorParser = errorParser;
-   }
-
-   public void handleError(HttpCommand command, HttpResponse response) {
-      String message = errorParser.apply(response);
-      Exception exception = new HttpResponseException(command, response, message);
-      try {
-         message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
-               response.getStatusLine());
-         switch (response.getStatusCode()) {
-            case 401:
-            case 403:
-               exception = new AuthorizationException(message, exception);
-               break;
-            case 404:
-               if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
-                  exception = new ResourceNotFoundException(message, exception);
-               }
-               break;
-         }
-      } finally {
-         closeQuietly(response.getPayload());
-         command.setException(exception);
-      }
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java b/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
deleted file mode 100644
index 1b6fcfe..0000000
--- a/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivateKey;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.ChefService;
-import org.jclouds.chef.config.ChefProperties;
-import org.jclouds.chef.domain.BootstrapConfig;
-import org.jclouds.chef.domain.Client;
-import org.jclouds.chef.domain.CookbookVersion;
-import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.chef.domain.Environment;
-import org.jclouds.chef.domain.Node;
-import org.jclouds.chef.functions.BootstrapConfigForGroup;
-import org.jclouds.chef.functions.GroupToBootScript;
-import org.jclouds.chef.functions.RunListForGroup;
-import org.jclouds.chef.strategy.CleanupStaleNodesAndClients;
-import org.jclouds.chef.strategy.CreateNodeAndPopulateAutomaticAttributes;
-import org.jclouds.chef.strategy.DeleteAllClientsInList;
-import org.jclouds.chef.strategy.DeleteAllNodesInList;
-import org.jclouds.chef.strategy.ListClients;
-import org.jclouds.chef.strategy.ListCookbookVersions;
-import org.jclouds.chef.strategy.ListCookbookVersionsInEnvironment;
-import org.jclouds.chef.strategy.ListEnvironments;
-import org.jclouds.chef.strategy.ListNodes;
-import org.jclouds.chef.strategy.ListNodesInEnvironment;
-import org.jclouds.chef.strategy.UpdateAutomaticAttributesOnNode;
-import org.jclouds.crypto.Crypto;
-import org.jclouds.domain.JsonBall;
-import org.jclouds.io.ByteStreams2;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.RSADecryptingPayload;
-import org.jclouds.io.payloads.RSAEncryptingPayload;
-import org.jclouds.json.Json;
-import org.jclouds.logging.Logger;
-import org.jclouds.scriptbuilder.domain.Statement;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Maps;
-import com.google.common.io.InputSupplier;
-
-@Singleton
-public class BaseChefService implements ChefService {
-
-   private final ChefContext chefContext;
-   private final ChefApi api;
-   private final CleanupStaleNodesAndClients cleanupStaleNodesAndClients;
-   private final CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes;
-   private final DeleteAllNodesInList deleteAllNodesInList;
-   private final ListNodes listNodes;
-   private final DeleteAllClientsInList deleteAllClientsInList;
-   private final ListClients listClients;
-   private final UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode;
-   private final Supplier<PrivateKey> privateKey;
-   private final GroupToBootScript groupToBootScript;
-   private final String databag;
-   private final BootstrapConfigForGroup bootstrapConfigForGroup;
-   private final RunListForGroup runListForGroup;
-   private final ListCookbookVersions listCookbookVersions;
-   private final ListCookbookVersionsInEnvironment listCookbookVersionsInEnvironment;
-   private final ListEnvironments listEnvironments;
-   private final ListNodesInEnvironment listNodesInEnvironment;
-   private final Json json;
-   private final Crypto crypto;
-
-   @Resource
-   @Named(ChefProperties.CHEF_LOGGER)
-   protected Logger logger = Logger.NULL;
-
-   @Inject
-   protected BaseChefService(ChefContext chefContext, ChefApi api,
-         CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
-         CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
-         DeleteAllNodesInList deleteAllNodesInList, ListNodes listNodes, DeleteAllClientsInList deleteAllClientsInList,
-         ListClients listClients, ListCookbookVersions listCookbookVersions,
-         UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode, Supplier<PrivateKey> privateKey,
-         @Named(CHEF_BOOTSTRAP_DATABAG) String databag, GroupToBootScript groupToBootScript,
-         BootstrapConfigForGroup bootstrapConfigForGroup, RunListForGroup runListForGroup,
-         ListEnvironments listEnvironments, ListNodesInEnvironment listNodesInEnvironment,
-         ListCookbookVersionsInEnvironment listCookbookVersionsInEnvironment, Json json, Crypto crypto) {
-      this.chefContext = checkNotNull(chefContext, "chefContext");
-      this.api = checkNotNull(api, "api");
-      this.cleanupStaleNodesAndClients = checkNotNull(cleanupStaleNodesAndClients, "cleanupStaleNodesAndClients");
-      this.createNodeAndPopulateAutomaticAttributes = checkNotNull(createNodeAndPopulateAutomaticAttributes,
-            "createNodeAndPopulateAutomaticAttributes");
-      this.deleteAllNodesInList = checkNotNull(deleteAllNodesInList, "deleteAllNodesInList");
-      this.listNodes = checkNotNull(listNodes, "listNodes");
-      this.deleteAllClientsInList = checkNotNull(deleteAllClientsInList, "deleteAllClientsInList");
-      this.listClients = checkNotNull(listClients, "listClients");
-      this.listCookbookVersions = checkNotNull(listCookbookVersions, "listCookbookVersions");
-      this.updateAutomaticAttributesOnNode = checkNotNull(updateAutomaticAttributesOnNode,
-            "updateAutomaticAttributesOnNode");
-      this.privateKey = checkNotNull(privateKey, "privateKey");
-      this.groupToBootScript = checkNotNull(groupToBootScript, "groupToBootScript");
-      this.databag = checkNotNull(databag, "databag");
-      this.bootstrapConfigForGroup = checkNotNull(bootstrapConfigForGroup, "bootstrapConfigForGroup");
-      this.runListForGroup = checkNotNull(runListForGroup, "runListForGroup");
-      this.listEnvironments = checkNotNull(listEnvironments, "listEnvironments");
-      this.listNodesInEnvironment = checkNotNull(listNodesInEnvironment, "listNodesInEnvironment");
-      this.listCookbookVersionsInEnvironment = checkNotNull(listCookbookVersionsInEnvironment, "listCookbookVersionsInEnvironment");
-      this.json = checkNotNull(json, "json");
-      this.crypto = checkNotNull(crypto, "crypto");
-   }
-
-   @Override
-   public ChefContext getContext() {
-      return chefContext;
-   }
-
-   @Override
-   public byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
-      return ByteStreams2.toByteArrayAndClose(new RSAEncryptingPayload(crypto, Payloads.newPayload(supplier.getInput()), privateKey
-                  .get()).openStream());
-   }
-
-   @Override
-   public byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
-      return ByteStreams2.toByteArrayAndClose(new RSADecryptingPayload(crypto, Payloads.newPayload(supplier.getInput()), privateKey
-                  .get()).openStream());
-   }
-
-   @VisibleForTesting
-   String buildBootstrapConfiguration(BootstrapConfig bootstrapConfig) {
-      checkNotNull(bootstrapConfig, "bootstrapConfig must not be null");
-
-      Map<String, Object> configMap = Maps.newHashMap();
-      configMap.put("run_list", bootstrapConfig.getRunList());
-
-      if (bootstrapConfig.getEnvironment().isPresent()) {
-         configMap.put("environment", bootstrapConfig.getEnvironment().get());
-      }
-
-      if (bootstrapConfig.getAttribtues().isPresent()) {
-         Map<String, Object> attributes = json.fromJson(bootstrapConfig.getAttribtues().get().toString(),
-               BootstrapConfigForGroup.BOOTSTRAP_CONFIG_TYPE);
-         configMap.putAll(attributes);
-      }
-
-      return json.toJson(configMap);
-   }
-
-   @Override
-   public Statement createBootstrapScriptForGroup(String group) {
-      return groupToBootScript.apply(group);
-   }
-
-   @Override
-   public void updateBootstrapConfigForGroup(String group, BootstrapConfig bootstrapConfig) {
-      try {
-         api.createDatabag(databag);
-      } catch (IllegalStateException e) {
-
-      }
-
-      String jsonConfig = buildBootstrapConfiguration(bootstrapConfig);
-      DatabagItem runlist = new DatabagItem(group, jsonConfig);
-
-      if (api.getDatabagItem(databag, group) == null) {
-         api.createDatabagItem(databag, runlist);
-      } else {
-         api.updateDatabagItem(databag, runlist);
-      }
-   }
-
-   @Override
-   public List<String> getRunListForGroup(String group) {
-      return runListForGroup.apply(group);
-   }
-
-   @Override
-   public JsonBall getBootstrapConfigForGroup(String group) {
-      return bootstrapConfigForGroup.apply(group);
-   }
-
-   @Override
-   public void cleanupStaleNodesAndClients(String prefix, int secondsStale) {
-      cleanupStaleNodesAndClients.execute(prefix, secondsStale);
-   }
-
-   @Override
-   public Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList) {
-      return createNodeAndPopulateAutomaticAttributes.execute(nodeName, runList);
-   }
-
-   @Override
-   public void updateAutomaticAttributesOnNode(String nodeName) {
-      updateAutomaticAttributesOnNode.execute(nodeName);
-   }
-
-   @Override
-   public void deleteAllNodesInList(Iterable<String> names) {
-      deleteAllNodesInList.execute(names);
-   }
-
-   @Override
-   public void deleteAllClientsInList(Iterable<String> names) {
-      deleteAllClientsInList.execute(names);
-   }
-
-   @Override
-   public Iterable<? extends Node> listNodes() {
-      return listNodes.execute();
-   }
-
-   @Override
-   public Iterable<? extends Node> listNodes(ExecutorService executorService) {
-      return listNodes.execute(executorService);
-   }
-
-   @Override
-   public Iterable<? extends Client> listClients() {
-      return listClients.execute();
-   }
-
-   @Override
-   public Iterable<? extends Client> listClients(ExecutorService executorService) {
-      return listClients.execute(executorService);
-   }
-
-   @Override
-   public Iterable<? extends CookbookVersion> listCookbookVersions() {
-      return listCookbookVersions.execute();
-   }
-
-   @Override public Iterable<? extends CookbookVersion> listCookbookVersions(
-         ExecutorService executorService) {
-      return listCookbookVersions.execute(executorService);
-   }
-
-   @Override
-   public Iterable<? extends CookbookVersion> listCookbookVersionsInEnvironment(String environmentName) {
-      return listCookbookVersionsInEnvironment.execute(environmentName);
-   }
-
-   @Override
-   public Iterable<? extends CookbookVersion> listCookbookVersionsInEnvironment(String environmentName,
-         ExecutorService executorService) {
-      return listCookbookVersionsInEnvironment.execute(executorService, environmentName);
-   }
-
-   @Override
-   public Iterable<? extends CookbookVersion> listCookbookVersionsInEnvironment(String environmentName,
-         String numVersions) {
-      return listCookbookVersionsInEnvironment.execute(environmentName, numVersions);
-   }
-
-   @Override
-   public Iterable<? extends CookbookVersion> listCookbookVersionsInEnvironment(String environmentName,
-         String numVersions, ExecutorService executorService) {
-      return listCookbookVersionsInEnvironment.execute(executorService, environmentName, numVersions);
-   }
-
-   @Override
-   public Iterable<? extends Environment> listEnvironments() {
-      return listEnvironments.execute();
-   }
-
-   @Override
-   public Iterable<? extends Node> listNodesInEnvironment(String environmentName) {
-      return listNodesInEnvironment.execute(environmentName);
-   }
-
-   @Override
-   public Iterable<? extends Node> listNodesInEnvironment(String environmentName, ExecutorService executorService) {
-      return listNodesInEnvironment.execute(executorService, environmentName);
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java b/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
deleted file mode 100644
index 8aef880..0000000
--- a/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.io.IOException;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.Context;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.ChefService;
-import org.jclouds.internal.BaseView;
-import org.jclouds.location.Provider;
-
-import com.google.common.reflect.TypeToken;
-
-@Singleton
-public class ChefContextImpl extends BaseView implements ChefContext {
-   private final ChefService chefService;
-
-   @Inject
-   protected ChefContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
-         ChefService chefService) {
-      super(backend, backendType);
-      this.chefService = checkNotNull(chefService, "chefService");
-   }
-
-   @Override
-   public ChefService getChefService() {
-      return chefService;
-   }
-
-   @Override
-   public void close() throws IOException {
-      delegate().close();
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/options/CreateClientOptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/options/CreateClientOptions.java b/core/src/main/java/org/jclouds/chef/options/CreateClientOptions.java
deleted file mode 100644
index 776d7bb..0000000
--- a/core/src/main/java/org/jclouds/chef/options/CreateClientOptions.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.options;
-
-/**
- * Options for the create client method.
- */
-public class CreateClientOptions implements Cloneable {
-   /** Administrator flag. This flag will be ignored in Opscode Hosted Chef. */
-   private boolean admin;
-
-   public CreateClientOptions() {
-   }
-
-   CreateClientOptions(final boolean admin) {
-      super();
-      this.admin = admin;
-   }
-
-   public boolean isAdmin() {
-      return admin;
-   }
-
-   public CreateClientOptions admin() {
-      this.admin = true;
-      return this;
-   }
-
-   @Override
-   protected Object clone() throws CloneNotSupportedException {
-      return new CreateClientOptions(admin);
-   }
-
-   @Override
-   public String toString() {
-      return "[admin=" + admin + "]";
-   }
-
-   public static class Builder {
-      /**
-       * @see CreateClientOptions#admin()
-       */
-      public static CreateClientOptions admin() {
-         CreateClientOptions options = new CreateClientOptions();
-         return options.admin();
-      }
-
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-chef/blob/cffeede4/core/src/main/java/org/jclouds/chef/options/SearchOptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/chef/options/SearchOptions.java b/core/src/main/java/org/jclouds/chef/options/SearchOptions.java
deleted file mode 100644
index cbc1d54..0000000
--- a/core/src/main/java/org/jclouds/chef/options/SearchOptions.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.options;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Options for the search api.
- */
-public class SearchOptions extends BaseHttpRequestOptions {
-
-   /**
-    * A valid search string.
-    */
-   public SearchOptions query(String query) {
-      this.queryParameters.put("q", checkNotNull(query, "query"));
-      return this;
-   }
-
-   /**
-    * A sort string, such as 'name DESC'.
-    */
-   public SearchOptions sort(String sort) {
-      this.queryParameters.put("sort", checkNotNull(sort, "sort"));
-      return this;
-   }
-
-   /**
-    * The number of rows to return.
-    */
-   public SearchOptions rows(int rows) {
-      this.queryParameters.put("rows", String.valueOf(rows));
-      return this;
-   }
-
-   /**
-    * The result number to start from.
-    */
-   public SearchOptions start(int start) {
-      this.queryParameters.put("start", String.valueOf(start));
-      return this;
-   }
-
-   public static class Builder {
-
-      /**
-       * @see SearchOptions#query(String)
-       */
-      public static SearchOptions query(String query) {
-         SearchOptions options = new SearchOptions();
-         return options.query(query);
-      }
-
-      /**
-       * @see SearchOptions#sort(String)
-       */
-      public static SearchOptions start(String start) {
-         SearchOptions options = new SearchOptions();
-         return options.sort(start);
-      }
-
-      /**
-       * @see SearchOptions#rows(int)
-       */
-      public static SearchOptions rows(int rows) {
-         SearchOptions options = new SearchOptions();
-         return options.rows(rows);
-      }
-
-      /**
-       * @see SearchOptions#start(int)
-       */
-      public static SearchOptions start(int start) {
-         SearchOptions options = new SearchOptions();
-         return options.start(start);
-      }
-   }
-
-}