Ejemplo n.º 1
0
      ProcessProfile(Resource device) {
        myARPReader.setProperty("WARN_RESOLVING_URI_AGAINST_EMPTY_BASE", "EM_IGNORE");
        myARPReader.setErrorHandler(
            new RDFErrorHandler() {
              // ARP parser error handling routines
              public void warning(Exception e) {
                outputMsg("RDF parser warning:" + e.getMessage());
              }

              public void error(Exception e) {
                outputMsg("RDF parser error:" + e.getMessage());
                profileValidFlag = false;
              }

              public void fatalError(Exception e) {
                e.printStackTrace();
                error(e);
              }
            });
        this.deviceURI = device.getURI();
        try {
          profile = UrlUtils.getURL(deviceURI).trim();
          if (profile.contains("<html") || profile.contains("<head>")) {
            // this is HTML not a UAProf profile
            device.removeProperties();
          } else if (!profile.contains("rdf") && !profile.contains("RDF")) {
            device.removeProperties();
          } else if (!profile.contains("uaprof") && !profile.contains("UAPROF")) {
            device.removeProperties();
          } else if (!profile.contains("openmobilealliance") && !profile.contains("wapforum")) {
            device.removeProperties();
          } else {
            validate(device);
            profiles.fixMetadata(device, profile);
          }
        } catch (IOException io) {
          outputMsg("Could not retrieve " + device.getURI());
          device.removeProperties();
          unreachableProfiles++;
        }
        System.out.println(messages.toString());
      }
Ejemplo n.º 2
0
 private void testResource(final Model model, final Resource r, final int numProps) {
   final Literal tvLiteral = model.createLiteral("test 12 string 2");
   final Resource tvResource = model.createResource();
   final String lang = "fr";
   //
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvBoolean)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvBoolean));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvByte)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvByte));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvShort)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvShort));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvInt)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvInt));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvLong)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvLong));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvChar)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvChar));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvFloat)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvFloat));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvDouble)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvDouble));
   Assert.assertTrue(
       r.addProperty(RDF.value, AbstractModelTestBase.tvString)
           .hasProperty(RDF.value, AbstractModelTestBase.tvString));
   Assert.assertTrue(
       r.addProperty(RDF.value, AbstractModelTestBase.tvString, lang)
           .hasProperty(RDF.value, AbstractModelTestBase.tvString, lang));
   Assert.assertTrue(
       r.addLiteral(RDF.value, AbstractModelTestBase.tvObject)
           .hasLiteral(RDF.value, AbstractModelTestBase.tvObject));
   Assert.assertTrue(r.addProperty(RDF.value, tvLiteral).hasProperty(RDF.value, tvLiteral));
   Assert.assertTrue(r.addProperty(RDF.value, tvResource).hasProperty(RDF.value, tvResource));
   Assert.assertTrue(r.getRequiredProperty(RDF.value).getSubject().equals(r));
   //
   final Property p = model.createProperty("foo/", "bar");
   try {
     r.getRequiredProperty(p);
     Assert.fail("should detect missing property");
   } catch (final PropertyNotFoundException e) {
     JenaTestBase.pass();
   }
   //
   Assert.assertEquals(13, GraphTestBase.iteratorToSet(r.listProperties(RDF.value)).size());
   Assert.assertEquals(
       setOf(r),
       GraphTestBase.iteratorToSet(
           r.listProperties(RDF.value).mapWith(Statement.Util.getSubject)));
   //
   Assert.assertEquals(0, GraphTestBase.iteratorToSet(r.listProperties(p)).size());
   Assert.assertEquals(
       new HashSet<Resource>(),
       GraphTestBase.iteratorToSet(r.listProperties(p).mapWith(Statement.Util.getSubject)));
   //
   Assert.assertEquals(13 + numProps, GraphTestBase.iteratorToSet(r.listProperties()).size());
   Assert.assertEquals(
       setOf(r),
       GraphTestBase.iteratorToSet(r.listProperties().mapWith(Statement.Util.getSubject)));
   //
   r.removeProperties();
   Assert.assertEquals(0, model.query(new SimpleSelector(r, null, (RDFNode) null)).size());
 }
 /** @see com.hp.hpl.jena.rdf.model.Resource#removeProperties() */
 public Resource removeProperties() {
   synchronized (model) {
     wrapped.removeProperties();
     return this;
   }
 }