Package net.fortytwo.ripple

Examples of net.fortytwo.ripple.RippleException


    public Representation dereference(final String uri) throws RippleException {
        // Don't dereference a URI which appears to point to a file which is not
        // an RDF document.
        int l = uri.lastIndexOf('.');
        if (l >= 0 && badExtensions.contains(uri.substring(l + 1))) {
            throw new RippleException("URI <" + StringUtils.escapeURIString(uri) + "> has blacklisted extension");
            // TODO: we can throw exceptions or return nulls to indicate an error, but we shouldn't do both
        }

        return new HTTPRepresentation(uri, linkedDataCache.getAcceptHeader());
    }
View Full Code Here


        URL getUrl;
        try {
            getUrl = RDFUtils.iriToUrl(uri);
        } catch (MalformedURLException e) {
            throw new RippleException(e);
        }
        method = HTTPUtils.createGetMethod(getUrl.toString());
        HTTPUtils.setAcceptHeader(method, acceptHeader);
        idleTime = HTTPUtils.throttleHttpRequest(method);

        HttpClient client = HTTPUtils.createClient();

        HttpResponse response;
        try {
            response = client.execute(method);
        } catch (IOException e) {
            throw new RippleException(e);
        }

        InputStream is;

        int code = response.getStatusLine().getStatusCode();

        if (2 != code / 100) {
            throw new ErrorResponseException("" + code + " response for resource <"
                    + StringUtils.escapeURIString(uri) + ">");
        }

        try {
            is = response.getEntity().getContent();
        } catch (IOException e) {
            throw new RippleException(e);
        }

        inputStream = new HttpRepresentationInputStream(is);

        Header h = response.getFirstHeader(HTTPUtils.CONTENT_TYPE);
View Full Code Here

                ? RDFParser.DatatypeHandling.VERIFY
                : p.equals("normalize")
                ? RDFParser.DatatypeHandling.NORMALIZE
                : null;
        if (null == datatypeHandling) {
            throw new RippleException("no such datatype handling policy: " + p);
        }

        // Rdfizers for registered RDF formats
        // TODO: 'tmp' is a hack to avoid a poorly-understood ConcurrentModificationException
        Collection<RDFFormat> tmp = new LinkedList<RDFFormat>();
View Full Code Here

            InputStream is;
            try {
                is = rep.getStream();
            } catch (IOException e) {
                throw new RippleException(e);
            }

            // Use the namespace portion of the original URI as the base URI for the retrieved RDF document.
            String baseUri = uri.getNamespace();

            memo.setStatus(rfiz.rdfize(is, handler, baseUri));

            // Only update the graph in the triple store if the operation was successful.
            if (CacheEntry.Status.Success == memo.getStatus()) {
                try {
                    sc.removeStatements(null, null, null, valueFactory.createURI(graphUri));
                } catch (SailException e) {
                    throw new RippleException(e);
                }

                buffer.flush();
            }
        } finally {
            metadata.setMemo(graphUri, memo, sc);

            // an autocommit happens independently of a call to LinkedDataSail#commit
            if (autoCommit) {
                try {
                    sc.commit();
                    sc.begin();
                } catch (SailException e) {
                    throw new RippleException(e);
                }
            }

            logStatus(uri, memo);
        }
View Full Code Here

    }

    public static MediaType findMediaType(final String uri) throws RippleException {
        RDFFormat format = RDFFormat.forFileName(uri);
        if (null == format) {
            throw new RippleException("no matching media type for " + uri);
        }

        List<String> types = format.getMIMETypes();
        if (0 == types.size()) {
            throw new IllegalStateException("RDF format has no media type(s): " + format);
View Full Code Here

            // Note: a comment by Jeen suggests that a new writer should be created
            //       for each use:
            //       http://www.openrdf.org/forum/mvnforum/viewthread?thread=785#3159
            writer = Rio.createWriter(format, out);
        } catch (Throwable t) {
            throw new RippleException(t);
        }

        return new SesameOutputAdapter(writer);
    }
View Full Code Here

            String s = removeFragmentIdentifier((subject).toString());

            try {
                return valueFactory.createURI(s);
            } catch (Throwable t) {
                throw new RippleException(t);
            }
        }
    }
View Full Code Here

            super(findMediaType(uri));

            try {
                inputStream = new FileInputStream(uri.substring(5));
            } catch (IOException e) {
                throw new RippleException(e);
            }
        }
View Full Code Here

            try {
//System.out.println( "uri = " + uri );
                jc = (JarURLConnection) (new URL(uri).openConnection());
                inputStream = jc.getInputStream();
            } catch (IOException e) {
                throw new RippleException(e);
            }
        }
View Full Code Here

        HttpGet method;

        try {
            method = new HttpGet(url);
        } catch (Throwable t) {
            throw new RippleException(t);
        }

        setAgent(method);

        return method;
View Full Code Here

TOP

Related Classes of net.fortytwo.ripple.RippleException

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.