Package com.couchbase.client.java.error

Examples of com.couchbase.client.java.error.TranscodingException


                @Override
                public BucketInfo call(BucketConfigResponse response) {
                    try {
                        return DefaultBucketInfo.create(CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.stringToJsonObject(response.config()));
                    } catch (Exception ex) {
                        throw new TranscodingException("Could not decode bucket info.", ex);
                    }
                }
            });
    }
View Full Code Here


                public Observable<DesignDocument> call(GetDesignDocumentsResponse response) {
                    JsonObject converted = null;
                    try {
                        converted = CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.stringToJsonObject(response.content());
                    } catch (Exception e) {
                        throw new TranscodingException("Could not decode design document.", e);
                    }
                    JsonArray rows = converted.getArray("rows");
                    List<DesignDocument> docs = new ArrayList<DesignDocument>();
                    for (Object doc : rows) {
                        JsonObject docObj = ((JsonObject) doc).getObject("doc");
View Full Code Here

                    JsonObject converted;
                    try {
                        converted = CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.stringToJsonObject(
                            response.content().toString(CharsetUtil.UTF_8));
                    } catch (Exception e) {
                        throw new TranscodingException("Could not decode design document.", e);
                    }
                    return DesignDocument.from(response.name(), converted);
                }
            });
    }
View Full Code Here

    public Observable<DesignDocument> upsertDesignDocument(final DesignDocument designDocument, boolean development) {
        String body = null;
        try {
            body = CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.jsonObjectToString(designDocument.toJsonObject());
        } catch (Exception e) {
            throw new TranscodingException("Could not encode design document: ", e);
        }
        UpsertDesignDocumentRequest req = new UpsertDesignDocumentRequest(designDocument.name(),
            body, development, bucket, password);
        return core.<UpsertDesignDocumentResponse>send(req)
            .map(new Func1<UpsertDesignDocumentResponse, DesignDocument>() {
View Full Code Here

            return doDecode(id, content, cas, expiry, flags, status);
        } catch(Exception ex) {
            if (ex instanceof TranscodingException) {
                throw (TranscodingException) ex;
            } else {
                throw new TranscodingException("Could not decode document with ID " + id, ex);
            }
        }
    }
View Full Code Here

            return doEncode(document);
        } catch(Exception ex) {
            if (ex instanceof TranscodingException) {
                throw (TranscodingException) ex;
            } else {
                throw new TranscodingException("Could not encode document with ID " + document.id(), ex);
            }
        }
    }
View Full Code Here

    @Override
    protected JsonDocument doDecode(String id, ByteBuf content, long cas, int expiry, int flags, ResponseStatus status)
        throws Exception {
        if (!TranscoderUtils.hasJsonFlags(flags)) {
            throw new TranscodingException("Flags (0x" + Integer.toHexString(flags) + ") indicate non-JSON document for "
                + "id " + id + ", could not decode.");
        }

        JsonObject converted = stringToJsonObject(content.toString(CharsetUtil.UTF_8));
        content.release();
View Full Code Here

    @Override
    protected StringDocument doDecode(String id, ByteBuf content, long cas, int expiry, int flags,
        ResponseStatus status) throws Exception {
        if (!TranscoderUtils.hasStringFlags(flags)) {
            throw new TranscodingException("Flags (0x" + Integer.toHexString(flags) + ") indicate non-String document for "
                + "id " + id + ", could not decode.");
        }
        return newDocument(id, expiry, content.toString(CharsetUtil.UTF_8), cas);
    }
View Full Code Here

        } else if (flags == 0) {
            if (decoded.startsWith("\"") && decoded.endsWith("\"")) {
                decoded = decoded.substring(1, decoded.length() - 1);
            }
        } else {
            throw new TranscodingException("Flags (0x" + Integer.toHexString(flags) + ") indicate non " +
                "JsonStringDocument id " + id + ", could not decode.");
        }

        return newDocument(id, expiry, decoded, cas);
    }
View Full Code Here

                @Override
                public ClusterInfo call(ClusterConfigResponse response) {
                    try {
                        return new DefaultClusterInfo(CouchbaseAsyncBucket.JSON_OBJECT_TRANSCODER.stringToJsonObject(response.config()));
                    } catch (Exception e) {
                        throw new TranscodingException("Could not decode cluster info.", e);
                    }
                }
            });
    }
View Full Code Here

TOP

Related Classes of com.couchbase.client.java.error.TranscodingException

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.