Project

General

Profile

« Previous | Next » 

Revision 7713

Added by Jing Tao over 11 years ago

Move the solr query part here since metacat-index needs to query the solr server too.

View differences:

metacat-common/src/main/java/edu/ucsb/nceas/metacat/common/query/EmbeddedSolrQueryService.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: tao $'
10
 *     '$Date: 2013-04-19 17:47:14 -0700 (Fri, 19 Apr 2013) $'
11
 * '$Revision: 7595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.common.query;
28

  
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.util.List;
32
import java.util.Map;
33
import java.util.Set;
34

  
35
import javax.xml.parsers.ParserConfigurationException;
36

  
37
import org.apache.solr.client.solrj.SolrServerException;
38
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
39
import org.apache.solr.client.solrj.response.QueryResponse;
40
import org.apache.solr.common.params.SolrParams;
41
import org.apache.solr.core.CoreContainer;
42
import org.apache.solr.core.SolrCore;
43
import org.apache.solr.schema.SchemaField;
44
import org.dataone.cn.indexer.solrhttp.SolrDoc;
45
import org.dataone.service.exceptions.NotFound;
46
import org.dataone.service.exceptions.NotImplemented;
47
import org.dataone.service.exceptions.UnsupportedType;
48
import org.dataone.service.types.v1.Subject;
49
import org.xml.sax.SAXException;
50

  
51
import edu.ucsb.nceas.metacat.common.SolrQueryResponseTransformer;
52

  
53

  
54
/**
55
 *The query service of the embedded solr server.
56
 * @author tao
57
 *
58
 */
59
public class EmbeddedSolrQueryService extends SolrQueryService {
60
    private EmbeddedSolrServer solrServer = null;
61
    private CoreContainer coreContainer = null;
62
    private String collectionName = null;
63
    private SolrCore solrCore = null;
64
    /**
65
     * Constructor.
66
     * @param solrServer
67
     * @param solrCore
68
     * @throws NotFound 
69
     */
70
    public EmbeddedSolrQueryService(EmbeddedSolrServer solrServer, CoreContainer coreContainer, String collectionName) throws NotFound {
71
        if(solrServer == null) {
72
            throw new NullPointerException("EmbeddedSolrQueryService.constructor - the EmbeddedSolrServer parameter can't be null.");
73
        }
74
        if(coreContainer == null) {
75
            throw new NullPointerException("EmbeddedSolrQueryService.constructor - the CoreContainer parameter can't be null.");
76
        }
77
        if(collectionName == null || collectionName.trim().equals("")) {
78
            throw new NullPointerException("EmbeddedSolrQueryService.constructor - the name of Collection parameter can't be null or empty.");
79
        }
80
        this.solrServer = solrServer;
81
        this.coreContainer = coreContainer;
82
        this.collectionName = collectionName;
83
        this.solrCore = this.coreContainer.getCore(collectionName);
84
        if(solrCore == null) {
85
            throw new NotFound("0000","EmbeddedSolrQueryService.constructor - There is no SolrCore named "+collectionName+".");
86
        }
87
    }
88
    /**
89
     * Query the Solr server with specified query and user's identity. If the Subjects
90
     * is null, there will be no access rules for the query. This is the for the http solr server.
91
     * @param query the query string
92
     * @param subjects the user's identity which sent the query
93
     * @return the response
94
     * @throws Exception
95
     */
96
    public InputStream query(String query, Set<Subject>subjects) throws Exception {
97
        throw new NotImplemented("0000", "EmbeddSolrQueryService - the method of  query(String query, Set<Subject>subjects) is not for the EmbeddedSolrServer. We donot need to implemente it");
98
    }
99
    
100
    /**
101
     * Query the Solr server with specified query and user's identity. If the Subjects
102
     * is null, there will be no access rules for the query. This is for the embedded solr server.
103
     * @param query the query params. 
104
     * @param subjects the user's identity which sent the query
105
     * @return the response
106
     * @throws SAXException 
107
     * @throws IOException 
108
     * @throws ParserConfigurationException 
109
     * @throws SolrServerException 
110
     * @throws UnsupportedType 
111
     * @throws Exception
112
     */
113
    public  InputStream query(SolrParams query, Set<Subject>subjects) throws ParserConfigurationException, IOException, SAXException, SolrServerException, UnsupportedType {
114
        InputStream inputStream = null;
115
        String wt = query.get(WT);
116
        query = appendAccessFilterParams(query, subjects);
117
        SolrQueryResponseTransformer solrTransformer = new SolrQueryResponseTransformer(solrCore);
118
        // handle normal and skin-based queries
119
        if (isSupportedWT(wt)) {
120
            // just handle as normal solr query
121
            //reload the core before query. Only after reloading the core, the query result can reflect the change made in metacat-index module.
122
            coreContainer.reload(collectionName);
123
            QueryResponse response = solrServer.query(query);
124
            inputStream = solrTransformer.transformResults(query, response, wt);
125
        } else {
126
            throw new UnsupportedType("0000","EmbeddSolrQueryService.query - the wt type "+wt+" in the solr query is not supported");
127
        }
128
        return inputStream;
129
    }
130
    
131
    
132
    /**
133
     * Get the list of SolrDocs for the specified ids from the solr server.
134
     *  * Note: each id only can have one SolrDoc or null SolrDoc. If it is null, it
135
     * wouldn't be added to the list.
136
     * @param ids the specified ids
137
     * @return the SolrDocs of the ids.
138
     * @throws Exception
139
     */
140
    public  List<SolrDoc> query(List<String> ids) throws Exception {
141
        return null;
142
    }
143
    
144
    
145
    /**
146
     * Get the fields list of the index schema
147
     * @return
148
     * @throws Exception
149
     */
150
    public  Map<String, SchemaField> getIndexSchemaFields() throws Exception {
151
        return null;
152
    }
153
    
154
    /**
155
     * Get the version of the solr server.
156
     * @return
157
     */
158
    public String getSolrServerVersion() {
159
        return null;
160
    }
161
}
metacat-common/src/main/java/edu/ucsb/nceas/metacat/common/query/HttpSolrQueryService.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: tao $'
10
 *     '$Date: 2013-04-19 17:47:14 -0700 (Fri, 19 Apr 2013) $'
