}
private Vertex savePage(Context context, String wikipediaPageVertexId, ParsePage parsePage, String pageString, String multiKey) throws IOException, InterruptedException {
boolean isRedirect = parsePage.getWikitext().startsWith("REDIRECT:");
StreamingPropertyValue rawPropertyValue = new StreamingPropertyValue(new ByteArrayInputStream(pageString.getBytes()), byte[].class);
rawPropertyValue.store(true);
rawPropertyValue.searchIndex(false);
StreamingPropertyValue textPropertyValue = new StreamingPropertyValue(new ByteArrayInputStream(parsePage.getWikitext().getBytes()), String.class);
VertexBuilder pageVertexBuilder = prepareVertex(wikipediaPageVertexId, visibility);
LumifyProperties.CONCEPT_TYPE.setProperty(pageVertexBuilder, WikipediaConstants.WIKIPEDIA_PAGE_CONCEPT_URI, visibility);
LumifyProperties.MIME_TYPE.setProperty(pageVertexBuilder, ImportMR.WIKIPEDIA_MIME_TYPE, visibility);
LumifyProperties.FILE_NAME.setProperty(pageVertexBuilder, sourceFileName, visibility);
LumifyProperties.SOURCE.setProperty(pageVertexBuilder, WikipediaConstants.WIKIPEDIA_SOURCE, visibility);
Map<String, Object> rawMetadata = new HashMap<String, Object>();
LumifyProperties.CONFIDENCE.setMetadata(rawMetadata, isRedirect ? 0.3 : 0.4);
LumifyProperties.RAW.addPropertyValue(pageVertexBuilder, multiKey, rawPropertyValue, rawMetadata, visibility);
Map<String, Object> titleMetadata = new HashMap<String, Object>();
LumifyProperties.CONFIDENCE.setMetadata(titleMetadata, isRedirect ? 0.3 : 0.4);
LumifyProperties.TITLE.addPropertyValue(pageVertexBuilder, multiKey, parsePage.getPageTitle(), titleMetadata, visibility);
Map<String, Object> sourceUrlMetadata = new HashMap<String, Object>();
LumifyProperties.CONFIDENCE.setMetadata(sourceUrlMetadata, isRedirect ? 0.3 : 0.4);
LumifyProperties.SOURCE_URL.addPropertyValue(pageVertexBuilder, multiKey, parsePage.getSourceUrl(), sourceUrlMetadata, visibility);
if (parsePage.getRevisionTimestamp() != null) {
Map<String, Object> publishedDateMetadata = new HashMap<String, Object>();
LumifyProperties.CONFIDENCE.setMetadata(publishedDateMetadata, isRedirect ? 0.3 : 0.4);
LumifyProperties.PUBLISHED_DATE.addPropertyValue(pageVertexBuilder, multiKey, parsePage.getRevisionTimestamp(), publishedDateMetadata, visibility);
}
if (!isRedirect) {
Map<String, Object> textMetadata = new HashMap<String, Object>();
textMetadata.put(LumifyProperties.META_DATA_TEXT_DESCRIPTION, "Text");
LumifyProperties.TEXT.addPropertyValue(pageVertexBuilder, multiKey, textPropertyValue, textMetadata, visibility);
}
Vertex pageVertex = pageVertexBuilder.save(authorizations);
// audit vertex
Audit audit = auditRepository.createAudit(AuditAction.CREATE, pageVertex.getId(), "Wikipedia MR", "", user, visibility);
context.write(auditTableNameText, AccumuloSession.createMutationFromRow(audit));
// because save above will cause the StreamingPropertyValue to be read we need to reset the position to 0 for search indexing
rawPropertyValue.getInputStream().reset();
textPropertyValue.getInputStream().reset();
return pageVertex;
}