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

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


   * @see com.hp.hpl.jena.gvs.services.Service#start()
   */
  public void start() {
    Graph trustedGraph = store.getGraphOverTime(trustedSources).getGraph(new Date());
    Model trustedModel = JenaUtil.getModelFromGraph(trustedGraph);
    final Resource configRes = trustedModel.getResource(configuration.getURIRef());
    try {
      GVSServerLauncher.launchGVSServer(store, new ServerBinding() {
        public InetAddress getInetAddress() {
          Statement nicStatement = configRes.getProperty(HTTPLISTENER.networkInterface);
          if (nicStatement != null) {
            try {
              return InetAddress.getByName(nicStatement.getString());
            } catch (UnknownHostException e) {
              throw new RuntimeException(e);
            }
          }
          return null;
        }

        public int getPort() {
          return configRes.getProperty(HTTPLISTENER.port).getInt();
        }
       
      }, identity, trustedSources, configuration);
    } catch (IOException e) {
      throw new RuntimeException(e);
View Full Code Here


      Date moment, Resource type) {
    if (isAsserting(source, moleculeRef, moment, type)) {
      return false;
    }
    sources.add(source);
    Resource moleculeResource = metaModel.createResource(moleculeRef
        .getURIRef());
    Resource assertion = metaModel.createResource();
    assertion.addProperty(METAMODEL.asserter, metaModel
        .createResource(source.getURIRef()));
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(moment);
    Literal momentLit = metaModel.createTypedLiteral(new XSDDateTime(
        calendar));
    /*
     * Literal momentLit = metaModel.createTypedLiteral( new
     * MillisDateFormat().format(moment), XSDDatatype.XSDdateTime);
     */
    assertion.addProperty(METAMODEL.assertionTime, momentLit);
    assertion.addProperty(METAMODEL.assertedComponent, moleculeResource);
    moleculeResource.addProperty(RDF.type, type);
    return true;

  }
View Full Code Here

  public Set<NamedNode> getAsserted(Set<Source> sources, Date moment,
      Resource type) {
    Set<NamedNode> result = new HashSet<NamedNode>();
    for (Source source : sources) {
      Resource sourceRes = metaModel.createResource(source.getURIRef());
      ResIterator assertions = metaModel.listSubjectsWithProperty(
          METAMODEL.asserter, sourceRes);
      while (assertions.hasNext()) {
        Resource assertion = assertions.nextResource();
        Literal assertionTimeLit = assertion.getProperty(
            METAMODEL.assertionTime).getLiteral();
        Resource assertedComponent = assertion.getProperty(
            METAMODEL.assertedComponent).getResource();
        if (!assertedComponent.hasProperty(RDF.type, type)) {
          continue;
        }

        Date assertionTime;
        assertionTime = ((XSDDateTime) assertionTimeLit.getValue())
            .asCalendar().getTime();
        /*
         * try { assertionTime = new MillisDateFormat()
         * .parse(assertionTimeLit.getLexicalForm()); } catch
         * (ParseException e) { throw new RuntimeException(e); }
         */
        if (moment.before(assertionTime)) {
          continue;
        }
        Statement revocationTimeStmt = assertion
            .getProperty(METAMODEL.revocationTime);
        if (revocationTimeStmt != null) {
          Literal revocationTimeLit = revocationTimeStmt.getLiteral();
          Date revocationTime = ((XSDDateTime) revocationTimeLit
              .getValue()).asCalendar().getTime();
          // not before rather than after as in the moment of
          // revocation it is revoked
          if (!moment.before(revocationTime)) {
            continue;
          }
        }

        result.add(new NamedNodeImpl(assertedComponent.getURI()));
      }
    }
    return result;
  }
View Full Code Here

      for (GVSPrincipal principal : gvsPrincipals) {
        if (principal == SuperUserGVSPrincipal.instance) {
          result.add(new GVSImpersonatePermission());
          result.add(new GVSSetClockPermission());
        }
        Resource userRes = getUserResource(principal.getUserName());
        if (userRes.hasProperty(RDF.type, AUTHORIZATION.ClockMaster));
        StmtIterator impersonateStmt = userRes.listProperties(AUTHORIZATION.mayImpersonate);
        while (impersonateStmt.hasNext()) {
          result.add(new GVSImpersonatePermission(new SourceImpl(impersonateStmt.nextStatement().getResource().toString())));
        }
      }
     
View Full Code Here

    return result;
  }

  public void revokeComponent(Source source, NamedNode moleculeRef,
      Date moment) {
    Resource revokingComponentRes = getAssertionOf(source, moleculeRef,
        moment);
    if (revokingComponentRes == null) {
      throw new StoreException("Assertion not found");
    }
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(moment);
    Literal momentLit = metaModel.createTypedLiteral(new XSDDateTime(
        calendar));
    /*
     * Literal momentLit = metaModel.createTypedLiteral( new
     * MillisDateFormat().format(moment), XSDDatatype.XSDdateTime);
     */
    revokingComponentRes.addProperty(METAMODEL.revocationTime, momentLit);

  }
