Example usage for com.fasterxml.jackson.core JsonParser readValueAs

List of usage examples for com.fasterxml.jackson.core JsonParser readValueAs

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonParser readValueAs.

Prototype

@SuppressWarnings("unchecked")
public <T> T readValueAs(TypeReference<?> valueTypeRef) throws IOException, JsonProcessingException 

Source Link

Document

Method to deserialize JSON content into a Java type, reference to which is passed as argument.

Usage

From source file:com.unboundid.scim2.client.requests.SearchRequestBuilder.java

/**
 * Invoke the SCIM retrieve request./*from w w  w. j a v  a  2 s  .  com*/
 *
 * @param post {@code true} to send the request using POST or {@code false}
 *             to send the request using GET.
 * @param <T> The type of objects to return.
 * @param resultHandler The search result handler that should be used to
 *                      process the resources.
 * @param cls The Java class object used to determine the type to return.
 * @throws ScimException If an error occurred.
 */
private <T> void invoke(final boolean post, final SearchResultHandler<T> resultHandler, final Class<T> cls)
        throws ScimException {
    Response response;
    if (post) {
        Set<String> attributeSet = null;
        Set<String> excludedAttributeSet = null;
        if (attributes != null && attributes.size() > 0) {
            if (!excluded) {
                attributeSet = attributes;
            } else {
                excludedAttributeSet = attributes;
            }
        }

        SearchRequest searchRequest = new SearchRequest(attributeSet, excludedAttributeSet, filter, sortBy,
                sortOrder, startIndex, count);

        Invocation.Builder builder = target().path(ApiConstants.SEARCH_WITH_POST_PATH_EXTENSION)
                .request(ScimService.MEDIA_TYPE_SCIM_TYPE, MediaType.APPLICATION_JSON_TYPE);
        for (Map.Entry<String, List<Object>> header : headers.entrySet()) {
            builder = builder.header(header.getKey(), StaticUtils.listToString(header.getValue(), ", "));
        }
        response = builder.post(Entity.entity(searchRequest, getContentType()));
    } else {
        response = buildRequest().get();
    }

    try {
        if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
            InputStream inputStream = response.readEntity(InputStream.class);
            try {
                JsonParser parser = JsonUtils.getObjectReader().getFactory().createParser(inputStream);
                try {
                    parser.nextToken();
                    boolean stop = false;
                    while (!stop && parser.nextToken() != JsonToken.END_OBJECT) {
                        String field = parser.getCurrentName();
                        parser.nextToken();
                        if (field.equals("schemas")) {
                            parser.skipChildren();
                        } else if (field.equals("totalResults")) {
                            resultHandler.totalResults(parser.getIntValue());
                        } else if (field.equals("startIndex")) {
                            resultHandler.startIndex(parser.getIntValue());
                        } else if (field.equals("itemsPerPage")) {
                            resultHandler.itemsPerPage(parser.getIntValue());
                        } else if (field.equals("Resources")) {
                            while (parser.nextToken() != JsonToken.END_ARRAY) {
                                if (!resultHandler.resource(parser.readValueAs(cls))) {
                                    stop = true;
                                    break;
                                }
                            }
                        } else if (SchemaUtils.isUrn(field)) {
                            resultHandler.extension(field, parser.<ObjectNode>readValueAsTree());
                        } else {
                            // Just skip this field
                            parser.nextToken();
                        }
                    }
                } finally {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    parser.close();
                }
            } catch (IOException e) {
                throw new ResponseProcessingException(response, e);
            }
        } else {
            throw toScimException(response);
        }
    } finally {
        response.close();
    }
}

From source file:org.springframework.security.oauth2.common.OAuth2AccessTokenJackson2Deserializer.java

