Mercurial > hg > eSciDocMPIWGServicesRestlet
comparison src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/search/SimpleSearch.java @ 4:938e45fabd7c default tip
version f?r escidoc produktionsversion
author | dwinter |
---|---|
date | Wed, 25 Jul 2012 12:36:25 +0200 |
parents | ffeb8be0bded |
children |
comparison
equal
deleted
inserted
replaced
3:498b68667ff3 | 4:938e45fabd7c |
---|---|
41 | 41 |
42 import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; | 42 import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; |
43 | 43 |
44 public class SimpleSearch extends ServerResource{ | 44 public class SimpleSearch extends ServerResource{ |
45 | 45 |
46 | |
46 private String eScidocServer; | 47 private String eScidocServer; |
47 private String eScidocPort; | 48 private String eScidocPort; |
48 private Logger logger= Logger.getRootLogger(); | 49 private Logger logger= Logger.getRootLogger(); |
49 private String eScidocUser; | 50 private String eScidocUser; |
50 private String eScidocUserPW; | 51 private String eScidocUserPW; |
52 | |
53 private String SEARCH_CMM="escidoc:131281"; //TODO: make this configurable, also a list of CMM should be possible | |
51 | 54 |
52 public SimpleSearch() throws IOException{ | 55 public SimpleSearch() throws IOException{ |
53 InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); | 56 InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); |
54 Properties prop = new Properties(); | 57 Properties prop = new Properties(); |
55 prop.load(is); | 58 prop.load(is); |
111 String searchAuthor=searchForm.getValues("author"); | 114 String searchAuthor=searchForm.getValues("author"); |
112 | 115 |
113 String queryString =""; | 116 String queryString =""; |
114 Boolean isSearch=false; | 117 Boolean isSearch=false; |
115 if (searchAll!=null && !searchAll.equals("")){ | 118 if (searchAll!=null && !searchAll.equals("")){ |
116 queryString="escidoc.metadata="+searchAll; | 119 queryString="metadata="+searchAll; |
117 isSearch=true; | 120 isSearch=true; |
118 } else if (searchTitle!=null && !searchTitle.equals("")){ | 121 } else if (searchTitle!=null && !searchTitle.equals("")){ |
119 queryString="escidoc.any-title="+searchTitle; | 122 queryString="any-title="+searchTitle; |
123 queryString+=" or meta.archimedes.title="+searchTitle; | |
124 queryString+=" or meta.bib.title="+searchTitle; | |
120 isSearch=true; | 125 isSearch=true; |
121 } else if (searchAuthor!=null && !searchAuthor.equals("")){ | 126 } else if (searchAuthor!=null && !searchAuthor.equals("")){ |
122 queryString="escidoc.creator="+searchAuthor; | 127 queryString="dc-md.creator="+searchAuthor; |
128 queryString+=" or meta.archimedes.author="+searchAuthor; | |
129 queryString+=" or meta.bib.author="+searchAuthor; | |
123 isSearch=true; | 130 isSearch=true; |
124 } | 131 } |
125 if (!isSearch) return null; | 132 if (!isSearch) return null; |
126 | 133 |
127 String query; | 134 String query; |
128 try { | 135 try { |
129 query = "/srw/search/escidoc_all?maximumRecords=1000&query="+URLEncoder.encode(queryString,"utf-8"); | 136 query = "/srw/search/escidoc_all?maximumRecords=1000&query="+URLEncoder.encode("content-model.objid="+SEARCH_CMM+" and "+ queryString,"utf-8"); |
130 } catch (UnsupportedEncodingException e) { | 137 } catch (UnsupportedEncodingException e) { |
131 logger.error("do Search, cannot encode:"+queryString); | 138 logger.error("do Search, cannot encode:"+queryString); |
132 setStatus(Status.SERVER_ERROR_INTERNAL); | 139 setStatus(Status.SERVER_ERROR_INTERNAL); |
133 return new StringRepresentation("<error>error</error>"); | 140 return new StringRepresentation("<error>error</error>"); |
134 } | 141 } |
177 JDOMResult out = new JDOMResult(); | 184 JDOMResult out = new JDOMResult(); |
178 transformer.transform(inxml, out); | 185 transformer.transform(inxml, out); |
179 //logger.debug(printXML(doc)); | 186 //logger.debug(printXML(doc)); |
180 | 187 |
181 Document docresult = out.getDocument(); | 188 Document docresult = out.getDocument(); |
189 | |
190 | |
191 | |
182 return new StringRepresentation(printXML(docresult),MediaType.TEXT_HTML); | 192 return new StringRepresentation(printXML(docresult),MediaType.TEXT_HTML); |
193 | |
194 | |
195 | |
183 | 196 |
184 } catch (Exception e) { | 197 } catch (Exception e) { |
185 logger.trace(e); | 198 logger.trace(e); |
186 return new StringRepresentation("<error>error</error>"); | 199 return new StringRepresentation("<error>error</error>"); |
187 } | 200 } |