private boolean is200AnRDF(CachedHTTPResource resource) { if (resource.isContainsRDF() != null) return resource.isContainsRDF(); if (resource != null && resource.getResponses() != null) { for (SerialisableHttpResponse response : resource.getResponses()) { if (response != null && response.getHeaders("Content-Type") != null) { if (LinkedDataContent.contentTypes.contains(response.getHeaders("Content-Type"))) { if (response.getHeaders("Content-Type").equals(WebContent.contentTypeTextPlain)) { Model m = this.tryRead(resource.getUri()); if (m != null && m.size() == 0) { this.createProblemQuad(resource.getUri(), DQM.SC200WithoutRDF); resource.setContainsRDF(false); return false; } } this.createProblemQuad(resource.getUri(), DQM.SC200WithRDF); resource.setContainsRDF(true); return true; } } } } this.createProblemQuad(resource.getUri(), DQM.SC200WithoutRDF); resource.setContainsRDF(false); return false; }
// Private Method to check content type private Model getMeaningfulData(CachedHTTPResource resource) { Model m = null; if (resource != null && resource.getResponses() != null) { for (SerialisableHttpResponse response : resource.getResponses()) { if (response != null && response.getHeaders("Content-Type") != null) { if (CommonDataStructures.ldContentTypes.contains(response.getHeaders("Content-Type"))) { m = this.tryRead(resource.getUri()); } } } } 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()); } } } }