@Override
public OAuth2AccessToken deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    String tokenValue = null;/*from   w w w. j av  a 2  s  .co m*/
    String tokenType = null;
    String refreshToken = null;
    Long expiresIn = null;
    Set<String> scope = null;
    Map<String, Object> additionalInformation = new LinkedHashMap<String, Object>();

    // TODO What should occur if a parameter exists twice
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String name = jp.getCurrentName();
        jp.nextToken();
        if (OAuth2AccessToken.ACCESS_TOKEN.equals(name)) {
            tokenValue = jp.getText();
        } else if (OAuth2AccessToken.TOKEN_TYPE.equals(name)) {
            tokenType = jp.getText();
        } else if (OAuth2AccessToken.REFRESH_TOKEN.equals(name)) {
            refreshToken = jp.getText();
        } else if (OAuth2AccessToken.EXPIRES_IN.equals(name)) {
            try {
                expiresIn = jp.getLongValue();
            } catch (JsonParseException e) {
                expiresIn = Long.valueOf(jp.getText());
            }
        } else if (OAuth2AccessToken.SCOPE.equals(name)) {
            String text = jp.getText();
            scope = OAuth2Utils.parseParameterList(text);
        } else {
            additionalInformation.put(name, jp.readValueAs(Object.class));
        }
    }

    // TODO What should occur if a required parameter (tokenValue or tokenType) is missing?

    DefaultOAuth2AccessToken accessToken = new DefaultOAuth2AccessToken(tokenValue);
    accessToken.setTokenType(tokenType);
    if (expiresIn != null) {
        accessToken.setExpiration(new Date(System.currentTimeMillis() + (expiresIn * 1000)));
    }
    if (refreshToken != null) {
        accessToken.setRefreshToken(new DefaultOAuth2RefreshToken(refreshToken));
    }
    accessToken.setScope(scope);
    accessToken.setAdditionalInformation(additionalInformation);

    return accessToken;
}

From source file:com.basistech.rosette.dm.jackson.array.ListAttributeArrayDeserializer.java

@Override
@SuppressWarnings("unchecked")
public ListAttribute deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    if (jp.getCurrentToken() == JsonToken.START_ARRAY) { // this is what we expect.
        // we advance to be in the same place the 'else' will be -- the first FIELD_NAME.
        jp.nextToken();/*from   www .  j  a v  a  2s  . c o  m*/
    } else {
        throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY,
                "ListAttributeDeserializer called not array start.");
    }

    if (jp.getCurrentToken() != JsonToken.VALUE_STRING) {
        throw ctxt.mappingException("Expected VALUE_STRING for item type.");
    }
    String itemTypeKeyName = jp.getText();

    KnownAttribute attribute = KnownAttribute.getAttributeForKey(itemTypeKeyName);
    if (attribute == null) {
        attribute = KnownAttribute.UNKNOWN;
    }
    Class<? extends BaseAttribute> itemClass = attribute.attributeClass();

    ListAttribute.Builder<BaseAttribute> builder = new ListAttribute.Builder<>(attribute.attributeClass());
    List<BaseAttribute> items = Lists.newArrayList();

    if (jp.nextToken() != JsonToken.START_ARRAY) {
        throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "No array of values for list.");
    }

    // we just read the elements as we see them,
    while (jp.nextToken() != JsonToken.END_ARRAY) {
        // the START_ARRAY case, which is _normal_. Read the elements.
        items.add(jp.readValueAs(itemClass));
    }
    builder.setItems(items);
    // we are still in the top-level array ...
    if (jp.nextToken() != JsonToken.START_OBJECT) {
        throw ctxt.wrongTokenException(jp, JsonToken.START_OBJECT, "No extended properties for list.");
    }
    Map<String, Object> props = jp.readValueAs(new TypeReference<Map<String, Object>>() {
    });
    for (Map.Entry<String, Object> me : props.entrySet()) {
        builder.extendedProperty(me.getKey(), me.getValue());
    }
    jp.nextToken(); // consume the END_OBJECT of the extended props
    return builder.build();
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Reads an array from JSON, where each value is of the class clazz.  Note that while the result
 * is an array, you cannot assume that it is an array of Object, or use generics because generics
 * are always Objects - this is because arrays of primitive types are not arrays of Objects
 * @param jp//from w w  w.  j a  va  2 s . c om
 * @param clazz
 * @return
 * @throws IOException
 */
