Project

General

Profile

« Previous | Next » 

Revision 7652

Added by Jing Tao over 11 years ago

Add double quotes to surrend the user or group names in the access fq. This will fix the issue if the names have white spaces.

View differences:

src/edu/ucsb/nceas/metacat/index/MetacatSolrIndex.java
233 233
        if(solrParams != null) {
234 234
            StringBuffer query = new StringBuffer();
235 235
            if (user != null && groups != null) {
236
                query.append(OPENPARENTHESE+READPERMISSION+COLON+user+CLOSEPARENTHESE);
236
                query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+user+"\""+CLOSEPARENTHESE);
237 237
                for(int i=0; i<groups.length; i++) {
238
                    query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
238
                    query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
239 239
                }
240 240
            } else if (user != null && groups == null) {
241
                query.append(OPENPARENTHESE+READPERMISSION+COLON+user+CLOSEPARENTHESE);
241
                query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+user+"\""+CLOSEPARENTHESE);
242 242
            } else if ( user == null && groups != null) {
243 243
                for (int i=0; i<groups.length; i++) {
244 244
                    if(i==0) {
245
                        query.append(OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
245
                        query.append(OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
246 246
                    } else {
247
                        query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+groups[i]+CLOSEPARENTHESE);
247
                        query.append(OR + OPENPARENTHESE+READPERMISSION+COLON+"\""+groups[i]+"\""+CLOSEPARENTHESE);
248 248
                    }
249 249
                }
250 250
            }
251 251
            if(query.length() != 0) {
252
                //System.out.println("=================== fq query is "+query.toString());
252
                log.info("=================== fq query is "+query.toString());
253 253
                NamedList fq = new NamedList();
254 254
                fq.add(FILTERQUERY, query.toString());
255 255
                SolrParams fqParam = SolrParams.toSolrParams(fq);

Also available in: Unified diff