1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.documenthandler;
17
18 import org.kuali.ole.docstore.common.document.content.instance.*;
19 import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
20 import org.kuali.ole.docstore.common.document.content.instance.xstream.InstanceOlemlRecordProcessor;
21
22 import javax.jcr.Node;
23 import javax.jcr.RepositoryException;
24 import java.util.ArrayList;
25
26
27
28
29
30
31
32 public class WorkInstanceOleMLContentHandler {
33 private InstanceOlemlRecordProcessor olemlProcessor = new InstanceOlemlRecordProcessor();
34
35
36
37
38
39
40
41
42
43
44 public void doInstanceOleMLContentManipulations(RequestDocument document, final String fileNodeUUID,
45 final Node parentNode) throws RepositoryException {
46 if (document.getContent().getContentObject() instanceof OleHoldings) {
47 ((OleHoldings) document.getContent().getContentObject()).setHoldingsIdentifier(fileNodeUUID);
48 document.getContent()
49 .setContent(olemlProcessor.toXML((OleHoldings) document.getContent().getContentObject()));
50 } else if (document.getContent().getContentObject() instanceof SourceHoldings) {
51 ((SourceHoldings) document.getContent().getContentObject()).setHoldingsIdentifier(fileNodeUUID);
52 document.getContent()
53 .setContent(olemlProcessor.toXML((SourceHoldings) document.getContent().getContentObject()));
54 } else if (document.getContent().getContentObject() instanceof Item) {
55 ((Item) document.getContent().getContentObject()).setItemIdentifier(fileNodeUUID);
56 document.getContent().setContent(olemlProcessor.toXML((Item) document.getContent().getContentObject()));
57 } else if (document.getContent().getContentObject() instanceof Instance) {
58 Instance inst = ((Instance) document.getContent().getContentObject());
59 inst.setInstanceIdentifier(parentNode.getIdentifier());
60 InstanceCollection instanceCollection = new InstanceCollection();
61 ArrayList<Instance> oleinsts = new ArrayList<Instance>();
62 oleinsts.add(inst);
63 instanceCollection.setInstance((oleinsts));
64 document.getContent().setContent(olemlProcessor.toXML(instanceCollection));
65 }
66 }
67 }