1 32 33 package com.knowgate.scheduler.jobs; 34 35 import java.io.IOException ; 36 37 import com.knowgate.debug.DebugFile; 38 import com.knowgate.dataobjs.DB; 39 import com.knowgate.scheduler.Atom; 40 import com.knowgate.scheduler.Job; 41 import com.knowgate.dataxslt.FastStreamReplacer; 42 import com.knowgate.dfs.FileSystem; 43 44 49 50 public class FTPPublisher extends Job { 51 52 private FastStreamReplacer oReplacer; 55 56 private FileSystem oFileSys; 57 58 public FTPPublisher() { 59 oReplacer = new FastStreamReplacer(); 60 oFileSys = new FileSystem(); 61 } 62 63 65 84 85 87 public void free() {} 88 89 public Object process(Atom oAtm) throws IOException { 90 91 String sPathHTML; char cBuffer[]; Object oReplaced; 95 final String sSep = System.getProperty("file.separator"); final String Yes = "1"; 97 98 if (DebugFile.trace) { 99 DebugFile.writeln("Begin FTPPublisher.process([Job:" + getStringNull(DB.gu_job,"") + ", Atom:" + String.valueOf(oAtm.getInt(DB.pg_atom)) + "])"); 100 DebugFile.incIdent(); 101 } 102 103 104 107 sPathHTML = getProperty("workareasput"); 109 if (!sPathHTML.endsWith(sSep)) sPathHTML += sSep; 110 111 sPathHTML += getParameter("gu_workarea") + sSep + "apps" + sSep + "Mailwire" + sSep + "html" + sSep + getParameter("gu_pageset") + sSep; 113 114 sPathHTML += getParameter("nm_pageset").replace(' ','_') + ".html"; 116 117 if (DebugFile.trace) DebugFile.writeln("PathHTML = " + sPathHTML); 118 119 122 oReplaced = oReplacer.replace(sPathHTML, oAtm.getItemMap()); 123 124 125 128 oFileSys.user(getParameter("tx_nickname")); 129 oFileSys.password(getParameter("tx_pwd")); 130 131 try { 132 133 if (Yes.equals(getParameter("bo_path"))) 134 oFileSys.mkdirs("ftp://" + getParameter("nm_server") + "/" + getParameter("path")); 135 136 oFileSys.copy( "file://" + sPathHTML, 137 "ftp://" + getParameter("nm_server") + "/" + getParameter("path") + "/" + getParameter("nm_file")); 138 139 } catch (java.lang.Exception e) { 140 throw new IOException (e.getMessage()); 141 } 142 143 iPendingAtoms--; 145 146 if (DebugFile.trace) { 147 DebugFile.writeln("End FTPPublisher.process([Job:" + getStringNull(DB.gu_job,"") + ", Atom:" + String.valueOf(oAtm.getInt(DB.pg_atom)) + "])"); 148 DebugFile.decIdent(); 149 } 150 151 return oReplaced; 152 } 154 } | Popular Tags |