use of org.openrdf.repository.RepositoryException in project stanbol by apache.
the class SesameYard method remove.
@Override
public void remove(String id) throws YardException, IllegalArgumentException {
if (id == null) {
throw new IllegalArgumentException("The parsed Representation id MUST NOT be NULL!");
}
RepositoryConnection con = null;
try {
con = repository.getConnection();
con.begin();
remove(con, sesameFactory.createURI(id));
con.commit();
} catch (RepositoryException e) {
throw new YardException("Unable to remove for Representation " + id, e);
} finally {
if (con != null) {
try {
con.close();
} catch (RepositoryException ignore) {
}
}
}
}
use of org.openrdf.repository.RepositoryException in project stanbol by apache.
the class SesameYard method removeAll.
@Override
public final void removeAll() throws YardException {
RepositoryConnection con = null;
try {
con = repository.getConnection();
con.begin();
//removes everything
con.clear(contexts);
con.commit();
} catch (RepositoryException e) {
throw new YardException("Unable to remove parsed Representations", e);
} finally {
if (con != null) {
try {
con.close();
} catch (RepositoryException ignore) {
}
}
}
}
use of org.openrdf.repository.RepositoryException in project stanbol by apache.
the class SesameYard method store.
/**
* Generic store method used by store and update methods
* @param representation the representation to store/update
* @param allowCreate if new representation are allowed to be created
* @param canNotCreateIsError if updates to existing one are allowed
* @return the representation as added to the yard
* @throws IllegalArgumentException
* @throws YardException
*/
protected final Representation store(Representation representation, boolean allowCreate, boolean canNotCreateIsError) throws IllegalArgumentException, YardException {
RepositoryConnection con = null;
try {
con = repository.getConnection();
con.begin();
Representation added = store(con, representation, allowCreate, canNotCreateIsError);
con.commit();
return added;
} catch (RepositoryException e) {
throw new YardException("Unable to remove parsed Representations", e);
} catch (IllegalArgumentException e) {
try {
//to avoid Exception logs in case store(..) throws an Exception
//in the case allowCreate and canNotCreateIsError do not allow
//the store operation
con.rollback();
} catch (RepositoryException ignore) {
}
throw e;
} finally {
if (con != null) {
try {
con.close();
} catch (RepositoryException ignore) {
}
}
}
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraph method remove.
public void remove(Resource tripleSubject, RDFProperty triplePredicate, Resource tripleObject) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
AbstractSesameResource sesameObject = (AbstractSesameResource) tripleObject;
try {
conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, sesameObject.getSesameNativeResource(), contextResource);
} catch (RepositoryException e) {
throw new ShineRuntimeException(e);
}
}
use of org.openrdf.repository.RepositoryException in project gocd by gocd.
the class SesameGraph method remove.
public void remove(Resource tripleSubject, RDFProperty triplePredicate, String tripleObject) {
AbstractSesameResource sesameSubject = (AbstractSesameResource) tripleSubject;
URI sesameNativePredicate = getSesameNativeProperty(triplePredicate);
try {
conn.remove(sesameSubject.getSesameNativeResource(), sesameNativePredicate, conn.getValueFactory().createLiteral(tripleObject, XMLSchema.STRING), contextResource);
} catch (RepositoryException e) {
throw new ShineRuntimeException(e);
}
}
Aggregations