[pal-cvs 3500] [1234] added admin tool, and added security constraint filter.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 24日 (金) 12:30:26 JST


Revision: 1234
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=1234
Author:   shinsuke
Date:     2008-10-24 12:30:25 +0900 (Fri, 24 Oct 2008)

Log Message:
-----------
added admin tool, and added security constraint filter.

Modified Paths:
--------------
    board/trunk/.classpath
    board/trunk/pom.xml
    board/trunk/src/main/java/jp/sf/pal/board/BoardConstants.java
    board/trunk/src/main/java/jp/sf/pal/board/action/message/AdminAction.java
    board/trunk/src/main/java/jp/sf/pal/board/action/message/ViewAction.java
    board/trunk/src/main/resources/application.properties
    board/trunk/src/main/resources/convention.dicon
    board/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml
    board/trunk/src/main/webapp/WEB-INF/portlet.xml
    board/trunk/src/main/webapp/WEB-INF/web.xml

Added Paths:
-----------
    board/trunk/src/main/java/jp/sf/pal/board/action/ConfigAction.java
    board/trunk/src/main/java/jp/sf/pal/board/common/filter/
    board/trunk/src/main/java/jp/sf/pal/board/common/filter/SecurityConstraintFilter.java
    board/trunk/src/main/java/jp/sf/pal/board/common/util/ConfigUtil.java
    board/trunk/src/main/java/jp/sf/pal/board/form/ConfigForm.java
    board/trunk/src/main/webapp/WEB-INF/board.xml
    board/trunk/src/main/webapp/WEB-INF/view/config/
    board/trunk/src/main/webapp/WEB-INF/view/config/index.jsp


-------------- next part --------------
Modified: board/trunk/.classpath
===================================================================
--- board/trunk/.classpath	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/.classpath	2008-10-24 03:30:25 UTC (rev 1234)
@@ -9,6 +9,8 @@
   <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar" sourcepath="M2_REPO/javax/servlet/jstl/1.1.2/jstl-1.1.2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/taglibs/standard/1.1.2/standard-1.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-configuration/commons-configuration/1.5/commons-configuration-1.5.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0.jar" sourcepath="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.3/commons-io-1.3.jar"/>
@@ -16,7 +18,6 @@
   <classpathentry kind="var" path="M2_REPO/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar" sourcepath="M2_REPO/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/commons-digester/commons-digester/1.6/commons-digester-1.6.jar" sourcepath="M2_REPO/commons-digester/commons-digester/1.6/commons-digester-1.6-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/2.1/commons-collections-2.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/oro/oro/2.0.8/oro-2.0.8.jar" sourcepath="M2_REPO/oro/oro/2.0.8/oro-2.0.8-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar" sourcepath="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13-sources.jar"/>

Modified: board/trunk/pom.xml
===================================================================
--- board/trunk/pom.xml	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/pom.xml	2008-10-24 03:30:25 UTC (rev 1234)
@@ -117,6 +117,16 @@
       <version>1.1.2</version>
     </dependency>
     <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.2</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+      <version>1.5</version>
+    </dependency>
+    <dependency>
       <groupId>commons-el</groupId>
       <artifactId>commons-el</artifactId>
       <version>1.0</version>

Modified: board/trunk/src/main/java/jp/sf/pal/board/BoardConstants.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/BoardConstants.java	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/java/jp/sf/pal/board/BoardConstants.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -56,4 +56,12 @@
 
     public static final Integer DEFAULT_CATEGORY_ID = Integer.valueOf(1);
 
+    public static final String MESSAGE_MAX_LENGTH = "message.max-length";
+
+    public static final String REPLY_MAX_LENGTH = "reply.max-length";
+
+    public static final String MESSAGE_EDITABLE_ON_PUBLIC = "message.editable-on-public";
+
+    public static final String MESSAGE_ATTACHMENT_SIZE = "message.attachment-size";
+
 }

