Package com.couchace.core.api.meta

Examples of com.couchace.core.api.meta.EntityMeta


            throw CouchException.badRequest("Unsupported DeleteRequestType " + deleteRequest.getType());
        }
    }

    protected WriteResponse executeDeleteEntity(DeleteEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        // Request does not define documentId or revision so look to the EntityMeta
        if (entityMeta.hasId() == false) {
            throw CouchException.internalServerError("Cannot build DeleteEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
        }

        // Read the id and revision
        Object entity = request.getEntity();
        String id = entityMeta.readDocumentId(entity);
        String revision = entityMeta.readDocumentRevision(entity);

        // Create the DeleteEntityRequest
        DeleteDocumentRequest deleteDocumentRequest = couch.delete().document(id, revision);

        CouchHttpResponse couchHttpResponse = httpClient.delete(httpRequestFactory.newHttpDeleteRequest(deleteDocumentRequest));
View Full Code Here


            throw new UnsupportedOperationException(msg);
        }
    }

    protected WriteResponse executePutEntity(PutEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        if (request.getDocumentId() == null && request.getDocumentRevision() == null) {
            // Request does not define documentId or revision so look to the EntityMeta
            if (entityMeta.hasId()) {
                // Read the id and revision
                Object entity = request.getEntity();
                String id = entityMeta.readDocumentId(entity);
                String revision = entityMeta.readDocumentRevision(entity);
                String entityType = entityMeta.getEntityType();

                // Create the PutEntityRequest
                request = couch.put().entity(id, entityType, entity, revision);
            } else {
                throw CouchException.internalServerError("Cannot build PutEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
View Full Code Here

            throw new UnsupportedOperationException(msg);
        }
    }

    protected WriteResponse executePostEntity(PostEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());
        HttpPostRequest httpPostRequest = httpRequestFactory.newHttpPostRequest(request);

        CouchHttpResponse couchHttpResponse = httpClient.post(httpPostRequest);

        if (couchHttpResponse.isSuccess()) {
View Full Code Here

            throw CouchException.badRequest("Unsupported DeleteRequestType " + deleteRequest.getType());
        }
    }

    protected WriteResponse executeDeleteEntity(DeleteEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        // Request does not define documentId or revision so look to the EntityMeta
        if (entityMeta.hasId() == false) {
            throw CouchException.internalServerError("Cannot build DeleteEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
        }

        // Read the id and revision
        Object entity = request.getEntity();
        String id = entityMeta.readDocumentId(entity);
        String revision = entityMeta.readDocumentRevision(entity);

        // Create the DeleteEntityRequest
        DeleteDocumentRequest deleteDocumentRequest = couch.delete().document(id, revision);

        CouchHttpResponse couchHttpResponse = httpClient.delete(httpRequestFactory.newHttpDeleteRequest(deleteDocumentRequest));
View Full Code Here

TOP

Related Classes of com.couchace.core.api.meta.EntityMeta

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.