/** * Try Read content returned by text/plain * * @param uri * @return */ private Model tryRead(String uri) { Model m = ModelFactory.createDefaultModel(); try { m = RDFDataMgr.loadModel(uri, Lang.NTRIPLES); } catch (RiotException r) { Log.debug("Resource could not be parsed:", r.getMessage()); } return m; }
// Private Method for checking forward linking private void checkForForwardLinking() { for (String uri : uriSet) { CachedHTTPResource httpResource = (CachedHTTPResource) DiachronCacheManager.getInstance() .getFromCache(DiachronCacheManager.HTTP_RESOURCE_CACHE, uri); if (httpResource == null || (httpResource.getResponses() == null && httpResource.getDereferencabilityStatusCode() != StatusCode.BAD)) { this.notFetchedQueue.add(uri); } else { logger.info("Checking resource: {}. URIs left: {}.", httpResource.getUri(), uriSet.size()); // We perform a semantic lookup using heuristics to check if we // really need to try parsing or not if (HTTPResourceUtils.semanticURILookup(httpResource)) { logger.info( "Trying to find any dereferencable forward links for {}.", httpResource.getUri()); if (Dereferencer.hasValidDereferencability(httpResource)) { logger.info("Dereferencable resource {}.", httpResource.getUri()); // boolean isValid = ModelParser.snapshotParserForForwardDereference(httpResource, // (Lang) null, httpResource.getUri()); // if (isValid){ // //ok // logger.info("A description exists for resource {}.", httpResource.getUri()); // // totalDerefDataWithSub++; // } else { // //not ok // this.createNotValidForwardLink(httpResource.getUri()); // } Model m = RDFDataMgr.loadModel(httpResource.getUri()); // load partial model Resource r = m.createResource(httpResource.getUri()); List<Statement> stmtList = m.listStatements(r, (Property) null, (RDFNode) null).toList(); if (stmtList.size() > 1) { // ok logger.info("A description exists for resource {}.", httpResource.getUri()); totalDerefDataWithSub++; } else { // not ok this.createNotValidForwardLink(httpResource.getUri()); } } } else { logger.info("Non-meaningful dereferencable resource {}.", httpResource.getUri()); this.createNotValidForwardLink(httpResource.getUri()); } } } }