[pal-cvs 3065] CVS-Update: blog/src/java/jp/sf/pal/blog/model committed by tigercat

アーカイブの一覧に戻る

TigerCat tiger****@users*****
2008年 2月 6日 (水) 14:40:49 JST


Update of /cvsroot/pal/blog/src/java/jp/sf/pal/blog/model
In directory sf-cvs:/tmp/cvs-serv31228/java/jp/sf/pal/blog/model

Modified Files:
	BlogComment.java BlogMessage.java 
Log Message:
Changed to output formatted text in comment entries as well as in blog entries.

blog/src/java/jp/sf/pal/blog/model/BlogComment.java 1.10 -> 1.11 (modified)
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/pal/blog/src/java/jp/sf/pal/blog/model/BlogComment.java.diff?r1=1.10&r2=1.11
blog/src/java/jp/sf/pal/blog/model/BlogMessage.java 1.21 -> 1.22 (modified)
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/pal/blog/src/java/jp/sf/pal/blog/model/BlogMessage.java.diff?r1=1.21&r2=1.22

===================================================================
RCS file: blog/src/java/jp/sf/pal/blog/model/BlogComment.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BlogComment.java	2006/06/30 12:29:21	1.10
+++ BlogComment.java	2008/02/06 05:40:49	1.11
@@ -1,259 +1,277 @@
-/*
- * Copyright 2005-2006 The Portal Application Laboratory Team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package jp.sf.pal.blog.model;
-
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import jp.sf.pal.blog.BlogConstants;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.marevol.utils.faces.util.DateFormatUtil;
-
-/**
- * BlogComment generated by hbm2java
- */
-public class BlogComment implements java.io.Serializable
-{
-
-    // Fields    
-
-    /**
-     * 
-     */
-    private static final long serialVersionUID = 562524292609035239L;
-
-    public static final String ID = "id";
-
-    public static final String NAME = "name";
-
-    public static final String EMAIL = "email";
-
-    public static final String URL = "url";
-
-    public static final String MESSAGE = "message";
-
-    public static final String CREATEDTIME = "createdtime";
-
-    private Long id;
-
-    private BlogMessage blogMessage;
-
-    private String name;
-
-    private String email;
-
-    private String url;
-
-    private String message;
-
-    private Date createdtime;
-
-    // Constructors
-
-    /** default constructor */
-    public BlogComment()
-    {
-    }
-
-    /** constructor with id */
-    public BlogComment(Long id)
-    {
-        this.id = id;
-    }
-
-    // Property accessors
-
-    /**
-     * 
-     */
-    public Long getId()
-    {
-        return this.id;
-    }
-
-    public void setId(Long id)
-    {
-        this.id = id;
-    }
-
-    /**
-     * 
-     */
-    public BlogMessage getBlogMessage()
-    {
-        return this.blogMessage;
-    }
-
-    public void setBlogMessage(BlogMessage blogMessage)
-    {
-        this.blogMessage = blogMessage;
-    }
-
-    /**
-     * 
-     */
-    public String getName()
-    {
-        return this.name;
-    }
-
-    public void setName(String name)
-    {
-        this.name = name;
-    }
-
-    /**
-     * 
-     */
-    public String getEmail()
-    {
-        return this.email;
-    }
-
-    public void setEmail(String email)
-    {
-        this.email = email;
-    }
-
-    /**
-     * 
-     */
-    public String getUrl()
-    {
-        if (url != null
-                && (url.startsWith("http://") || url.startsWith("https://")))
-        {
-            return this.url;
-        }
-        return "";
-    }
-
-    public void setUrl(String url)
-    {
-        this.url = url;
-    }
-
-    /**
-     * 
-     */
-    public String getMessage()
-    {
-        return this.message;
-    }
-
-    public void setMessage(String message)
-    {
-        this.message = message;
-    }
-
-    /**
-     * 
-     */
-    public Date getCreatedtime()
-    {
-        return this.createdtime;
-    }
-
-    public void setCreatedtime(Date createdtime)
-    {
-        this.createdtime = createdtime;
-    }
-
-    public Boolean getDeleteEnabled()
-    {
-        String user = FacesContext.getCurrentInstance().getExternalContext()
-                .getRemoteUser();
-        if (user == null)
-        {
-            return Boolean.FALSE;
-        }
-
-        if (user.equals(getBlogMessage().getOwner()))
-        {
-            return Boolean.TRUE;
-        }
-        return Boolean.FALSE;
-
-    }
-
-    public String getFormattedCreatedtime()
-    {
-        return DateFormatUtil.getMediumFormattedDateTime(getCreatedtime());
-    }
-
-    public String getAbbreviatedMessage()
-    {
-        return getAbbreviatedMessage(BlogConstants.DEFAULT_TITLE_MAX_LENGTH);
-    }
-
-    public String getAbbreviatedMessage(int maxLength)
-    {
-        return StringUtils.abbreviate(getMessage(), maxLength);
-    }
-
-    public void setAbbreviatedMessage(String msg)
-    {
-        setMessage(msg);
-    }
-
-    /**
-     * @return Returns the emptyComment.
-     */
-    public boolean isEmptyMessage()
-    {
-        return StringUtils.isEmpty(getMessage());
-    }
-
-    /**
-     * @param emptyComment The emptyComment to set.
-     */
-    public void setEmptyMessage(boolean emptyMessage)
-    {
-    }
-
-    /**
-     * @return Returns the emptyEmail.
-     */
-    public boolean isEmptyEmail()
-    {
-        return StringUtils.isEmpty(getEmail());
-    }
-
-    /**
-     * @param emptyEmail The emptyEmail to set.
-     */
-    public void setEmptyEmail(boolean emptyEmail)
-    {
-    }
-
-    /**
-     * @return Returns the emptyUrl.
-     */
-    public boolean isEmptyUrl()
-    {
-        return StringUtils.isEmpty(getUrl());
-    }
-
-    /**
-     * @param emptyUrl The emptyUrl to set.
-     */
-    public void setEmptyUrl(boolean emptyUrl)
-    {
-    }
-}
+/*
+ * Copyright 2005-2008 The Portal Application Laboratory Team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jp.sf.pal.blog.model;
+
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import jp.sf.pal.blog.BlogConstants;
+import jp.sf.pal.blog.converter.Converter;
+
+import org.apache.commons.lang.StringUtils;
+import org.seasar.framework.container.S2Container;
+import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
+
+import com.marevol.utils.faces.util.DateFormatUtil;
+
+/**
+ * BlogComment generated by hbm2java
+ */
+public class BlogComment implements java.io.Serializable
+{
+
+    // Fields    
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 562524292609035239L;
+
+    public static final String ID = "id";
+
+    public static final String NAME = "name";
+
+    public static final String EMAIL = "email";
+
+    public static final String URL = "url";
+
+    public static final String MESSAGE = "message";
+
+    public static final String CREATEDTIME = "createdtime";
+
+    public static final String DEFAULT_FORMAT_CONVERTER = "TextConverter";
+
+    private Long id;
+
+    private BlogMessage blogMessage;
+
+    private String name;
+
+    private String email;
+
+    private String url;
+
+    private String message;
+
+    private Date createdtime;
+
+    // Constructors
+
+    /** default constructor */
+    public BlogComment()
+    {
+    }
+
+    /** constructor with id */
+    public BlogComment(Long id)
+    {
+        this.id = id;
+    }
+
+    // Property accessors
+
+    /**
+     * 
+     */
+    public Long getId()
+    {
+        return this.id;
+    }
+
+    public void setId(Long id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * 
+     */
+    public BlogMessage getBlogMessage()
+    {
+        return this.blogMessage;
+    }
+
+    public void setBlogMessage(BlogMessage blogMessage)
+    {
+        this.blogMessage = blogMessage;
+    }
+
+    /**
+     * 
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * 
+     */
+    public String getEmail()
+    {
+        return this.email;
+    }
+
+    public void setEmail(String email)
+    {
+        this.email = email;
+    }
+
+    /**
+     * 
+     */
+    public String getUrl()
+    {
+        if (url != null
+                && (url.startsWith("http://") || url.startsWith("https://")))
+        {
+            return this.url;
+        }
+        return "";
+    }
+
+    public void setUrl(String url)
+    {
+        this.url = url;
+    }
+
+    /**
+     * 
+     */
+    public String getMessage()
+    {
+        return this.message;
+    }
+
+    public void setMessage(String message)
+    {
+        this.message = message;
+    }
+
+    /**
+     * 
+     */
+    public Date getCreatedtime()
+    {
+        return this.createdtime;
+    }
+
+    public void setCreatedtime(Date createdtime)
+    {
+        this.createdtime = createdtime;
+    }
+
+    public Boolean getDeleteEnabled()
+    {
+        String user = FacesContext.getCurrentInstance().getExternalContext()
+                .getRemoteUser();
+        if (user == null)
+        {
+            return Boolean.FALSE;
+        }
+
+        if (user.equals(getBlogMessage().getOwner()))
+        {
+            return Boolean.TRUE;
+        }
+        return Boolean.FALSE;
+
+    }
+
+    public String getFormattedMessage()
+    {
+        S2Container container = SingletonS2ContainerFactory.getContainer();
+        Converter converter = (Converter)container
+                .getComponent(DEFAULT_FORMAT_CONVERTER);
+        String formattedMessage = converter.convert(getMessage());
+        if (formattedMessage == null)
+        {
+            return getMessage();
+        }
+        return formattedMessage;
+    }
+
+    public String getFormattedCreatedtime()
+    {
+        return DateFormatUtil.getMediumFormattedDateTime(getCreatedtime());
+    }
+
+    public String getAbbreviatedMessage()
+    {
+        return getAbbreviatedMessage(BlogConstants.DEFAULT_TITLE_MAX_LENGTH);
+    }
+
+    public String getAbbreviatedMessage(int maxLength)
+    {
+        return StringUtils.abbreviate(getMessage(), maxLength);
+    }
+
+    public void setAbbreviatedMessage(String msg)
+    {
+        setMessage(msg);
+    }
+
+    /**
+     * @return Returns the emptyComment.
+     */
+    public boolean isEmptyMessage()
+    {
+        return StringUtils.isEmpty(getMessage());
+    }
+
+    /**
+     * @param emptyComment The emptyComment to set.
+     */
+    public void setEmptyMessage(boolean emptyMessage)
+    {
+    }
+
+    /**
+     * @return Returns the emptyEmail.
+     */
+    public boolean isEmptyEmail()
+    {
+        return StringUtils.isEmpty(getEmail());
+    }
+
+    /**
+     * @param emptyEmail The emptyEmail to set.
+     */
+    public void setEmptyEmail(boolean emptyEmail)
+    {
+    }
+
+    /**
+     * @return Returns the emptyUrl.
+     */
+    public boolean isEmptyUrl()
+    {
+        return StringUtils.isEmpty(getUrl());
+    }
+
+    /**
+     * @param emptyUrl The emptyUrl to set.
+     */
+    public void setEmptyUrl(boolean emptyUrl)
+    {
+    }
+}

===================================================================
RCS file: blog/src/java/jp/sf/pal/blog/model/BlogMessage.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- BlogMessage.java	2008/02/06 03:53:02	1.21
+++ BlogMessage.java	2008/02/06 05:40:49	1.22
@@ -304,77 +304,12 @@
                 Converter converter = (Converter) obj;
                 if (converter.getFormatType().equals(getFormattype()))
                 {
-                    StringBuffer buffer = new StringBuffer();
-                    try
+                    String formattedMessage = converter.convert(getMessage());
+                    if (formattedMessage == null)
                     {
-                        StreamStorage storage;
-                        try
-                        {
-                            storage = new ByteArrayStreamStorageImpl(
-                                    new ByteArrayInputStream(getMessage()
-                                            .getBytes(BlogConstants.UTF_8)),
-                                    BlogConstants.UTF_8);
-                        }
-                        catch (UnsupportedEncodingException e1)
-                        {
-                            log.warn("Unsupported encoding. ", e1);
-                            storage = new ByteArrayStreamStorageImpl(
-                                    new ByteArrayInputStream(getMessage()
-                                            .getBytes()), BlogConstants.UTF_8);
-                        }
-                        converter.getConverter().invoke(storage);
-
-                        BufferedReader r = null;
-                        try
-                        {
-                            r = new BufferedReader(new InputStreamReader(
-                                    storage.getResultInputStream(), storage
-                                            .getEncoding()));
-                            String l = null;
-                            while ((l = r.readLine()) != null)
-                            {
-                                buffer.append(l);
-                                buffer.append("\n");
-                            }
-                        }
-                        catch (UnsupportedEncodingException e)
-                        {
-                            log.warn("Unsupported Encoding. ", e);
-                        }
-                        catch (StreamStorageException e)
-                        {
-                            log.warn("Stream Storage Exception. ", e);
-                        }
-                        catch (IOException e)
-                        {
-                            log.error("I/O Exception. ", e);
-                        }
-                        finally
-                        {
-                            if (r != null)
-                            {
-                                try
-                                {
-                                    r.close();
-                                }
-                                catch (IOException e)
-                                {
-                                }
-                            }
-                        }
-                        storage.destroy();
-                        return buffer.toString();
-                    }
-                    catch (StreamStorageException e)
-                    {
-                        log.error("StreamStorage Exception.", e);
-                        return getMessage();
-                    }
-                    catch (PipelineException e)
-                    {
-                        log.error("Pipeline Exception.", e);
                         return getMessage();
                     }
+                    return formattedMessage;
                 }
             }
             else




pal-cvs メーリングリストの案内
アーカイブの一覧に戻る