001: /*
002: * Created on 2006.5.12
003: * Milin Radivoj
004: * rmilin@gmail.com
005: */
006:
007: package org.enhydra.snapperAdmin.business;
008:
009: import java.io.File;
010: import java.sql.Date;
011: import java.sql.PreparedStatement;
012: import java.sql.SQLException;
013:
014: /*import com.lutris.appserver.server.sql.DBConnection;
015: import com.lutris.appserver.server.sql.DatabaseManager;
016: import com.lutris.appserver.server.sql.DatabaseManagerException;
017: */
018: /**
019: * @author Milin Radivoj
020: *
021: */
022: public class FillIncludeList {
023:
024: static int i = 0;
025: //private DatabaseManager dbm;
026: String db;
027: String tb;
028: String co;
029:
030: //public void add( String fileName) throws SQLException, DatabaseManagerException {
031: public void add(String fileName) throws SQLException {
032: i++;
033: //DBConnection dbconn = null;
034: try {
035: // dbconn = dbm.findLogicalDatabase(db).allocateConnection();
036:
037: // PreparedStatement pstmt = dbconn.prepareStatement("INSERT INTO "+tb+" (OBJECTID,FILENAME,MODIFIED)VALUES(?,?,?)");
038: // pstmt.setInt(1,i);
039: // pstmt.setString(2,fileName );
040: //pstmt.setDate(3, new Date(System.currentTimeMillis()));
041:
042: //pstmt.executeUpdate();
043: // dbconn.commit();
044: // dbconn.release();
045: System.out.println(" dodajem fajl u bazu : " + fileName);
046: } catch (Exception ex) {
047:
048: ex.printStackTrace();
049:
050: }
051:
052: }
053:
054: /* public void indexFS(String db,
055: String tb,
056: String co,
057: String location, DatabaseManager dbm,boolean direct) {
058: this.dbm = dbm;
059:
060: this.db = db;
061: this.tb = tb;
062: this.co = co;
063:
064:
065: File loc;
066: try {
067:
068: loc = new File(location);
069: if (loc.canRead()) {
070: if (loc.isDirectory()) {
071: String[] files = loc.list();
072: if (files != null) {
073: for (int p = 0; p < files.length; p++) {
074: File fl = new File(location, files[p]);
075:
076: if (fl.isDirectory()) {
077: String[] fls = fl.list();
078: indexSubfolders(fl, fls, direct);
079: }
080: // *** Apply filters ***
081: //allfiles.add(new File(location, files[p]));
082: // indexDocs(new File(location, files[p]));
083: if((fl.isDirectory() && direct) || (!fl.isDirectory() && !direct))
084: add((new File(location, files[p])).getAbsolutePath());
085: }
086: }
087: }
088: }
089:
090: // SnapperManager.getInstance().getLoggingManager().info(
091: // "Indexing finished");
092:
093: } catch (Exception e) {
094: e.printStackTrace();
095: }
096: }
097:
098: private void indexSubfolders(File dir, String[] files,boolean direct ) {
099: if (files != null) {
100: for (int q = 0; q < files.length; q++) {
101: File fl = new File(dir, files[q]);
102: if (fl.isDirectory()) {
103: String[] fls = fl.list();
104: indexSubfolders(fl, fls, direct);
105: }
106: //originalFile = new File(dir, files[q]);
107: try {
108: //allfiles.add(new File(location, files[p]));
109: // indexDocs(new File(dir, files[q]));
110: if((fl.isDirectory() && direct) || (!fl.isDirectory() && !direct))
111: add((new File(dir, files[q])).getAbsolutePath());
112: } catch (Exception ex) {
113: }
114:
115: }
116: }
117: }
118: */
119:
120: }
|