From 91cec09186607e7b38db465652491d31692ed8f0 Mon Sep 17 00:00:00 2001 From: mconway Date: Fri, 22 Aug 2014 13:36:11 -0400 Subject: [PATCH] #4 fixes for metadata create --- .../indexing/wrapper/IndexerWrapper.java | 58 ++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/jargon-indexing-wrapper/src/main/java/org/irods/jargon/indexing/wrapper/IndexerWrapper.java b/jargon-indexing-wrapper/src/main/java/org/irods/jargon/indexing/wrapper/IndexerWrapper.java index 8baff83..95f833d 100644 --- a/jargon-indexing-wrapper/src/main/java/org/irods/jargon/indexing/wrapper/IndexerWrapper.java +++ b/jargon-indexing-wrapper/src/main/java/org/irods/jargon/indexing/wrapper/IndexerWrapper.java @@ -26,6 +26,7 @@ */ public class IndexerWrapper implements Indexer { + public static final String METADATA_OBJECT = "metadataObject"; private IndexingService indexingService; private Scheduler scheduler; @@ -105,30 +106,45 @@ private void processUnionOperation(Message message, Messages ofMessages) { // look at message part for a part that is the metadata for (DataEntity part : message.getHasPart()) { - if (part.getMetadata() == null || part.getMetadata().isEmpty()) { - log.info("no metadata present"); - } else { - log.info("part being processed:{}", part); - for (AVU avu : part.getMetadata()) { + /* + * Look for AVU create event + */ - log.info("process as AVU add event{}", part); - MetadataEvent addMetadataEvent = new MetadataEvent(); - addMetadataEvent.setActionsEnum(actionsEnum.ADD); - addMetadataEvent - .setIrodsAbsolutePath(part.getDescription()); - try { - AvuData avuData = AvuData.instance(avu.getAttribute(), - avu.getValue(), avu.getUnit()); - addMetadataEvent.setAvuData(avuData); - this.onMetadataAdd(addMetadataEvent); - } catch (JargonException e) { - log.error("error", e); - throw new GeneralIndexerRuntimeException( - "jargon exception occurred processing AVU", e); - } - } + if (part.getAdditionalProperties() == null + || part.getAdditionalProperties().isEmpty()) { + log.info("no additional properties"); + continue; + } + + log.info("inspecting additional properties for avu create"); + + if (part.getAdditionalProperties().get(METADATA_OBJECT) != null) { + log.info("have a metadataObject property for this part, process as a metadata create"); + } else { + log.info("no metadata"); + continue; + } + log.info("have metadata object:{}", part.getAdditionalProperties() + .get(METADATA_OBJECT)); + AVU avu = (AVU) part.getAdditionalProperties().get(METADATA_OBJECT); + + log.info("as AVU:{}", avu); + + log.info("process as AVU add event{}", part); + MetadataEvent addMetadataEvent = new MetadataEvent(); + addMetadataEvent.setActionsEnum(actionsEnum.ADD); + addMetadataEvent.setIrodsAbsolutePath(part.getDescription()); + try { + AvuData avuData = AvuData.instance(avu.getAttribute(), + avu.getValue(), avu.getUnit()); + addMetadataEvent.setAvuData(avuData); + this.onMetadataAdd(addMetadataEvent); + } catch (JargonException e) { + log.error("error", e); + throw new GeneralIndexerRuntimeException( + "jargon exception occurred processing AVU", e); } }