1 |
7609
|
tao
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2000-2011 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author: leinfelder $'
|
7 |
|
|
* '$Date: 2012-11-29 16:52:29 -0800 (Thu, 29 Nov 2012) $'
|
8 |
|
|
*
|
9 |
|
|
* This program is free software; you can redistribute it and/or modify
|
10 |
|
|
* it under the terms of the GNU General Public License as published by
|
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
* (at your option) any later version.
|
13 |
|
|
*
|
14 |
|
|
* This program is distributed in the hope that it will be useful,
|
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
* GNU General Public License for more details.
|
18 |
|
|
*
|
19 |
|
|
* You should have received a copy of the GNU General Public License
|
20 |
|
|
* along with this program; if not, write to the Free Software
|
21 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22 |
|
|
*/
|
23 |
|
|
package edu.ucsb.nceas.metacat.index;
|
24 |
|
|
|
25 |
|
|
import java.io.ByteArrayInputStream;
|
26 |
7647
|
leinfelder
|
import java.io.ByteArrayOutputStream;
|
27 |
7609
|
tao
|
import java.io.File;
|
28 |
7635
|
tao
|
import java.io.FileInputStream;
|
29 |
7609
|
tao
|
import java.io.IOException;
|
30 |
|
|
import java.io.InputStream;
|
31 |
7647
|
leinfelder
|
import java.io.OutputStreamWriter;
|
32 |
7609
|
tao
|
import java.io.StringWriter;
|
33 |
|
|
import java.io.Writer;
|
34 |
7664
|
tao
|
import java.net.MalformedURLException;
|
35 |
|
|
import java.net.URL;
|
36 |
7647
|
leinfelder
|
import java.sql.SQLException;
|
37 |
|
|
import java.util.ArrayList;
|
38 |
7635
|
tao
|
import java.util.Collection;
|
39 |
7647
|
leinfelder
|
import java.util.Hashtable;
|
40 |
|
|
import java.util.List;
|
41 |
7634
|
tao
|
import java.util.Map;
|
42 |
7609
|
tao
|
|
43 |
7620
|
tao
|
import javax.xml.parsers.ParserConfigurationException;
|
44 |
|
|
|
45 |
7647
|
leinfelder
|
import org.apache.commons.io.IOUtils;
|
46 |
7609
|
tao
|
import org.apache.commons.logging.Log;
|
47 |
|
|
import org.apache.commons.logging.LogFactory;
|
48 |
|
|
import org.apache.solr.client.solrj.SolrServer;
|
49 |
|
|
import org.apache.solr.client.solrj.SolrServerException;
|
50 |
|
|
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
|
51 |
7664
|
tao
|
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
|
52 |
7609
|
tao
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
53 |
7648
|
tao
|
import org.apache.solr.common.params.AppendedSolrParams;
|
54 |
7647
|
leinfelder
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
55 |
7609
|
tao
|
import org.apache.solr.common.params.SolrParams;
|
56 |
7648
|
tao
|
import org.apache.solr.common.util.NamedList;
|
57 |
7609
|
tao
|
import org.apache.solr.core.CoreContainer;
|
58 |
7635
|
tao
|
import org.apache.solr.core.SolrConfig;
|
59 |
7609
|
tao
|
import org.apache.solr.core.SolrCore;
|
60 |
|
|
import org.apache.solr.request.LocalSolrQueryRequest;
|
61 |
|
|
import org.apache.solr.response.CSVResponseWriter;
|
62 |
|
|
import org.apache.solr.response.JSONResponseWriter;
|
63 |
|
|
import org.apache.solr.response.PHPResponseWriter;
|
64 |
|
|
import org.apache.solr.response.PHPSerializedResponseWriter;
|
65 |
|
|
import org.apache.solr.response.PythonResponseWriter;
|
66 |
|
|
import org.apache.solr.response.QueryResponseWriter;
|
67 |
|
|
import org.apache.solr.response.RubyResponseWriter;
|
68 |
|
|
import org.apache.solr.response.SolrQueryResponse;
|
69 |
7648
|
tao
|
import org.apache.solr.response.VelocityResponseWriter;
|
70 |
7609
|
tao
|
import org.apache.solr.response.XMLResponseWriter;
|
71 |
7635
|
tao
|
import org.apache.solr.schema.IndexSchema;
|
72 |
|
|
import org.apache.solr.schema.SchemaField;
|
73 |
7609
|
tao
|
import org.apache.solr.servlet.SolrRequestParsers;
|
74 |
|
|
import org.dataone.configuration.Settings;
|
75 |
7634
|
tao
|
import org.dataone.service.types.v1_1.QueryEngineDescription;
|
76 |
|
|
import org.dataone.service.types.v1_1.QueryField;
|
77 |
7669
|
tao
|
import org.dataone.service.util.Constants;
|
78 |
7635
|
tao
|
import org.xml.sax.InputSource;
|
79 |
7620
|
tao
|
import org.xml.sax.SAXException;
|
80 |
7609
|
tao
|
|
81 |
7647
|
leinfelder
|
import edu.ucsb.nceas.metacat.DBTransform;
|
82 |
7609
|
tao
|
import edu.ucsb.nceas.metacat.MetaCatServlet;
|
83 |
7664
|
tao
|
import edu.ucsb.nceas.metacat.common.SolrServerFactory;
|
84 |
7647
|
leinfelder
|
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
85 |
7609
|
tao
|
|
86 |
|
|
|
87 |
|
|
/**
|
88 |
|
|
* This class will query the solr server and return the result.
|
89 |
|
|
* @author tao
|
90 |
|
|
*
|
91 |
|
|
*/
|
92 |
|
|
public class MetacatSolrIndex {
|
93 |
|
|
|
94 |
7634
|
tao
|
|
95 |
|
|
public static final String SOLRQUERY = "solr";
|
96 |
7609
|
tao
|
public static final String SOLR_HOME_PROPERTY_NAME = "solr.homeDir";
|
97 |
|
|
public static final String SOLR_CONFIG_FILE_NAME_PROPERTY_NAME = "solr.configFileName";
|
98 |
|
|
public static final String SOLR_COLLECTION_NAME_PROPERTY_NAME = "solr.collectionName";
|
99 |
|
|
public static final String SOLR_SERVER_CLASSNAME_PROPERTY_NAME = "solr.server.classname";
|
100 |
|
|
private static final String WT = "wt";//the property name to specify the return type
|
101 |
|
|
private static final String XML = "xml";
|
102 |
|
|
private static final String JSON = "json";
|
103 |
|
|
private static final String PYTHON = "python";
|
104 |
|
|
private static final String RUBY = "ruby";
|
105 |
|
|
private static final String PHP = "php";
|
106 |
|
|
private static final String PHPS = "phps";
|
107 |
|
|
private static final String VELOCITY = "velocity";
|
108 |
|
|
private static final String CSV ="csv";
|
109 |
7647
|
leinfelder
|
private static List<String> supportedWriterTypes = null;
|
110 |
7634
|
tao
|
private static final String VERSION = "3.4";
|
111 |
7635
|
tao
|
private static final String SOLRCONFDIR = "/conf";
|
112 |
|
|
private static final String SOLRSCHEMAFILEPATH = SOLRCONFDIR+"/schema.xml";
|
113 |
7648
|
tao
|
private static final String FILTERQUERY = "fq";
|
114 |
|
|
private static final String READPERMISSION = "readPermission";
|
115 |
7669
|
tao
|
private static final String RIGHTSHOLDER = "rightsHolder";
|
116 |
7648
|
tao
|
private static final String OPENPARENTHESE = "(";
|
117 |
|
|
private static final String CLOSEPARENTHESE = ")";
|
118 |
|
|
private static final String COLON = ":";
|
119 |
|
|
private static final String OR = "OR";
|
120 |
7635
|
tao
|
//private static final String SOLRCONFIGPATH = "/conf/solrconfig.xml";
|
121 |
7609
|
tao
|
|
122 |
|
|
private static Log log = LogFactory.getLog(MetacatSolrIndex.class);
|
123 |
|
|
private CoreContainer coreContainer = null;
|
124 |
|
|
private SolrServer solrServer = null;
|
125 |
7648
|
tao
|
//private String wt = null;//specify the return format.
|
126 |
7609
|
tao
|
private String collectionName = null;
|
127 |
7664
|
tao
|
private String solrBaseURL = null;
|
128 |
|
|
private boolean isEmbeddedSolrServer = true;
|
129 |
7634
|
tao
|
private static MetacatSolrIndex solrIndex = null;
|
130 |
7609
|
tao
|
|
131 |
7664
|
tao
|
public static MetacatSolrIndex getInstance() throws Exception {
|
132 |
7634
|
tao
|
if (solrIndex == null) {
|
133 |
|
|
solrIndex = new MetacatSolrIndex();
|
134 |
|
|
}
|
135 |
|
|
return solrIndex;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
7609
|
tao
|
/**
|
139 |
|
|
* Constructor
|
140 |
7620
|
tao
|
* @throws SAXException
|
141 |
|
|
* @throws IOException
|
142 |
|
|
* @throws ParserConfigurationException
|
143 |
7609
|
tao
|
*/
|
144 |
7664
|
tao
|
private MetacatSolrIndex() throws Exception {
|
145 |
7647
|
leinfelder
|
// these are handled directly by solr
|
146 |
|
|
supportedWriterTypes = new ArrayList<String>();
|
147 |
|
|
supportedWriterTypes.add(CSV);
|
148 |
|
|
supportedWriterTypes.add(JSON);
|
149 |
|
|
supportedWriterTypes.add(PHP);
|
150 |
|
|
supportedWriterTypes.add(PHPS);
|
151 |
|
|
supportedWriterTypes.add(RUBY);
|
152 |
|
|
supportedWriterTypes.add(VELOCITY);
|
153 |
|
|
supportedWriterTypes.add(PYTHON);
|
154 |
|
|
supportedWriterTypes.add(XML);
|
155 |
|
|
|
156 |
7664
|
tao
|
generateSolrServer();
|
157 |
7609
|
tao
|
}
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
/*
|
161 |
|
|
* Generate the embedded solr server
|
162 |
|
|
*/
|
163 |
7664
|
tao
|
private void generateSolrServer() throws Exception {
|
164 |
|
|
solrServer = SolrServerFactory.createSolrServer();
|
165 |
|
|
if(solrServer instanceof EmbeddedSolrServer) {
|
166 |
|
|
isEmbeddedSolrServer = true;
|
167 |
|
|
coreContainer = SolrServerFactory.getCoreContainer();
|
168 |
|
|
collectionName = SolrServerFactory.getCollectionName();
|
169 |
|
|
} else {
|
170 |
|
|
isEmbeddedSolrServer = false;
|
171 |
|
|
CommonsHttpSolrServer httpServer = (CommonsHttpSolrServer)solrServer;
|
172 |
|
|
solrBaseURL = httpServer.getBaseURL();
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
|
176 |
7609
|
tao
|
}
|
177 |
|
|
|
178 |
|
|
/**
|
179 |
|
|
* Query the solr server
|
180 |
|
|
* @param query the solr query
|
181 |
|
|
* @return the result as the InputStream
|
182 |
|
|
* @throws SolrServerException
|
183 |
7647
|
leinfelder
|
* @throws ClassNotFoundException
|
184 |
|
|
* @throws SQLException
|
185 |
|
|
* @throws PropertyNotFoundException
|
186 |
7609
|
tao
|
*/
|
187 |
7648
|
tao
|
public InputStream query(String query, String user, String[] groups) throws SolrServerException, IOException, PropertyNotFoundException, SQLException, ClassNotFoundException {
|
188 |
7664
|
tao
|
if(isEmbeddedSolrServer) {
|
189 |
|
|
return queryEmbedded(query, user, groups);
|
190 |
|
|
} else {
|
191 |
|
|
return queryHttp(query, user, groups);
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
/**
|
195 |
|
|
* Query a solr embedded server
|
196 |
|
|
* @param query the solr query
|
197 |
|
|
* @return the result as the InputStream
|
198 |
|
|
* @throws SolrServerException
|
199 |
|
|
* @throws ClassNotFoundException
|
200 |
|
|
* @throws SQLException
|
201 |
|
|
* @throws PropertyNotFoundException
|
202 |
|
|
*/
|
203 |
|
|
private InputStream queryEmbedded(String query, String user, String[] groups) throws SolrServerException, IOException, PropertyNotFoundException, SQLException, ClassNotFoundException {
|
204 |
7609
|
tao
|
InputStream inputStream = null;
|
205 |
|
|
SolrParams solrParams = SolrRequestParsers.parseQueryString(query);
|
206 |
7648
|
tao
|
solrParams = appendAccessFilterParams(solrParams, user, groups);
|
207 |
|
|
String wt = solrParams.get(WT);
|
208 |
7647
|
leinfelder
|
|
209 |
|
|
// handle normal and skin-based queries
|
210 |
7648
|
tao
|
if (wt == null ||supportedWriterTypes.contains(wt)) {
|
211 |
7647
|
leinfelder
|
// just handle as normal solr query
|
212 |
|
|
QueryResponse response = solrServer.query(solrParams);
|
213 |
7648
|
tao
|
inputStream = transformResults(solrParams, response, wt);
|
214 |
7647
|
leinfelder
|
}
|
215 |
|
|
else {
|
216 |
|
|
// assume it is a skin name
|
217 |
|
|
String qformat = wt;
|
218 |
|
|
|
219 |
|
|
// perform the solr query using wt=XML
|
220 |
|
|
wt = XML;
|
221 |
|
|
ModifiableSolrParams msp = new ModifiableSolrParams(solrParams);
|
222 |
|
|
msp.set(WT, wt);
|
223 |
|
|
QueryResponse response = solrServer.query(msp);
|
224 |
7648
|
tao
|
inputStream = transformResults(msp, response, wt);
|
225 |
7647
|
leinfelder
|
|
226 |
|
|
// apply the stylesheet (XML->HTML)
|
227 |
|
|
DBTransform transformer = new DBTransform();
|
228 |
|
|
String documentContent = IOUtils.toString(inputStream, "UTF-8");
|
229 |
|
|
String sourceType = "solr";
|
230 |
|
|
String targetType = "-//W3C//HTML//EN";
|
231 |
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
232 |
|
|
Writer writer = new OutputStreamWriter(baos , "UTF-8");
|
233 |
|
|
// TODO: include more params?
|
234 |
|
|
Hashtable<String, String[]> params = new Hashtable<String, String[]>();
|
235 |
|
|
params.put("qformat", new String[] {qformat});
|
236 |
|
|
transformer.transformXMLDocument(
|
237 |
|
|
documentContent ,
|
238 |
|
|
sourceType,
|
239 |
|
|
targetType ,
|
240 |
|
|
qformat,
|
241 |
|
|
writer,
|
242 |
|
|
params,
|
243 |
|
|
null //sessionid
|
244 |
|
|
);
|
245 |
|
|
|
246 |
|
|
// finally, get the HTML back
|
247 |
|
|
inputStream = new ByteArrayInputStream(baos.toByteArray());
|
248 |
|
|
}
|
249 |
|
|
|
250 |
7609
|
tao
|
return inputStream;
|
251 |
|
|
}
|
252 |
|
|
|
253 |
7664
|
tao
|
/*
|
254 |
|
|
* Query a http server. We directly build the url to send the http server.
|
255 |
|
|
* The reason we don't use the method is:
|
256 |
|
|
* QueryResponse response = solrServer.query(solrParams);
|
257 |
|
|
* When we transform the QueryReponse object to the InputStream object, we need to have SolrCore object
|
258 |
|
|
* which is not available for the SolrHttpServer.
|
259 |
|
|
*
|
260 |
|
|
*/
|
261 |
|
|
private InputStream queryHttp(String query, String user, String[] groups) throws IOException {
|
262 |
|
|
StringBuffer accessFilter = generateAccessFilterParamsString(user, groups);
|
263 |
|
|
if(accessFilter != null && accessFilter.length() != 0) {
|
264 |
|
|
query = solrBaseURL+"/select?"+query+"&"+FILTERQUERY+"="+accessFilter.toString();
|
265 |
|
|
}
|
266 |
|
|
URL url = new URL(query);
|
267 |
|
|
return url.openStream();
|
268 |
|
|
}
|
269 |
7648
|
tao
|
|
270 |
7664
|
tao
|
|
271 |
7648
|
tao
|
/*
|
272 |
|
|
* Append the access filter query to the params
|
273 |
|
|
*/
|
274 |
|
|
private SolrParams appendAccessFilterParams(SolrParams solrParams, String user, String[] groups) {
|
275 |
|
|
SolrParams append = null;
|
276 |
|
|
if(solrParams != null) {
|
277 |
7664
|
tao
|
StringBuffer query = generateAccessFilterParamsString(user, groups);
|
278 |
|
|
if(query != null && query.length() != 0) {
|
279 |
|
|
log.info("=================== fq query is "+query.toString());
|
280 |
|
|
NamedList fq = new NamedList();
|
281 |
|
|
fq.add(FILTERQUERY, query.toString());
|
282 |
|
|
SolrParams fqParam = SolrParams.toSolrParams(fq);
|
283 |
|
|
append = new AppendedSolrParams(solrParams, fqParam);
|
284 |
|
|
} else {
|
285 |
|
|
append = solrParams;
|
286 |
|
|
}
|
287 |
|
|
}
|
288 |
|
|
return append;
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
private StringBuffer generateAccessFilterParamsString(String user, String[] groups) {
|
292 |
|
|
StringBuffer query = new StringBuffer();
|
293 |
|
|
if (user != null && groups != null) {
|
294 |
7652
|
tao
|
query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+user+"\""+CLOSEPARENTHESE);
|
295 |
7669
|
tao
|
if(!user.equals(Constants.SUBJECT_PUBLIC)) {
|
296 |
|
|
query.append(OR+OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+user+"\""+CLOSEPARENTHESE);
|
297 |
|
|
}
|
298 |
7648
|
tao
|
for(int i=0; i<groups.length; i++) {
|
299 |
7669
|
tao
|
if(groups[i] != null) {
|
300 |
|
|
query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
301 |
|
|
if(!groups[i].equals(Constants.SUBJECT_PUBLIC)) {
|
302 |
|
|
query.append(OR + OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
303 |
|
|
}
|
304 |
|
|
}
|
305 |
7648
|
tao
|
}
|
306 |
7664
|
tao
|
} else if (user != null && groups == null) {
|
307 |
7669
|
tao
|
query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+user+"\""+CLOSEPARENTHESE);
|
308 |
|
|
if(!user.equals(Constants.SUBJECT_PUBLIC)) {
|
309 |
|
|
query.append(OR+OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+user+"\""+CLOSEPARENTHESE);
|
310 |
|
|
}
|
311 |
7664
|
tao
|
} else if ( user == null && groups != null) {
|
312 |
7648
|
tao
|
for (int i=0; i<groups.length; i++) {
|
313 |
7669
|
tao
|
if(groups[i]!= null) {
|
314 |
|
|
if(i==0) {
|
315 |
|
|
query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
316 |
|
|
if(!groups[i].equals(Constants.SUBJECT_PUBLIC)) {
|
317 |
|
|
query.append(OR + OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
318 |
|
|
}
|
319 |
|
|
} else {
|
320 |
|
|
query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
321 |
|
|
if(!groups[i].equals(Constants.SUBJECT_PUBLIC)) {
|
322 |
|
|
query.append(OR + OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
|
323 |
|
|
}
|
324 |
|
|
}
|
325 |
7648
|
tao
|
}
|
326 |
7669
|
tao
|
|
327 |
7648
|
tao
|
}
|
328 |
|
|
}
|
329 |
7664
|
tao
|
return query;
|
330 |
7648
|
tao
|
}
|
331 |
|
|
|
332 |
7609
|
tao
|
|
333 |
|
|
/*
|
334 |
|
|
* Transform the Queryresponse to the InputStream
|
335 |
|
|
*/
|
336 |
7648
|
tao
|
private InputStream transformResults(SolrParams request, QueryResponse response, String wt) throws SolrServerException, IOException {
|
337 |
7609
|
tao
|
//InputStream stream = null;
|
338 |
7648
|
tao
|
QueryResponseWriter writer = generateResponseWriter(wt);
|
339 |
7609
|
tao
|
Writer results = new StringWriter();
|
340 |
|
|
SolrQueryResponse sResponse = new SolrQueryResponse();
|
341 |
|
|
sResponse.setAllValues(response.getResponse());
|
342 |
|
|
SolrCore core =coreContainer.getCore(collectionName);
|
343 |
|
|
writer.write(results, new LocalSolrQueryRequest(core, request), sResponse);
|
344 |
|
|
return new ByteArrayInputStream(results.toString().getBytes(MetaCatServlet.DEFAULT_ENCODING));
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
|
348 |
|
|
/* Here is the list of the handler class to handle different format.
|
349 |
|
|
* <queryResponseWriter name="xml" default="true" class="solr.XMLResponseWriter" />
|
350 |
|
|
* <queryResponseWriter name="json" class="solr.JSONResponseWriter"/>
|
351 |
|
|
* <queryResponseWriter name="python" class="solr.PythonResponseWriter"/>
|
352 |
|
|
* <queryResponseWriter name="ruby" class="solr.RubyResponseWriter"/>
|
353 |
|
|
* <queryResponseWriter name="php" class="solr.PHPResponseWriter"/>
|
354 |
|
|
* <queryResponseWriter name="phps" class="solr.PHPSerializedResponseWriter"/>
|
355 |
|
|
* <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/>
|
356 |
|
|
* <queryResponseWriter name="csv" class="solr.CSVResponseWriter"/>
|
357 |
|
|
*/
|
358 |
7648
|
tao
|
private QueryResponseWriter generateResponseWriter(String wt) throws SolrServerException {
|
359 |
7609
|
tao
|
QueryResponseWriter writer = null;
|
360 |
|
|
if(wt == null || wt.trim().equals("") || wt.equals(XML)) {
|
361 |
|
|
writer = new XMLResponseWriter();
|
362 |
|
|
} else if(wt.equals(JSON)) {
|
363 |
|
|
writer = new JSONResponseWriter();
|
364 |
|
|
} else if(wt.equals(PYTHON)) {
|
365 |
|
|
writer = new PythonResponseWriter();
|
366 |
|
|
} else if(wt.equals(RUBY)) {
|
367 |
|
|
writer = new RubyResponseWriter();
|
368 |
|
|
} else if(wt.equals(PHP)) {
|
369 |
|
|
writer = new PHPResponseWriter();
|
370 |
|
|
} else if(wt.equals(PHPS)) {
|
371 |
|
|
writer = new PHPSerializedResponseWriter();
|
372 |
7648
|
tao
|
} else if(wt.equals(VELOCITY)) {
|
373 |
|
|
writer = new VelocityResponseWriter();
|
374 |
7609
|
tao
|
} else if(wt.equals(CSV)) {
|
375 |
|
|
writer = new CSVResponseWriter();
|
376 |
|
|
} else {
|
377 |
|
|
throw new SolrServerException("Metacat doesn't support this response format "+wt);
|
378 |
|
|
}
|
379 |
|
|
return writer;
|
380 |
|
|
}
|
381 |
7664
|
tao
|
|
382 |
7609
|
tao
|
}
|