Added: board/trunk/src/main/java/jp/sf/pal/board/action/ConfigAction.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/action/ConfigAction.java	                        (rev 0)
+++ board/trunk/src/main/java/jp/sf/pal/board/action/ConfigAction.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,86 @@
+package jp.sf.pal.board.action;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpServletRequest;
+
+import jp.sf.pal.board.BoardConstants;
+import jp.sf.pal.board.common.util.ConfigUtil;
+import jp.sf.pal.board.common.util.SAStrutsUtil;
+import jp.sf.pal.board.form.ConfigForm;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.seasar.struts.annotation.ActionForm;
+import org.seasar.struts.annotation.Execute;
+import org.seasar.struts.exception.ActionMessagesException;
+
+public class ConfigAction implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Log log = LogFactory.getLog(ConfigAction.class);
+
+    @ActionForm
+    private ConfigForm configForm;
+
+    private transient HttpServletRequest request;
+
+    protected String displayIndex() {
+        configForm.messageMaxLength = ConfigUtil.getString(
+                BoardConstants.MESSAGE_MAX_LENGTH, "4000");
+        configForm.replyMaxLength = ConfigUtil.getString(
+                BoardConstants.REPLY_MAX_LENGTH, "4000");
+        configForm.messageEditableOnPublic = ConfigUtil.getString(
+                BoardConstants.MESSAGE_EDITABLE_ON_PUBLIC, "true");
+        configForm.messageAttachmentSize = ConfigUtil.getString(
+                BoardConstants.MESSAGE_ATTACHMENT_SIZE, "10000000");
+        return "index.jsp";
+    }
+
+    @Execute(validator = false, input = "index.jsp")
+    public String index() {
+        ConfigUtil.init(request);
+        return displayIndex();
+    }
+
+    @Execute(validator = false, input = "index.jsp")
+    public String update() {
+        ConfigUtil.init(request);
+        ConfigUtil.setProperty(BoardConstants.MESSAGE_MAX_LENGTH,
+                configForm.messageMaxLength);
+        ConfigUtil.setProperty(BoardConstants.REPLY_MAX_LENGTH,
+                configForm.replyMaxLength);
+        ConfigUtil.setProperty(BoardConstants.MESSAGE_EDITABLE_ON_PUBLIC,
+                configForm.messageEditableOnPublic);
+        ConfigUtil.setProperty(BoardConstants.MESSAGE_ATTACHMENT_SIZE,
+                configForm.messageAttachmentSize);
+        try {
+            ConfigUtil.save();
+            SAStrutsUtil.addMessage(request, "success.update_config");
+
+            return displayIndex();
+        } catch (ConfigurationException e) {
+            log.error(e.getMessage(), e);
+            throw new ActionMessagesException("errors.failed_to_update_config");
+        }
+    }
+
+    public ConfigForm getConfigForm() {
+        return configForm;
+    }
+
+    public void setConfigForm(ConfigForm configForm) {
+        this.configForm = configForm;
+    }
+
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(HttpServletRequest request) {
+        this.request = request;
+    }
+
+}


Property changes on: board/trunk/src/main/java/jp/sf/pal/board/action/ConfigAction.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: board/trunk/src/main/java/jp/sf/pal/board/action/message/AdminAction.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/action/message/AdminAction.java	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/java/jp/sf/pal/board/action/message/AdminAction.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -12,6 +12,7 @@
 
 import jp.sf.pal.board.BoardConstants;
 import jp.sf.pal.board.common.CommonException;
+import jp.sf.pal.board.common.util.ConfigUtil;
 import jp.sf.pal.board.common.util.SAStrutsUtil;
 import jp.sf.pal.board.db.exentity.Attachment;
 import jp.sf.pal.board.db.exentity.Category;
@@ -86,6 +87,8 @@
 
     @Execute(validator = false, input = "error.jsp")
     public String index() {
+        ConfigUtil.init(request);
+
         checkWritableCategories();
         return createIndex();
     }