View Full Code Here

    return getDateList(sources, moment, false);
  }

  private Resource getAssertionOf(Source source, NamedNode componentName,
      Date moment) {
    Resource sourceRes = metaModel.createResource(source.getURIRef());
    Resource component = metaModel
        .createResource(componentName.getURIRef());
    ResIterator assertionsOfComponent = metaModel.listSubjectsWithProperty(
        METAMODEL.assertedComponent, component);
    while (assertionsOfComponent.hasNext()) {
      Resource assertion = assertionsOfComponent.nextResource();
      if (!assertion.hasProperty(METAMODEL.asserter, sourceRes)) {
        continue;
      }
      Literal assertionTimeLit = assertion.getProperty(
          METAMODEL.assertionTime).getLiteral();
      Date assertionTime;
      assertionTime = ((XSDDateTime) assertionTimeLit.getValue())
          .asCalendar().getTime();

      if (moment.before(assertionTime)) {
        continue;
      }
      Statement revocationTimeStmt = assertion
          .getProperty(METAMODEL.revocationTime);
      if (revocationTimeStmt != null) {
        Literal revocationTimeLit = revocationTimeStmt.getLiteral();
        Date revocationTime = ((XSDDateTime) revocationTimeLit
            .getValue()).asCalendar().getTime();
View Full Code Here

  private Iterator<Date> getDateList(Set<Source> sources, Date moment,
      final boolean forward) {

    Set<Date> resultDateSet = new HashSet<Date>();
    for (Source source : sources) {
      Resource sourceRes = metaModel.createResource(source.getURIRef());
      ResIterator assertions = metaModel.listSubjectsWithProperty(
          METAMODEL.asserter, sourceRes);
      while (assertions.hasNext()) {
        Resource assertion = assertions.nextResource();
        Literal assertionTimeLit = assertion.getProperty(
            METAMODEL.assertionTime).getLiteral();
        Date assertionTime;
        try {
          assertionTime = ((XSDDateTime) assertionTimeLit.getValue())
              .asCalendar().getTime();
          /*
           * assertionTime = new MillisDateFormat()
           * .parse(assertionTimeLit.getLexicalForm());
           */
        } catch (/* Parse */Exception e) {
          throw new RuntimeException(e);
        }
        if (forward) {
          if (assertionTime.after(moment)) {
            resultDateSet.add(assertionTime);
          }
        } else {
          if (!assertionTime.after(moment)) {
            resultDateSet.add(assertionTime);
          }
        }
        Statement revocationTimeStmt = assertion
            .getProperty(METAMODEL.revocationTime);
        if (revocationTimeStmt != null) {
          Literal revocationTimeLit = revocationTimeStmt.getLiteral();
          Date revocationTime;
          revocationTime = ((XSDDateTime) revocationTimeLit
View Full Code Here

   * @see com.hp.hpl.jena.gvs.storage.MetaStore#getAssertions(com.hp.hpl.jena.gvs.Source,
   *      java.util.Date, com.hp.hpl.jena.rdf.model.Resource)
   */
  public Set<NamedNode> getAssertions(Source source, Date moment,
      Resource type) {
    Resource sourceRes = metaModel.createResource(source.getURIRef());
    ResIterator assertions = metaModel.listSubjectsWithProperty(
        METAMODEL.asserter, sourceRes);
    Set<NamedNode> result = new HashSet<NamedNode>();
    while (assertions.hasNext()) {
      Resource assertion = assertions.nextResource();
      Literal assertionTimeLit = assertion.getProperty(
          METAMODEL.assertionTime).getLiteral();
      Resource assertedComponent = assertion.getProperty(
          METAMODEL.assertedComponent).getResource();
      if (!assertedComponent.hasProperty(RDF.type, type)) {
        continue;
      }

      Date assertionTime;
      assertionTime = ((XSDDateTime) assertionTimeLit.getValue())
          .asCalendar().getTime();
      if (moment.equals(assertionTime)) {
        result.add(new NamedNodeImpl(assertedComponent.getURI()));
      }

    }
    return result;
  }
View Full Code Here

   * @see com.hp.hpl.jena.gvs.storage.MetaStore#getRevocations(com.hp.hpl.jena.gvs.Source,
   *      java.util.Date, com.hp.hpl.jena.rdf.model.Resource)
   */
  public Set<NamedNode> getRevocations(Source source, Date moment,
      Resource type) {
    Resource sourceRes = metaModel.createResource(source.getURIRef());
    ResIterator assertions = metaModel.listSubjectsWithProperty(
        METAMODEL.asserter, sourceRes);
    Set<NamedNode> result = new HashSet<NamedNode>();
    while (assertions.hasNext()) {
      Resource assertion = assertions.nextResource();
      Resource assertedComponent = assertion.getProperty(
          METAMODEL.assertedComponent).getResource();
      if (!assertedComponent.hasProperty(RDF.type, type)) {
        continue;
      }
      Statement revocationTimeStmt = assertion
          .getProperty(METAMODEL.revocationTime);
      if (revocationTimeStmt != null) {
        Literal revocationTimeLit = revocationTimeStmt.getLiteral();
        Date revocationTime = ((XSDDateTime) revocationTimeLit
            .getValue()).asCalendar().getTime();
        if (moment.equals(revocationTime)) {
          result.add(new NamedNodeImpl(assertedComponent.getURI()));
        }
      }

    }
    return result;
View Full Code Here

   */
  public void handle(Request request, TypedResponse<Graph> response) throws HandlerException {
    Set<Source> sources = store.getSources();
    Model resultModel = ModelFactory.createDefaultModel();
    for (Source source : sources) {
      Resource sourceRes = resultModel.createResource(source.getURIRef());
      sourceRes.addProperty(RDF.type, METAMODEL.Source);
    }
    Subject subject = Subject.getSubject(AccessController.getContext());
    Set<GVSPrincipal> gvsPrincipals = subject.getPrincipals(GVSPrincipal.class);
    for (GVSPrincipal principal : gvsPrincipals) {
      resultModel.add(org.wymiwyg.commons.jena.JenaUtil.getExpandedResource(principal.getUserResource(), 2));
View Full Code Here

TOP

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

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.