11
 * '$Revision: 7595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.common.query;
28

  
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.net.MalformedURLException;
32
import java.net.URL;
33
import java.util.List;
34
import java.util.Map;
35
import java.util.Set;
36

  
37
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
38
import org.apache.solr.client.solrj.response.QueryResponse;
39
import org.apache.solr.common.params.SolrParams;
40
import org.apache.solr.schema.SchemaField;
41
import org.dataone.cn.indexer.solrhttp.HTTPService;
42
import org.dataone.cn.indexer.solrhttp.SolrDoc;
43
import org.dataone.service.exceptions.NotFound;
44
import org.dataone.service.exceptions.NotImplemented;
45
import org.dataone.service.exceptions.UnsupportedType;
46
import org.dataone.service.types.v1.Subject;
47

  
48
import edu.ucsb.nceas.metacat.common.SolrQueryResponseTransformer;
49

  
50
/**
51
 * The query service for the http solr server.
52
 * @author tao
53
 *
54
 */
55
public class HttpSolrQueryService extends SolrQueryService {
56
    
57
    private String solrServerBaseURL = null;
58
    private CommonsHttpSolrServer httpSolrServer = null;
59
    
60
    /**
61
     * Constructor
62
     * @param httpSolrServer
63
     */
64
    public HttpSolrQueryService(CommonsHttpSolrServer httpSolrServer) {
65
        if(httpSolrServer == null) {
66
            throw new NullPointerException("HttpSolrQueryService.constructor - The httpSolrServer parameter can't be null");
67
        }
68
        this.httpSolrServer = httpSolrServer;
69
        this.solrServerBaseURL = httpSolrServer.getBaseURL();
70
    }
71
    
72
    /**
73
     * Query the Solr server with specified query and user's identity. If the Subjects
74
     * is null, there will be no access rules for the query. This is the for the http solr server.
75
     * @param query the query string
76
     * @param subjects the user's identity which sent the query
77
     * @return the response
78
     * @throws NotFound 
79
     * @throws IOException 
80
     * @throws Exception
81
     */
82
    public InputStream query(String query, Set<Subject>subjects) throws NotFound, IOException {
83
        StringBuffer accessFilter = generateAccessFilterParamsString(subjects);
84
        if(accessFilter != null && accessFilter.length() != 0) {
85
            query = solrServerBaseURL+"/select?"+query+"&"+FILTERQUERY+"="+accessFilter.toString();
86
            query = HTTPService.escapeQueryChars(query);
87
        } else {
88
            throw new NotFound("0000", "HttpSolrQueryService.query - There is no identity (even user public) for the user who issued the query");
89
        }
90
        URL url = new URL(query);
91
        return url.openStream();
92
    }
93
    
94
    /**
95
     * Query the Solr server with specified query and user's identity. If the Subjects
96
     * is null, there will be no access rules for the query. This is for the embedded solr server.
97
     * @param query the query params. 
98
     * @param subjects the user's identity which sent the query
99
     * @return the response
100
     * @throws Exception
101
     */
102
    public  InputStream query(SolrParams query, Set<Subject>subjects) throws Exception {
103
        throw new NotImplemented("0000", "HttpSolrQueryService - the method of  query(SolrParams query, Set<Subject>subjects) is not for the HttpSolrQueryService. We donot need to implemente it");
104
    }
105
    
106
    
107
    /**
108
     * Get the list of SolrDocs for the specified ids from the solr server.
109
     *  * Note: each id only can have one SolrDoc or null SolrDoc. If it is null, it
110
     * wouldn't be added to the list.
111
     * @param ids the specified ids
112
     * @return the SolrDocs of the ids.
113
     * @throws Exception
114
     */
115
    public  List<SolrDoc> query(List<String> ids) throws Exception {
116
        return null;
117
    }
118
    
119
    
120
    /**
121
     * Get the fields list of the index schema
122
     * @return
123
     * @throws Exception
124
     */
125
    public  Map<String, SchemaField> getIndexSchemaFields() throws Exception {
126
        return null;
127
    }
128
    
129
    /**
130
     * Get the version of the solr server.
131
     * @return
132
     */
133
    public String getSolrServerVersion() {
134
        return null;
135
    }
136
}
metacat-common/src/main/java/edu/ucsb/nceas/metacat/common/query/SolrQueryService.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: tao $'
10
 *     '$Date: 2013-04-19 17:47:14 -0700 (Fri, 19 Apr 2013) $'
