1 package de.webman.content.eventhandler; 2 3 import com.teamkonzept.web.*; 4 import com.teamkonzept.webman.*; 5 import com.teamkonzept.webman.db.TKWebmanDBManager; 6 import com.teamkonzept.webman.mainint.*; 7 import com.teamkonzept.webman.mainint.db.*; 8 import com.teamkonzept.webman.mainint.db.queries.content.*; 9 import com.teamkonzept.webman.mainint.db.queries.*; 10 import com.teamkonzept.webman.mainint.events.*; 11 import com.teamkonzept.lib.*; 12 import com.teamkonzept.field.*; 13 import com.teamkonzept.field.db.*; 14 import com.teamkonzept.db.*; 15 import de.webman.content.workflow.*; 16 import de.webman.content.Content; 17 import java.sql.*; 18 import java.io.*; 19 20 25 public class CEOnlineHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults 26 { 27 28 private CEOnlineHandler() 29 {} 30 31 private static CEOnlineHandler instance = new CEOnlineHandler(); 32 33 public static CEOnlineHandler getInstance() 34 { 35 return instance; 36 } 37 38 public void handleEvent(TKEvent evt) throws TKException 39 { 40 try 41 { 42 CEUtils.checkEvent(evt); 43 TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_ce.tmpl" ); 44 String contentNodeID = evt.getParameter(PARAMETER, "CONTENT_NODE_ID"); 46 48 49 boolean showonlyGroup = false; 50 if (contentNodeID == null) 51 { 52 showonlyGroup = true; 53 contentNodeID = evt.getParameter(PARAMETER, "GROUP_CONTENT_NODE_ID"); 54 } 55 56 boolean isGroup = false; 58 boolean neu = evt.getParameter(PARAMETER, "NEW") != null; 60 61 if (!showonlyGroup) 62 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CE_SHOWLIST", "CE_EDIT" ); 63 else 64 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CE_SHOWLIST", "CE_GROUP_LIST" ); 65 66 TKQuery query = TKDBManager.newQuery(TKDBContentTreeGetParentInfo.class); 69 query.setQueryParams("CONTENT_NODE_ID", new Integer (contentNodeID)); 70 query.execute(); 71 ResultSet rs = query.fetchResultSet(); 72 73 String parentNodeID =""; 76 String parentName = ""; 77 String parentShortName = ""; 78 String contentNodeName = ""; 79 String contentNodeShortName = ""; 80 String contentNodeType = ""; 83 String contentForm = ""; 84 if (rs.next()) 85 { 86 parentNodeID = rs.getString("CONTENT_NODE_ID"); 88 parentName = rs.getString("CONTENT_NODE_NAME"); 89 parentShortName = rs.getString("CONTENT_NODE_SHORTNAME"); 90 contentNodeType = rs.getString("CONTENT_NODE_TYPE"); 91 isGroup = contentNodeType.equals(GROUP); 92 contentForm = rs.getString("CONTENT_FORM"); 93 TKParams params = new TKParams(); 95 String grouphelp = ""; 96 if (isGroup) 97 grouphelp = "GROUP"; 98 params.put(PARAMETER, grouphelp + "CONTENT_NODE_ID", parentNodeID); 99 params.put(PARAMETER, grouphelp + "CONTENT_NODE_NAME", parentName); 100 params.put(PARAMETER, grouphelp + "CONTENT_NODE_SHORTNAME", parentShortName); 101 params.put(PARAMETER, "CONTENT_NODE_TYPE", contentNodeType); 102 if (contentForm != null) 103 params.put(PARAMETER, "CONTENT_FORM", contentForm); 104 105 ContentContext ct = new ContentContext(params, null); 106 t.set("NAVIGATION_CONTEXT", ct.calculateNavContext()); 107 108 } 109 if (rs.next()) 110 { 111 contentNodeName = rs.getString("CONTENT_NODE_NAME"); 112 contentNodeShortName = rs.getString("CONTENT_NODE_SHORTNAME"); 113 contentForm = rs.getString("CONTENT_FORM"); 114 } 115 Content content = null; 116 if (!neu && !showonlyGroup) 117 { 118 content = VersionCache.getContentInfo(new Integer (contentNodeID)); 120 } 121 TKVector openNodes = new TKVector(); 122 openNodes.addElement(parentNodeID); 123 TKStandardIterator iterator1 = new TKStandardIterator( openNodes, t.getListIterator(), "OPEN_NODES", "OPEN_NODES" ); 125 t.setListIterator( iterator1 ); 126 127 t.set("GROUP_CONTENT_NODE_ID", parentNodeID); 128 t.set("CONTENT_FORM", contentForm); 129 if (showonlyGroup) 130 t.set("GROUP_CONTENT_NODE_ID", contentNodeID); 131 if (isGroup || showonlyGroup) 132 { 133 t.set("GROUP_CONTENT_NODE_NAME", parentName); 134 t.set("GROUP_CONTENT_NODE_SHORTNAME", parentShortName); 135 } 136 if (!neu) 137 { 138 t.set("CONTENT_NODE_NAME", contentNodeName); 139 t.set("CONTENT_NODE_SHORTNAME", contentNodeShortName); 140 t.set("CONTENT_NODE_ID", contentNodeID); 141 142 if (!showonlyGroup) 143 { 144 t.set("INSTANCE_ID", content.getInstanceId()); 145 ContentVersion version = content.getCurrentVersion(); 146 t.set("VERSION_ID" , version.getId()); 147 t.set("NEW_STATUS", new Integer (1)); 149 } 150 } 151 t.set("CONTENT_NODE_TYPE", contentNodeType); 152 evt.finishTemplate(t); 153 } 154 catch (Throwable e) 155 { 156 throw WebmanExceptionHandler.getException(e); 158 } 159 } 160 161 public boolean isHandler(TKEvent evt) 162 { 163 return evt.getName().equalsIgnoreCase("CE_ONLINE"); 164 } 165 } 166 | Popular Tags |