Codota Logo
RestKieServerControllerClient
Code IndexAdd Codota to your IDE (free)

How to use
RestKieServerControllerClient
in
org.kie.server.controller.client.rest

Best Java code snippets using org.kie.server.controller.client.rest.RestKieServerControllerClient (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: org.kie.server/kie-server-controller-client

/**
 * Creates a new Kie Controller Client using REST based service
 * @param controllerUrl the URL to the server (e.g.: "http://localhost:8080/kie-server-controller/rest/controller")
 * @param login user login
 * @param password user password
 * @return client instance
 */
public static KieServerControllerClient newRestClient(final String controllerUrl,
                           final String login,
                           final String password) {
  return new RestKieServerControllerClient(controllerUrl,
                       login,
                       password);
}
origin: org.kie.server/kie-server-controller-client

private RuntimeException createExceptionForUnexpectedFailure(WebTarget request, Exception e) {
  String summaryMessage = "Unexpected exception when requesting URI '" + getClientRequestUri(request) + "'!";
  logger.debug(summaryMessage);
  return new RuntimeException(summaryMessage, e);
}
origin: org.kie.server/kie-server-controller-client

@Override
public void deleteServerTemplate(String serverTemplateId) {
  makeDeleteRequest(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId);
}
origin: org.kie.server/kie-server-controller-client

private <T> T makePostRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType) {
  WebTarget clientRequest = httpClient.target(uri);
  Response response;
  try {
    Entity<String> requestEntity = Entity.entity(serialize(bodyObject), getMediaType(format));
    response = clientRequest.request(getMediaType(format)).post(requestEntity);
  } catch (Exception e) {
    throw createExceptionForUnexpectedFailure(clientRequest, e);
  }
  try {
    if (response.getStatus() == Response.Status.CREATED.getStatusCode() ||
        response.getStatus() == Response.Status.OK.getStatusCode()) {
      return deserialize(response,
                resultType);
    } else {
      throw createExceptionForUnexpectedResponseCode(clientRequest,
                              response);
    }
  } finally {
    response.close();
  }
}
origin: org.kie.server/kie-server-controller-client

private <T> T makeGetRequestAndCreateCustomResponse(String uri, Class<T> resultType) {
  WebTarget clientRequest = httpClient.target(uri);
  Response response;
  response = clientRequest.request(getMediaType(format)).get();
  try {
    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
      return deserialize(response,
                resultType);
    } else {
      throw createExceptionForUnexpectedResponseCode(clientRequest,
                              response);
    }
  } finally {
    response.close();
  }
}
origin: org.kie.server/kie-server-controller-client

private void makeDeleteRequest(String uri) {
  WebTarget clientRequest = httpClient.target(uri);
  Response response;
  try {
    response = clientRequest.request(getMediaType(format)).delete();
  } catch (Exception e) {
    throw createExceptionForUnexpectedFailure(clientRequest,
                         e);
  }
  try {
    if (response.getStatus() != Response.Status.NO_CONTENT.getStatusCode()) {
      throw createExceptionForUnexpectedResponseCode(clientRequest,
                              response);
    }
  } finally {
    response.close();
  }
}
origin: org.kie.server/kie-server-controller-client

spec.addConfig(Capability.RULE,
        ruleConfig);
final String specContent = client.serialize(spec);
LOGGER.info("{} content\n{}", marshallingFormat.getType(), specContent);
final ContainerSpec specResult = client.deserialize(specContent,
                          ContainerSpec.class);
origin: org.kie.server/kie-server-controller-client

protected <T> T deserialize(Response response, Class<T> type) {
  try {
    if(type == null) {
      return null;
    }
    String content = response.readEntity(String.class);
    logger.debug("About to deserialize content: \n '{}' \n into type: '{}'", content, type);
    if (content == null || content.isEmpty()) {
      return null;
    }
    return deserialize(content, type);
  } catch ( MarshallingException e ) {
    throw new RuntimeException( "Error while deserializing data received from server!", e );
  }
}
origin: org.kie.server/kie-server-controller-client

@Override
public ServerTemplate getServerTemplate(String serverTemplateId) {
  return makeGetRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId, ServerTemplate.class);
}
origin: org.kie.server/kie-server-controller-client

@Override
public void updateContainerSpec(String serverTemplateId, String containerId, ContainerSpec containerSpec) {
  makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId + CONTAINERS_URI_PART + containerId, containerSpec, Object.class);
}
origin: org.kie.server/kie-server-controller-client

private <T> T makePutRequestAndCreateCustomResponse(String uri, Object bodyObject, Class<T> resultType) {
  WebTarget clientRequest = httpClient.target(uri);
  Response response;
  try {
    Entity<String> requestEntity = Entity.entity(serialize(bodyObject), getMediaType(format));
    response = clientRequest.request(getMediaType(format)).put(requestEntity);
  } catch (Exception e) {
    throw createExceptionForUnexpectedFailure(clientRequest, e);
  }
  try {
    if (response.getStatus() == Response.Status.CREATED.getStatusCode()) {
      return deserialize(response,
                resultType);
    } else {
      throw createExceptionForUnexpectedResponseCode(clientRequest,
                              response);
    }
  } finally {
    response.close();
  }
}
origin: org.kie.server/kie-server-controller-client