11
 * '$Revision: 7595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.common.query;
28

  
29
import java.io.InputStream;
30
import java.util.ArrayList;
31
import java.util.List;
32
import java.util.Map;
33
import java.util.Set;
34

  
35
import org.apache.commons.logging.Log;
36
import org.apache.commons.logging.LogFactory;
37
import org.apache.solr.client.solrj.response.QueryResponse;
38
import org.apache.solr.common.params.AppendedSolrParams;
39
import org.apache.solr.common.params.SolrParams;
40
import org.apache.solr.common.util.NamedList;
41
import org.apache.solr.schema.SchemaField;
42
import org.dataone.cn.indexer.solrhttp.SolrDoc;
43
import org.dataone.service.types.v1.Subject;
44
import org.dataone.service.util.Constants;
45

  
46
import edu.ucsb.nceas.metacat.common.SolrQueryResponseWriterFactory;
47

  
48

  
49
/**
50
 * A query interface for the solr server
51
 * @author tao
52
 *
53
 */
54
public abstract class SolrQueryService {
55
    
56
    public static final String WT = "wt";//the property name to specify the return type
57
    
58
    protected static final String FILTERQUERY = "fq";
59
    private static final String READPERMISSION = "readPermission";
60
    private static final String RIGHTSHOLDER = "rightsHolder";
61
    private static final String OPENPARENTHESE = "(";
62
    private static final String CLOSEPARENTHESE = ")";
63
    private static final String COLON = ":";
64
    private static final String OR = "OR";
65
    
66
    private static Log log = LogFactory.getLog(SolrQueryService.class);
67
    private static List<String> supportedWriterTypes = null;
68
    static {
69
        supportedWriterTypes = new ArrayList<String>();
70
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.CSV);
71
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.JSON);
72
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.PHP);
73
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.PHPS);
74
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.RUBY);
75
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.VELOCITY);
76
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.PYTHON);
77
        supportedWriterTypes.add(SolrQueryResponseWriterFactory.XML);
