Changeset 1905

Show
Ignore:
Timestamp:
2008-04-10 17:32:00 (4 months ago)
Author:
th-schwarz
Message:

solved rewrite/restructure SessionData, svn:2081

Location:
FCKeditor.Java/branches/2.4
Files:
6 added
2 removed
7 modified
1 moved

Legend:

Unmodified
Added
Removed
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/connector/ConnectorServlet.java

    r1720 r1905  
    3434import net.fckeditor.handlers.ConnectorHandler; 
    3535import net.fckeditor.handlers.ExtensionsHandler; 
     36import net.fckeditor.handlers.RequestCycleHandler; 
    3637import net.fckeditor.handlers.ResourceTypeHandler; 
    37 import net.fckeditor.handlers.SessionDataHandler; 
    3838import net.fckeditor.response.UploadResponse; 
    3939import net.fckeditor.response.XmlResponse; 
     
    113113                XmlResponse xr; 
    114114 
    115                 if (!SessionDataHandler.isEnabledForFileBrowsing(request)) 
     115                if (!RequestCycleHandler.isEnabledForFileBrowsing(request)) 
    116116                        xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.NOT_AUTHORIZED_FOR_BROWSING); 
    117117                else if (!CommandHandler.isValidForGet(commandStr)) 
     
    209209                } 
    210210 
    211                 if (!SessionDataHandler.isEnabledForFileUpload(request)) 
     211                if (!RequestCycleHandler.isEnabledForFileUpload(request)) 
    212212                        ur = new UploadResponse(UploadResponse.EN_SECURITY_ERROR, null, null, 
    213213                                Messages.NOT_AUTHORIZED_FOR_UPLOAD); 
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/connector/Messages.java

    • Property svn:keywords set to Id
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/FCKeditorConfig.java

    • Property svn:keywords set to Id
    r1537 r1905  
    3737 * the config.js file. 
    3838 *  
    39  * @version $Id: FCKeditorConfig.java 1444 2008-01-28 16:53:01Z mosipov $ 
     39 * @version $Id$ 
    4040 */ 
    4141public class FCKeditorConfig extends HashMap<String, String> { 
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/handlers/CommandHandler.java

    • Property svn:keywords set to Id
    r1653 r1905  
    2727 * Handler for the get and post commands. 
    2828 *  
    29  * @version $Id: ResourceTypeHandler.java 1606 2008-02-24 17:07:52Z th-schwarz $ 
     29 * @version $Id$ 
    3030 */ 
    3131public class CommandHandler { 
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java

    r1881 r1905  
    2323import javax.servlet.http.HttpServletRequest; 
    2424 
    25 import net.fckeditor.SessionData; 
     25import net.fckeditor.requestcycle.UserPathBuilder; 
    2626 
    2727/** 
    28  * Handler for some base properties. 
     28 * Handler for some base properties.<br> 
     29 * It's a kind of wrapper to some basic properties handled by the {@link PropertiesLoader}. 
    2930 *  
    3031 * @version $Id$ 
     
    3536     * Getter for the base dir (using for user files). 
    3637     *  
    37      * @return {@link SessionData#getUserFilesPath(HttpServletRequest)} or the default base dir, if 
    38      *         {@link SessionData}} isn't set. 
     38     * @return {@link UserPathBuilder#getUserFilesPath(HttpServletRequest)} or the default base dir, if 
     39     *         {@link UserPathBuilder}} isn't set. 
    3940     */ 
    4041    public static String getUserFilesPath(final HttpServletRequest servletRequest) { 
    41         String userFilePath = SessionDataHandler.getUserFilePath(servletRequest); 
     42        String userFilePath = RequestCycleHandler.getUserFilePath(servletRequest); 
    4243        return (userFilePath != null) ? userFilePath : getDefaultUserFilesPath(); 
    4344    } 
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/handlers/RequestCycleHandler.java

    r1682 r1905  
    2323import javax.servlet.http.HttpServletRequest; 
    2424 
     25import net.fckeditor.requestcycle.UserAction; 
     26import net.fckeditor.requestcycle.UserPathBuilder; 
     27 
    2528import org.slf4j.Logger; 
    2629import org.slf4j.LoggerFactory; 
    2730 
    28 import net.fckeditor.SessionData; 
    29  
    3031/** 
    31  * Handler for session based data provided by {@link SessionData}. 
     32 * Handler for classes which implement the interfaces from the package 
     33 * {@link net.fckeditor.requestcycle}. 
    3234 *  
    3335 * @version $Id$ 
    3436 */ 
    35 public class SessionDataHandler { 
    36         private static Logger logger = LoggerFactory.getLogger(SessionDataHandler.class); 
    37         private static SessionData sessionData = null; 
     37public class RequestCycleHandler { 
     38        private static Logger logger = LoggerFactory.getLogger(RequestCycleHandler.class); 
     39        private static UserAction userAction = null; 
     40        private static UserPathBuilder userPathBuilder = null; 
    3841 
    3942        static { 
    40                 // try to instanciate the SessionData object 
    41                 String fqcn = PropertiesLoader.getProperty("connector.sessionDataImpl"); 
     43                // If there are more objects to instantiate in future, we could solve the following by reflection! 
     44                 
     45                // 1. try to instantiate the UserAction object 
     46                String fqcn = PropertiesLoader.getProperty("requestcycle.userActionImpl"); 
    4247                if (fqcn == null) 
    43                         logger.warn("No property found for SessionData implementation, any user action is disabled!"); 
     48                        logger.warn("No property found for UserAction implementation, any user action is disabled!"); 
    4449                else { 
    4550                        try { 
    4651                                @SuppressWarnings("unchecked") 
    4752                                Class clazz = Class.forName(fqcn); 
    48                                 sessionData = (SessionData) clazz.newInstance(); 
    49                                 logger.info("SessionData object successfull instanciated!"); 
     53                                userAction = (UserAction) clazz.newInstance(); 
     54                                logger.info("UserAction object successful instanciated!"); 
    5055                        } catch (Exception e) { 
    5156                                logger.error("Couldn't instanciate the class [".concat(fqcn).concat( 
     
    5358                        } 
    5459                } 
     60 
     61                // 2. try to instantiate the UserPathBuilder object 
     62                fqcn = PropertiesLoader.getProperty("requestcycle.userPathBuilderImpl"); 
     63                if (fqcn == null) 
     64                        logger.warn("No property found for UserPathBuilder implementation, any user action is disabled!"); 
     65                else { 
     66                        try { 
     67                                @SuppressWarnings("unchecked") 
     68                                Class clazz = Class.forName(fqcn); 
     69                                userPathBuilder = (UserPathBuilder) clazz.newInstance(); 
     70                                logger.info("UserPathBuilder object successfull instanciated!"); 
     71                        } catch (Exception e) { 
     72                                logger.error("Couldn't instanciate the class [" 
     73                                                .concat(fqcn) 
     74                                        .concat("], The default of users's 'BaseDir' will be used in the ConnectorServlet!"), e); 
     75                        } 
     76                } 
    5577        } 
    5678 
    5779        /** 
    58          * Just a wrapper to {@link SessionData#isEnabledForFileBrowsing(HttpServletRequest)}. 
     80         * Just a wrapper to {@link UserAction#isEnabledForFileBrowsing(HttpServletRequest)}. 
    5981         *  
    6082         * @param servletRequest 
    61          * @return {@link SessionData#isEnabledForFileBrowsing(HttpServletRequest)} or false, if 
     83         * @return {@link UserAction#isEnabledForFileBrowsing(HttpServletRequest)} or false, if 
    6284         *         sessionData isn't set. 
    6385         */ 
    6486        public static boolean isEnabledForFileBrowsing(final HttpServletRequest servletRequest) { 
    65                 return (sessionData != null && sessionData.isEnabledForFileBrowsing(servletRequest)); 
     87                return (userAction != null && userAction.isEnabledForFileBrowsing(servletRequest)); 
    6688        } 
    6789 
    6890        /** 
    69          * Just a wrapper to {@link SessionData#isEnabledForFileUpload(HttpServletRequest)}. 
     91         * Just a wrapper to {@link UserAction#isEnabledForFileUpload(HttpServletRequest)}. 
    7092         *  
    7193         * @param request 
    72          * @return {@link SessionData#isEnabledForFileUpload(HttpServletRequest)} or false, if 
    73          *         sessionData isn't set. 
     94         * @return {@link UserAction#isEnabledForFileUpload(HttpServletRequest)} or false, if userAction 
     95         *         isn't set. 
    7496         */ 
    7597        public static boolean isEnabledForFileUpload(final HttpServletRequest request) { 
    76                 return (sessionData != null && sessionData.isEnabledForFileUpload(request)); 
     98                return (userAction != null && userAction.isEnabledForFileUpload(request)); 
    7799        } 
    78100 
     
    82104         *  
    83105         * @param request 
    84          * @return {@link SessionData#getUserFilesPath(HttpServletRequest)} or null, if sessionData is 
    85          *         null. 
     106         * @return {@link UserPathBuilder#getUserFilesPath(HttpServletRequest)} or null, if 
     107         *         userPathBuilder is null. 
    86108         */ 
    87109        protected static String getUserFilePath(final HttpServletRequest request) { 
    88                 return (sessionData != null) ? sessionData.getUserFilesPath(request) : null; 
     110                return (userPathBuilder != null) ? userPathBuilder.getUserFilesPath(request) : null; 
    89111        } 
    90112} 
  • FCKeditor.Java/branches/2.4/java-core/src/main/java/net/fckeditor/tags/CheckTag.java

    • Property svn:keywords set to Id
    r1843 r1905  
    3232 
    3333import net.fckeditor.handlers.PropertiesLoader; 
    34 import net.fckeditor.handlers.SessionDataHandler; 
     34import net.fckeditor.handlers.RequestCycleHandler; 
    3535import net.fckeditor.tool.Compatibility; 
    3636 
     
    7878 
    7979                if (command.equals(FILE_UPLOAD)) { 
    80                         if (SessionDataHandler.isEnabledForFileUpload(request)) 
     80                        if (RequestCycleHandler.isEnabledForFileUpload(request)) 
    8181                                response = PropertiesLoader 
    8282                                        .getProperty(CheckTag.PROPERTY_MESSAGE_FILE_UPLOAD_ENABLED); 
     
    8787 
    8888                if (command.equals(FILE_BROWSING)) { 
    89                         if (SessionDataHandler.isEnabledForFileBrowsing(request)) 
     89                        if (RequestCycleHandler.isEnabledForFileBrowsing(request)) 
    9090                                response = PropertiesLoader 
    9191                                        .getProperty(CheckTag.PROPERTY_MESSAGE_FILE_BROWSING_ENABLED); 
  • FCKeditor.Java/branches/2.4/java-demo/src/main/resources/fckeditor.properties

    • Property svn:keywords set to Id
    r1785 r1905  
    1 connector.sessionDataImpl=net.fckeditor.impl.BasicSessionData 
     1requestcycle.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl 
     2requestcycle.userPathBuilderImpl=net.fckeditor.requestcycle.impl.UserPathBuilderImpl