1
|
package eu.etaxonomy.cdm.remote.view.oaipmh;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.io.StringReader;
|
5
|
import java.time.ZonedDateTime;
|
6
|
import java.util.Map;
|
7
|
|
8
|
import javax.xml.parsers.DocumentBuilder;
|
9
|
import javax.xml.parsers.DocumentBuilderFactory;
|
10
|
import javax.xml.parsers.ParserConfigurationException;
|
11
|
|
12
|
import org.w3c.dom.Document;
|
13
|
import org.w3c.dom.Element;
|
14
|
import org.xml.sax.InputSource;
|
15
|
import org.xml.sax.SAXException;
|
16
|
|
17
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.DeletedRecord;
|
18
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.Description;
|
19
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.Granularity;
|
20
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.Identify;
|
21
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.OAIPMH;
|
22
|
import eu.etaxonomy.cdm.remote.dto.oaipmh.Verb;
|
23
|
import eu.etaxonomy.cdm.remote.view.OaiPmhResponseView;
|
24
|
|
25
|
public class IdentifyView extends OaiPmhResponseView {
|
26
|
|
27
|
@Override
|
28
|
protected void constructResponse(OAIPMH oaiPmh,Map<String,Object> model) {
|
29
|
oaiPmh.getRequest().setVerb(Verb.IDENTIFY);
|
30
|
oaiPmh.getRequest().setValue((String)model.get("request"));
|
31
|
Identify identify = new Identify();
|
32
|
identify.setRepositoryName((String)model.get("repositoryName"));
|
33
|
identify.setBaseURL((String)model.get("baseURL"));
|
34
|
identify.setProtocolVersion((String)model.get("protocolVersion"));
|
35
|
identify.setDeletedRecord((DeletedRecord) model.get("deletedRecord"));
|
36
|
identify.setGranularity((Granularity) model.get("granularity"));
|
37
|
identify.setEarliestDatestamp((ZonedDateTime) model.get("earliestDatestamp"));
|
38
|
identify.getAdminEmail().add((String) model.get("adminEmail"));
|
39
|
if(model.get("description") != null){
|
40
|
Description description = new Description();
|
41
|
InputSource inputSource = new InputSource(new StringReader((String)model.get("description")));
|
42
|
DocumentBuilderFactory documentBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
|
43
|
documentBuilderFactory.setNamespaceAware(false);
|
44
|
Document document = null;
|
45
|
DocumentBuilder documentBuilder;
|
46
|
try {
|
47
|
documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
48
|
document = documentBuilder.parse(inputSource);
|
49
|
Element domElem = document.getDocumentElement();
|
50
|
|
51
|
description.setAny(domElem);
|
52
|
} catch (ParserConfigurationException e) {
|
53
|
// TODO Auto-generated catch block
|
54
|
e.printStackTrace();
|
55
|
} catch (SAXException e) {
|
56
|
// TODO Auto-generated catch block
|
57
|
e.printStackTrace();
|
58
|
} catch (IOException e) {
|
59
|
// TODO Auto-generated catch block
|
60
|
e.printStackTrace();
|
61
|
}
|
62
|
|
63
|
identify.getDescription().add(description);
|
64
|
}
|
65
|
|
66
|
oaiPmh.setIdentify(identify);
|
67
|
}
|
68
|
}
|