Package org.platformlayer.ops.helpers

Examples of org.platformlayer.ops.helpers.CurlRequest


  private CurlResult execute(String action) throws OpsException {
    String url = "http://127.0.0.1:8080/solr/admin/cores?core=" + coreKey;

    url += "&action=" + action;

    CurlRequest request = new CurlRequest(url);
    CurlResult result = request.executeRequest(target);
    log.info("result: " + result);
    return result;
  }
View Full Code Here


    log.info("Uploading to " + getContainerName() + "/" + objectPath);

    RequestBuilder requestBuilder = getStorageClient(request.target).root().containers().id(getContainerName())
        .objects().buildPutRequest(openstackProperties);

    CurlRequest curlRequest = ((RemoteCurlOpenstackRequest) requestBuilder).toCurlRequest();
    curlRequest.bodyFromStdin = true;

    Command curlCommand = curlRequest.toCommand();
    Command pipedCommand = dataSourceCommand.pipeTo(curlCommand);

    ProcessExecution execution = request.target.executeCommand(pipedCommand);

    CurlResult curlResult = curlRequest.parseResponse(execution);

    int httpResult = curlResult.getHttpResult();
    switch (httpResult) {
    case 200:
      break;
View Full Code Here

    OpenstackStorageClient storageClient = session.getStorageClient();

    RequestBuilder request = storageClient.root().containers().id(containerName).objects().id(objectPath)
        .buildDownloadRequest();

    CurlRequest curlRequest = session.toCurlRequest(request);
    curlRequest.bareRequest = true;

    Command curlCommand = curlRequest.toCommand();
    curlCommand.addLiteral(">");
    curlCommand.addFile(targetPath);

    ProcessExecution execution = target.executeCommand(curlCommand);
View Full Code Here

      super(RemoteCurlOpenstackSession.this, resourceUrl);
    }

    @Override
    public <T> T doRequest0(Class<T> c) {
      CurlRequest request = toCurlRequest();
      CurlResult result;
      try {
        result = request.executeRequest(target);
      } catch (OpsException e) {
        throw new OpenstackException("Error issuing request", e);
      }

      int httpStatus = result.getHttpResult();
View Full Code Here

        }
      }
    }

    public CurlRequest toCurlRequest() {
      CurlRequest request = new CurlRequest(resourceUrl);
      if (body != null) {
        JaxbHelper jaxb = JaxbHelper.get(body.getClass());
        String xml;
        try {
          xml = jaxb.marshal(body, false);
        } catch (JAXBException e) {
          throw new OpenstackException("Error serializing request body", e);
        }
        request.body = xml;
      }
      request.method = this.method;
      if (this.contentType != null) {
        request.getHeaders().put("Content-Type", this.contentType.toString());
      }
      if (this.acceptTypes != null) {
        String accept = Joiner.on(",").join(this.acceptTypes);
        request.getHeaders().put("Accept", accept);
      }
      for (Entry<String, String> entry : this.headers.entrySet()) {
        request.getHeaders().put(entry.getKey(), entry.getValue());
      }
      return request;
    }
View Full Code Here

      // }

      {
        // We choose the fastest proxy that gives us a 200 response
        String url = "http://ftp.debian.org/debian/dists/stable/Release.gpg";
        CurlRequest request = new CurlRequest(url);
        request.proxy = proxy;
        request.timeout = TimeSpan.FIVE_SECONDS;
        try {
          CurlResult result = request.executeRequest(target);
          if (result.getHttpResult() != 200) {
            log.info("Unexpected response code while testing proxy: " + proxy + ".  Code="
                + result.getHttpResult());
            continue;
          }
View Full Code Here

    } catch (UnknownHostException e) {
      throw new OpsException("Unable to resolve host: " + uri, e);
    }

    if (InetAddressUtils.isPublic(host)) {
      CurlRequest curlRequest = new CurlRequest(uri);
      curlRequest.bareRequest = true;
      CommandEnvironment commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.General, uri);

      Command curlCommand = curlRequest.toCommand();
      curlCommand.addLiteral(">");
      curlCommand.addFile(remoteFilePath);
      curlCommand.setEnvironment(commandEnvironment);
      curlCommand.setTimeout(TimeSpan.FIVE_MINUTES);
View Full Code Here

    }

    if (url != null && casObject == null) {
      target.mkdir(remoteFilePath.getParentFile());

      CurlRequest curlRequest = new CurlRequest(url);
      curlRequest.bareRequest = true;

      CommandEnvironment commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.General, url);

      Command curlCommand = curlRequest.toCommand();
      curlCommand.addLiteral(">");
      curlCommand.addFile(remoteFilePath);
      curlCommand.setEnvironment(commandEnvironment);
      curlCommand.setTimeout(TimeSpan.FIVE_MINUTES);
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.helpers.CurlRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.