@Override protected String getKey(Document result) { return result.getId(); }
private static String bwmetaStorePath(Document document) { return "metadata" + File.separator + "bwmeta-2.1.0" + File.separator + document.getId() + ".xml"; }
@Override public Document process(Document item) throws Exception { if (item != null) { processedElements.add(item.getId()); } return item; } }
private static void writeDataToZipFile(Iterator<Record> itr, String zipFile) { logger.info("starting zipFile {}", zipFile); try { FileOutputStream fos = new FileOutputStream(zipFile); ZipOutputStream zos = new ZipOutputStream(fos); int count = 0; while (itr.hasNext() && count < FILES_PER_ZIP) { Document document = transformer.apply(itr.next()); logger.debug("zipFile {} document {}", zipFile, document.getId()); ZipEntry ze = new ZipEntry(bwmetaStorePath(document)); zos.putNextEntry(ze); String data = writerSupport.write(document.getMetadata()); zos.write(data.getBytes()); count++; } zos.closeEntry(); zos.close(); } catch (IOException ex) { logger.error("error", ex); } }
@Override public void write(List<? extends Document> items) throws Exception { List<PeopleIndexDocument> documents = new ArrayList<>(); String sampleId = StringUtils.EMPTY; for (Document document : items) { sampleId = StringUtils.isNotBlank(sampleId) ? sampleId : document.getId(); documents.add(peopleNodesTransformer.process(document)); } try { if (CollectionUtils.isNotEmpty(documents)) { service.updateDocuments(documents); } } catch (ConcurrencyFailureException e) { problemHandler.handleProblem(LogSeverity.ERROR, ObjectType.DOCUMENT, sampleId, "Problem when updating people index", e); throw e; } }
@Override public Document process(final Document document) { try { YExportable metadata = document.getMetadata(); if (metadata instanceof YElement) { YElement element = (YElement) metadata; structureBuilder.enrich(element); } else { problemHandler.handleProblem(LogSeverity.WARN, document.getId(), "YExportable", "metadata not YElement"); } } catch (BwmetaValidationException e) { problemHandler.handleProblem(LogSeverity.WARN, document.getId(), e.getValidationType(), e); } return document; } }
private void processDocument(Document document) { YExportable exportable = document.getMetadata(); if (!(exportable instanceof YElement)) { return; } YElement element = (YElement) exportable; try { if (transformer.modify(element)) { document.setMetadata(exportable); } } catch (Exception e) { problemHandler.handleProblem(LogSeverity.WARN, document.getId(), "enriching problem", e); } }
public void writeContent(Document document, InputStream inputStream, String contentFormat) { YElement metadata = (YElement) document.getMetadata(); String contentPartName = addOrReplaceYContent(metadata, contentFormat); document.setMetadata(metadata); try { document.addBinaryAttachment(contentPartName, new InputStreamResource(inputStream)); } catch (IOException e) { throw new GeneralBusinessException("Encountered a problem while adding attachment: {} to document: {}", contentPartName, document.getId()); } repository.storeDocument(document, null); }
logger.debug("Saving publication {} information in people index", document.getId()); ResourceVisibility visibility = ResourceVisibility.fromString(document.getTagValue(RepositoryStoreConstants.TAG_NAME_OBJECT_VISIBILITY)); ContentIndexDocumentWithIdentities contentDocument = new ContentIndexDocumentWithIdentities(document.getId(), ContentType.PUBLICATION); if (ResourceVisibility.PUBLIC != visibility) { contentDocument.setStatus(Status.HIDDEN);