1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 import org.cofax.cms.CofaxToolsUtil; 7 8 17 public class s_insertMultimedia extends StoredProcedure implements ProcedureInterface { 18 19 String itemID; 21 22 String type; 23 24 String itemName; 25 26 String caption; 27 28 String mimeType; 29 30 int rank; 31 32 String credit; 33 34 String size; 35 36 String icon; 37 38 String filename; 40 43 public s_insertMultimedia() { 44 } 45 46 54 public void init(HashMap initData, Connection con) { 55 super.init(initData, con); 57 itemID = utils.getString(data, "ITEMID", ""); 59 type = utils.getString(data, "MULTIMEDIATYPE", ""); 60 itemName = utils.getString(data, "ARTICLEIMAGENAME", ""); 61 caption = utils.getString(data, "MULTIMEDIACAPTION", ""); 62 size = utils.getString(data, "SIZE", "0"); 63 icon = utils.getString(data, "ICON", ""); 64 filename = utils.getString(data, "FILENAME", "dummy.bin"); 67 if (rank == 0) { 68 rank = 999; 69 } 70 } 71 72 78 public void checkParams() throws SQLException { 79 80 if (caption == null) { 81 caption = ""; 82 } 83 if (itemID.equals("") || type.equals("") || itemName.equals("")) { 84 85 throw new SQLException("ERROR: REQUIRED FIELDS WERE NOT SENT."); 86 } 87 } 88 89 95 public void checkAction() throws SQLException { 96 } 97 98 104 public void executeAction() throws SQLException { 105 if ((type.equals("sectionImage")) || (type.equals("articleImage"))) { 106 StringBuffer v_sbDelete = new StringBuffer (); 107 v_sbDelete.append("DELETE from tblmultimedia").append(" WHERE type = '" + type + "'").append(" AND itemID = '" + itemID + "'"); 108 execStatement(v_sbDelete.toString()); 109 } else { 110 StringBuffer v_sbDelete = new StringBuffer (); 111 v_sbDelete.append("DELETE from tblmultimedia").append(" WHERE type = '" + type + "'").append(" AND itemID = '" + itemID + "'").append( 112 " AND itemName = '" + itemName + "'"); 113 execStatement(v_sbDelete.toString()); 114 } 115 116 StringBuffer v_sbInsert = new StringBuffer (); 117 v_sbInsert.append("INSERT INTO tblmultimedia ").append( 118 "(filename, itemID, type, itemName, mimeType, caption, rank, credit, multimediaUpdateDate, size, icon)").append( 119 " VALUES ('" + filename + "', '" + itemID + "', '" + type + "', '" + itemName + "', '" + mimeType + "', '" + caption + "', '" + rank + "', '" 120 + credit + "', '" + sdf.format(new java.util.Date ()) + "', '" + size + "', '" + icon + "')"); 121 122 CofaxToolsUtil.log("Insert avec le filename :" + filename); execStatement(v_sbInsert.toString()); 125 126 StringBuffer v_sbUpdate = new StringBuffer (); 127 v_sbUpdate.append("UPDATE tblarticles ").append(" SET updateDate = now() ").append(" WHERE itemID = '" + itemID + "'"); 128 129 execStatement(v_sbUpdate.toString()); 130 131 if (type.equals("articleImage")) { 133 StringBuffer v_sbUpdate2 = new StringBuffer (); 134 v_sbUpdate2.append("UPDATE tblarticlepreload SET ").append(" articleImage= '" + itemName + "', ") 135 .append(" articleImagecaption= '" + caption + "' ").append(" WHERE ITEMID= '" + itemID + "' "); 136 execStatement(v_sbUpdate2.toString()); 137 } 138 139 if (type.equals("sectionImage")) { 140 StringBuffer v_sbUpdate2 = new StringBuffer (); 141 v_sbUpdate2.append("UPDATE tblarticlepreload SET ").append(" listImage= '" + itemName + "', ").append(" listImagecaption= '" + caption + "' ") 142 .append(" WHERE ITEMID= '" + itemID + "' "); 143 execStatement(v_sbUpdate2.toString()); 144 } 145 146 execStatementToRS(queryResultOk); 147 148 } 149 } 150 | Popular Tags |