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.*; 9 import com.teamkonzept.webman.mainint.events.*; 10 import com.teamkonzept.lib.*; 11 import com.teamkonzept.field.*; 12 import com.teamkonzept.field.db.*; 13 import com.teamkonzept.db.*; 14 import com.teamkonzept.publishing.markups.*; 15 import de.webman.content.workflow.*; 16 import java.sql.*; 17 import java.io.*; 18 19 import org.apache.log4j.Category; 20 21 26 public class CEUpdateGroupContentHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults 27 { 28 29 private static Category cat = Category.getInstance(CEUpdateGroupContentHandler.class); 30 31 34 private CEUpdateGroupContentHandler() 35 {} 36 37 private static CEUpdateGroupContentHandler instance = new CEUpdateGroupContentHandler(); 38 39 public static CEUpdateGroupContentHandler getInstance() 40 { 41 return instance; 42 } 43 44 public void handleEvent(TKEvent evt) throws TKException 45 { 46 try 47 { 48 CEUtils.checkEvent(evt); 49 ContentContext ceContext = new ContentContext (evt.getParams()); 50 51 VersionStatics statics = VersionStatics.setup(); 53 if (ceContext.conNodeShortName == null && ceContext.conNodeName != null) 55 { 56 ceContext.conNodeShortName = TKUploadField.checkFileName( ceContext.conNodeName); 57 } 58 if (ceContext.conNodeName == null || ceContext.conNodeName.equals("")) 59 throw new TKUserException("Es muß ein Name angegeben werden", NO_PATHNAME, USER_SEVERITY, true, null); 60 61 CEUtils.isValidPathname( ceContext.conNodeShortName ); 62 if (ceContext.groupConNodeId.intValue() != -1) 63 CEUtils.checkShortName(ceContext.groupConNodeId, ceContext.conNodeId, ceContext.conNodeShortName); 64 String upBase = CEUtils.getCurrentPath(ceContext.conNodeId); 65 TKQuery q = TKDBManager.newQuery(TKDBContentTreeUpdateNode.class); 66 q.setQueryParams( "CONTENT_NODE_ID", ceContext.conNodeId ); 67 q.setQueryParams( "CONTENT_NODE_NAME", ceContext.conNodeName ); 68 q.setQueryParams( "CONTENT_NODE_SHORTNAME", ceContext.conNodeShortName ); 69 q.setQueryParams( "CONTENT_NODE_TYPE", SINGLE_INTEGER ); 70 q.setQueryParams( "CONTENT_FORM", ceContext.formId ); 71 q.setQueryParams( "TREE_ID", new Integer (0) ); 72 q.setQueryParams( "PROTOTYPE_ID", TKNull.NULL ); 73 q.execute(); 74 75 String oldName = ceContext.getParam ( "OLD_CONTENT_NODE_NAME"); 76 String oldShortName = evt.getParameter(PARAMETER, "OLD_CONTENT_NODE_SHORTNAME"); 77 78 if (!oldShortName.equals(ceContext.conNodeShortName)) 80 { 81 String docRoot = evt.getHttpInterface().getDocumentRoot(); 83 String oldDir = docRoot + upBase; 84 File old = new File(oldDir); 85 86 if (old.exists()) 87 { 88 File newDir = new File(old.getParent() + File.separator + ceContext.conNodeShortName); 89 90 if (newDir.exists()) 91 { 92 cat.error("Can't rename Asset Directory due to existing directory"); 93 } 94 else 95 { 96 old.renameTo(newDir); 97 } 98 } 99 } 100 String Info = "Umbenannt"+(oldName != null ? " von "+oldName : "")+" nach "+ceContext.conNodeName; 101 102 VersionStatus trackingStatus = VersionStatus.lookupRename (statics); 103 if (trackingStatus == null) trackingStatus = VersionStatus.lookupComment (statics); 104 105 if (trackingStatus != null) { 106 q = TKDBManager.newQuery(TKDBContentNewVersion.class); 107 q.setQueryParams( "INSTANCE_ID", ceContext.instanceId ); 108 q.setQueryParams( "STATUS_ID", new Integer (trackingStatus.status_id) ); 109 q.setQueryParams( "VERS_INFO", Info ); 110 q.setQueryParams( "VERS_AUTHOR", evt.getRemoteUser() ); 111 q.execute(); 112 } 113 evt.getParams().put(PARAMETER, "RECALCULATE", "a"); 115 CEBrowseHandler.getInstance().handleEvent(evt); 116 } 117 catch (Throwable e) 118 { 119 throw WebmanExceptionHandler.getException(e); 121 } 122 } 123 124 public boolean isHandler(TKEvent evt) 125 { 126 return evt.getName().equalsIgnoreCase("CE_UPDATE_GROUP_CONTENT"); 127 } 128 } 129 | Popular Tags |