78
    }
79
    /**
80
     * Query the Solr server with specified query and user's identity. If the Subjects
81
     * is null, there will be no access rules for the query. This is the for the http solr server.
82
     * @param query the query string
83
     * @param subjects the user's identity which sent the query
84
     * @return the response
85
     * @throws Exception
86
     */
87
    public abstract InputStream query(String query, Set<Subject>subjects) throws Exception;
88
    
89
    /**
90
     * Query the Solr server with specified query and user's identity. If the Subjects
91
     * is null, there will be no access rules for the query. This is for the embedded solr server.
92
     * @param query the query params. 
93
     * @param subjects the user's identity which sent the query
94
     * @return the response
95
     * @throws Exception
96
     */
97
    public abstract InputStream query(SolrParams query, Set<Subject>subjects) throws Exception;
98
    
99
    
100
    /**
101
     * Get the list of SolrDocs for the specified ids from the solr server.
102
     *  * Note: each id only can have one SolrDoc or null SolrDoc. If it is null, it
103
     * wouldn't be added to the list.
104
     * @param ids the specified ids
105
     * @return the SolrDocs of the ids.
106
     * @throws Exception
107
     */
108
    public abstract List<SolrDoc> query(List<String> ids) throws Exception;
109
    
110
    
111
    /**
112
     * Get the fields list of the index schema
113
     * @return
114
     * @throws Exception
115
     */
116
    public abstract Map<String, SchemaField> getIndexSchemaFields() throws Exception;
117
    
118
    /**
119
     * Get the version of the solr server.
120
     * @return
121
     */
122
    public abstract String getSolrServerVersion();
123
    
124
    
125
    
126
    /**
127
     * If the solr server supports the specified wt.
128
     * @param wt
129
     * @return true if it supports; otherwise false.
130
     */
131
    public static boolean isSupportedWT(String wt) {
132
        if (wt == null ||supportedWriterTypes.contains(wt)) {
133
            return true;
134
        } else {
135
            return false;
136
        }
137
    }
138
    
139
    /*
140
     * Append the access filter query to the params
141
     */
142
    protected SolrParams appendAccessFilterParams(SolrParams solrParams, Set<Subject>subjects) {
143
        SolrParams append = null;
144
        if(solrParams != null) {
145
            StringBuffer query = generateAccessFilterParamsString(subjects);      
146
            if(query != null && query.length() != 0) {
147
                log.info("=================== fq query is "+query.toString());
148
                NamedList fq = new NamedList();
149
                fq.add(FILTERQUERY, query.toString());
150
                SolrParams fqParam = SolrParams.toSolrParams(fq);
151
                append = new AppendedSolrParams(solrParams, fqParam);
152
            } else {
153
                append = solrParams;
154
            }
155
        }
156
        return append;
157
    }
158
    
159
    protected StringBuffer generateAccessFilterParamsString(Set<Subject>subjects) {
160
        StringBuffer query = new StringBuffer();
161
        boolean first = true;
162
        if(subjects != null) {
163
            for(Subject subject : subjects) {
164
                if(subject != null) {
165
                    String subjectName = subject.getValue();
166
                    if(subjectName != null && !subjectName.trim().equals("")) {
167
                        if(first) {
168
                            first = false;
169
                            query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+subjectName+"\""+CLOSEPARENTHESE);
170
                            if(!subjectName.equals(Constants.SUBJECT_PUBLIC) && !subjectName.equals(Constants.SUBJECT_AUTHENTICATED_USER)) {
171
                                query.append(OR+OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+subjectName+"\""+CLOSEPARENTHESE);
172
                            }
173
                        } else {
174
                            query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+"\""+subjectName+"\""+CLOSEPARENTHESE);
175
                            if(!subjectName.equals(Constants.SUBJECT_PUBLIC) && !subjectName.equals(Constants.SUBJECT_AUTHENTICATED_USER)) {
176
                                query.append(OR + OPENPARENTHESE+RIGHTSHOLDER+COLON+"\""+subjectName+"\""+CLOSEPARENTHESE);
177
                            }
178
                        }
179
                    }
180
                   
181
                }
182
               
183
            }
