Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

Commit

Permalink
#4 fixes for metadata create
Browse files Browse the repository at this point in the history
  • Loading branch information
mconway committed Aug 22, 2014
1 parent bb02ef9 commit 3f64bcd
Showing 1 changed file with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.irods.jargon.indexing.wrapper;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.pub.domain.AvuData;
Expand Down Expand Up @@ -131,25 +131,40 @@ private void processUnionOperation(Message message, Messages ofMessages) {

log.info("have metadata object:{}", part.getAdditionalProperties()
.get(METADATA_OBJECT));
List avuDataEntry = (ArrayList) part.getAdditionalProperties().get(
METADATA_OBJECT);
List<Map<String, String>> avuEntries = (List<Map<String, String>>) part
.getAdditionalProperties().get(METADATA_OBJECT);

if (avuDataEntry.size() != 3) {
log.warn("expected 3 elements in avu data...discarded");
continue;
}
log.info("avuEntries:{}", avuEntries);
log.info("with size:{}", avuEntries.size());

Map<String, String> entry = avuEntries.get(0);

/*
* if (avuDataEntry.size() != 3) {
* log.warn("expected 3 elements in avu data...discarded");
* continue; }
*
* String attribute = (String) avuDataEntry.get(2); String value =
* (String) avuDataEntry.get(1); String unit = (String)
* avuDataEntry.get(0);
*/

String attribute = (String) avuDataEntry.get(2);
String value = (String) avuDataEntry.get(1);
String unit = (String) avuDataEntry.get(0);
String attribute = entry.get("attribute");
String value = entry.get("value");
String unit = entry.get("unit");

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(attribute.substring(10),
value.substring(6), unit.substring(5));
AvuData avuData = AvuData.instance(attribute, value, unit);

/*
* AvuData avuData = AvuData.instance(attribute.substring(10),
* value.substring(6), unit.substring(5));
*/

addMetadataEvent.setAvuData(avuData);
this.onMetadataAdd(addMetadataEvent);
} catch (JargonException e) {
Expand Down

0 comments on commit 3f64bcd

Please sign in to comment.