Package org.openrdf.rio

Examples of org.openrdf.rio.RDFFormat


     * @throws org.apache.marmotta.platform.core.exception.io.UnsupportedExporterException
     *          in case there is no matching exporter for the given mime type
     */
    @Override
    public String exportData(URI resource, URI context, String mimeType) throws UnsupportedExporterException {
        RDFFormat serializer = ioService.getSerializer(mimeType);
        if(serializer == null) {
            log.warn("could not find serializer for MIME type {}",mimeType);
            throw new UnsupportedExporterException("No serializer for mime type "+mimeType);
        }
        try {
View Full Code Here


     *                             in case there is no matching exporter for the given mime type
     * @throws java.io.IOException in case there is an error writing to the output
     */
    @Override
    public void exportData(Writer writer, URI resource, URI context, String mimeType) throws UnsupportedExporterException, IOException {
        RDFFormat serializer = ioService.getSerializer(mimeType);
        if(serializer == null) {
            log.warn("could not find serializer for MIME type {}",mimeType);
            throw new UnsupportedExporterException("No serializer for mime type "+mimeType);
        }

View Full Code Here

     *                             in case there is no matching exporter for the given mime type
     * @throws java.io.IOException in case there is an error writing to the output
     */
    @Override
    public void exportData(OutputStream outputStream, URI resource, URI context, String mimeType) throws UnsupportedExporterException, IOException {
        RDFFormat serializer = ioService.getSerializer(mimeType);
        if(serializer == null) {
            log.warn("could not find serializer for MIME type {}",mimeType);
            throw new UnsupportedExporterException("No serializer for mime type "+mimeType);
        }
        // HINT: This method might be executed outside a transaction!
View Full Code Here

    }

    public FileBackend(File file, String mimetype) {
        super();

        RDFFormat format = null;

        if(mimetype != null) {
            format = Rio.getParserFormatForMIMEType(mimetype);
        }
View Full Code Here

    }

    public FileBackend(URL url, String mimetype) {
        super();

        RDFFormat format = null;

        if(mimetype != null) {
            format = Rio.getParserFormatForMIMEType(mimetype);
        }
View Full Code Here

     * @param contentType content type as returned in the HTTP headers of the remote webservice   @return an RDF repository containing an RDF representation of the dataset located at the remote resource.
     * @throws java.io.IOException in case an error occurs while reading the input stream
     */
    @Override
    public List<String> parseResponse(final String resourceUri, String requestUrl, Model triples, InputStream in, String contentType) throws DataRetrievalException {
        RDFFormat format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(contentType, RDFFormat.RDFXML);

        try {
            ModelCommons.add(triples, in, resourceUri, format, new Predicate<Statement>() {
                @Override
                public boolean test(Statement param) {
View Full Code Here

                final URI resource = conn.getValueFactory().createURI(resource_string);

                final ContentType type = getContentType(types_string);

                //get serializer
                final RDFFormat serializer = lmfIOService.getSerializer(type.getMime());

                //create response serialisation
                StreamingOutput entity = new StreamingOutput() {
                    @Override
                    public void write(OutputStream output) throws IOException, WebApplicationException {
View Full Code Here

     */
    //@RaiseEvent("ontologyChanged")
    private int importData(InputStream is, String format, Resource user, URI context, String baseUri) throws MarmottaImportException {

        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName,"Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseUri", baseUri);

        int count = 0;

        try {
View Full Code Here

     */
    @Override
    public int importData(Reader reader, String format, Resource user, URI context) throws MarmottaImportException {

        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        String baseUri = configurationService.getBaseUri() + "resource/";
        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName, "Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseURI", baseUri);

        int count = 0;

        try {
View Full Code Here

        final Path config = file.getParent().resolve(configurationService.getStringConfiguration(CONFIG_KEY_CONF_FILE, "config"));
        if (Files.isReadable(config)) {
            Properties prop = loadConfigFile(file);
            final String fmt = prop.getProperty("format");
            if (fmt != null) {
                RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(fmt);
                if (rdfFormat != null) {
                    format = rdfFormat.getDefaultMIMEType();
                    log.debug("Using format {} from config file {}", format, config);
                } else {
                    log.debug("Unknown format {} in config file {}, ignoring", fmt, config);
                }
            } else {
                log.trace("No format defined in {}", config);
            }
        }

        // mimetype detection based on file-extension
        if (format == null) {
            // FIXME: Maybe use GzipUtils and BZip2Utils instead?
            RDFFormat rdfFormat = Rio.getParserFormatForFileName(fileName.replaceFirst("\\.(gz|bz2)$",""));
            if (rdfFormat != null) {
                format = rdfFormat.getDefaultMIMEType();
                log.trace("Using format {} based on file-name {}", format, fileName);
            }
        }

        if (format == null || !importService.getAcceptTypes().contains(format)) {
View Full Code Here

TOP

Related Classes of org.openrdf.rio.RDFFormat

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.