comparison software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/xml/SchemaHandler.java @ 16:257f67be5c00

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Sep 2011 16:40:57 +0200
parents 59ff47d1e237
children
comparison
equal deleted inserted replaced
15:e99964f390e4 16:257f67be5c00
33 String docBase = docOperation.getDocBase(); 33 String docBase = docOperation.getDocBase();
34 // file name validation 34 // file name validation
35 String fName = docOperation.getFileName(); 35 String fName = docOperation.getFileName();
36 if (fName == null || fName.trim().equals("")) 36 if (fName == null || fName.trim().equals(""))
37 throw new ApplicationException("Your document file name is empty. Please specify a file name for your document."); 37 throw new ApplicationException("Your document file name is empty. Please specify a file name for your document.");
38 if (! fName.endsWith(".xml")) 38 if (! fName.endsWith(".xml") && docBase != null && ! docBase.equals("diverse"))
39 throw new ApplicationException("Your document file name does not end with \".xml\". Please specify a file name with the suffix \".xml\" for your document."); 39 throw new ApplicationException("Your document file name does not end with \".xml\". Please specify a file name with the suffix \".xml\" for your document.");
40 // RelaxNG schema validation 40 // RelaxNG schema validation
41 validateByRelaxNGSchema(destFile, docBase); 41 validateByRelaxNGSchema(destFile, docBase);
42 // parse validation 42 // parse validation
43 Node docNode = parse(destFile); 43 Node docNode = parse(destFile);
72 } else if (docBase != null && docBase.equals("tei")) { 72 } else if (docBase != null && docBase.equals("tei")) {
73 mdRecord = getMetadataRecordTEI(documentNode); 73 mdRecord = getMetadataRecordTEI(documentNode);
74 if (mdRecord != null) { 74 if (mdRecord != null) {
75 String id = getIdByExistId(eXistIdentifier); 75 String id = getIdByExistId(eXistIdentifier);
76 mdRecord.setIdentifier("TEI:" + id + ".xml"); 76 mdRecord.setIdentifier("TEI:" + id + ".xml");
77 }
78 } else if (docBase != null && docBase.equals("diverse")) {
79 mdRecord = getMetadataRecordDiverse(documentNode);
80 if (mdRecord != null) {
81 String id = getIdByExistId(eXistIdentifier);
82 mdRecord.setIdentifier(id);
83 String lang = docOperation.getLanguage();
84 mdRecord.setLanguage(lang);
77 } 85 }
78 } 86 }
79 if (mdRecord != null) { 87 if (mdRecord != null) {
80 mdRecord.setEXistIdentifier(eXistIdentifier); 88 mdRecord.setEXistIdentifier(eXistIdentifier);
81 mdRecord.setMediaType("fulltext"); 89 mdRecord.setMediaType("fulltext");
130 } 138 }
131 return retNode; 139 return retNode;
132 } 140 }
133 141
134 private void validate(Node docNode, String docBase) throws ApplicationException { 142 private void validate(Node docNode, String docBase) throws ApplicationException {
143 if (docBase.equals("diverse"))
144 return;
135 XmlUtil xmlUtil = XmlUtil.getInstance(); 145 XmlUtil xmlUtil = XmlUtil.getInstance();
136 NamespaceContext nsContext = getEchoNsContext(); 146 NamespaceContext nsContext = getEchoNsContext();
137 String echoTest = null; 147 String echoTest = null;
138 String archimedesTest = null; 148 String archimedesTest = null;
139 String teiTest = null; 149 String teiTest = null;
190 } 200 }
191 return schemaUrl; 201 return schemaUrl;
192 } 202 }
193 203
194 private void validate(MetadataRecord mdRecord) throws ApplicationException { 204 private void validate(MetadataRecord mdRecord) throws ApplicationException {
205 String docBase = mdRecord.getDocBase();
206 if (docBase.equals("diverse"))
207 return;
195 String identifier = mdRecord.getIdentifier(); 208 String identifier = mdRecord.getIdentifier();
196 String creator = mdRecord.getCreator(); 209 String creator = mdRecord.getCreator();
197 String title = mdRecord.getTitle(); 210 String title = mdRecord.getTitle();
198 if (identifier == null || identifier.trim().equals("")) 211 if (identifier == null || identifier.trim().equals(""))
199 throw new ApplicationException("Your document file does not contain the metadata field: " + "identifier"); 212 throw new ApplicationException("Your document file does not contain the metadata field: " + "identifier");
311 if (accessRights == null) 324 if (accessRights == null)
312 accessRights = "free"; 325 accessRights = "free";
313 accessRights = StringUtilEscapeChars.deresolveXmlEntities(accessRights); 326 accessRights = StringUtilEscapeChars.deresolveXmlEntities(accessRights);
314 MetadataRecord mdRecord = new MetadataRecord(null, language, creator, title, null, null, "text/xml", rights, date); 327 MetadataRecord mdRecord = new MetadataRecord(null, language, creator, title, null, null, "text/xml", rights, date);
315 mdRecord.setDocBase("tei"); 328 mdRecord.setDocBase("tei");
329 mdRecord.setLicense(license);
330 mdRecord.setAccessRights(accessRights);
331 return mdRecord;
332 }
333
334 private MetadataRecord getMetadataRecordDiverse(Node documentNode) throws ApplicationException {
335 String rights = "open access";
336 String license = "http://echo.mpiwg-berlin.mpg.de/policy/oa_basics/declaration";
337 String accessRights = "free";
338 accessRights = StringUtilEscapeChars.deresolveXmlEntities(accessRights);
339 MetadataRecord mdRecord = new MetadataRecord(null, null, null, null, null, null, null, rights, null);
340 mdRecord.setDocBase("diverse");
316 mdRecord.setLicense(license); 341 mdRecord.setLicense(license);
317 mdRecord.setAccessRights(accessRights); 342 mdRecord.setAccessRights(accessRights);
318 return mdRecord; 343 return mdRecord;
319 } 344 }
320 345