@@ -207,6 +210,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String confirm() {
+        if (adminForm.content != null
+                && adminForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         categoryItems = categoryService.getCategoryList(BoardUtil
                 .getCategoryAccessNameList(request), null);
 
@@ -230,6 +242,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String create() {
+        if (adminForm.content != null
+                && adminForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         try {
             Message message = createMessage();
             messageService.store(message);
@@ -247,6 +268,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String update() {
+        if (adminForm.content != null
+                && adminForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         try {
             Message message = createMessage();
             messageService.store(message);
@@ -281,6 +311,15 @@
 
     @Execute(validator = true, input = "error.jsp")
     public String addreply() {
+        if (adminForm.replyContent != null
+                && adminForm.replyContent.length() > ConfigUtil.getInt(
+                        BoardConstants.REPLY_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.reply_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.REPLY_MAX_LENGTH, 4000) });
+        }
+
         try {
             Reply reply = createReply();
             messageService.store(reply);
@@ -347,6 +386,13 @@
                     "errors.failed_to_upload_attachment_because_of_null");
         }
 
+        if (adminForm.attachmentFile.getFileSize() > ConfigUtil.getInt(
+                BoardConstants.MESSAGE_ATTACHMENT_SIZE, 10000000)) {
+            throw new ActionMessagesException("errors.maxuploadsize",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_ATTACHMENT_SIZE, 10000000) });
+        }
+
         String username = request.getRemoteUser();
         try {
             Attachment attachment = new Attachment();

Modified: board/trunk/src/main/java/jp/sf/pal/board/action/message/ViewAction.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/action/message/ViewAction.java	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/java/jp/sf/pal/board/action/message/ViewAction.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -12,6 +12,7 @@
 
 import jp.sf.pal.board.BoardConstants;
 import jp.sf.pal.board.common.CommonException;
+import jp.sf.pal.board.common.util.ConfigUtil;
 import jp.sf.pal.board.common.util.SAStrutsUtil;
 import jp.sf.pal.board.db.exentity.Attachment;
 import jp.sf.pal.board.db.exentity.Category;
@@ -87,6 +88,8 @@
 
     @Execute(validator = false, input = "error.jsp")
     public String index() {
+        ConfigUtil.init(request);
+
         checkWritableCategories();
         return createIndex();
     }
@@ -166,6 +169,14 @@
             owner = false;
         }
 
+        if (BoardConstants.MESSAGE_STATUS_PUBLIC.equals(viewForm.status)) {
+            // public
+            if (!ConfigUtil.getBoolean(
+                    BoardConstants.MESSAGE_EDITABLE_ON_PUBLIC, true)) {
+                owner = false;
+            }
+        }
+
         return "confirm.jsp";
     }
 
@@ -218,6 +229,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String confirm() {
+        if (viewForm.content != null
+                && viewForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         categoryItems = categoryService.getCategoryList(BoardUtil
                 .getCategoryAccessNameList(request),
                 BoardConstants.ACCESS_TYPE_VIEW_ONLY);
@@ -243,6 +263,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String create() {
+        if (viewForm.content != null
+                && viewForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         try {
             Message message = createMessage();
             messageService.store(message);
@@ -260,6 +289,15 @@
 
     @Execute(validator = true, input = "edit.jsp")
     public String update() {
+        if (viewForm.content != null
+                && viewForm.content.length() > ConfigUtil.getInt(
+                        BoardConstants.MESSAGE_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.message_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_MAX_LENGTH, 4000) });
+        }
+
         try {
             Message message = createMessage();
             messageService.store(message);
@@ -294,6 +332,15 @@
 
     @Execute(validator = true, input = "error.jsp")
     public String addreply() {
+        if (viewForm.replyContent != null
+                && viewForm.replyContent.length() > ConfigUtil.getInt(
+                        BoardConstants.REPLY_MAX_LENGTH, 4000)) {
+            throw new ActionMessagesException(
+                    "errors.reply_length_is_too_long",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.REPLY_MAX_LENGTH, 4000) });
+        }
+
         try {
             Reply reply = createReply();
             messageService.store(reply);
@@ -371,6 +418,13 @@
                     "errors.failed_to_upload_attachment_because_of_null");
         }
 
+        if (viewForm.attachmentFile.getFileSize() > ConfigUtil.getInt(
+                BoardConstants.MESSAGE_ATTACHMENT_SIZE, 10000000)) {
+            throw new ActionMessagesException("errors.maxuploadsize",
+                    new Object[] { ConfigUtil.getInt(
+                            BoardConstants.MESSAGE_ATTACHMENT_SIZE, 10000000) });
+        }
+
         String username = request.getRemoteUser();
         try {
             Attachment attachment = new Attachment();

Added: board/trunk/src/main/java/jp/sf/pal/board/common/filter/SecurityConstraintFilter.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/common/filter/SecurityConstraintFilter.java	                        (rev 0)
+++ board/trunk/src/main/java/jp/sf/pal/board/common/filter/SecurityConstraintFilter.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,50 @@
+package jp.sf.pal.board.common.filter;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class SecurityConstraintFilter implements Filter {
+    private static final String ACCEPT_URL_PATHS = "acceptUrlPaths";
+
+    private String[] acceptUrlPaths;
+
+    public void init(FilterConfig config) throws ServletException {
+        String value = config.getInitParameter(ACCEPT_URL_PATHS);
+        if (value != null) {
+            acceptUrlPaths = value.split(",");
+        } else {
+            acceptUrlPaths = new String[0];
+        }
+    }
+
+    public void destroy() {
+
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response,
+            FilterChain chain) throws IOException, ServletException {
+        boolean accept = false;
+        HttpServletRequest hRequest = (HttpServletRequest) request;
+        for (int i = 0; i < acceptUrlPaths.length; i++) {
+            String servletPath = hRequest.getServletPath();
+            if (servletPath != null && servletPath.matches(acceptUrlPaths[i])) {
+                accept = true;
+            }
+        }
+        if (accept) {
+            chain.doFilter(request, response);
+        } else {
+            ((HttpServletResponse) response)
+                    .sendError(HttpServletResponse.SC_FORBIDDEN);
+        }
+    }
+
+}


Property changes on: board/trunk/src/main/java/jp/sf/pal/board/common/filter/SecurityConstraintFilter.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: board/trunk/src/main/java/jp/sf/pal/board/common/util/ConfigUtil.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/common/util/ConfigUtil.java	                        (rev 0)
+++ board/trunk/src/main/java/jp/sf/pal/board/common/util/ConfigUtil.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,207 @@
+package jp.sf.pal.board.common.util;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+
+public class ConfigUtil {
+
+    public static final String CONFIG_PATH = "/WEB-INF/board.xml";
+
+    private static XMLConfiguration config;
+
+    public static void init(HttpServletRequest request) {
+        if (config == null) {
+            synchronized (ConfigUtil.class) {
+                if (config == null) {
+                    try {
+                        config = new XMLConfiguration(SAStrutsUtil.getRealPath(
+                                request, CONFIG_PATH));
+                    } catch (ConfigurationException e) {
+                        throw new IllegalStateException(
+                                "Could not load a config file: "
+                                        + SAStrutsUtil.getRealPath(request,
+                                                CONFIG_PATH), e);
+                    }
+                }
+            }
+        }
+    }
+
+    public static void save() throws ConfigurationException {
+        config.save();
+    }
+
+    public static void addProperty(String s, Object obj) {
+        config.addProperty(s, obj);
+    }
+
+    public static void clear() {
+        config.clear();
+    }
+
+    public static void clearProperty(String s) {
+        config.clearProperty(s);
+    }
+
+    public static boolean containsKey(String s) {
+        return config.containsKey(s);
+    }
+
+    public static BigDecimal getBigDecimal(String s, BigDecimal bigdecimal) {
+        return config.getBigDecimal(s, bigdecimal);
+    }
+
+    public static BigDecimal getBigDecimal(String s) {
+        return config.getBigDecimal(s);
+    }
+
+    public static BigInteger getBigInteger(String s, BigInteger biginteger) {
+        return config.getBigInteger(s, biginteger);
+    }
+
+    public static BigInteger getBigInteger(String s) {
+        return config.getBigInteger(s);
+    }
+
+    public static boolean getBoolean(String s, boolean flag) {
+        return config.getBoolean(s, flag);
+    }
+
+    public static Boolean getBoolean(String s, Boolean boolean1) {
+        return config.getBoolean(s, boolean1);
+    }
+
+    public static boolean getBoolean(String s) {
+        return config.getBoolean(s);
+    }
+
+    public static byte getByte(String s, byte byte0) {
+        return config.getByte(s, byte0);
+    }
+
+    public static Byte getByte(String s, Byte byte1) {
+        return config.getByte(s, byte1);
+    }
+
+    public static byte getByte(String s) {
+        return config.getByte(s);
+    }
+
+    public static double getDouble(String s, double d) {
+        return config.getDouble(s, d);
+    }
+
+    public static Double getDouble(String s, Double double1) {
+        return config.getDouble(s, double1);
+    }
+
+    public static double getDouble(String s) {
+        return config.getDouble(s);
+    }
+
+    public static float getFloat(String s, float f) {
+        return config.getFloat(s, f);
+    }
+
+    public static Float getFloat(String s, Float float1) {
+        return config.getFloat(s, float1);
+    }
+
+    public static float getFloat(String s) {
+        return config.getFloat(s);
+    }
+
+    public static int getInt(String s, int i) {
+        return config.getInt(s, i);
+    }
+
+    public static int getInt(String s) {
+        return config.getInt(s);
+    }
+
+    public static Integer getInteger(String s, Integer integer) {
+        return config.getInteger(s, integer);
+    }
+
+    public static Iterator getKeys() {
+        return config.getKeys();
+    }
+
+    public static Iterator getKeys(String s) {
+        return config.getKeys(s);
+    }
+
+    public static List getList(String s, List list) {
+        return config.getList(s, list);
+    }
+
+    public static List getList(String s) {
+        return config.getList(s);
+    }
+
+    public static long getLong(String s, long l) {
+        return config.getLong(s, l);
+    }
+
+    public static Long getLong(String s, Long long1) {
+        return config.getLong(s, long1);
+    }
+
+    public static long getLong(String s) {
+        return config.getLong(s);
+    }
+
+    public static Properties getProperties(String s) {
+        return config.getProperties(s);
+    }
+
+    public static Object getProperty(String s) {
+        return config.getProperty(s);
+    }
+
+    public static short getShort(String s, short word0) {
+        return config.getShort(s, word0);
+    }
+
+    public static Short getShort(String s, Short short1) {
+        return config.getShort(s, short1);
+    }
+
+    public static short getShort(String s) {
+        return config.getShort(s);
+    }
+
+    public static String getString(String s, String s1) {
+        return config.getString(s, s1);
+    }
+
+    public static String getString(String s) {
+        return config.getString(s);
+    }
+
+    public static String[] getStringArray(String s) {
+        return config.getStringArray(s);
+    }
+
+    public static boolean isEmpty() {
+        return config.isEmpty();
+    }
+
+    public static void setProperty(String s, Object obj) {
+        config.setProperty(s, obj);
+    }
+
+    public static Configuration subset(String s) {
+        return config.subset(s);
+    }
+
+}


Property changes on: board/trunk/src/main/java/jp/sf/pal/board/common/util/ConfigUtil.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: board/trunk/src/main/java/jp/sf/pal/board/form/ConfigForm.java
===================================================================
--- board/trunk/src/main/java/jp/sf/pal/board/form/ConfigForm.java	                        (rev 0)
+++ board/trunk/src/main/java/jp/sf/pal/board/form/ConfigForm.java	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,26 @@
+package jp.sf.pal.board.form;
+
+import java.io.Serializable;
+
+import org.seasar.struts.annotation.IntegerType;
+import org.seasar.struts.annotation.Required;
+
+public class ConfigForm implements Serializable {
+
+    private static final long serialVersionUID = 1089309559852652620L;
+
+    @Required(target = "update")
+    @IntegerType
+    public String messageMaxLength;
+
+    @Required(target = "update")
+    @IntegerType
+    public String replyMaxLength;
+
+    @Required(target = "update")
+    public String messageEditableOnPublic;
+
+    @Required(target = "update")
+    @IntegerType
+    public String messageAttachmentSize;
+}


Property changes on: board/trunk/src/main/java/jp/sf/pal/board/form/ConfigForm.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: board/trunk/src/main/resources/application.properties
===================================================================
--- board/trunk/src/main/resources/application.properties	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/resources/application.properties	2008-10-24 03:30:25 UTC (rev 1234)
@@ -78,6 +78,7 @@
 labels.display_name2=Addressor
 labels.update_time=Updated Time
 
+success.update_config=Updated configuration.
 success.create_category=Created a category information.
 success.update_category=Updated the category information.
 success.delete_category=Deleted the category information.
@@ -94,6 +95,7 @@
 success.create_message_attachment=Created the attachment.
 success.delete_message_attachment=Deleted the attachment.
 
+errors.failed_to_update_config=Failed to update the configuration.
 errors.invalid.mode=Invalid mode(expected value is {0}, but it's {1}).
 errors.failed_to_create_category=Failed to create a new category information.
 errors.failed_to_update_category=Failed to update the category information.
@@ -122,3 +124,6 @@
 errors.failed_to_download_attachment=Failed to download the file.
 errors.failed_to_download_attachment_because_of_null=Failed to download the file. Could not find it.
 errors.failed_to_delete_message_attachment=Failed to delete the attachment.
+errors.message_length_is_too_long=The message length is too long. (Max lenght: {0})
+errors.reply_length_is_too_long=The reply length is too long. (Max lenght: {0})
+errors.maxuploadsize=The size of the upload file can not be greater than {0} bytes.

Modified: board/trunk/src/main/resources/convention.dicon
===================================================================
--- board/trunk/src/main/resources/convention.dicon	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/resources/convention.dicon	2008-10-24 03:30:25 UTC (rev 1234)
@@ -9,5 +9,8 @@
 		<initMethod name="addIgnorePackageName">
 			<arg>"jp.sf.pal.board.db"</arg>
 		</initMethod>
+		<initMethod name="addIgnorePackageName">
+			<arg>"jp.sf.pal.board.common.util"</arg>
+		</initMethod>
 	</component>
 </components>

Added: board/trunk/src/main/webapp/WEB-INF/board.xml
===================================================================
--- board/trunk/src/main/webapp/WEB-INF/board.xml	                        (rev 0)
+++ board/trunk/src/main/webapp/WEB-INF/board.xml	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+<message>
+<editable-on-public>true</editable-on-public>
+<attachment-size>10000000</attachment-size>
+<max-length>4000</max-length>
+</message>
+<reply>
+<max-length>4000</max-length>
+</reply>
+</configuration>


Property changes on: board/trunk/src/main/webapp/WEB-INF/board.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: board/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml
===================================================================
--- board/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml	2008-10-24 03:30:25 UTC (rev 1234)
@@ -26,6 +26,10 @@
     <portlet-name>MessageAdmin</portlet-name>
     <js:security-constraint-ref>admin</js:security-constraint-ref>
   </portlet>
+  <portlet>
+    <portlet-name>BoardConfig</portlet-name>
+    <js:security-constraint-ref>admin</js:security-constraint-ref>
+  </portlet>
   <js:services>
     <js:service name="SecurityProvider"/>
     <!--

Modified: board/trunk/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- board/trunk/src/main/webapp/WEB-INF/portlet.xml	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/webapp/WEB-INF/portlet.xml	2008-10-24 03:30:25 UTC (rev 1234)
@@ -88,6 +88,28 @@
       <keywords>Board,Message</keywords>
     </portlet-info>
   </portlet>
+  <portlet>
+    <portlet-name>BoardConfig</portlet-name>
+    <display-name>Board: Board Configuration</display-name>
+    <description>Edit configurations.</description>
+    <portlet-class>org.seasar.struts.portlet.SAStrutsPortlet</portlet-class>
+    <init-param>
+      <name>viewPage</name>
+      <value>/config/</value>
+    </init-param>
+    <expiration-cache>0</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <supported-locale>ja</supported-locale>
+    <portlet-info>
+      <title>Board Configuration</title>
+      <short-title>Config</short-title>
+      <keywords>Board,URL</keywords>
+    </portlet-info>
+  </portlet>
   <user-attribute>
     <description>Given name</description>
     <name>user.name.given</name>

Added: board/trunk/src/main/webapp/WEB-INF/view/config/index.jsp
===================================================================
--- board/trunk/src/main/webapp/WEB-INF/view/config/index.jsp	                        (rev 0)
+++ board/trunk/src/main/webapp/WEB-INF/view/config/index.jsp	2008-10-24 03:30:25 UTC (rev 1234)
@@ -0,0 +1,49 @@
+<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+<title></title>
+</head>
+<body>
+<div style="padding:3px;">
+<div><html:messages id="msg" message="true"><bean:write name="msg" ignore="true"/></html:messages><html:errors/></div>
+<div class="form-table">
+<s:form>
+<table>
+	<caption>設定情報</caption>
+	<tbody>
+		<tr>
+			<th>投稿記事の最大文字数</th>
+			<td><html:text property="messageMaxLength" size="5"/></td>
+		</tr>
+		<tr>
+			<th>返信の最大文字数</th>
+			<td><html:text property="replyMaxLength" size="5"/></td>
+		</tr>
+		<tr>
+			<th>投稿後の編集</th>
+			<td>
+				<html:select property="messageEditableOnPublic">
+<html:option value="true">編集可</html:option>
+<html:option value="false">編集不可</html:option>
+				</html:select>
+			</td>
+		</tr>
+		<tr>
+			<th>添付ファイルの最大サイズ</th>
+			<td><html:text property="messageAttachmentSize" size="8"/> バイト</td>
+		</tr>
+	</tbody>
+	<tfoot>
+		<tr>
+			<td colspan="2">
+<input type="submit" name="update" value="更新"/>
+			</td>
+		</tr>
+	</tfoot>
+</table>
+</s:form>
+</div>
+</div>
+</body>
+</html>


Property changes on: board/trunk/src/main/webapp/WEB-INF/view/config/index.jsp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: board/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- board/trunk/src/main/webapp/WEB-INF/web.xml	2008-10-24 01:17:39 UTC (rev 1233)
+++ board/trunk/src/main/webapp/WEB-INF/web.xml	2008-10-24 03:30:25 UTC (rev 1234)
@@ -15,7 +15,7 @@
  * governing permissions and limitations under the License.
 -->
 <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
-  <display-name>Blog</display-name>
+  <display-name>Message Board</display-name>
   <context-param>
     <param-name>sastruts.VIEW_PREFIX</param-name>
     <param-value>/WEB-INF/view</param-value>
@@ -60,11 +60,23 @@
       <param-value>false</param-value>
     </init-param>
   </filter>
+  <filter>
+    <filter-name>securityConstraintFilter</filter-name>
+    <filter-class>jp.sf.pal.board.common.filter.SecurityConstraintFilter</filter-class>
+    <init-param>
+      <param-name>acceptUrlPaths</param-name>
+      <param-value>/message/view/download/.*</param-value>
+    </init-param>
+  </filter>
   <filter-mapping>
     <filter-name>encodingfilter</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
   <filter-mapping>
+    <filter-name>securityConstraintFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+  <filter-mapping>
     <filter-name>portletRequestFilter</filter-name>
     <url-pattern>/*</url-pattern>
     <dispatcher>INCLUDE</dispatcher>


pal-cvs メーリングリストの案内
Back to archive index