1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 16 public class s_insertPublication extends StoredProcedure implements ProcedureInterface { 17 18 21 protected String pubConfigAction; 22 23 String publication; 24 25 String pubName; 26 27 String pubDesc; 28 29 String tagLine; 30 31 String keywords; 32 33 String homePage; 34 35 String icon; 36 37 String iconWidth; 38 39 String iconHeight; 40 41 String javaScript; 42 43 String rolloverTime; 44 45 String defaultSection; 46 47 String defaultSectionWithDate; 48 49 String domainName; 50 51 String testFTPServer; 52 53 String testFTPLogin; 54 55 String testFTPPassword; 56 57 String testTemplateFolder; 58 59 String testImagesFolder; 60 61 String liveFTPServer; 62 63 String liveFTPLogin; 64 65 String liveFTPPassword; 66 67 String liveTemplateFolder; 68 69 String liveImagesFolder; 70 71 String liveImagesServer; 72 73 String importFTPServer; 74 75 String importFTPLogin; 76 77 String importFTPPassword; 78 79 String importFTPFilePath; 80 81 String importFTPFileContents; 82 83 String mainCofaxServer; 84 85 String imagesURLPrefix; 86 87 String cacheServers; 88 89 String pubID; 90 91 String P3PPolicyRef; 92 93 String P3PCompactHeader; 94 95 String errorHeaders; 96 97 String wmails; 98 99 String wlevels; 100 101 String wadminemail; 102 103 106 public s_insertPublication() { 107 } 108 109 117 public void init(HashMap initData, Connection con) { 118 super.init(initData, con); 120 publication = utils.getString(data, "PUBLICATION", ""); 122 pubName = utils.getString(data, "PUBNAME", ""); 123 pubDesc = utils.getString(data, "PUBDESC", ""); 124 tagLine = utils.getString(data, "TAGLINE", ""); 125 keywords = utils.getString(data, "KEYWORDS", ""); 126 homePage = utils.getString(data, "HOMEPAGE", ""); 127 icon = utils.getString(data, "ICON", ""); 128 iconWidth = utils.getString(data, "ICONWIDTH", ""); 129 iconHeight = utils.getString(data, "ICONHEIGHT", ""); 130 javaScript = utils.getString(data, "JAVASCRIPT", ""); 131 rolloverTime = utils.getString(data, "ROLLOVERTIME", "4"); 132 defaultSection = utils.getString(data, "DEFAULTSECTION", ""); 133 defaultSectionWithDate = utils.getString(data, "DEFAULTSECTIONWITHDATE", ""); 134 domainName = utils.getString(data, "DOMAINNAME", ""); 135 testFTPServer = utils.getString(data, "TESTFTPSERVER", ""); 136 testFTPLogin = utils.getString(data, "TESTFTPLOGIN", ""); 137 testFTPPassword = utils.getString(data, "TESTFTPPASSWORD", ""); 138 testTemplateFolder = utils.getString(data, "TESTTEMPLATEFOLDER", ""); 139 testImagesFolder = utils.getString(data, "TESTIMAGESFOLDER", ""); 140 liveFTPServer = utils.getString(data, "LIVEFTPSERVER", ""); 141 liveFTPLogin = utils.getString(data, "LIVEFTPLOGIN", ""); 142 liveFTPPassword = utils.getString(data, "LIVEFTPPASSWORD", ""); 143 liveTemplateFolder = utils.getString(data, "LIVETEMPLATEFOLDER", ""); 144 liveImagesFolder = utils.getString(data, "LIVEIMAGESFOLDER", ""); 145 liveImagesServer = utils.getString(data, "LIVEIMAGESSERVER", ""); 146 importFTPServer = utils.getString(data, "IMPORTFTPSERVER", ""); 147 importFTPLogin = utils.getString(data, "IMPORTFTPLOGIN", ""); 148 importFTPPassword = utils.getString(data, "IMPORTFTPPASSWORD", ""); 149 importFTPFilePath = utils.getString(data, "IMPORTFTPFILEPATH", ""); 150 importFTPFileContents = utils.getString(data, "IMPORTFTPFILECONTENTS", ""); 151 mainCofaxServer = utils.getString(data, "MAINCOFAXSERVER", ""); 152 imagesURLPrefix = utils.getString(data, "IMAGESURLPREFIX", ""); 153 cacheServers = utils.getString(data, "CACHESERVERS", ""); 154 pubID = utils.getString(data, "PUBID", "0"); 155 P3PPolicyRef = utils.getString(data, "POLICYREF", ""); 156 P3PCompactHeader = utils.getString(data, "COMPACTHEADER", ""); 157 errorHeaders = utils.getString(data, "USEERROR", ""); 158 wmails = utils.getString(data, "WORKFLOW_MAILS", ""); 159 wlevels = utils.getString(data, "WORKFLOW_LEVELS", ""); 160 wadminemail = utils.getString(data, "WORKFLOW_ADMINEMAIL", ""); 161 } 162 163 169 public void checkAction() throws SQLException { 170 execStatementToRS("SELECT * FROM tblpublications WHERE pubID = " + pubID); 172 if (Integer.parseInt(pubID) > 0 && psResult.next()) { 173 action = "update"; 174 } else if (Integer.parseInt(pubID) == 0) { 175 action = "insert"; 176 } else { 177 throw new SQLException("ERROR: Publication DOES NOT EXIST."); 178 } 179 close(); 180 181 execStatementToRS("SELECT * FROM tbltoolspublicationconfig WHERE pubID = " + pubID); 183 if (Integer.parseInt(pubID) > 0 && psResult.next()) { 184 pubConfigAction = "update"; 185 } else { 186 pubConfigAction = "insert"; 187 } 188 close(); 189 190 } 191 192 198 public void checkParams() throws SQLException { 199 if (publication.equals("") || pubName.equals("") || pubDesc.equals("")) { 200 throw new SQLException("ERROR: REQUIRED FIELDS WERE NOT SENT."); 201 } 202 } 203 204 210 public void executeAction() throws SQLException { 211 if (action.equals("update")) { 213 StringBuffer v_sb = new StringBuffer (); 214 v_sb.append("UPDATE tblpublications").append(" SET publication = '" + publication + "',").append(" pubName = '" + pubName + "',").append( 215 " pubDesc = '" + pubDesc + "',").append(" tagLine = '" + tagLine + "',").append(" keywords = '" + keywords + "',").append( 216 " homePage = '" + homePage + "',").append(" icon = '" + icon + "',").append(" iconWidth = '" + iconWidth + "',").append( 217 " iconHeight = '" + iconHeight + "',").append(" javaScript = '" + javaScript + "',").append(" rolloverTime = '" + rolloverTime + "',") 218 .append(" defaultSection = '" + defaultSection + "',").append(" defaultSectionWithDate = '" + defaultSectionWithDate + "',").append( 219 " pubUpdateDate = '" + sdf.format(new java.util.Date ()) + "', ").append(" workflow_mails = '" + wmails + "',").append( 220 " workflow_levels = '" + wlevels + "',").append(" workflow_adminEmail = '" + wadminemail + "' ").append(" WHERE pubID = " + pubID); 221 222 execStatement(v_sb.toString()); 223 } else if (action.equals("insert")) { 224 StringBuffer v_sb = new StringBuffer (); 225 v_sb.append("INSERT INTO tblpublications ").append("(publication,").append("pubName,").append("pubDesc,").append("tagLine,").append("keywords,") 226 .append("homePage,").append("icon,").append("iconWidth,").append("iconHeight,").append("javaScript,").append("rolloverTime,").append( 227 "defaultSection,").append("defaultSectionWithDate,").append("pubUpdateDate, ").append( 228 "workflow_mails, workflow_levels, workflow_adminEmail) ").append(" VALUES ('" + publication + "',").append("'" + pubName + "',") 229 .append("'" + pubDesc + "',").append("'" + tagLine + "',").append("'" + keywords + "',").append("'" + homePage + "',").append( 230 "'" + icon + "',").append("'" + iconWidth + "',").append("'" + iconHeight + "',").append("'" + javaScript + "',").append( 231 "'" + rolloverTime + "',").append("'" + defaultSection + "',").append("'" + defaultSectionWithDate + "',").append( 232 "'" + sdf.format(new java.util.Date ()) + "', ").append("'" + wmails + "','" + wlevels + "', '" + wadminemail + "')"); 233 234 synchronized (this) { 236 execStatement(v_sb.toString()); 237 pubID = getMax("tblpublications", "pubID"); 239 } 240 } 241 242 if (pubConfigAction.equals("update")) { 244 StringBuffer v_sb = new StringBuffer (); 245 v_sb.append("UPDATE tbltoolspublicationconfig").append(" SET domainName = '" + domainName + "',").append( 246 " testFTPServer = '" + testFTPServer + "',").append(" testFTPLogin = '" + testFTPLogin + "',").append( 247 " testFTPPassword = '" + testFTPPassword + "',").append(" testTemplateFolder = '" + testTemplateFolder + "',").append( 248 " testImagesFolder = '" + testImagesFolder + "',").append(" liveFTPServer = '" + liveFTPServer + "',").append( 249 " liveFTPLogin = '" + liveFTPLogin + "',").append(" liveFTPPassword = '" + liveFTPPassword + "',").append( 250 " liveTemplateFolder = '" + liveTemplateFolder + "',").append(" liveImagesFolder = '" + liveImagesFolder + "',").append( 251 " liveImagesServer = '" + liveImagesServer + "',").append(" importFTPServer = '" + importFTPServer + "',").append( 252 " importFTPLogin = '" + importFTPLogin + "',").append(" importFTPPassword = '" + importFTPPassword + "',").append( 253 " importFTPFilePath = '" + importFTPFilePath + "',").append(" importFTPFileContents = '" + importFTPFileContents + "',").append( 254 " mainCofaxServer = '" + mainCofaxServer + "',").append(" cacheServers = '" + cacheServers + "',").append( 255 " imagesURLPrefix = '" + imagesURLPrefix + "', ").append(" errorHeaders = '" + errorHeaders + "', ").append( 256 " P3PPolicyRef = '" + P3PPolicyRef + "', ").append(" P3PCompactHeader = '" + P3PCompactHeader + "' ").append(" WHERE pubID = " + pubID); 257 execStatement(v_sb.toString()); 258 } else if (pubConfigAction.equals("insert")) { 259 StringBuffer v_sb = new StringBuffer (); 260 v_sb.append(" INSERT INTO tbltoolspublicationconfig ").append(" VALUES (" + pubID + ",").append("'" + domainName + "',").append( 261 "'" + testFTPServer + "',").append("'" + testFTPLogin + "',").append("'" + testFTPPassword + "',").append("'" + testTemplateFolder + "',") 262 .append("'" + testImagesFolder + "',").append("'" + liveFTPServer + "',").append("'" + liveFTPLogin + "',").append( 263 "'" + liveFTPPassword + "',").append("'" + liveTemplateFolder + "',").append("'" + liveImagesFolder + "',").append( 264 "'" + liveImagesServer + "',").append("'" + importFTPServer + "',").append("'" + importFTPLogin + "',").append( 265 "'" + importFTPPassword + "',").append("'" + importFTPFilePath + "',").append("'" + importFTPFileContents + "',").append( 266 "'" + mainCofaxServer + "',").append("'" + imagesURLPrefix + "',").append("'" + cacheServers + "', ").append( 267 "'" + errorHeaders + "', ").append("'" + P3PPolicyRef + "', ").append("'" + P3PCompactHeader + "')"); 268 execStatement(v_sb.toString()); 269 } 270 String v_select = "select " + pubID + " as pubID"; 271 execStatementToRS(queryResultOk); 272 } 273 } 274 | Popular Tags |