184
        }
185
        return query;
186
    }
187
}
metacat-common/src/main/java/edu/ucsb/nceas/metacat/common/query/SolrQueryServiceController.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A class that gets Accession Number, check for uniqueness
4
 *             and register it into db
5
 *  Copyright: 2000 Regents of the University of California and the
6
 *             National Center for Ecological Analysis and Synthesis
7
 *    Authors: Jivka Bojilova, Matt Jones
8
 *
9
 *   '$Author: tao $'
10
 *     '$Date: 2013-04-19 17:47:14 -0700 (Fri, 19 Apr 2013) $'
11
 * '$Revision: 7595 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27
package edu.ucsb.nceas.metacat.common.query;
28

  
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.util.Set;
32

  
33
import javax.xml.parsers.ParserConfigurationException;
34

  
35
import org.apache.solr.client.solrj.SolrServer;
36
import org.apache.solr.client.solrj.SolrServerException;
37
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
38
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
39
import org.apache.solr.client.solrj.response.QueryResponse;
40
import org.apache.solr.common.params.SolrParams;
41
import org.apache.solr.core.CoreContainer;
42
import org.dataone.service.exceptions.NotFound;
43
import org.dataone.service.exceptions.NotImplemented;
44
import org.dataone.service.exceptions.UnsupportedType;
45
import org.dataone.service.types.v1.Subject;
46
import org.xml.sax.SAXException;
47

  
48
import edu.ucsb.nceas.metacat.common.SolrQueryResponseTransformer;
49
import edu.ucsb.nceas.metacat.common.SolrServerFactory;
50

  
51
/**
52
 * A class to handle the solr query. 
53
 * @author tao
54
 *
55
 */
56
public class SolrQueryServiceController {
57
    private static SolrQueryServiceController controller = null;
58
    private boolean isEmbeddedSolrServer = false;
59
    private EmbeddedSolrQueryService embeddedQueryService = null;
60
    private HttpSolrQueryService httpQueryService = null;
61
    
62
    /*
63
     * Private consctructor
64
     */
65
    private SolrQueryServiceController() throws UnsupportedType, ParserConfigurationException, IOException, SAXException, NotFound {
66
        SolrServer solrServer = SolrServerFactory.createSolrServer();
67
        if(solrServer instanceof EmbeddedSolrServer) {
68
            isEmbeddedSolrServer = true;
69
            EmbeddedSolrServer embeddedServer = (EmbeddedSolrServer) solrServer;
70
            CoreContainer coreContainer = SolrServerFactory.getCoreContainer();
71
            String collectionName = SolrServerFactory.getCollectionName();
72
            embeddedQueryService = new EmbeddedSolrQueryService(embeddedServer, coreContainer, collectionName);
73
        } else {
74
            isEmbeddedSolrServer = false;
75
            CommonsHttpSolrServer httpServer = (CommonsHttpSolrServer)solrServer;
76
            httpQueryService = new HttpSolrQueryService(httpServer);
77
        }
78
    }
79
    
80
    /**
81
     * Get the controller
82
     * @return
83
     * @throws UnsupportedType
84
     * @throws NotFound
85
     * @throws ParserConfigurationException
86
     * @throws IOException
87
     * @throws SAXException
88
     */
89
    public static SolrQueryServiceController getInstance() throws UnsupportedType, NotFound, ParserConfigurationException, IOException, SAXException {
90
        if(controller == null) {
91
            controller = new SolrQueryServiceController();
92
        }
93
        return controller;
94
    }
95
    
96
    /**
97
     * Query the Solr server with specified query and user's identity. If the Subjects
98
     * is null, there will be no access rules for the query. This is the for the http solr server.
99
     * @param query the query string
100
     * @param subjects the user's identity which sent the query
101
     * @return the response
102
     * @throws NotImplemented 
103
     * @throws IOException 
104
     * @throws NotFound 
105
     * @throws Exception
106
     */
107
    public InputStream query(String query, Set<Subject>subjects) throws NotImplemented, NotFound, IOException  {
108
        if(isEmbeddedSolrServer) {
109
            throw new NotImplemented("0000", "SolrQueryServiceController - the method of  query(String query, Set<Subject>subjects) is not for the EmbeddedSolrServer. We donot need to implemente it");
110
        } else {
111
            return httpQueryService.query(query, subjects);
112
        }
113
      
114
    }
115
    
116
    /**
117
     * Query the Solr server with specified query and user's identity. If the Subjects
118
     * is null, there will be no access rules for the query. This is for the embedded solr server.
119
     * @param query the query params. 
120
     * @param subjects the user's identity which sent the query
121
     * @return the response
122
     * @throws SAXException 
123
     * @throws IOException 
124
     * @throws ParserConfigurationException 
125
     * @throws SolrServerException 
126
     * @throws UnsupportedType 
127
     * @throws NotImplemented 
128
     * @throws Exception
129
     */
130
    public  InputStream query(SolrParams query, Set<Subject>subjects) throws UnsupportedType, ParserConfigurationException, IOException, SAXException, SolrServerException, NotImplemented {
131
        if(isEmbeddedSolrServer) {
132
            return embeddedQueryService.query(query, subjects);
133
        } else {
134
            throw new NotImplemented("0000", "QueryServiceController - the method of  query(String query, Set<Subject>subjects) is not for the EmbeddedSolrServer. We donot need to implemente it");
135
        }
136
    }
137
    
138
}
metacat-common/pom.xml
25 25
			<version>3.4.0</version>
