From: <yo...@us...> - 2010-04-07 20:33:15
|
Revision: 679 http://treebase.svn.sourceforge.net/treebase/?rev=679&view=rev Author: youjun Date: 2010-04-07 20:33:07 +0000 (Wed, 07 Apr 2010) Log Message: ----------- template modification on oai-pmh-provider Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/OAIPMHController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/util/IdentifyUtil.java trunk/treebase-web/src/main/webapp/WEB-INF/vmFiles/ListMetadataFormats.vm Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/OAIPMHController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/OAIPMHController.java 2010-04-06 20:37:41 UTC (rev 678) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/OAIPMHController.java 2010-04-07 20:33:07 UTC (rev 679) @@ -232,24 +232,24 @@ List<Person> authors=citation.getAuthors(); - map.put("title", IdentifyUtil.escape4XML(citation.getTitle())); + map.put("title", IdentifyUtil.escape4XML(study.getId(),citation.getTitle())); map.put("creator", authors); - map.put("subject", IdentifyUtil.escape4XML(citation.getKeywords())); + map.put("subject", IdentifyUtil.escape4XML(study.getId(),citation.getKeywords())); if(study.getName()!=null&study.getNotes()!=null) - map.put("description", IdentifyUtil.escape4XML(study.getName()+" "+study.getNotes())); + map.put("description", IdentifyUtil.escape4XML(study.getId(),study.getName()+" "+study.getNotes())); else if(study.getNotes()==null) - map.put("description",IdentifyUtil.escape4XML(study.getName())); + map.put("description",IdentifyUtil.escape4XML(study.getId(),study.getName())); else - map.put("description",IdentifyUtil.escape4XML(study.getNotes())); - map.put("publisher", IdentifyUtil.escape4XML(publisher)); + map.put("description",IdentifyUtil.escape4XML(study.getId(),study.getNotes())); + map.put("publisher", IdentifyUtil.escape4XML(study.getId(),publisher)); map.put("date", "published on "+citation.getPublishYear()); map.put("identifier", "TreeBASE.org/study/TB2:s"+study.getId()); map.put("datestamp", study.getReleaseDate()); - }catch(NullPointerException e){ + }catch(Exception e){ //study 253 citation= null, data should be fixed System.err.println("study "+study.getId()+ - " citation= "+e.getMessage()); + " citation= "+e.toString()); return null; } Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/util/IdentifyUtil.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/util/IdentifyUtil.java 2010-04-06 20:37:41 UTC (rev 678) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/util/IdentifyUtil.java 2010-04-07 20:33:07 UTC (rev 679) @@ -51,32 +51,41 @@ return new Date(utcMiliseconds + cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)); } - public static String escape4XML(String aText){ - final StringBuilder result = new StringBuilder(); - final StringCharacterIterator iterator = new StringCharacterIterator(aText); - char character = iterator.current(); - while (character != CharacterIterator.DONE ){ - if (character == '<') { + public static String escape4XML(long study_id, String xmlStr){ + if(xmlStr==null)return null; + StringBuilder result = new StringBuilder(); + StringCharacterIterator sci = new StringCharacterIterator(xmlStr); + char c = sci.current(); + while (c != CharacterIterator.DONE ){ + if (c == '<') { result.append("<"); } - else if (character == '>') { + else if (c == '>') { result.append(">"); } - else if (character == '\"') { + else if (c == '\"') { result.append("""); } - else if (character == '\'') { + else if (c == '\'') { result.append("'"); } - else if (character == '&') { + else if (c == '&') { result.append("&"); } else { - //the char is not a special one - //add it to the result as is - result.append(character); + if (!Character.isDefined(c)) { + try { + throw new Exception(); + } catch (Exception e) { + // TODO Auto-generated catch block + System.err.println("study:"+ study_id+" undefined charachter:"+ c + " in " + xmlStr ); + } + + + } + result.append(c); } - character = iterator.next(); + c = sci.next(); } return result.toString(); } Modified: trunk/treebase-web/src/main/webapp/WEB-INF/vmFiles/ListMetadataFormats.vm =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/vmFiles/ListMetadataFormats.vm 2010-04-06 20:37:41 UTC (rev 678) +++ trunk/treebase-web/src/main/webapp/WEB-INF/vmFiles/ListMetadataFormats.vm 2010-04-07 20:33:07 UTC (rev 679) @@ -2,17 +2,14 @@ <ListMetadataFormats> <metadataFormat> <metadataPrefix>oai_dc</metadataPrefix> - <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd - </schema> - <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/ - </metadataNamespace> + <schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema> + <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace> </metadataFormat> <metadataFormat> <metadataPrefix>dryad</metadataPrefix> <schema>http://ils.unc.edu/mrc/dryad/version1_0/dryad_1_0.xsd</schema> - <metadataNamespace>http://ils.unc.edu/mrc/dryad/ - </metadataNamespace> + <metadataNamespace>http://ils.unc.edu/mrc/dryad/</metadataNamespace> </metadataFormat> </ListMetadataFormats> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |