Project

General

Profile

« Previous | Next » 

Revision 3223

Added by Jing Tao over 17 years ago

Get rid of user_owner=public part in access query.

View differences:

src/edu/ucsb/nceas/metacat/QuerySpecification.java
114 114
    private int countAttributeReturnField = 0;
115 115

  
116 116
    private StringBuffer textBuffer = new StringBuffer();
117

  
117
    
118
   
118 119
    private static Logger logMetacat = Logger.getLogger(QuerySpecification.class);
119 120

  
120 121
    /**
......
232 233
    private String createOwerQuery()
233 234
    {
234 235
        String ownerQuery = null;
235
        ownerQuery = "SELECT docid FROM xml_documents WHERE ";
236
        if (userName != null && !userName.equals("")) {
237
            ownerQuery = ownerQuery + "lower(user_owner) ='" + userName + "'";
236
        //if user is public, we don't need to run owner query
237
        if (userName != null && !userName.equalsIgnoreCase(PUBLIC))
238
        {
239
	        ownerQuery = "SELECT docid FROM xml_documents WHERE ";
240
	        if (userName != null && !userName.equals("")) {
241
	            ownerQuery = ownerQuery + "lower(user_owner) ='" + userName + "'";
242
	        }
238 243
        }
239

  
240 244
        logMetacat.info("OwnerQuery: " + ownerQuery);
241 245
        return ownerQuery;
242 246
    }
......
354 358
        String onwer = createOwerQuery();
355 359
        String allow = createAllowRuleQuery();
356 360
        String deny = createDenyRuleQuery();
357
        accessQuery = " AND (docid IN(" + onwer + ")";
358
        accessQuery = accessQuery + " OR (docid IN (" + allow + ")"
361
        if (onwer != null)
362
        {
363
          accessQuery = " AND (docid IN(" + onwer + ")";
364
          accessQuery = accessQuery + " OR (docid IN (" + allow + ")"
359 365
                + " AND docid NOT IN (" + deny + ")))";
366
        }
367
        else
368
        {
369
        	accessQuery = " AND (docid IN (" + allow + ")"
370
                + " AND docid NOT IN (" + deny + "))";
371
        }
360 372
        logMetacat.warn("accessquery is: " + accessQuery);
361 373
        return accessQuery;
362 374
    }

Also available in: Unified diff