/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.engine.view.calcnode.stats;

import java.net.URI;

import javax.time.Instant;

import com.opengamma.util.ArgumentChecker;
import com.opengamma.util.rest.AbstractRemoteClient;

/**
 * Provides access to a remote {@link FunctionCostsMaster}.
 */
public class RemoteFunctionCostsMaster extends AbstractRemoteClient implements FunctionCostsMaster {

  /**
   * Creates an instance.
   * 
   * @param baseUri  the base target URI for all RESTful web services, not null
   */
  public RemoteFunctionCostsMaster(final URI baseUri) {
    super(baseUri);
  }

  //-------------------------------------------------------------------------
  @Override
  public FunctionCostsDocument load(String configurationName, String functionId, Instant versionAsOf) {
    ArgumentChecker.notNull(configurationName, "configurationName");
    ArgumentChecker.notNull(functionId, "functionId");
    
    URI uri = DataFunctionCostsMasterResource.uriLoad(getBaseUri(), configurationName, functionId, versionAsOf);
    return accessRemote(uri).get(FunctionCostsDocument.class);
  }

  @Override
  public FunctionCostsDocument store(FunctionCostsDocument costs) {
    ArgumentChecker.notNull(costs, "costs");
    
    URI uri = DataFunctionCostsMasterResource.uriStore(getBaseUri());
    return accessRemote(uri).post(FunctionCostsDocument.class, costs);
  }

}

@@ -327,16 +327,76 @@
 eClient;
+%0Aimport com.sun.jersey.api.client.UniformInterfaceException;
 %0A%0A/**%0A *
@@ -1200,16 +1200,28 @@
 nAsOf);%0A
+    try %7B%0A  
     retu
@@ -1271,24 +1271,169 @@
 ent.class);%0A
+    %7D catch (UniformInterfaceException ex) %7B%0A      if (ex.getResponse().getStatus() == 404) %7B%0A        return null;%0A      %7D%0A      throw ex;%0A    %7D%0A
   %7D%0A%0A  @Over

Handle 404s correctly