1 package de.webman.content.eventhandler; 2 3 import com.teamkonzept.web.*; 4 import com.teamkonzept.webman.*; 5 import com.teamkonzept.webman.mainint.*; 6 import com.teamkonzept.webman.mainint.db.queries.*; 7 import com.teamkonzept.webman.mainint.events.*; 8 import com.teamkonzept.lib.*; 9 import com.teamkonzept.field.*; 10 import com.teamkonzept.field.db.*; 11 import com.teamkonzept.db.*; 12 13 import de.webman.content.workflow.*; 14 import java.sql.*; 15 16 17 25 public class CEContentVersionsHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants 26 { 27 private CEContentVersionsHandler() 28 {} 29 30 private static CEContentVersionsHandler instance = new CEContentVersionsHandler(); 31 32 public static CEContentVersionsHandler getInstance() 33 { 34 return instance; 35 } 36 37 42 public void handleEvent(TKEvent evt) throws TKException 43 { 44 try 45 { 46 CEUtils.checkEvent(evt); 47 48 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ce_conVersList.tmpl" ); 49 50 ContentContext ceContext = CEUtils.keepCEContext( evt, t ); 51 52 VersionStatics statics = VersionStatics.setup(); 54 55 String action = evt.getParameter(ACTION,evt.getName()); 56 57 if (action == null || action.length() == 0 || action.equalsIgnoreCase ("GET")) 58 { 59 if (ceContext.instanceId.intValue() != -1) 60 { 61 TKQuery q = TKDBManager.newQuery(TKDBListContentVersions.class); 62 q.setQueryParams( "INSTANCE_ID", ceContext.instanceId ); 63 q.execute(); 64 ResultSet rs = q.fetchResultSet(); 65 TKVector vec = new TKVector(); 66 int currentContentId = -1; 67 68 while (rs.next()) 69 { 70 TKHashtable tb = new TKHashtable(); 71 vec.addElement (tb); 72 73 int statusId = rs.getInt("STATUS_ID"); 74 75 String version = rs.getString ("VERSION_ID"); 76 String status = rs.getString ("STATUS"); 77 String info = rs.getString ("INFO"); 78 String author = rs.getString ("AUTHOR"); 79 String date = TKContentAttributeTableData.dateFormat.format(rs.getTimestamp("VERSION_DATE")); 80 81 int contentId = rs.getInt ("CONTENT_ID"); 83 84 VersionStatus desc = (VersionStatus) 85 statics.getStatusPool().get (new Integer (statusId)); 86 if (desc.comment) tb.put ("IS_COMMENT",Boolean.TRUE); 87 88 tb.put ("VERSION_ID",version); 89 tb.put ("STATUS",status); 90 tb.put ("INFO",info); 91 if (author != null) tb.put ("AUTHOR",author); 92 tb.put ("DATE",date); 93 94 tb.put ("CURR_CONTENT_ID",new Integer (currentContentId)); 95 tb.put ("CONTENT_ID",new Integer (contentId)); 96 97 if (currentContentId != -1 && currentContentId != contentId) 98 tb.put ("NEW_CONTENT", Boolean.TRUE); 99 100 currentContentId = contentId; 101 } 102 103 t.setListIterator (new TKStandardPluginIterator ("CONTENT_VERSIONS","VERSION", 104 vec,false,t.getListIterator())); 105 } 106 WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ContextConstants.CONTENT_EDIT); 107 evt.finishTemplate(t); 108 return; 109 } 110 } 111 catch (Throwable e) 112 { 113 throw WebmanExceptionHandler.getException(e); 115 } 116 } 117 118 public boolean isHandler(TKEvent evt) 119 { 120 return evt.getName().equalsIgnoreCase("CE_CONTENT_VERSIONS"); 121 } 122 } 123 | Popular Tags |