1 /*
2 Loader - tool for transfering data from one JDBC source to another and
3 doing transformations during copy.
4 Copyright (C) 2002-2003 Together
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 You should have received a copy of the GNU Lesser General Public
14 License along with this library; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 Loader.java
17 Date: 03.03.2003.
18 @version 2.1 alpha
19 @author:
20 Radoslav Dutina rale@prozone.co.yu
21 */
22
23
24 package org.webdocwf.util.loader;
25
26 import java.util.*;
27 import java.io.*;
28 import javax.xml.parsers.DocumentBuilderFactory;
29 import javax.xml.parsers.DocumentBuilder;
30 import org.w3c.dom.*;
31 import org.xml.sax.*;
32 import org.webdocwf.util.loader.logging.*;
33
34 /***
35 * ParseLoggerParam class is use to check needed parameters for Logger object
36 * @author Radoslav Dutina
37 * @version 1.0
38 */
39 public class ParseLoggerParam {
40
41 private String logClassName = "";
42 private String pathToLoggerConf = "";
43 private String pathToLoaderJob="";
44
45 /***
46 * This is the constructor of ParseLoggerParam class
47 * @param loaderJob defines the string path to loaderJob xml file
48 * @throws LoaderException
49 */
50 public ParseLoggerParam(String loaderJob) throws LoaderException {
51 File file = new File(loaderJob);
52 this.pathToLoaderJob=file.getAbsoluteFile().getParent();
53 Document doc = null;
54 try {
55 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
56 DocumentBuilder db = null;
57 db = dbf.newDocumentBuilder();
58 doc = db.parse(file);
59 }
60 catch (Exception e) {
61 System.out.println("Sorry, an error occurred: " + e.getMessage());
62 BufferOctopusClass.getInstance().writeToBuffer("Sorry, an error occurred: " + e.getMessage()
63 + "\n");
64 LoaderException le = new LoaderException("Exception: ", (Throwable)e);
65 throw le;
66 }
67
68 if (doc != null) {
69 NodeList tagLoaderJob = doc.getElementsByTagName("loaderJob");
70 if (tagLoaderJob.getLength() != 0) {
71 NamedNodeMap log = tagLoaderJob.item(0).getAttributes();
72 Node nodeLogClassName = log.getNamedItem("logClassName");
73 if (nodeLogClassName != null)
74 this.logClassName = nodeLogClassName.getNodeValue();
75 Node nodeLogPath = log.getNamedItem("pathToLoggerConf");
76 if (nodeLogPath != null){
77 this.pathToLoggerConf = nodeLogPath.getNodeValue();
78 File fileLogger=new File(this.pathToLoggerConf);
79 if(!fileLogger.isAbsolute()){
80 String fullPathToLoggerConf=this.pathToLoaderJob+System.getProperty("file.separator")+
81 this.pathToLoggerConf;
82 File loggerFile=new File(fullPathToLoggerConf);
83 try {
84 this.pathToLoggerConf=loggerFile.getCanonicalPath();
85 }
86 catch (Exception ex) {
87 System.out.println(ex.getMessage());
88 ex.printStackTrace();
89 }
90 }
91 }
92 }
93 }
94 }
95
96 /***
97 * This method is use to retrive value of logClassName parameter
98 * @return value of logClassName parameter
99 */
100 public String getLogClassName() {
101 return this.logClassName;
102 }
103
104 /***
105 * This method is use to retrive value of pathToLoggerCong parameter
106 * @return value of pathToLoggerCong parameter
107 */
108 public String getPathToLoggerConf() {
109 return this.pathToLoggerConf;
110 }
111 }
This page was automatically generated by Maven