Search in sources :

Example 1 with GetSchemaResponse

use of org.apache.servicecomb.service.center.client.model.GetSchemaResponse in project java-chassis by ServiceComb.

the class ServiceCenterClient method getServiceSchemaContext.

/**
 * Get one schema context of service
 *
 * @param serviceId
 * @param schemaId
 * @return
 * @throws OperationException
 */
public String getServiceSchemaContext(String serviceId, String schemaId) {
    try {
        HttpResponse response = httpClient.getHttpRequest("/registry/microservices/" + serviceId + "/schemas/" + schemaId, null, null);
        if (response.getStatusCode() == HttpStatus.SC_OK) {
            GetSchemaResponse getSchemaResponse = HttpUtils.deserialize(response.getContent(), GetSchemaResponse.class);
            return getSchemaResponse.getSchema();
        }
        sendUnAuthorizedEvent(response);
        throw new OperationException("get service schema context fails, statusCode = " + response.getStatusCode() + "; message = " + response.getMessage() + "; content = " + response.getContent());
    } catch (IOException e) {
        throw new OperationException("get service schemas context fails", e);
    }
}
Also used : HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) GetSchemaResponse(org.apache.servicecomb.service.center.client.model.GetSchemaResponse) IOException(java.io.IOException) OperationException(org.apache.servicecomb.service.center.client.exception.OperationException)

Aggregations

IOException (java.io.IOException)1 HttpResponse (org.apache.servicecomb.http.client.common.HttpResponse)1 OperationException (org.apache.servicecomb.service.center.client.exception.OperationException)1 GetSchemaResponse (org.apache.servicecomb.service.center.client.model.GetSchemaResponse)1