当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryException类代码示例

本文整理汇总了Java中org.eclipse.rdf4j.repository.RepositoryException的典型用法代码示例。如果您正苦于以下问题:Java RepositoryException类的具体用法?Java RepositoryException怎么用?Java RepositoryException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RepositoryException类属于org.eclipse.rdf4j.repository包,在下文中一共展示了RepositoryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createLdpath

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
private LDPath<Value> createLdpath(Model model) {
  Repository repository = new SailRepository(new MemoryStore());
  Rdf4jRepositoryBackend repositoryBackend;

  try {
    repository.initialize();
    repositoryBackend = new Rdf4jRepositoryBackend(repository);

    final RepositoryConnection connection = repository.getConnection();
    connection.add(model);
    connection.close();
  } catch (RepositoryException re) {
    throw new LdPathExecutorRuntimeException("Unable to initialize RDF4JRepository.", re);
  }

  LDPath<Value> result = new LDPath<>(repositoryBackend, LD_PATH_CONFIG);

  result.registerFunction(new SortByPropertyFunction<>(ldpathNamespaces));

  return result;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:LdPathExecutor.java

示例2: loadTriples

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
public void loadTriples() throws RepositoryException {
    ValueFactory vf = SimpleValueFactory.getInstance();
    IRI graph = vf.createIRI("urn:test");
    int docSize = 100000;

    conn.configureWriteCache(750,750,600); // customise write cache (initDelay interval, delayCache interval, cache size)

    conn.begin();
    Set<Statement> bulkInsert = new HashSet();
    for (int term = 0; term < docSize; term++) {
        bulkInsert.add(vf.createStatement
                (vf.createIRI("urn:subject:" + term),
                        vf.createIRI("urn:predicate:" + term),
                        vf.createIRI("urn:object:" + term)));
    }
    conn.add(bulkInsert, graph);
    conn.commit();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:19,代码来源:Example4_Load_Triples.java

示例3: performUpdateQuery

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
/**
 * Executes UpdateQuery
 *
 * @param queryString
 * @param bindings
 * @param tx
 * @param includeInferred
 * @param baseURI
 */
public void performUpdateQuery(String queryString, SPARQLQueryBindingSet bindings, Transaction tx, boolean includeInferred, String baseURI) {
    SPARQLQueryDefinition qdef = sparqlManager.newQueryDefinition(queryString);
    if(Util.notNull(baseURI) && !baseURI.isEmpty()){ qdef.setBaseUri(baseURI);}
    if (Util.notNull(ruleset) && includeInferred) {qdef.setRulesets(ruleset);}
    if(Util.notNull(graphPerms)){ qdef.setUpdatePermissions(graphPerms);}
    qdef.setIncludeDefaultRulesets(includeInferred);
    sparqlManager.clearPageLength();
    try {
        sparqlManager.executeUpdate(qdef, tx);
    }
    catch (ForbiddenUserException e)
    {
        throw new RepositoryException(e.getMessage());
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicClientImpl.java

示例4: close

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
/**
 * Releases the connection to the database. Ensures that open transactions
 * are complete. Stops write cache timer.
 */
@Override
public void close()
        throws RepositoryException
{
    if(this.isOpen()){
        sync();
        if (this.isActive()) {
            logger.debug("rollback open transaction on closing connection.");
            client.rollbackTransaction();
        }
        client.stopTimer();
        client.close();
        super.close();
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:20,代码来源:MarkLogicRepositoryConnection.java

示例5: prepareQuery

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
/**
 * Base method for prepareQuery
 *
 * Routes to all other query forms (prepareTupleQuery,prepareBooleanQuery,prepareGraphQuery)
 *
 * @param queryLanguage  Query language to be used, for the query string.
 * @param queryString  Query string to be used.
 * @param baseURI Base URI to be used, with query string.
 * @return MarkLogicQuery
 * @throws RepositoryException
 * @throws MalformedQueryException
 */
@Override
public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI)
        throws RepositoryException, MalformedQueryException
{
    // function routing based on query form
    if (SPARQL.equals(queryLanguage)) {
        String queryStringWithoutProlog = QueryParserUtil.removeSPARQLQueryProlog(queryString).toUpperCase();
        if (queryStringWithoutProlog.startsWith("SELECT")) {
            return prepareTupleQuery(queryLanguage, queryString, baseURI);   //must be a TupleQuery
        }
        else if (queryStringWithoutProlog.startsWith("ASK")) {
            return prepareBooleanQuery(queryLanguage, queryString, baseURI); //must be a BooleanQuery
        }
        else {
            return prepareGraphQuery(queryLanguage, queryString, baseURI);   //all the rest use GraphQuery
        }
    }
    throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName());
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:32,代码来源:MarkLogicRepositoryConnection.java

示例6: testRepo1

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Test
  public void testRepo1()
          throws Exception {

  	testRepository.initialize();
      Assert.assertTrue(testRepository.getConnection() instanceof MarkLogicRepositoryConnection);

  	testRepository.shutDown();
  	testRepository.initialize();
  	testRepository.initialize();
  	testRepository.shutDown();
  	testRepository.shutDown();
  	try {
  		testConn = testRepository.getConnection();
	fail("Getting connection object should fail if repository is not initialized");
}
catch (Exception e) {
	Assert.assertTrue(e instanceof RepositoryException);
}
  	testRepository.initialize();
  	testConn = testRepository.getConnection();
      Assert.assertTrue(testRepository.getDataDir() == null);
      Assert.assertTrue(testRepository.isWritable());
      Assert.assertTrue(testRepository.getValueFactory() instanceof SimpleValueFactory);
  }
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:26,代码来源:MarkLogicRepositoryTest.java

示例7: initializeInternal

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
/**
 * @deprecated
 * implemented to honor Repository interface
 *
 * @throws RepositoryException
 */
@Override
@Deprecated
protected void initializeInternal() throws RepositoryException
{
    if(this.databaseClient == null || this.client == null || this.databaseClient.getClientImplementation() == null)
    {
        if(this.securityContext == null)
        {
            this.databaseClient = util.getClientBasedOnAuth(this.host, this.port, this.user, this.password, this.database, this.auth);
            this.client = new MarkLogicClient(databaseClient);
        }
        else
        {
            this.databaseClient = util.getClientBasedOnAuth(this.host, this.port, this.database, this.securityContext);
            this.client = new MarkLogicClient(databaseClient);
        }
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicRepository.java

示例8: loadResources_ThrowsException_RepositoryConnectionError

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Test
public void loadResources_ThrowsException_RepositoryConnectionError() {
  // Arrange
  when(configurationRepository.getConnection()).thenThrow(RepositoryException.class);

  // Assert
  thrown.expect(ConfigurationException.class);
  thrown.expectMessage("Error while getting repository connection.");

  // Act
  appearanceResourceProvider.loadResources();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:13,代码来源:AppearanceResourceProviderTest.java

示例9: loadResources_ThrowsException_WhenRepositoryConnectionError

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Test
public void loadResources_ThrowsException_WhenRepositoryConnectionError() throws IOException {
  // Arrange
  Resource resource = mock(Resource.class);
  when(((ResourcePatternResolver) resourceLoader).getResources(anyString())).thenReturn(
      new Resource[] {resource});
  when(repository.getConnection()).thenThrow(RepositoryException.class);

  // Assert
  thrown.expect(ConfigurationException.class);
  thrown.expectMessage("Error while getting repository connection.");

  // Act
  backend.loadResources();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:16,代码来源:FileConfigurationBackendTest.java

示例10: loadResources_ThrowsException_RepositoryConnectionError

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Test
public void loadResources_ThrowsException_RepositoryConnectionError() {
  // Arrange
  when(configurationRepository.getConnection()).thenThrow(RepositoryException.class);

  // Assert
  thrown.expect(ConfigurationException.class);
  thrown.expectMessage("Error while getting repository connection.");

  // Act
  backendResourceProvider.loadResources();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:13,代码来源:BackendResourceProviderTest.java

示例11: main

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
public static void main(String... args) throws RepositoryException {
    System.out.println("instantiate Simple class");
    Example3_Other simple = new Example3_Other(); // we instantiate so we can call non static methods
    try {
        logger.info("start examples");
        simple.tripleCount(); // return number of triples in repo
        logger.info("finished examples");
    }finally {
        simple.teardown();
    }
    System.exit(0);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:Example3_Other.java

示例12: main

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
public static void main(String... args) throws RepositoryException {
    System.out.println("instantiate Simple class");
    Example4_Load_Triples simple = new Example4_Load_Triples(); // we instantiate so we can call non static methods
    try {
        logger.info("start examples");
        simple.loadTriples(); //load 100,000 triples
        logger.info("finished examples");
    }finally {
        simple.teardown();
    }
    System.exit(0);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:13,代码来源:Example4_Load_Triples.java

示例13: openTransaction

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
/**
 * Opens a transaction.
 *
 * @throws MarkLogicTransactionException
 */
public void openTransaction() throws MarkLogicTransactionException {
	if (!isActiveTransaction()) {
		try {
               this.tx = getClient().getDatabaseClient().openTransaction();
           }
           catch (ForbiddenUserException e)
           {
               throw new RepositoryException(e.getMessage());
           }
	}else{
		throw new MarkLogicTransactionException("Only one active transaction allowed.");
	}
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:19,代码来源:MarkLogicClient.java

示例14: testRemoveStatementIteration

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Test
public void testRemoveStatementIteration()
        throws Exception
{
    ValueFactory f= conn.getValueFactory();
    Resource context1 = f.createIRI("http://marklogic.com/test/context1");
    Resource context2 = f.createIRI("http://marklogic.com/test/context2");
    Resource context3 = f.createIRI("http://marklogic.com/test/context3");

    final IRI alice = f.createIRI("http://example.org/people/alice");
    IRI name = f.createIRI("http://example.org/ontology/name");
    Literal alicesName = f.createLiteral("Alice");
    IRI age = f.createIRI("http://example.org/ontology/age");
    Literal alicesAge = f.createLiteral(11);

    Statement st1 = f.createStatement(alice, name, alicesName);
    Statement st2 = f.createStatement(alice, age, alicesAge);

    conn.begin();
    conn.add(st1, context1);
    conn.add(st2, context2);
    conn.add(st1, context3);
    conn.commit();

    Assert.assertEquals(1L, conn.size(context1));

    Iteration<? extends Statement, RepositoryException> iter = conn.getStatements(null, null,
            null, false);

    conn.remove(iter, context1);
    Assert.assertEquals(0L, conn.size(context1));
    Assert.assertEquals(1L, conn.size(context1, context2));

    iter = conn.getStatements(null, null, null, false);
    conn.remove(iter);
    Assert.assertEquals(0L, conn.size(context1, context2, context3));
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:38,代码来源:MarkLogicRepositoryConnectionTest.java

示例15: setUp

import org.eclipse.rdf4j.repository.RepositoryException; //导入依赖的package包/类
@Before
public void setUp() throws RepositoryException, FileNotFoundException {
    logger.debug("setting up test");
    rep.initialize();
    f = rep.getValueFactory();
    conn = rep.getConnection();
    logger.info("test setup complete.");
    File testData = new File(TESTFILE_OWL);

    GraphManager gmgr = writerClient.newGraphManager();
    gmgr.setDefaultMimetype(RDFMimeTypes.RDFXML);
    gmgr.write("/directory1/test.rdf", new FileHandle(testData));
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:14,代码来源:MarkLogicTupleQueryTest.java


注:本文中的org.eclipse.rdf4j.repository.RepositoryException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。