Пример #1
0
 /**
  *
  *
  * <pre>
  * Converts API response into object and returns the object array in case of get request.
  * </pre>
  */
 protected base_resource[] get_nitro_response(nitro_service service, String response)
     throws Exception {
   xen_health_resource_response result =
       (xen_health_resource_response)
           service
               .get_payload_formatter()
               .string_to_resource(xen_health_resource_response.class, response);
   if (result.errorcode != 0) {
     if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session();
     if (result.severity != null) {
       if (result.severity.equals("ERROR"))
         throw new nitro_exception(result.message, result.errorcode);
     } else {
       throw new nitro_exception(result.message, result.errorcode);
     }
   }
   return result.xen_health_resource;
 }
Пример #2
0
  /**
   *
   *
   * <pre>
   * Converts API response of bulk operation into object and returns the object array in case of get request.
   * </pre>
   */
  protected base_resource[] get_nitro_bulk_response(nitro_service service, String response)
      throws Exception {
    xen_health_resource_responses result =
        (xen_health_resource_responses)
            service
                .get_payload_formatter()
                .string_to_resource(xen_health_resource_responses.class, response);
    if (result.errorcode != 0) {
      if (result.errorcode == SESSION_NOT_EXISTS) service.clear_session();
      throw new nitro_exception(
          result.message,
          result.errorcode,
          (base_response[]) result.xen_health_resource_response_array);
    }
    xen_health_resource[] result_xen_health_resource =
        new xen_health_resource[result.xen_health_resource_response_array.length];

    for (int i = 0; i < result.xen_health_resource_response_array.length; i++) {
      result_xen_health_resource[i] =
          result.xen_health_resource_response_array[i].xen_health_resource[0];
    }

    return result_xen_health_resource;
  }