annotate src/de/mpiwg/itgroup/eSciDoc/harvesting/ECHO_ESCIDOC_init.java @ 0:c6929e63b0b8

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