Project

General

Profile

« Previous | Next » 

Revision 5311

Added by daigle about 14 years ago

Merge 1.9.2 changes back into the trunk

View differences:

QuerySpecification.java
164 164
        // Initialize the parser and read the queryspec
165 165
        XMLReader parser = initializeParser();
166 166
        if (parser == null) {
167
            System.err.println("SAX parser not instantiated properly.");
167
        	logMetacat.error("QuerySpecification() - SAX parser not instantiated properly.");
168 168
        }
169 169
        try {
170 170
            parser.parse(new InputSource(queryspec));
171
        } catch (SAXException e) {
172
            System.err.println("error parsing data in "
173
                    + "QuerySpecification.QuerySpecification");
174
            System.err.println(e.getMessage());
171
        } catch (SAXException se) {
172
            logMetacat.error("QuerySpecification() - SAX error parsing data: " + se.getMessage());
175 173
        }
176 174
    }
177 175

  
......
260 258
	            ownerQuery = ownerQuery + "lower(user_owner) ='" + userName + "'";
261 259
	        }
262 260
        }
263
        logMetacat.info("OwnerQuery: " + ownerQuery);
261
        logMetacat.info("QuerySpecification.createOwerQuery - OwnerQuery: " + ownerQuery);
264 262
        return ownerQuery;
265 263
    }
266 264

  
......
274 272
        String allowString = constructAllowString();
275 273
        allowQuery = "SELECT docid from xml_access WHERE( " + allowString;
276 274
        allowQuery = allowQuery + ")";
277
        logMetacat.info("allow query is: " + allowQuery);
275
        logMetacat.info("QuerySpecification.createAllowRuleQuery - allow query is: " + allowQuery);
278 276
        return allowQuery;
279 277

  
280 278
    }
......
306 304
        }//if
307 305
        // add allow rule
308 306
        allowQuery = allowQuery + ") AND perm_type = 'allow'" + " AND permission > 3";
309
        logMetacat.info("allow string is: " + allowQuery);
307
        logMetacat.info("QuerySpecification.constructAllowString - allow string is: " + allowQuery);
310 308
        return allowQuery;
311 309
    }
312 310

  
......
321 319
        String denyString = constructDenyString();
322 320
        denyQuery = "SELECT docid from xml_access WHERE( " + denyString;
323 321
        denyQuery = denyQuery + ") ";
324
        logMetacat.info("denyquery is: " + denyQuery);
322
        logMetacat.info("QuerySpecification.createDenyRuleQuery - denyquery is: " + denyQuery);
325 323
        return denyQuery;
326 324

  
327 325
    }
......
353 351
         }//if
354 352
         // add deny rules
355 353
         denyQuery = denyQuery + ") AND perm_type = 'deny'" +  " AND perm_order ='allowFirst'" +" AND permission > 3";
356
         logMetacat.info("allow string is: " + denyQuery);
354
         logMetacat.info("QuerySpecification.constructDenyString - deny string is: " + denyQuery);
357 355
         return denyQuery;
358 356
        
359 357
    }
......
371 369
        String onwer = createOwerQuery();
372 370
        String allow = createAllowRuleQuery();
373 371
        String deny = createDenyRuleQuery();
374
        //logMetacat.warn("onwer " +onwer);
375
        //logMetacat.warn("allow "+allow);
376
        //logMetacat.warn("deny "+deny);
372

  
377 373
        if (onwer != null)
378 374
        {
379 375
          accessQuery = " AND (docid IN(" + onwer + ")";
......
385 381
        	accessQuery = " AND (docid IN (" + allow + ")"
386 382
                + " AND docid NOT IN (" + deny + "))";
387 383
        }
388
        logMetacat.warn("accessquery is: " + accessQuery);
384
        logMetacat.info("QuerySpecification.getAccessQuery - access query is: " + accessQuery);
389 385
        return accessQuery;
390 386
    }
391 387

  
......
548 544
            parser.setErrorHandler(this);
549 545

  
550 546
        } catch (Exception e) {
551
            System.err.println("Error in QuerySpcecification.initializeParser "
552
                    + e.toString());
547
            logMetacat.error("QuerySpecification.getAccessQuery - Error: " + e.getMessage());
553 548
        }
554 549

  
555 550
        return parser;
......
563 558
    public void startElement(String uri, String localName, String qName,
564 559
            Attributes atts) throws SAXException
565 560
    {
566
        logMetacat.debug("start at startElement "+localName);
561
        logMetacat.debug("QuerySpecification.startElement - start element " + localName);
567 562
        BasicNode currentNode = new BasicNode(localName);
568 563
        //write element name into xml buffer.
569 564
        xml.append("<");
......
595 590
            }
596 591
            queryStack.push(currentGroup);
597 592
        }
598
        logMetacat.debug("end in startElement "+localName);
593
        logMetacat.debug("QuerySpecification.startElement - ending startElement " + localName);
599 594
    }
