roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r209352 - in /incubator/roller/trunk: contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/ src/org/roller/pojos/ src/org/roller/presentation/velocity/ src/org/roller/presentation/website/actions/ src/org/roller/presentatio...
Date Tue, 05 Jul 2005 23:45:12 GMT
Author: agilliland
Date: Tue Jul  5 16:45:10 2005
New Revision: 209352

URL: http://svn.apache.org/viewcvs?rev=209352&view=rev
Log:
A couple slight refactorings for WeblogTemplate.java which affected some other classes. namely
...
  - changed getTemplate() to getContents() to conform to Template interface
  - changed getUpdateTime() to getLastModified() to conform to Template interface
  - changed member access levels from protected to private


Modified:
    incubator/roller/trunk/contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/AcronymsPlugin.java
    incubator/roller/trunk/src/org/roller/pojos/WeblogTemplate.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/WeblogTemplateFormAction.java
    incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BloggerAPIHandler.java
    incubator/roller/trunk/web/website/edit-page.jsp

Modified: incubator/roller/trunk/contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/AcronymsPlugin.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/AcronymsPlugin.java?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/AcronymsPlugin.java
(original)
+++ incubator/roller/trunk/contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/AcronymsPlugin.java
Tue Jul  5 16:45:10 2005
@@ -201,7 +201,7 @@
 	 */
 	private Properties parseAcronymPage(WeblogTemplate acronymPage, Properties acronyms)
 	{
-		String rawAcronyms = acronymPage.getTemplate();
+		String rawAcronyms = acronymPage.getContents();
 		
 		if (mLogger.isDebugEnabled()) 
 		{

Modified: incubator/roller/trunk/src/org/roller/pojos/WeblogTemplate.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogTemplate.java?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogTemplate.java (original)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogTemplate.java Tue Jul  5 16:45:10 2005
@@ -1,14 +1,19 @@
 package org.roller.pojos;
 
+import java.io.Serializable;
 import java.util.Date;
-
 import org.roller.RollerException;
 import org.roller.model.Roller;
 import org.roller.model.RollerFactory;
+import org.roller.model.Template;
 
 
 /**
- * Page bean.
+ * Pojo that represents a single user defined template page.
+ *
+ * This template is different from the generic template because it also
+ * contains a reference to the website it is part of.
+ *
  * @author David M Johnson
  * 
  * @ejb:bean name="WeblogTemplate"
@@ -16,18 +21,17 @@
  * @hibernate.class table="webpage" 
  * hibernate.jcs-cache usage="read-write"
  */
-public class WeblogTemplate
-   extends org.roller.pojos.PersistentObject
-   implements java.io.Serializable
+public class WeblogTemplate extends PersistentObject
+   implements Serializable, Template
 {
    static final long serialVersionUID = -613737191638263428L;
 
-   protected java.lang.String id;
-   protected java.lang.String name;
-   protected java.lang.String description;
-   protected java.lang.String link;
-   protected java.lang.String template;
-   protected java.util.Date updateTime;
+   private java.lang.String id;
+   private java.lang.String name;
+   private java.lang.String description;
+   private java.lang.String link;
+   private java.lang.String contents;
+   private java.util.Date lastModified;
 
    protected WebsiteData mWebsite = null;
 
@@ -49,8 +53,8 @@
       this.name = name;
       this.description = description;
       this.link = link;
-      this.template = template;
-      this.updateTime = (Date)updateTime.clone();
+      this.contents = template;
+      this.lastModified = (Date)updateTime.clone();
    }
 
    public WeblogTemplate( WeblogTemplate otherData )
@@ -60,8 +64,8 @@
       this.name = otherData.name;
       this.description = otherData.description;
       this.link = otherData.link;
-      this.template = otherData.template;
-      this.updateTime = otherData.updateTime;
+      this.contents = otherData.contents;
+      this.lastModified = otherData.lastModified;
 
    }
 
@@ -141,34 +145,34 @@
     * @ejb:persistent-field 
     * @hibernate.property column="template" non-null="true" unique="false"
     */
-   public java.lang.String getTemplate()
+   public java.lang.String getContents()
    {
-      return this.template;
+      return this.contents;
    }
    /** @ejb:persistent-field */ 
-   public void setTemplate( java.lang.String template )
+   public void setContents( java.lang.String template )
    {
-      this.template = template;
+      this.contents = template;
    }
 
    /** 
     * @ejb:persistent-field 
     * @hibernate.property column="updatetime" non-null="true" unique="false"
     */
-   public java.util.Date getUpdateTime()
+   public java.util.Date getLastModified()
    {
-      return (Date)this.updateTime.clone();
+      return (Date)this.lastModified.clone();
    }   
    /** @ejb:persistent-field */ 
-   public void setUpdateTime(final java.util.Date newtime )
+   public void setLastModified(final java.util.Date newtime )
    {
       if (newtime != null)	
       {
-      	 updateTime = (Date)newtime.clone();
+      	 lastModified = (Date)newtime.clone();
       }
       else 
       {
-      	 updateTime = null;
+      	 lastModified = null;
       }
    }
 
@@ -177,8 +181,8 @@
       StringBuffer str = new StringBuffer("{");
 
       str.append("id=" + id + " " + "name=" + name + " " + "description=" 
-      + description + " " + "link=" + link + " " + "template=" + template 
-      + " " + "updateTime=" + updateTime);
+      + description + " " + "link=" + link + " " + "template=" + contents 
+      + " " + "updateTime=" + lastModified);
       str.append('}');
 
       return(str.toString());