26 26
		</dependency>
27 27
		<dependency>
28
			<groupId>org.dataone</groupId>
29
			<artifactId>d1_common_java</artifactId>
30
			<version>1.2.0-SNAPSHOT</version>
31
			<type>jar</type>
32
			<!-- exclude extraneous artifacts (jars) -->
33
			<exclusions>
34
		        <exclusion>
35
		          <groupId>org.jibx</groupId>
36
		          <artifactId>jibx-tools</artifactId>
37
		        </exclusion>
38
		        <exclusion>
39
		          <groupId>org.jibx</groupId>
40
		          <artifactId>jibx-schema</artifactId>
41
		        </exclusion>
42
		        <exclusion>
43
		          <groupId>org.jibx</groupId>
44
		          <artifactId>jibx-extras</artifactId>
45
		        </exclusion>
46
		        <exclusion>
47
		          <groupId>org.jibx</groupId>
48
		          <artifactId>jibx-bind</artifactId>
49
		        </exclusion>
50
		        <exclusion>
51
		        	<groupId>org.apache.maven.plugins</groupId>
52
					<artifactId>maven-compiler-plugin</artifactId>
53
		        </exclusion>
54
		        <exclusion>
55
		        	<groupId>org.apache.maven.plugins</groupId>
56
					<artifactId>maven-jar-plugin</artifactId>
57
		        </exclusion>
58
		        <exclusion>
59
		        	<groupId>org.apache.maven.plugins</groupId>
60
					<artifactId>maven-clean-plugin</artifactId>
61
		        </exclusion>
62
		        <exclusion>
63
		        	<groupId>org.jibx</groupId>
64
					<artifactId>maven-jibx-plugin</artifactId>
65
		        </exclusion>
66
			</exclusions>
67
		</dependency>
28
        <groupId>org.dataone</groupId>
29
        <artifactId>d1_cn_index_processor</artifactId>
30
        <version>1.2.0-SNAPSHOT</version>
31
        <type>jar</type>
32
        <exclusions>
33
                <exclusion>
34
                    <groupId>org.slf4j</groupId>
35
                    <artifactId>slf4j-log4j12</artifactId>
36
                </exclusion>
37
        </exclusions>
38
    </dependency>
68 39
	</dependencies>
69 40
</project>

Also available in: Unified diff