Examples of RestEntity


Examples of org.apache.rave.rest.model.RestEntity

    public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
        String method = containerRequestContext.getRequest().getMethod();

        if (method.equals("POST") && containerResponseContext.getStatus() == Response.Status.OK.getStatusCode()) {
            containerResponseContext.setStatus(Response.Status.CREATED.getStatusCode());
            RestEntity entity = (RestEntity) containerResponseContext.getEntity();
            String id = entity.getId();
            containerResponseContext.getHeaders().add("Location",
                    containerRequestContext.getUriInfo().getAbsolutePathBuilder().path(id).build().toString());
        }

        //containerResponseContext.getHeaders().put("Location")
View Full Code Here

Examples of org.neo4j.rest.graphdb.entity.RestEntity

    }

    @Override
    @SuppressWarnings("unchecked")
    public <T extends PropertyContainer> T putIfAbsent(T entity, RestIndex index, String key, Object value) {
        final RestEntity restEntity = (RestEntity) entity;
        restEntity.flush();
        String uri = restEntity.getUri();
        if (value instanceof ValueContext) {
            value = ((ValueContext)value).getCorrectValue();
        }
        final Map<String, Object> data = map("key", key, "value", value, "uri", uri);
        final RequestResult result = getRestRequest().post(uniqueIndexPath(index), data);
        if (result.statusIs(Response.Status.CREATED)) {
            if (index.getEntityType().equals(Node.class)) return (T)createRestNode(result);
            if (index.getEntityType().equals(Relationship.class)) return (T)createRestRelationship(result,restEntity);
        }
        if (result.statusIs(Response.Status.OK)) {
            return (T) getEntityExtractor().convertFromRepresentation(result);
        }
        throw new RuntimeException(String.format("Error adding element %d %s %s to index %s", restEntity.getId(), key, value, index.getIndexName()));
    }
View Full Code Here

Examples of org.neo4j.rest.graphdb.entity.RestEntity

        return value;
    }

    private Object convertToEntityIfPossible(Object value) {
        if (value instanceof Map) {
            RestEntity restEntity = restApi.createRestEntity((Map) value);
            if (restEntity != null) return restEntity;
        }
        return value;
    }
View Full Code Here

Examples of org.neo4j.rest.graphdb.entity.RestEntity

        return indexPath(index,null,null) + "?uniqueness=get_or_create";
    }

    @Override
    public <T extends PropertyContainer> void addToIndex(T entity, RestIndex index, String key, Object value) {
        final RestEntity restEntity = (RestEntity) entity;
        String uri = restEntity.getUri();      
        if (value instanceof ValueContext) {
            value = ((ValueContext)value).getCorrectValue();
        }
        final Map<String, Object> data = map("key", key, "value", value, "uri", uri);
        final RequestResult result = getRestRequest().post(indexPath(index, null, null), data);
        if (result.statusOtherThan(Status.CREATED)) throw new RuntimeException(String.format("Error adding element %d %s %s to index %s", restEntity.getId(), key, value, index.getIndexName()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.