private Map readMap(JsonParser jp, Class keyClazz, Class clazz) throws IOException {
    if (jp.getCurrentToken() == JsonToken.VALUE_NULL)
        return null;

    boolean isProxyClass = Proxied.class.isAssignableFrom(clazz);
    if (keyClazz == null)
        keyClazz = String.class;
    HashMap result = new HashMap();
    for (; jp.nextToken() != JsonToken.END_OBJECT;) {
        Object key = readSimpleValue(jp, keyClazz);

        jp.nextToken();

        if (isProxyClass) {
            Integer id = jp.readValueAs(Integer.class);
            if (id != null) {
                Proxied obj = getProxied(id);
                if (!clazz.isInstance(obj))
                    throw new ClassCastException(
                            "Cannot cast " + obj + " class " + obj.getClass() + " to " + clazz);
                result.put(key, obj);
            } else
                result.put(key, null);
        } else {
            Object obj = readSimpleValue(jp, clazz);
            result.put(key, obj);
        }
    }

    return result;
}

From source file:no.ssb.jsonstat.v2.deser.DatasetDeserializer.java

@Override
public DatasetBuildable deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    if (p.getCurrentToken() == JsonToken.START_OBJECT) {
        p.nextToken();//from   w  w w.  ja v  a  2s  .  c  o m
    }

    Set<String> ids = Collections.emptySet();
    List<Integer> sizes = Collections.emptyList();
    Multimap<String, String> roles = ArrayListMultimap.create();
    Map<String, Dimension.Builder> dims = Collections.emptyMap();
    List<Number> values = Collections.emptyList();

    DatasetBuilder builder = Dataset.create();
    Optional<String> version = Optional.empty();
    Optional<String> clazz = Optional.empty();
    Optional<ObjectNode> extension = Optional.empty();

    while (p.nextValue() != JsonToken.END_OBJECT) {
        switch (p.getCurrentName()) {
        case "label":
            builder.withLabel(_parseString(p, ctxt));
            break;
        case "source":
            builder.withSource(_parseString(p, ctxt));
            break;
        case "href":
            break;
        case "updated":
            Instant updated = parseEcmaDate(_parseString(p, ctxt));
            builder.updatedAt(updated);
            break;
        case "value":
            values = parseValues(p, ctxt);
            break;
        case "dimension":
            if (!version.orElse("1.x").equals("2.0")) {
                dims = Maps.newHashMap();
                // Deal with the id, size and role inside dimension.
                while (p.nextValue() != JsonToken.END_OBJECT) {
                    switch (p.getCurrentName()) {
                    case "id":
                        ids = p.readValueAs(ID_SET);
                        break;
                    case "size":
                        sizes = p.readValueAs(SIZE_LIST);
                        break;
                    case "role":
                        roles = p.readValueAs(ROLE_MULTIMAP);
                        break;
                    default:
                        dims.put(p.getCurrentName(), ctxt.readValue(p, Dimension.Builder.class));
                    }
                }
            } else {
                dims = p.readValueAs(DIMENSION_MAP);
            }
            break;
        case "id":
            ids = p.readValueAs(ID_SET);
            break;
        case "size":
            sizes = p.readValueAs(SIZE_LIST);
            break;
        case "role":
            roles = p.readValueAs(ROLE_MULTIMAP);
            break;
        case "extension":
            extension = Optional.of(ctxt.readValue(p, ObjectNode.class));
            break;
        case "link":
        case "status":
            // TODO
            p.skipChildren();
            break;
        case "version":
            version = Optional.of(_parseString(p, ctxt));
            break;
        case "class":
            // TODO
            clazz = Optional.of(_parseString(p, ctxt));
            break;
        default:
            boolean handled = ctxt.handleUnknownProperty(p, this, Dimension.Builder.class, p.getCurrentName());
            if (!handled)
                p.skipChildren();
            break;
        }
    }

    // Setup roles
    for (Map.Entry<String, String> dimRole : roles.entries()) {
        Dimension.Roles role = Dimension.Roles.valueOf(dimRole.getKey().toUpperCase());
        Dimension.Builder dimension = checkNotNull(dims.get(dimRole.getValue()),
                "could not assign the role {} to the dimension {}. The dimension did not exist", role,
                dimRole.getValue()

        );
        dimension.withRole(role);
    }

    List<Dimension.Builder> orderedDimensions = Lists.newArrayList();
    for (String dimensionName : ids) {
        orderedDimensions.add(dims.get(dimensionName));
    }

    // TODO: Check size?

    // Check ids and add to the data set.
    checkArgument(ids.size() == dims.size(), "dimension and size did not match");

    if (extension.isPresent()) {
        builder.withExtension(extension.get());
    }

    return builder.withDimensions(orderedDimensions).withValues(values);
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Handles setting a server object property from the client; expects a serverId, propertyName, and a value
 * @param jp// ww  w. j av a  2s  .co  m
 * @throws ServletException
 * @throws IOException
 */
