Project

General

Profile

« Previous | Next » 

Revision 2663

Added by sgarg over 18 years ago

Replacing MetaCatUtil.debugMessage or MetaCatUtil.logMetacat call with logMetacat (private Logger object) call

View differences:

ContentTypeProvider.java
34 34
import java.util.Hashtable;
35 35
import java.util.Vector;
36 36

  
37
import org.apache.log4j.Logger;
37 38
import org.apache.xpath.objects.XObject;
38 39
import org.apache.xpath.XPathAPI;
39 40
import org.apache.xerces.parsers.DOMParser;
......
103 104
  private String BINARYRASTERFORMAT = "binaryRasterFormat";
104 105

  
105 106
  private String DATAFILEPATH ="//physical/distribution/online/url";
107
  private static Logger logMetacat = Logger.getLogger(ContentTypeProvider.class);
106 108

  
107 109
  /**
108 110
   * Constructor of ContentTypeProvider
......
190 192
    {
191 193
      // if faild, set default value
192 194
      contentType = DEFAULTCONTENTTYPE;
193
      MetaCatUtil.debugMessage("Error in ContentTypeProvider." +
194
                         "findContentTypeInEML2()" + e.getMessage(), 30);
195
      logMetacat.error("Error in ContentTypeProvider." +
196
                         "findContentTypeInEML2()" + e.getMessage());
195 197
      return;
196 198
    }
197 199
    Node dataFormatNode = findDataFormatNodeInEML2(doc, DATAFILEPATH,
......
199 201
    if (dataFormatNode == null)
200 202
    {
201 203
      contentType = DEFAULTCONTENTTYPE;
202
      MetaCatUtil.debugMessage("Couldn't find data format node", 30);
204
      logMetacat.info("Couldn't find data format node");
203 205
      return;
204 206

  
205 207
    }
......
212 214
      // if has text format child set to text/plain
213 215
      if (child.getNodeName() != null && child.getNodeName().equals(TEXTFORMAT))
214 216
      {
215
        MetaCatUtil.debugMessage("in text format", 35);
217
        logMetacat.info("in text format");
216 218
        contentType = TEXTYPE;
217 219
      }
218 220

  
219 221
      //external format
220 222
      if (child.getNodeName() != null && child.getNodeName().equals(EXTENALFORMAT))
221 223
      {
222
        MetaCatUtil.debugMessage("in external format ", 35);
224
        logMetacat.info("in external format ");
223 225
        String format = getTextValueForGivenChildTag(child, FORMATNAME);
224
        MetaCatUtil.debugMessage("The format is: "+format, 35);
226
        logMetacat.info("The format is: "+format);
225 227
        // if we can find the format in the contentTypeHash table
226 228
        contentType = (String)lookUpContentType(format);
227 229
        if (contentType == null)
......
255 257
      Node child = childList.item(i);
256 258
      if (child.getNodeName() != null && child.getNodeName().equals(childTagName))
257 259
      {
258
        MetaCatUtil.debugMessage("Find child node: " + childTagName, 35);
260
        logMetacat.info("Find child node: " + childTagName);
259 261
        Node textNode = child.getFirstChild();
260 262
        if (textNode.getNodeType() == Node.TEXT_NODE)
261 263
        {
......
263 265
        }//if
264 266
      }//if
265 267
    }//for
266
    MetaCatUtil.debugMessage("The text value for element- " + childTagName +
267
                             " is " + textValue, 30);
268
    logMetacat.info("The text value for element- " + childTagName +
269
                             " is " + textValue);
268 270
    return textValue;
269 271
  }//getTExtValueForGivenChildTag
270 272

  
......
293 295
      } //for
294 296
      if (targetNode != null)
295 297
      {
296
        MetaCatUtil.debugMessage("dataFormat node'name: " +
297
                                 targetNode.getNodeName(), 35);
298
        logMetacat.info("dataFormat node'name: " +
299
                                 targetNode.getNodeName());
298 300
      }
299 301
    }//if
300 302
    return targetNode;
......
312 314
    catch (Exception e)
313 315
    {
314 316
      // catch an error and return null
315
      MetaCatUtil.debugMessage("Error in findDataFileNode: "+e.getMessage(), 30);
317
      logMetacat.error("Error in findDataFileNode: "+e.getMessage());
316 318
      return dataFileNode;
317 319
    }
318 320
    // go through the list and find target docid in online/url
......
325 327
        if (textNode.getNodeType() == node.TEXT_NODE)
326 328
        {
327 329
          String URLData = textNode.getNodeValue();
328
          MetaCatUtil.debugMessage("online/url text data: " + URLData, 30);
330
          logMetacat.info("online/url text data: " + URLData);
329 331
          //Only handle ecogrid data file
330 332
          if (URLData.indexOf(DBSAXHandler.ECOGRID) != -1 )
331 333
          {
......
334 336
                               getAccessionNumberFromEcogridIdentifier(URLData);
335 337
            // Get rid of revision
336 338
            docId = MetaCatUtil.getDocIdFromAccessionNumber(docId);
337
            MetaCatUtil.debugMessage("docid from url element in xml is: " +
338
                                     docId, 30);
339
            logMetacat.info("docid from url element in xml is: " +
340
                                     docId);
339 341
            //if this docid equals target one, we find it
340 342
            if (docId != null && docId.equals(targetDocId))
341 343
            {
342
              MetaCatUtil.debugMessage("Find target docid in online/url: " +
343
                                       docId, 30);
344
              logMetacat.info("Find target docid in online/url: " +
345
                                       docId);
344 346
              dataFileNode = node;
345 347
              break;
346 348
            }
......
395 397
                                     contains(packType))
396 398
      {
397 399
        //this is beta4 or beta6 version
398
        MetaCatUtil.debugMessage("This is beta package", 30);
400
        logMetacat.warn("This is beta package");
399 401
        packageType = BETA;
400 402
      }
401 403
      else if ((MetaCatUtil.getOptionList
402 404
               (MetaCatUtil.getOption("eml2_0_0namespace"))).contains(packType))
403 405
      {
404 406
        // this eml 2 document
405
        MetaCatUtil.debugMessage("This is EML2.0.0 package", 30);
407
        logMetacat.warn("This is EML2.0.0 package");
406 408
        packageType = EML2;
407 409
      }
408 410
      else if ((MetaCatUtil.getOptionList
409 411
               (MetaCatUtil.getOption("eml2_0_1namespace"))).contains(packType))
410 412
      {
411 413
        // this eml 2 document
412
        MetaCatUtil.debugMessage("This is EML2.0.1 package", 30);
414
        logMetacat.warn("This is EML2.0.1 package");
413 415
        packageType = EML2;
414 416
      }
415 417

  
......
419 421
    catch(SQLException e)
420 422
    {
421 423

  
422
      MetaCatUtil.debugMessage("ContenTypProvider.getRelativeDoclist1 " +
423
                             e.getMessage(), 30);
424
      logMetacat.error("ContenTypProvider.getRelativeDoclist1 " +
425
                             e.getMessage());
424 426
    }//catch
425 427
    finally
426 428
    {
......
430 432
      }
431 433
      catch (SQLException ee)
432 434
      {
433
        MetaCatUtil.debugMessage("ContenTypProvider.getRelativeDoclist2 " +
434
                             ee.getMessage(), 30);
435
        logMetacat.error("ContenTypProvider.getRelativeDoclist2 " +
436
                             ee.getMessage());
435 437
      }
436 438
      finally
437 439
      {
......
465 467
    }//for
466 468
    // add parensis
467 469
    sql = sql + ")";
468
    MetaCatUtil.debugMessage("SQL for select doctype: "+ sql, 35);
470
    logMetacat.info("SQL for select doctype: "+ sql);
469 471
    ResultSet rs = null;
470 472
    PreparedStatement pStmt=null;
471 473
    DBConnection conn = null;
......
499 501
    catch(SQLException e)
500 502
    {
501 503

  
502
      MetaCatUtil.debugMessage("ContenTypProvider.setPhysicalDocIdForBeta1 " +
503
                             e.getMessage(), 30);
504
      logMetacat.error("ContenTypProvider.setPhysicalDocIdForBeta1 " +
505
                             e.getMessage());
504 506
    }//catch
505 507
    finally
506 508
    {
......
510 512
      }
511 513
      catch(SQLException ee)
512 514
      {
513
        MetaCatUtil.debugMessage("ContenTypProvider.setPhysicalDocIdForBeta2 " +
514
                             ee.getMessage(), 30);
515
        logMetacat.error("ContenTypProvider.setPhysicalDocIdForBeta2 " +
516
                             ee.getMessage());
515 517
      }//catch
516 518
      finally
517 519
      {
518 520
        DBConnectionPool.returnDBConnection(conn, serialNumber);
519 521
      }
520 522
    }//finally
521
    MetaCatUtil.debugMessage("target docid is: "+ docId + " "+
522
                             "for target doctype: "+targetType, 25);
523
    logMetacat.warn("target docid is: "+ docId + " "+
524
                             "for target doctype: "+targetType);
523 525
    return docId;
524 526
  }
525 527

  
......
542 544
    catch (Exception e)
543 545
    {
544 546
      contentType = DEFAULTCONTENTTYPE;
545
      MetaCatUtil.debugMessage("Error in ContentTypeProvider." +
546
                         "parsePhysicalDocumentForBeta()" + e.getMessage(), 30);
547
      logMetacat.error("Error in ContentTypeProvider." +
548
                         "parsePhysicalDocumentForBeta()" + e.getMessage());
547 549
      return;
548 550
    }
549 551
      // get format element's text value
......
584 586
    }
585 587
    catch (Exception e)
586 588
    {
587
      MetaCatUtil.debugMessage("error in ContentTypeProvider."+
588
                               "getTextValueFromPath: "+e.getMessage(), 30);
589
      logMetacat.error("error in ContentTypeProvider."+
590
                               "getTextValueFromPath: "+e.getMessage());
589 591
    }
590
    MetaCatUtil.debugMessage("The text value for " + xPath + " is: "+
591
                              textValue, 30);
592
    logMetacat.info("The text value for " + xPath + " is: "+
593
                              textValue);
592 594
    return textValue;
593 595
  }//getTextValueFromPath
594 596

  
......
600 602
    newFormat = format.toLowerCase().trim();
601 603
    String type = null;
602 604
    type = (String)contentTypeHash.get(newFormat);
603
    MetaCatUtil.debugMessage("contentType looked from hashtalbe is: " +
604
                              type, 30);
605
    logMetacat.info("contentType looked from hashtalbe is: " +
606
                              type);
605 607
    return type;
606 608
  }// lookupcontentypes
607 609

  
......
630 632
       //ContentTypeProvider provider = new ContentTypeProvider("tao.9830");
631 633
       ContentTypeProvider provider = new ContentTypeProvider("tao.0001");
632 634
       String str = provider.getContentType();
633
       MetaCatUtil.debugMessage("content type is : " + str, 20);
635
       logMetacat.warn("content type is : " + str);
634 636
     }
635 637
     catch(Exception e)
636 638
     {
637
       MetaCatUtil.debugMessage("erorr in Schemalocation.main: " +
638
                                e.getMessage(), 30);
639
       logMetacat.error("erorr in Schemalocation.main: " +
640
                                e.getMessage());
639 641
     }
640 642
  }
641 643
}//ContentTypeProvider

Also available in: Unified diff