0
|
1 package de.mpiwg.itgroup.eSciDoc.harvesting;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.io.InputStream;
|
|
5
|
|
6
|
|
7
|
|
8 import org.apache.http.HttpResponse;
|
|
9 import org.apache.log4j.BasicConfigurator;
|
|
10 import org.apache.log4j.Level;
|
|
11 import org.apache.log4j.Logger;
|
|
12 import org.jdom.Attribute;
|
|
13 import org.jdom.Document;
|
|
14 import org.jdom.JDOMException;
|
|
15 import org.jdom.input.SAXBuilder;
|
|
16 import org.jdom.xpath.XPath;
|
|
17
|
|
18 import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler;
|
|
19 import de.mpiwg.itgroup.eSciDoc.Tools.EScidocTools;
|
|
20 import de.mpiwg.itgroup.eSciDoc.utils.eSciDocXmlObject;
|
|
21
|
|
22 public class ECHO_ESCIDOC_init {
|
|
23
|
|
24 private EScidocBasicHandler connector;
|
|
25
|
|
26 public ECHO_ESCIDOC_init(EScidocBasicHandler connector) {
|
|
27 this.connector = connector;
|
|
28 }
|
|
29
|
|
30 public String createResourceCM() throws IOException, IllegalStateException, JDOMException{
|
|
31 InputStream str = getClass().getResourceAsStream("/de/mpiwg/itgroup/eSciDoc/xmlTemplates/ECHOResource_content-model.xml");
|
|
32 HttpResponse result = connector.eScidocPut("/cmm/content-model", str);
|
|
33
|
|
34 Document doc = new SAXBuilder().build(result.getEntity().getContent());
|
|
35
|
|
36
|
|
37 XPath xp = EScidocTools.getESciDocXpath("//escidocContentModel:content-model/@xlink:href");
|
|
38 Attribute href = (Attribute) xp.selectSingleNode(doc);
|
|
39
|
|
40
|
|
41 return href.getValue();
|
|
42 }
|
|
43
|
|
44 public String createCollectionCM() throws IOException, IllegalStateException, JDOMException{
|
|
45 InputStream str = getClass().getResourceAsStream("/de/mpiwg/itgroup/eSciDoc/xmlTemplates/ECHOCollection_content-model.xml");
|
|
46 HttpResponse result = connector.eScidocPut("/cmm/content-model", str);
|
|
47 Document doc = new SAXBuilder().build(result.getEntity().getContent());
|
|
48
|
|
49
|
|
50 XPath xp = EScidocTools.getESciDocXpath("//escidocContentModel:content-model/@xlink:href");
|
|
51 Attribute href = (Attribute) xp.selectSingleNode(doc);
|
|
52
|
|
53
|
|
54 return href.getValue();
|
|
55 }
|
|
56
|
|
57 public String createFoxridgeResourceCM() throws IOException, IllegalStateException, JDOMException{
|
|
58 InputStream str = getClass().getResourceAsStream("/de/mpiwg/itgroup/eSciDoc/xmlTemplates/FoxridgeResource_content-model.xml");
|
|
59 HttpResponse result = connector.eScidocPut("/cmm/content-model", str);
|
|
60 Document doc = new SAXBuilder().build(result.getEntity().getContent());
|
|
61
|
|
62
|
|
63 XPath xp = EScidocTools.getESciDocXpath("//escidocContentModel:content-model/@xlink:href");
|
|
64 Attribute href = (Attribute) xp.selectSingleNode(doc);
|
|
65
|
|
66
|
|
67 return href.getValue();
|
|
68 }
|
|
69
|
|
70
|
|
71 /**
|
|
72 * @param args
|
|
73 * @throws JDOMException
|
|
74 * @throws IOException
|
|
75 * @throws IllegalStateException
|
|
76 */
|
|
77 public static void main(String[] args) throws IllegalStateException, IOException, JDOMException {
|
|
78
|
|
79
|
|
80 Logger rl = Logger.getRootLogger();
|
|
81 BasicConfigurator.configure();
|
|
82 rl.setLevel(Level.DEBUG);
|
|
83
|
|
84
|
|
85 EScidocBasicHandler connector = new EScidocBasicHandler("192.168.56.2",8080,"dwinter","weikiki7");
|
|
86
|
|
87 ECHO_ESCIDOC_init ini = new ECHO_ESCIDOC_init(connector);
|
|
88 //System.out.println(ini.createCollectionCM());
|
|
89 System.out.println(ini.createFoxridgeResourceCM());
|
|
90
|
|
91
|
|
92 }
|
|
93
|
|
94 }
|