protected void cmdSetProperty(JsonParser jp) throws ServletException, IOException {
    // Get the basics
    int serverId = getFieldValue(jp, "serverId", Integer.class);
    String propertyName = getFieldValue(jp, "propertyName", String.class);
    Object value = null;

    Proxied serverObject = getProxied(serverId);
    ProxyType type = ProxyTypeManager.INSTANCE.getProxyType(serverObject.getClass());
    ProxyProperty prop = getProperty(type, propertyName);

    skipFieldName(jp, "value");
    MetaClass propClass = prop.getPropertyClass();
    if (propClass.isSubclassOf(Proxied.class)) {

        if (propClass.isArray() || propClass.isCollection()) {
            value = readArray(jp, propClass.getJavaType());

        } else if (propClass.isMap()) {
            value = readMap(jp, propClass.getKeyClass(), propClass.getJavaType());

        } else {
            Integer id = jp.readValueAs(Integer.class);
            if (id != null)
                value = getProxied(id);
        }
    } else {
        if (propClass.isArray() || propClass.isCollection()) {
            value = readArray(jp, propClass.getJavaType());

        } else if (propClass.isMap()) {
            value = readMap(jp, propClass.getKeyClass(), propClass.getJavaType());

        } else {
            value = jp.readValueAs(Object.class);
            if (value != null && Enum.class.isAssignableFrom(propClass.getJavaType())) {
                String str = Helpers.camelCaseToEnum(value.toString());
                value = Enum.valueOf(propClass.getJavaType(), str);
            }
        }
    }

    setPropertyValue(type, serverObject, propertyName, value);
    jp.nextToken();
}

From source file:com.zenesis.qx.remote.RequestHandler.java

/**
 * Reads an array from JSON, where each value is of the listed in types; EG the first element
 * is class type[0], the second element is class type[1] etc
 * @param jp// w  w  w.  j  a va2  s.co  m
 * @param types
 * @return
 * @throws IOException
 */
private Object[] readArray(JsonParser jp, Class[] types) throws IOException {
    if (jp.getCurrentToken() == JsonToken.VALUE_NULL)
        return null;

    ArrayList result = new ArrayList();
    for (int paramIndex = 0; jp.nextToken() != JsonToken.END_ARRAY; paramIndex++) {
        Class type = null;
        if (types != null && paramIndex < types.length)
            type = types[paramIndex];

        if (type != null && type.isArray()) {
            if (jp.getCurrentToken() == JsonToken.VALUE_NULL)
                result.add(null);
            else if (jp.getCurrentToken() == JsonToken.START_ARRAY) {
                Object obj = readArray(jp, type.getComponentType());
                result.add(obj);
            } else
                throw new IllegalStateException("Expected array but found " + jp.getCurrentToken());

        } else if (type != null && Proxied.class.isAssignableFrom(type)) {
            Integer id = jp.readValueAs(Integer.class);
            if (id != null) {
                Proxied obj = getProxied(id);
                result.add(obj);
            } else
                result.add(null);

        } else if (type != null && Enum.class.isAssignableFrom(type)) {
            Object obj = jp.readValueAs(Object.class);
            if (obj != null) {
                String str = Helpers.camelCaseToEnum(obj.toString());
                obj = Enum.valueOf(type, str);
                result.add(obj);
            }
        } else {
            Object obj = jp.readValueAs(type != null ? type : Object.class);
            result.add(obj);
        }
    }
    return result.toArray(new Object[result.size()]);
}