@Override
public ContainerSpec getContainerInfo(String serverTemplateId, String containerId) {
  return makeGetRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId + CONTAINERS_URI_PART + containerId, ContainerSpec.class);
}
origin: org.kie.server/kie-server-controller-client

@Override
public void updateContainerConfig(String serverTemplateId, String containerId, Capability capability, ContainerConfig config) {
  makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId + CONTAINERS_URI_PART + containerId + CONFIG_URI_PART + capability.toString(), config, Object.class);
}
origin: org.kie.server/kie-server-controller-client

/**
 * Creates a new Kie Controller Client using REST based service
 * @param controllerUrl the URL to the server (e.g.: "http://localhost:8080/kie-server-controller/rest/controller")
 * @param login user login
 * @param password user password
 * @param format marshaling format
 * @return client instance
 */
public static KieServerControllerClient newRestClient(final String controllerUrl,
                           final String login,
                           final String password,
                           final MarshallingFormat format) {
  return new RestKieServerControllerClient(controllerUrl,
                       login,
                       password,
                       format);
}
origin: org.kie.server/kie-server-controller-client

@Override
public ServerInstanceKeyList getServerInstances(String serverTemplateId) {
  return makeGetRequestAndCreateCustomResponse(controllerBaseUrl + RUNTIME_URI_PART + serverTemplateId + INSTANCES_URI_PART, ServerInstanceKeyList.class);
}
origin: org.kie.server/kie-server-controller-client

@Override
public void activateContainer(ContainerSpecKey containerSpecKey) {
  makePostRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + containerSpecKey.getServerTemplateKey().getId() + CONTAINERS_URI_PART + containerSpecKey.getId() + ACTIVATED_STATUS_URI_PART, "", null);
}
origin: org.kie.server/kie-server-controller-client

@Override
public void deleteContainerSpec(String serverTemplateId, String containerId) {
  makeDeleteRequest(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId + CONTAINERS_URI_PART + containerId);
}
origin: org.kie.server/kie-server-controller-client

private RuntimeException createExceptionForUnexpectedResponseCode(WebTarget request,
                                 Response response) {
  StringBuffer stringBuffer = new StringBuffer();
  stringBuffer.append("Unexpected HTTP response code when requesting URI '");
  stringBuffer.append(getClientRequestUri(request));
  stringBuffer.append("'! Response code: ");
  stringBuffer.append(response.getStatus());
  try {
    String responseEntity = response.readEntity(String.class);
    stringBuffer.append(" Response message: ");
    stringBuffer.append(responseEntity);
  } catch (IllegalStateException e) {
    logger.warn("Error trying to read response entity: {}", e.getMessage(), e);
  }
  logger.debug(stringBuffer.toString());
  return new KieServerControllerHTTPClientException(response.getStatus(), stringBuffer.toString());
}
origin: org.kie.server/kie-server-controller-client

/**
 * Creates a new Kie Controller Client using REST based service
 * @param controllerUrl the URL to the server (e.g.: "http://localhost:8080/kie-server-controller/rest/controller")
 * @param login user login
 * @param password user password
 * @param format marshaling format
 * @param configuration REST client configuration
 * @return client instance
 */
public static KieServerControllerClient newRestClient(final String controllerUrl,
                           final String login,
                           final String password,
                           final MarshallingFormat format,
                           final Configuration configuration) {
  return new RestKieServerControllerClient(controllerUrl,
                       login,
                       password,
                       format,
                       configuration);
}
origin: org.kie.server/kie-server-controller-client

@Override
public ContainerSpecList listContainerSpec(String serverTemplateId) {
  return makeGetRequestAndCreateCustomResponse(controllerBaseUrl + MANAGEMENT_URI_PART + serverTemplateId + CONTAINERS_LAST_URI_PART, ContainerSpecList.class);
}
org.kie.server.controller.client.restRestKieServerControllerClient

Most used methods

  • <init>
  • deserialize
  • serialize
  • createExceptionForUnexpectedFailure
  • createExceptionForUnexpectedResponseCode
  • getClientRequestUri
  • getMediaType
  • makeDeleteRequest
  • makeGetRequestAndCreateCustomResponse
  • makePostRequestAndCreateCustomResponse
  • makePutRequestAndCreateCustomResponse
  • setMarshallingFormat
  • makePutRequestAndCreateCustomResponse,
  • setMarshallingFormat,
  • throwUnsupportedException,
  • updateContainerSpec

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • onRequestPermissionsResult (Fragment)
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now