Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Model


     */
    public Configuration(Store store, GraphOverTime configGOT,
        NamedNode configuration) {

      Graph configGraph = configGOT.getGraph(new Date());
      Model configModel = JenaUtil.getModelFromGraph(configGraph);
      Resource httpConfigRes = configModel.createResource(configuration
          .getURIRef());
      Statement amConfigStmt = httpConfigRes
          .getProperty(WEBACCOUNTMANAGER.webAccountManagerConfiguration);
      if (amConfigStmt != null) {
        Resource amConfigRes = amConfigStmt.getResource();
View Full Code Here


        } catch (NoSuchElementException e) {
        } catch (ParseException e) {
          throw new RuntimeException(e);
        }
      }
      Model model = ModelFactory.createDefaultModel();
      model.read(connection.getInputStream(), sliceURL.toExternalForm());
      // model.write(System.out);
      return new SliceResponse(model, nextFollowing);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

  private Set<String> getSources(URL remoteService) {
    Set<String> result = new HashSet<String>();
    try {
      URL sourcesURL = new URL(remoteService, "/meta/sources");
      Model sourcesModel = ModelFactory.createDefaultModel();
      sourcesModel.read(sourcesURL.toString());
      ResIterator sourcesIter = sourcesModel.listSubjectsWithProperty(
          RDF.type, METAMODEL.Source);
      while (sourcesIter.hasNext()) {
        result.add(sourcesIter.nextResource().getURI());
      }
    } catch (MalformedURLException e) {
View Full Code Here

    Set<Source> trustedSources  = new HashSet<Source>();
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/identity");;
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
        .toString());
    URL serverURL = new URL("http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/danbri");
    HttpURLConnection connection = (HttpURLConnection) serverURL
        .openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(403, responseCode);
    webServer.stop();

  }
View Full Code Here

        + serverBinding.getPort() + "/danbri");
    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
        .toString());
    model = LeanDiffPatch.leanify(model);
    HttpURLConnection connection = (HttpURLConnection) sourceURL
        .openConnection();
    connection.addRequestProperty("Cookie", "login=beta:tester");
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(200, responseCode);
    connection.disconnect();
    Model retrievedModel = ModelFactory.createDefaultModel();
    retrievedModel.read(sourceURL.toString());
    assertTrue("Retrieved model isomorphic to equals", model.isIsomorphicWith(retrievedModel));
    webServer.stop();

  }
View Full Code Here

        + serverBinding.getPort() + "/danbri");
    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
        .toString());
    model = LeanDiffPatch.leanify(model);
    HttpURLConnection connection = (HttpURLConnection) sourceURL
        .openConnection();
    connection.addRequestProperty("Cookie", "login=beta:wrong");
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
    model.write(out);
    int responseCode = connection.getResponseCode();
    assertEquals(403, responseCode);
    connection.disconnect();
    webServer.stop();
View Full Code Here

    File moleculeStoreDir = new File(storeDir, "moleculestore");
    moleculeStoreDir.mkdirs();
    fsMoleculeStore = new FSMoleculeStore(moleculeStoreDir, cache);
    setMoleculeStore(fsMoleculeStore);
    File metaStoreFile = new File(storeDir, "meta-store.nt");
    Model metaModel = ModelFactory.createModelForGraph(new NTFileGraph(
        metaStoreFile));
    MetaStore metaStore;// = new ModelMetaStore(metaModel);
    metaStore = new CachingMetaStore(metaModel);
    setMetaStore(metaStore);
  }
View Full Code Here

    new Thread() {

      @Override
      public void run() {
        while (true) {
          Model model = ModelFactory.createModelForGraph(trustedGOT
              .getGraph(new Date()));
          addURIsForType(model, DISCOBITS.InfoDiscoBit);
          addURIsForType(model, DISCOBITS.XHTMLInfoDiscoBit);
          try {
            Thread.sleep(60 * 1000); // Sleep a minute
          } catch (InterruptedException e) {
            throw new RuntimeException(e);
          }
        }
      }

      private void addURIsForType(Model model, OntClass type) {
        ResIterator subjectIter = model.listSubjectsWithProperty(
            RDF.type, type);
        // model.write(System.out);
        while (subjectIter.hasNext()) {
          Resource infoDiscoResource = subjectIter.nextResource();
          RDFNode infoBitNode = infoDiscoResource.getProperty(
View Full Code Here

   */
  public void start() {
    int previousTrustedSourceSize = 0;
    while (trustedSources.size() > previousTrustedSourceSize) {
      previousTrustedSourceSize = trustedSources.size();
      Model currentModel = ModelFactory.createModelForGraph(store.getGraphOverTime(trustedSources).getGraph(new Date()));
      StmtIterator seeAlsoStmt = currentModel.listStatements(null, RDFS.seeAlso, (Resource)null);
      while(seeAlsoStmt.hasNext()) {
        Statement stmt = seeAlsoStmt.nextStatement();
        RDFNode object = stmt.getObject();
        try {
          Source seeAlsoSource = new SourceImpl(((Resource)object).getURI());
View Full Code Here

  /**
   * @param source
   */
  private void downloadSource(Source source) {
    log.info("Spidering: "+source);
    Model downloadModel = ModelFactory.createDefaultModel();
    try {
      URL url = new URL(source.getURIRef());
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setInstanceFollowRedirects(false);
      connection.addRequestProperty(HeaderName.ACCEPT.toString(), "application/rdf+xml; q=1, application/xml; q=.9, text/xml; q=.8, */*; q=.1");
      connection.setReadTimeout(3000);
      connection.connect();
      int responseCode = connection.getResponseCode();
      if (responseCode != 200) {
        log.info("Response code: "+connection.getResponseCode());
        if ((responseCode >= 300) && (responseCode < 400)) {
          String location = connection.getHeaderField(HeaderName.LOCATION.toString());
          if (location != null) {
            connection.disconnect();
            downloadSource(new SourceImpl(location));
          }
        }
       
        return;
      }
      downloadModel.read(connection.getInputStream(), source.getURIRef());
      store.assertGraph(source, new FCAGraphImpl(downloadModel));
      connection.disconnect();
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    } catch (IOException e) {
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Model

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.