Ticket #3371: spring_connector.patch
File spring_connector.patch, 19.3 KB (added by , 14 years ago) |
---|
-
java-core/src/main/java/net/fckeditor/connector/ConnectorServlet.java
77 77 public class ConnectorServlet extends HttpServlet { 78 78 private static final long serialVersionUID = -5742008970929377161L; 79 79 private static final Logger logger = LoggerFactory.getLogger(ConnectorServlet.class); 80 pr ivateDispatcher dispatcher;80 protected Dispatcher dispatcher; 81 81 82 82 /** 83 83 * Initializes the {@link Dispatcher}. -
java-core/src/main/java/net/fckeditor/connector/Dispatcher.java
80 80 this.connector = ConnectorHandler.getConnector(); 81 81 this.connector.init(servletContext); 82 82 } 83 84 //TODO Arguably the Connector should be passed into this class 85 //not the Servlet context or ConecntorHandler 86 //as this adds a unnecessary dependency on these classes 87 public Dispatcher(Connector connector){ 88 this.connector = connector; 89 } 83 90 84 91 /** 85 92 * Manages <code>GET</code> requests (<code>GetFolders</code>, -
java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java
46 46 logger.error("Empty Connector implementation class name provided"); 47 47 else { 48 48 try { 49 Class<?> clazz = Class.forName(className); 49 //Class<?> clazz = Class.forName(className); 50 Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className); 50 51 connector = (Connector) clazz.newInstance(); 51 52 logger.info("Connector initialized to {}", className); 52 53 } catch (Throwable e) { -
java-demo/pom.xml
11 11 <version>2.5-SNAPSHOT</version> 12 12 </dependency> 13 13 <dependency> 14 <groupId>net.fckeditor</groupId> 15 <artifactId>spring-connector</artifactId> 16 <version>2.5-SNAPSHOT</version> 17 </dependency> 18 19 <dependency> 14 20 <groupId>org.slf4j</groupId> 15 21 <artifactId>slf4j-simple</artifactId> 16 22 <version>${slf4j.version}</version> 17 23 <scope>runtime</scope> 18 24 </dependency> 25 <dependency> 26 <groupId>javax.servlet</groupId> 27 <artifactId>servlet-api</artifactId> 28 <version>2.4</version> 29 <scope>provided</scope> 30 </dependency> 19 31 </dependencies> 20 32 <parent> 21 33 <groupId>net.fckeditor</groupId> -
java-demo/src/main/java/net/fckeditor/sample/spring/FCKEditorConnector.java
1 package net.fckeditor.sample.spring; 2 3 import java.io.InputStream; 4 import java.util.List; 5 import java.util.Map; 6 7 import javax.servlet.ServletContext; 8 9 import net.fckeditor.connector.Connector; 10 import net.fckeditor.connector.exception.FolderAlreadyExistsException; 11 import net.fckeditor.connector.exception.InvalidCurrentFolderException; 12 import net.fckeditor.connector.exception.InvalidNewFolderNameException; 13 import net.fckeditor.connector.exception.ReadException; 14 import net.fckeditor.connector.exception.WriteException; 15 import net.fckeditor.connector.impl.AbstractLocalFileSystemConnector; 16 import net.fckeditor.handlers.ResourceType; 17 18 /** 19 * This example will upload files to /spring_connector in the server root 20 * directory 21 * @author whiteda 22 * 23 */ 24 public class FCKEditorConnector extends AbstractLocalFileSystemConnector { 25 public static final String USER_PATH = "/spring_connector"; 26 @Override 27 protected String getRealUserFilesAbsolutePath(String path) { 28 return USER_PATH+path; 29 } 30 31 public void init(ServletContext servletContext) throws Exception { 32 this.servletContext = servletContext; 33 } 34 35 } -
java-demo/src/main/webapp/jsp/sample06.config.js
41 41 var sOtherPluginPath = FCKConfig.BasePath.substr(0, FCKConfig.BasePath.length - 7) + 'editor/plugins/' ; 42 42 FCKConfig.Plugins.Add( 'placeholder', 'en,it', sOtherPluginPath ) ; 43 43 //FCKConfig.Plugins.Add( 'tablecommands', 'en,it', sOtherPluginPath ) ; 44 45 FCKConfig.ImageUpload = true ; 46 FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ; 47 FCKConfig.ImageUploadAllowedExtensions = ".(jpg|gif|jpeg|png|bmp)$" ; // empty for all 48 FCKConfig.ImageUploadDeniedExtensions = "" ; 49 No newline at end of file -
java-demo/src/main/webapp/jsp/sample08.jsp
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <%@ page language="java" contentType="text/html; charset=UTF-8" 3 pageEncoding="UTF-8" %> 4 <%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %> 5 <%-- 6 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 7 * Copyright (C) 2004-2009 Frederico Caldeira Knabben 8 * 9 * == BEGIN LICENSE == 10 * 11 * Licensed under the terms of any of the following licenses at your 12 * choice: 13 * 14 * - GNU General Public License Version 2 or later (the "GPL") 15 * http://www.gnu.org/licenses/gpl.html 16 * 17 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 18 * http://www.gnu.org/licenses/lgpl.html 19 * 20 * - Mozilla Public License Version 1.1 or later (the "MPL") 21 * http://www.mozilla.org/MPL/MPL-1.1.html 22 * 23 * == END LICENSE == 24 * @version: $Id: sample07.jsp 2869 2009-01-09 22:01:33Z mosipov $ 25 --%> 26 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 27 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 28 <html xmlns="http://www.w3.org/1999/xhtml"> 29 <head> 30 <title>FCKeditor - Sample</title> 31 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 32 <meta name="robots" content="noindex, nofollow" /> 33 <link href="../sample.css" rel="stylesheet" type="text/css" /> 34 <link rel="shortcut icon" href="../fckeditor.gif" 35 type="image/x-icon" /> 36 <script type="text/javascript"> 37 function FCKeditor_OnComplete(editorInstance) { 38 window.status = editorInstance.Description; 39 } 40 </script> 41 </head><body> 42 <h1>FCKeditor - JSP - Sample 8</h1> 43 In this sample the user can upload images to the server using the sample 44 Spring based connector FCKEditorConnector. Images 45 will be stored in the server root at /spring_connector/userfiles/image. 46 <hr /> 47 <form action="sampleposteddata.jsp" method="post" target="_blank"> 48 <FCK:editor instanceName="EditorDefault"> 49 <jsp:attribute name="value"> 50 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 51 <html> 52 <head> 53 <title>Full Page Test</title> 54 <meta content="text/html; charset=utf-8" 55 http-equiv="Content-Type"/> 56 </head> 57 <body>This is some <strong>sample text</strong>. You are 58 using <a href="http://www.fckeditor.net/">FCKeditor 59 </a>. 60 </body> 61 </html> 62 </jsp:attribute> 63 <jsp:body> 64 <FCK:config FullPage="true"/> 65 </jsp:body> 66 </FCK:editor> 67 <br /> 68 <input type="submit" value="Submit" /> 69 </form> 70 </body> 71 </html> -
java-demo/src/main/webapp/sampleslist.jsp
59 59 support</option> 60 60 <option value="jsp/sample07.jsp">Sample 07: Full Page 61 61 editing</option> 62 <option value="jsp/sample08.jsp">Sample 08: Image upload using Spring Connector</option> 62 63 </select></td> 63 64 </tr> 64 65 </table> -
java-demo/src/main/webapp/WEB-INF/applicationContext.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> 5 6 <bean id="FCKEditorConnectorSample" class="net.fckeditor.sample.spring.FCKEditorConnector"/> 7 8 </beans> -
java-demo/src/main/webapp/WEB-INF/web.xml
5 5 > 6 6 <display-name>FCKeditor.Java Sample Web Application</display-name> 7 7 <description>FCKeditor.Java Sample Web Application</description> 8 9 <context-param> 10 <param-name>FCKEDITOR_SPRING_CONNECTOR</param-name> 11 <param-value>FCKEditorConnectorSample</param-value> 12 </context-param> 8 13 14 <listener> 15 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 16 </listener> 17 9 18 <servlet> 10 <servlet-name> ConnectorServlet</servlet-name>19 <servlet-name>SpringConnectorServlet</servlet-name> 11 20 <servlet-class> 12 net.fckeditor. connector.ConnectorServlet21 net.fckeditor.spring.connector.SpringConnectorServlet 13 22 </servlet-class> 23 <!-- You don`t need to add this init param. By default the servlet 24 will look for a bean named FCKEditorConnector 25 in spring web application context. But if you don`t want the default 26 you can use this init param--> 27 <init-param> 28 <param-name>FCKEDITOR_SPRING_CONNECTOR</param-name> 29 <param-value>FCKEditorConnectorSample</param-value> 30 </init-param> 14 31 <load-on-startup>1</load-on-startup> 15 32 </servlet> 16 33 17 34 <servlet-mapping> 18 <servlet-name> ConnectorServlet</servlet-name>35 <servlet-name>SpringConnectorServlet</servlet-name> 19 36 <!-- Do not wrap this line otherwise Glassfish will fail to load this file --> 20 37 <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern> 21 38 </servlet-mapping> 39 40 <!-- <servlet> 41 <servlet-name>ConnectorServlet</servlet-name> 42 <servlet-class> 43 net.fckeditor.connector.ConnectorServlet 44 </servlet-class> 45 <load-on-startup>1</load-on-startup> 46 </servlet>--> 47 48 <!-- <servlet-mapping> 49 <servlet-name>ConnectorServlet</servlet-name>--> 50 <!-- Do not wrap this line otherwise Glassfish will fail to load this file --> 51 <!--<url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern> 52 </servlet-mapping>--> 22 53 </web-app> 54 No newline at end of file -
pom.xml
1 <project xmlns="http://maven.apache.org/POM/4.0.0" 2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 3 <modelVersion>4.0.0</modelVersion> 5 4 <groupId>net.fckeditor</groupId> 6 5 <artifactId>fckeditor-java</artifactId> … … 9 8 <modules> 10 9 <module>java-core</module> 11 10 <module>java-demo</module> 12 </modules> 11 <module>spring-connector</module> 12 </modules> 13 13 <properties> 14 14 <project.build.sourceEncoding> 15 15 UTF-8 … … 126 126 </goals> 127 127 <configuration> 128 128 <tasks> 129 <copy overwrite="true" todir="src/site" 130 flatten="true"> 129 <copy overwrite="true" todir="src/site" flatten="true"> 131 130 <fileset dir=".."> 132 <include 133 name="src/site/site.xml" /> 131 <include name="src/site/site.xml"/> 134 132 </fileset> 135 133 </copy> 136 <replace value="<src>../" 137 token="<src>/" dir=".."> 138 <include 139 name="${pom.artifactId}/src/site/site.xml" /> 140 <exclude 141 name="fckeditor-java/src/site/site.xml" /> 134 <replace value="<src>../" token="<src>/" dir=".."> 135 <include name="${pom.artifactId}/src/site/site.xml"/> 136 <exclude name="fckeditor-java/src/site/site.xml"/> 142 137 </replace> 143 <replace value="href="../" 144 token="href="/" dir=".."> 145 <include 146 name="${pom.artifactId}/src/site/site.xml" /> 147 <exclude 148 name="fckeditor-java/src/site/site.xml" /> 138 <replace value="href="../" token="href="/" dir=".."> 139 <include name="${pom.artifactId}/src/site/site.xml"/> 140 <exclude name="fckeditor-java/src/site/site.xml"/> 149 141 </replace> 150 <replace value="href="" 151 token="href="../${pom.artifactId}/" dir=".."> 152 <include 153 name="${pom.artifactId}/src/site/site.xml" /> 154 <exclude 155 name="fckeditor-java/src/site/site.xml" /> 142 <replace value="href="" token="href="../${pom.artifactId}/" dir=".."> 143 <include name="${pom.artifactId}/src/site/site.xml"/> 144 <exclude name="fckeditor-java/src/site/site.xml"/> 156 145 </replace> 157 <replace value="href="../images" 158 token="href="images" dir=".."> 159 <include 160 name="${pom.artifactId}/src/site/site.xml" /> 161 <exclude 162 name="fckeditor-java/src/site/site.xml" /> 146 <replace value="href="../images" token="href="images" dir=".."> 147 <include name="${pom.artifactId}/src/site/site.xml"/> 148 <exclude name="fckeditor-java/src/site/site.xml"/> 163 149 </replace> 164 150 </tasks> 165 151 </configuration> -
spring-connector/pom.xml
1 <?xml version="1.0"?><project> 2 <parent> 3 <artifactId>fckeditor-java</artifactId> 4 <groupId>net.fckeditor</groupId> 5 <version>2.5-SNAPSHOT</version> 6 </parent> 7 8 <modelVersion>4.0.0</modelVersion> 9 <artifactId>spring-connector</artifactId> 10 <name>spring-connector</name> 11 12 <url>http://maven.apache.org</url> 13 <dependencies> 14 <dependency> 15 <groupId>junit</groupId> 16 <artifactId>junit</artifactId> 17 <version>3.8.1</version> 18 <scope>test</scope> 19 </dependency> 20 <dependency> 21 <groupId>org.springframework</groupId> 22 <artifactId>spring</artifactId> 23 <version>2.5.1</version> 24 </dependency> 25 <dependency> 26 <groupId>javax.servlet</groupId> 27 <artifactId>servlet-api</artifactId> 28 <version>2.4</version> 29 <scope>provided</scope> 30 </dependency> 31 <dependency> 32 <groupId>net.fckeditor</groupId> 33 <artifactId>java-core</artifactId> 34 <version>2.5-SNAPSHOT</version> 35 <classifier>pom</classifier> 36 </dependency> 37 </dependencies> 38 </project> 39 No newline at end of file -
spring-connector/src/main/java/META-INF/MANIFEST.MF
1 Manifest-Version: 1.0 2 Class-Path: 3 -
spring-connector/src/main/java/net/fckeditor/spring/connector/SpringConnectorServlet.java
1 package net.fckeditor.spring.connector; 2 3 import javax.servlet.ServletException; 4 5 import org.slf4j.Logger; 6 import org.slf4j.LoggerFactory; 7 import org.springframework.web.context.WebApplicationContext; 8 import org.springframework.web.context.support.WebApplicationContextUtils; 9 10 import net.fckeditor.connector.Connector; 11 import net.fckeditor.connector.ConnectorServlet; 12 import net.fckeditor.connector.Dispatcher; 13 14 public class SpringConnectorServlet extends ConnectorServlet{ 15 16 private static final long serialVersionUID = 1L; 17 18 private static final Logger logger = LoggerFactory.getLogger(SpringConnectorServlet.class); 19 public static final String FCKEDITOR_SPRING_CONNECTOR_INIT_PARAM = "FCKEDITOR_SPRING_CONNECTOR"; 20 public static final String FCKEDITOR_DEFAULT_CONNECTOR_BEAN_NAME = "FCKEditorConnector"; 21 22 @Override 23 public void init() throws ServletException { 24 try { 25 26 WebApplicationContext ctx = 27 WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); 28 29 //Try to look up the Connector bean name from 30 //web.xml. If it can`t be found then use the default name 31 String connectorBeanName = 32 getInitParameter(FCKEDITOR_SPRING_CONNECTOR_INIT_PARAM); 33 34 Connector connector = null; 35 if(connectorBeanName !=null && connectorBeanName.trim().length()>0){ 36 connector = (Connector)ctx.getBean(connectorBeanName); 37 }else{ 38 connector = (Connector)ctx.getBean(FCKEDITOR_DEFAULT_CONNECTOR_BEAN_NAME); 39 } 40 41 dispatcher = new Dispatcher(connector); 42 } catch (Exception e) { 43 logger.error("Dispatcher could not be initialized", e); 44 throw new ServletException(e); 45 } 46 } 47 } -
spring-connector/src/test/java/net/fckeditor/AppTest.java
1 package net.fckeditor; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 7 /** 8 * Unit test for simple App. 9 */ 10 public class AppTest 11 extends TestCase 12 { 13 /** 14 * Create the test case 15 * 16 * @param testName name of the test case 17 */ 18 public AppTest( String testName ) 19 { 20 super( testName ); 21 } 22 23 /** 24 * @return the suite of tests being tested 25 */ 26 public static Test suite() 27 { 28 return new TestSuite( AppTest.class ); 29 } 30 31 /** 32 * Rigourous Test :-) 33 */ 34 public void testApp() 35 { 36 assertTrue( true ); 37 } 38 }