From source file:com.basistech.rosette.dm.jackson.ListAttributeDeserializer.java

@SuppressWarnings("unchecked")
private ListAttribute deserialize(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb)
        throws IOException {
    jp.nextToken();//from  w  w  w .  ja  v a2s  .  co  m
    String keyName = jp.getText();

    if (tb != null) { // need to put back skipped properties?
        jp = JsonParserSequence.createFlattened(tb.asParser(jp), jp);
    }
    // Must point to the next value; tb had no current, jp pointed to VALUE_STRING:

    KnownAttribute attribute = KnownAttribute.getAttributeForKey(keyName);
    if (attribute == null) {
        attribute = KnownAttribute.UNKNOWN;
    }
    Class<? extends BaseAttribute> itemClass = attribute.attributeClass();

    ListAttribute.Builder<BaseAttribute> builder = new ListAttribute.Builder<>(attribute.attributeClass());
    List<BaseAttribute> items = Lists.newArrayList();

    JsonToken nextToken;
    while ((nextToken = jp.nextToken()) != JsonToken.END_OBJECT) {
        if (nextToken != JsonToken.FIELD_NAME) {
            throw ctxt.wrongTokenException(jp, JsonToken.END_OBJECT, "Expected field name.");
        } else {
            String name = jp.getCurrentName();
            if ("items".equals(name)) {
                // the actual list items.
                nextToken = jp.nextToken();
                if (nextToken == JsonToken.VALUE_EMBEDDED_OBJECT) {
                    Object o = jp.getEmbeddedObject();
                    if (o instanceof List) { // could it be an array, also?!?
                        // when using JsonTree, sometimes Jackson just sticks the entire Java object in here.
                        items.addAll((List) o);
                    } else {
                        throw ctxt.mappingException(
                                "List contains VALUE_EMBEDDED_OBJECT for items, but it wasn't a list.");
                    }
                } else if (nextToken != JsonToken.START_ARRAY) { // what about nothing?
                    throw ctxt.wrongTokenException(jp, JsonToken.START_ARRAY, "Expected array of items");
                } else {
                    // the START_ARRAY case, which is _normal_. Read the elements.
                    while (jp.nextToken() != JsonToken.END_ARRAY) {
                        items.add(jp.readValueAs(itemClass));
                    }
                }
            } else {
                nextToken = jp.nextToken();
                Object value;
                if (nextToken == JsonToken.VALUE_EMBEDDED_OBJECT) {
                    value = jp.getEmbeddedObject();
                } else {
                    value = jp.readValueAs(Object.class);
                }
                builder.extendedProperty(name, value);
            }
        }
    }
    builder.setItems(items);
    return builder.build();
}

From source file:tachyon.master.MasterInfo.java

/**
 * Load the image from <code>parser</code>, which is created based on the <code>path</code>.
 * Assume this blocks the whole MasterInfo.
 *
 * @param parser the JsonParser to load the image
 * @param path the file to load the image
 * @throws IOException/*  w  w  w .j av  a 2  s  .c  o  m*/
 */
