Search in sources :

Example 66 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class TestReifier method getGraph.

@Override
public Graph getGraph() {
    try {
        Constructor<?> cons = getConstructor(graphClass, new Class[] {});
        if (cons != null)
            return (Graph) cons.newInstance();
        Constructor<?> cons2 = getConstructor(graphClass, new Class[] { this.getClass() });
        if (cons2 != null)
            return (Graph) cons2.newInstance(this);
        throw new JenaException("no suitable graph constructor found for " + graphClass);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new JenaException(e);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) JenaException(org.apache.jena.shared.JenaException)

Example 67 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class DatasetGraphAccessorHTTP method target.

protected final String target(Node name) {
    if (!name.isURI())
        throw new JenaException("Not a URI: " + name);
    String guri = name.getURI();
    // Encode
    guri = IRILib.encodeUriComponent(guri);
    return remote + "?" + HttpNames.paramGraph + "=" + guri;
}
Also used : JenaException(org.apache.jena.shared.JenaException)

Example 68 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.

@SuppressWarnings("deprecation")
@ContractTest
public void testExecuteInTransactionCatchesThrowable() {
    TransactionHandler th = getTransactionHandlerProducer().newInstance();
    if (th.transactionsSupported()) {
        Command cmd = new Command() {

            @Override
            public Object execute() throws Error {
                throw new Error();
            }
        };
        try {
            th.executeInTransaction(cmd);
            fail("Should have thrown JenaException");
        } catch (JenaException x) {
        }
        try {
            th.execute(() -> {
                throw new Error();
            });
            fail("Should have thrown JenaException");
        } catch (JenaException x) {
        }
        try {
            th.calculate(() -> {
                throw new Error();
            });
            fail("Should have thrown JenaException");
        } catch (JenaException x) {
        }
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Command(org.apache.jena.shared.Command) TransactionHandler(org.apache.jena.graph.TransactionHandler) ContractTest(org.xenei.junit.contract.ContractTest)

Example 69 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class GraphHelper method getGraph.

/**
	 * Answer an instance of <code>graphClass</code>. If <code>graphClass</code>
	 * has a constructor that takes a <code>ReificationStyle</code> argument,
	 * then that constructor is run on <code>style</code> to get the instance.
	 * Otherwise, if it has a # constructor that takes an argument of
	 * <code>wrap</code>'s class before the <code>ReificationStyle</code>, that
	 * constructor is used; this allows non-static inner classes to be used for
	 * <code>graphClass</code>, with <code>wrap</code> being the outer class
	 * instance. If no suitable constructor exists, a JenaException is thrown.
	 * 
	 * @param wrap
	 *            the outer class instance if graphClass is an inner class
	 * @param graphClass
	 *            a class implementing Graph
	 * @return an instance of graphClass with the given style
	 * @throws RuntimeException
	 *             or JenaException if construction fails
	 */
public static Graph getGraph(Object wrap, Class<? extends Graph> graphClass) {
    try {
        Constructor<?> cons = getConstructor(graphClass, new Class[] {});
        if (cons != null)
            return (Graph) cons.newInstance(new Object[] {});
        Constructor<?> cons2 = getConstructor(graphClass, new Class[] { wrap.getClass() });
        if (cons2 != null)
            return (Graph) cons2.newInstance(new Object[] { wrap });
        throw new JenaException("no suitable graph constructor found for " + graphClass);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new JenaException(e);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) JenaException(org.apache.jena.shared.JenaException)

Example 70 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class LockMRSWLite method leaveCriticalSection.

@Override
public synchronized void leaveCriticalSection() {
    if (count == 0)
        throw new JenaException("Bad lock release - don't appear to be in a critical section");
    if (count < 0) {
        mrswLock.writeLock().unlock();
        count = 0;
        return;
    } else {
        mrswLock.readLock().unlock();
        count--;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException)

Aggregations

JenaException (org.apache.jena.shared.JenaException)70 Model (org.apache.jena.rdf.model.Model)12 RDFReader (org.apache.jena.rdf.model.RDFReader)8 IOException (java.io.IOException)7 QueryException (org.apache.jena.query.QueryException)5 QueryParseException (org.apache.jena.query.QueryParseException)5 java.io (java.io)4 InputStream (java.io.InputStream)4 Reader (java.io.Reader)4 StringReader (java.io.StringReader)4 Graph (org.apache.jena.graph.Graph)4 ServletOutputStream (javax.servlet.ServletOutputStream)3 CmdException (jena.cmd.CmdException)3 AmbiguousSpecificTypeException (org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException)3 MediaType (org.apache.jena.atlas.web.MediaType)3 Triple (org.apache.jena.graph.Triple)3 BadDescriptionMultipleRootsException (org.apache.jena.shared.BadDescriptionMultipleRootsException)3 BadDescriptionNoRootException (org.apache.jena.shared.BadDescriptionNoRootException)3 ARQParser (org.apache.jena.sparql.lang.arq.ARQParser)3 FileNotFoundException (java.io.FileNotFoundException)2