@@ -231,21 +235,21 @@
          {
             lEquals = lEquals && this.link.equals( lTest.link );
          }
-         if( this.template == null )
+         if( this.contents == null )
          {
-            lEquals = lEquals && ( lTest.template == null );
+            lEquals = lEquals && ( lTest.contents == null );
          }
          else
          {
-            lEquals = lEquals && this.template.equals( lTest.template );
+            lEquals = lEquals && this.contents.equals( lTest.contents );
          }
-         if( this.updateTime == null )
+         if( this.lastModified == null )
          {
-            lEquals = lEquals && ( lTest.updateTime == null );
+            lEquals = lEquals && ( lTest.lastModified == null );
          }
          else
          {
-            lEquals = lEquals && this.updateTime.equals( lTest.updateTime );
+            lEquals = lEquals && this.lastModified.equals( lTest.lastModified );
          }
 
          return lEquals;
@@ -264,8 +268,8 @@
       result = 37*result + ((this.name != null) ? this.name.hashCode() : 0);
       result = 37*result + ((this.description != null) ? this.description.hashCode() : 0);
       result = 37*result + ((this.link != null) ? this.link.hashCode() : 0);
-      result = 37*result + ((this.template != null) ? this.template.hashCode() : 0);
-      result = 37*result + ((this.updateTime != null) ? this.updateTime.hashCode() : 0);
+      result = 37*result + ((this.contents != null) ? this.contents.hashCode() : 0);
+      result = 37*result + ((this.lastModified != null) ? this.lastModified.hashCode() :
0);
       return result;
       }
 
@@ -285,9 +289,9 @@
 
       this.link = ((WeblogTemplate) otherData).link;
 
-      this.template = ((WeblogTemplate) otherData).template;
+      this.contents = ((WeblogTemplate) otherData).contents;
 
-      this.updateTime = ((WeblogTemplate) otherData).updateTime;
+      this.lastModified = ((WeblogTemplate) otherData).lastModified;
    }
 
    public boolean canSave() throws RollerException

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/RollerResourceLoader.java
Tue Jul  5 16:45:10 2005
@@ -84,7 +84,7 @@
 					"RollerResourceLoader: page \"" + 
 					name + "\" not found");
             }
