Package org.restlet.resource

Examples of org.restlet.resource.Representation


       
        getResponse().setEntity(represent());
    }
   
    public Representation represent(Variant variant) throws ResourceException {
        Representation representation;
        if (variant.getMediaType() == MediaType.APPLICATION_XML) {
            representation = new WriterRepresentation(MediaType.APPLICATION_XML) {
                public void write(Writer writer) throws IOException {
                    XmlMarshaller.marshalDocument(writer,"script", makeDataModel());
                }
            };
        } else {
            representation = new WriterRepresentation(MediaType.TEXT_HTML) {
                public void write(Writer writer) throws IOException {
                    ScriptResource.this.writeHtml(writer);
                }
            };
        }
        // TODO: remove if not necessary in future?
        representation.setCharacterSet(CharacterSet.UTF_8);
        return representation;
    }
View Full Code Here


    public Representation represent(Variant variant) throws ResourceException {
        if (appCtx == null) {
            throw new ResourceException(404);
        }

        Representation representation;
        if (variant.getMediaType() == MediaType.APPLICATION_XML) {
            representation = new WriterRepresentation(MediaType.APPLICATION_XML) {
                public void write(Writer writer) throws IOException {
                    XmlMarshaller.marshalDocument(writer, "beans", makeDataModel());
                }
            };
        } else {
            representation = new WriterRepresentation(
                    MediaType.TEXT_HTML) {
                public void write(Writer writer) throws IOException {
                    BeanBrowseResource.this.writeHtml(writer);
                }
            };
        }
        // TODO: remove if not necessary in future?
        representation.setCharacterSet(CharacterSet.UTF_8);
        return representation;
    }
View Full Code Here

    public Representation represent(Variant variant) throws ResourceException {
        if (cj == null) {
            throw new ResourceException(404);
        }

        Representation representation = null;
        if (variant.getMediaType() == MediaType.APPLICATION_XML) {
            representation = new WriterRepresentation(MediaType.APPLICATION_XML) {
                public void write(Writer writer) throws IOException {
                    CrawlJobModel model = makeDataModel();
                    model.put("heapReport", getEngine().heapReportData());
                    XmlMarshaller.marshalDocument(writer, "job", model);
                }
            };
        } else {
            representation = new WriterRepresentation(MediaType.TEXT_HTML) {
                public void write(Writer writer) throws IOException {
                    JobResource.this.writeHtml(writer);
                }
            };
        }

        // TODO: remove if not necessary in future?
        // honor requested charset?
        representation.setCharacterSet(CharacterSet.UTF_8);
        return representation;
    }
View Full Code Here

    }
    public Configuration getTemplateConfiguration(){
        return _templateConfiguration;
    }
    public Representation represent(Variant variant) throws ResourceException {
        Representation representation;
        if (variant.getMediaType() == MediaType.APPLICATION_XML) {
            representation = new WriterRepresentation(MediaType.APPLICATION_XML) {
                public void write(Writer writer) throws IOException {
                    XmlMarshaller.marshalDocument(writer, "engine", makeDataModel());
                }
            };
        } else {
            representation = new WriterRepresentation(MediaType.TEXT_HTML) {
                public void write(Writer writer) throws IOException {
                    EngineResource.this.writeHtml(writer);
                }
            };
        }
        // TODO: remove if not necessary in future?
        representation.setCharacterSet(CharacterSet.UTF_8);
        return representation;
    }
View Full Code Here

        String description = String.format("osm import %s, repository: %s", urlOrFilepath, repo);
        asyncCommand = AsyncContext.get().run(command, description);

        final String rootPath = request.getRootRef().toString();
        MediaType mediaType = variant.getMediaType();
        Representation rep = new OSMReportRepresentation(mediaType, asyncCommand, rootPath);
        return rep;
    }
View Full Code Here

                        filterFileArg, bboxArg, mappingFileArg, update, rebase, repo);
        asyncCommand = AsyncContext.get().run(command, description);

        final String rootPath = request.getRootRef().toString();
        MediaType mediaType = variant.getMediaType();
        Representation rep = new OSMReportRepresentation(mediaType, asyncCommand, rootPath);
        return rep;
    }
View Full Code Here

    }

    @Override
    public Representation getRepresentation(Variant variant) {
        Request request = getRequest();
        Representation representation = runCommand(variant, request);
        return representation;
    }
View Full Code Here

    private Representation runCommand(Variant variant, Request request) {

        final Optional<GeoGIG> geogig = getGeogig(request);
        Preconditions.checkState(geogig.isPresent());

        Representation rep = null;
        WebAPICommand command = null;
        Form options = getRequest().getResourceRef().getQueryAsForm();
        String commandName = (String) getRequest().getAttributes().get("command");
        MediaType format = resolveFormat(options, variant);
        try {
View Full Code Here

        InputStream input = null;

        Request request = getRequest();
        try {
            LOGGER.info("Receiving objects from {}", request.getClientInfo().getAddress());
            Representation representation = request.getEntity();
            input = representation.getStream();
            final GeoGIG ggit = getGeogig(request).get();
            final BinaryPackedObjects unpacker = new BinaryPackedObjects(ggit.getRepository()
                    .objectDatabase());

            CountingInputStream countingStream = new CountingInputStream(input);
View Full Code Here

            final GeoGIG ggit = getGeogig(request).get();
            final Repository repository = ggit.getRepository();
            final Deduplicator deduplicator = ggit.command(CreateDeduplicator.class).call();

            BinaryPackedObjects packer = new BinaryPackedObjects(repository.stagingDatabase());
            Representation rep = new RevObjectBinaryRepresentation(packer, want, have, deduplicator);
            Response response = getResponse();
            response.setEntity(rep);
        }
View Full Code Here

TOP

Related Classes of org.restlet.resource.Representation

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.