600 595

  
601 596
    /**
......
606 601
    public void endElement(String uri, String localName, String qName)
607 602
            throws SAXException
608 603
    {
609
    	 logMetacat.debug("start in endElement "+localName);
604
    	 logMetacat.debug("QuerySpecification.endElement - endElement "+localName);
610 605
        BasicNode leaving = (BasicNode) elementStack.pop();
611 606
        if (leaving.getTagName().equals("queryterm")) {
612 607
            boolean isCaseSensitive = (new Boolean(leaving
......
647 642
              ownerList.add(textBuffer.toString().trim());
648 643
        }
649 644
        String normalizedXML = textBuffer.toString().trim();
650
        logMetacat.debug("================before normailze "+normalizedXML);
645
        logMetacat.debug("QuerySpecification.endElement - before normalize: " + normalizedXML);
651 646
        normalizedXML =  MetacatUtil.normalize(normalizedXML);
652
        logMetacat.debug("================after normailze "+normalizedXML);
647
        logMetacat.debug("QuerySpecification.endElement - after normalize " + normalizedXML);
653 648
        xml.append(normalizedXML);
654 649
        xml.append("</");
655 650
        xml.append(localName);
......
680 675
      // buffer all text nodes for same element. This is for text was splited
681 676
      // into different nodes
682 677
      String text = new String(ch, start, length);
683
      logMetacat.debug("the text in characters "+text);
678
      logMetacat.debug("QuerySpecification.characters - the text in characters " + text);
684 679
      textBuffer.append(text);
685 680

  
686 681
    }
......
715 710

  
716 711
            if (predicateEnd == -1)
717 712
            {
718
                logMetacat.warn("handleReturnField(): ");
719
                logMetacat.warn("    Invalid path: " + inputString);
713
                logMetacat.warn("QuerySpecification.handleReturnField - Invalid path: " + inputString);
720 714
                return;
721 715
            }
722 716

  
......
736 730
        }
737 731

  
738 732
        containsExtendedSQL = true;
739

  
740
     
733
   
741 734
        // no attribute value will be returned
742
        logMetacat.info("QuerySpecification.handleReturnField(): " );
743
        logMetacat.info("  there are no attributes in the XPATH statement" );
744
        returnFieldList.add(inputString);
745
       
746

  
747
       
735
        logMetacat.info("QuerySpecification.handleReturnField - there are no attributes in the XPATH statement" );
736
        returnFieldList.add(inputString);       
748 737
    }
749 738

  
750 739
    /**
......
768 757
        } else {
769 758
        	queryFromQueryGroup = "";
770 759
        }
771
        logMetacat.info("Query from query in QuerySpec.printSQL: " 
772
        		+ queryFromQueryGroup);
760
        logMetacat.info("QuerySpecification.printSQL - Query : " + queryFromQueryGroup);
773 761
        
774 762
        if(!queryFromQueryGroup.trim().equals("")){
775 763
            self.append(" docid IN (");
......
837 825
        }
838 826

  
839 827
        // if there is only one percentage search item, this query is a
840
        // percentage
841
        // search query
842
        logMetacat.info("percentage number: "
843
                + query.getPercentageSymbolCount());
844
        if (query.getPercentageSymbolCount() == 1) {
845
            logMetacat.info("It is a percentage search");
846
            percentageSearch = true;
828
        // percentage search query
829
        if (query != null) {
830
        	logMetacat.info("QuerySpecification.printSQL - percentage number: " + query.getPercentageSymbolCount());
831
			if (query.getPercentageSymbolCount() == 1) {
832
				logMetacat.info("QuerySpecification.printSQL - It is a percentage search");
833
				percentageSearch = true;
834
			}
847 835
        }
848 836

  
849 837
        queryString.append(self.toString());
......
942 930
    	    	// if there is slash in the path, path should be replace by the last part
943 931
    	    	path = path.substring(slashIndex+1);
944 932
    	    }
945
    	    logMetacat.debug("In QuerySpecification.returnFieldIsAttribute method, final path is "+path);
933
    	    logMetacat.debug("QuerySpecification.returnFieldIsAttribute - final path is " + path);
946 934
    	    // if first of character of path is @, the path is attribute
947 935
    	    if (path.charAt(0) == '@')
948 936
    	    {
949
    	    	logMetacat.debug("it is attribute");
937
    	    	logMetacat.debug("QuerySpecification.returnFieldIsAttribute - it is an attribute");
950 938
    	    	isAttribute = true;
951 939
    	    }
952 940
    	}
......
964 952
     *            which this user should not access
965 953
     */
966 954
    private String printExtendedSQL(String doclist) {
967
        logMetacat.info("querySpecification.printExtendedSQL called\n");
955
        logMetacat.debug("QuerySpecification.printExtendedSQL - in printExtendedSQL");
968 956
        StringBuffer self = new StringBuffer();
969 957
        Vector elementVector = new Vector();
970 958
        Vector attributeVector = new Vector();
......
996 984
					usePathIndex = false;   
997 985
				}
998 986
			} catch (MetacatUtilException mue) {
999
				logMetacat.warn("Could not get index paths: "  + mue.getMessage());
987
				logMetacat.warn("QuerySpecification.printExtendedSQL - Could not get index paths: "  + mue.getMessage());
1000 988
			}
1001 989
         
1002 990
        }
......
1187 1175
        if (index != 0) {
1188 1176
            newExpression = pathExpression.substring(0, index - 1);
1189 1177
        }
1190
        logMetacat.info("The path expression without attributes: "
1178
        logMetacat.info("QuerySpecification.newPathExpressionWithOutAttribute - The path expression without attributes: "
1191 1179
                + newExpression);
1192 1180
        return newExpression;
1193 1181
    }
......
1202 1190
        if (index != 1) {
1203 1191
            attributeName = path.substring(index + 1, size);
1204 1192
        }
1205
        logMetacat.info("The attirbute name from path: "
1206
                + attributeName);
1193
        logMetacat.info("QuerySpecification.getAttributeName - The attirbute name from path: " + attributeName);
1207 1194
        return attributeName;
1208 1195
    }
1209 1196

  

Also available in: Unified diff