-            return new ByteArrayInputStream( page.getTemplate().getBytes("UTF-8") );
+            return new ByteArrayInputStream( page.getContents().getBytes("UTF-8") );
         }
         catch (UnsupportedEncodingException uex)
         {
@@ -123,9 +123,9 @@
             if (mLogger.isDebugEnabled())
             {
                 mLogger.debug(name + ": resource=" + resource.getLastModified() + 
-							    " vs. page=" + page.getUpdateTime().getTime());
+							    " vs. page=" + page.getLastModified().getTime());
             }
-            return page.getUpdateTime().getTime();
+            return page.getLastModified().getTime();
         }
         catch (RollerException re)
         {

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/WeblogTemplateFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/WeblogTemplateFormAction.java?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/WeblogTemplateFormAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/WeblogTemplateFormAction.java
Tue Jul  5 16:45:10 2005
@@ -21,6 +21,7 @@
 import org.roller.RollerException;
 import org.roller.RollerPermissionsException;
 import org.roller.model.UserManager;
+import org.roller.model.Template;
 import org.roller.pojos.WeblogTemplate;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WebsiteData;
@@ -65,9 +66,9 @@
                 WebsiteData hd = rreq.getWebsite();
 
                 data.setWebsite( hd );
-                data.setUpdateTime( new java.util.Date() );
+                data.setLastModified( new java.util.Date() );
                 data.setDescription("");
-                data.setTemplate("");
+                data.setContents("");
                 validateLink( data );
 
                 UserManager mgr = rreq.getRoller().getUserManager();
@@ -115,7 +116,7 @@
             if ( rreq.isUserAuthorizedToEdit() )
             {
                 UserData ud = rreq.getUser();
-                WeblogTemplate pd = rreq.getPage();
+                WeblogTemplate pd = (WeblogTemplate) rreq.getPage();
                 WeblogTemplateForm pf = (WeblogTemplateForm)actionForm;
                 pf.copyFrom(pd, request.getLocale());
 
@@ -228,7 +229,7 @@
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
             if ( rreq.isUserAuthorizedToEdit() )
             {
-                WeblogTemplate cd = rreq.getPage();
+                WeblogTemplate cd = (WeblogTemplate) rreq.getPage();
                 WeblogTemplateForm pf = (WeblogTemplateForm)actionForm;
                 pf.copyFrom(cd, request.getLocale());
 
@@ -267,7 +268,7 @@
                 WeblogTemplate data = mgr.retrievePage(form.getId());
                 data.save(); // should through exception if no save permission
                 form.copyTo(data, request.getLocale());
-                data.setUpdateTime( new java.util.Date() );
+                data.setLastModified( new java.util.Date() );
                 data.setWebsite( rreq.getWebsite() );
 
                 validateLink( data );

Modified: incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BloggerAPIHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BloggerAPIHandler.java?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BloggerAPIHandler.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BloggerAPIHandler.java Tue Jul
 5 16:45:10 2005
@@ -131,7 +131,7 @@
             UserManager userMgr = roller.getUserManager();
 
             WeblogTemplate page = userMgr.retrievePage(templateType);
-            page.setTemplate(templateData);
+            page.setContents(templateData);
             userMgr.storePage(page);
             flushPageCache(userid);
 
@@ -182,7 +182,7 @@
             }
             else
             {
-                return page.getTemplate();
+                return page.getContents();
             }
         }
         catch (Exception e)

Modified: incubator/roller/trunk/web/website/edit-page.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/web/website/edit-page.jsp?rev=209352&r1=209351&r2=209352&view=diff
==============================================================================
--- incubator/roller/trunk/web/website/edit-page.jsp (original)
+++ incubator/roller/trunk/web/website/edit-page.jsp Tue Jul  5 16:45:10 2005
@@ -24,7 +24,7 @@
         </tr>
         <tr>
             <td><fmt:message key="pageForm.template" /><br />
-            <html:textarea property="template" cols="80" rows="30" style="width: 100%"
/>
+            <html:textarea property="contents" cols="80" rows="30" style="width: 100%"
/>
             </td>
         </tr>
     </table>



Mime
View raw message