public void loadImage(JsonParser parser, TachyonURI path) throws IOException {
    while (true) {
        ImageElement ele;
        try {
            ele = parser.readValueAs(ImageElement.class);
            LOG.debug("Read Element: {}", ele);
        } catch (IOException e) {
            // Unfortunately brittle, but Jackson rethrows EOF with this message.
            if (e.getMessage().contains("end-of-input")) {
                break;
            } else {
                throw e;
            }
        }

        switch (ele.mType) {
        case Version: {
            if (ele.getInt("version") != Constants.JOURNAL_VERSION) {
                throw new IOException("Image " + path + " has journal version " + ele.getInt("version")
                        + ". The system has version " + Constants.JOURNAL_VERSION);
            }
            break;
        }
        case Checkpoint: {
            mInodeCounter.set(ele.getInt("inodeCounter"));
            mCheckpointInfo.updateEditTransactionCounter(ele.getLong("editTransactionCounter"));
            mCheckpointInfo.updateDependencyCounter(ele.getInt("dependencyCounter"));
            break;
        }
        case Dependency: {
            Dependency dep = Dependency.loadImage(ele, mTachyonConf);

            mFileIdToDependency.put(dep.mId, dep);
            if (!dep.hasCheckpointed()) {
                mUncheckpointedDependencies.add(dep.mId);
            }
            for (int parentDependencyId : dep.mParentDependencies) {
                mFileIdToDependency.get(parentDependencyId).addChildrenDependency(dep.mId);
            }
            break;
        }
        case InodeFile: {
            // This element should not be loaded here. It should be loaded by InodeFolder.
            throw new IOException("Invalid element type " + ele);
        }
        case InodeFolder: {
            Inode inode = InodeFolder.loadImage(parser, ele);
            addToInodeMap(inode, mFileIdToInodes);
            recomputePinnedFiles(inode, Optional.<Boolean>absent());

            if (inode.getId() != 1) {
                throw new IOException("Invalid element type " + ele);
            }
            mRoot = (InodeFolder) inode;

            break;
        }
        case RawTable: {
            mRawTables.loadImage(ele);
            break;
        }
        default:
            throw new IOException("Invalid element type " + ele);
        }
    }
}

From source file:org.instagram4j.DefaultInstagramClient.java

private <T> Result<T> requestEntity(HttpRequestBase method, Class<T> type, boolean signableRequest)
        throws InstagramException {
    method.getParams().setParameter("http.useragent", "Instagram4j/1.0");

    JsonParser jp = null;
    HttpResponse response = null;/*from w  ww  .  j  a va  2s  .c  o  m*/
    ResultMeta meta = null;

    try {
        method.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
        if (signableRequest)
            setEnforceHeader(method);

        HttpClient client = new DefaultHttpClient();
        client.getParams().setParameter(AllClientPNames.CONNECTION_TIMEOUT, 15000);
        client.getParams().setParameter(AllClientPNames.SO_TIMEOUT, 30000);

        if (LOG.isDebugEnabled())
            LOG.debug(String.format("Requesting entity entry point %s, method %s", method.getURI().toString(),
                    method.getMethod()));

        autoThrottle();

        response = client.execute(method);

        jp = createParser(response, method);

        JsonToken tok = jp.nextToken();
        if (tok != JsonToken.START_OBJECT) {
            if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
                throw createInstagramException("Instagram request failed", method.getURI().toString(), response,
                        null, null);

            throw createInstagramException("Invalid response format from Instagram API",
                    method.getURI().toString(), response, null, null);
        }

        T data = null;

        while (true) {
            tok = jp.nextValue();
            if (tok == JsonToken.START_ARRAY) {
                throw createInstagramException("Unexpected array in entity response " + jp.getCurrentName(),
                        method.getURI().toString(), response, meta, null);
            } else if (tok == JsonToken.START_OBJECT) {
                // Should be "data" or "meta"
                String name = jp.getCurrentName();
                if ("meta".equals(name))
                    meta = jp.readValueAs(ResultMeta.class);
                else if ("data".equals(name)) {
                    if (type != null)
                        data = jp.readValueAs(type);
                    else
                        jp.readValueAs(Map.class); // Consume & ignore
                } else
                    throw createInstagramException("Unexpected field name " + name, method.getURI().toString(),
                            response, meta, null);
            } else
                break;
        }

        if (data == null && meta == null && response.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
            throw createInstagramException("Instagram request failed", method.getURI().toString(), response,
                    null, null);

        Result<T> result = new Result<T>(null, meta, data);
        setRateLimits(response, result);

        return result;
    } catch (JsonParseException e) {
        throw createInstagramException("Error parsing response from Instagram: " + e.getMessage(),
                method.getURI().toString(), response, meta, e);
    } catch (JsonProcessingException e) {
        throw createInstagramException("Error parsing response from Instagram: " + e.getMessage(),
                method.getURI().toString(), response, meta, e);
    } catch (IOException e) {
        throw createInstagramException("Error communicating with Instagram: " + e.getMessage(),
                method.getURI().toString(), response, meta, e);
    } finally {
        if (jp != null)
            try {
                jp.close();
            } catch (IOException e) {
            }
        method.releaseConnection();
    }
}