File Source: EntryBean.java

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   *  contributor license agreements.  The ASF licenses this file to You
     4   * under the Apache License, Version 2.0 (the "License"); you may not
     5   * use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.  For additional information regarding
    15   * copyright in this work, please see the NOTICE file in the top level
    16   * directory of this distribution.
    17   */
    18  
    19  package org.apache.roller.weblogger.ui.struts2.editor;
    20  
    21  import java.sql.Timestamp;
    22  import java.text.DateFormat;
    23  import java.text.SimpleDateFormat;
    24  import java.util.Calendar;
    25  import java.util.Date;
    26  import java.util.Locale;
    27  import java.util.Set;
    28  import java.util.TimeZone;
    29  import org.apache.commons.lang.StringUtils;
    30  import org.apache.commons.logging.Log;
    31  import org.apache.commons.logging.LogFactory;
    32  import org.apache.roller.weblogger.WebloggerException;
    33  import org.apache.roller.weblogger.business.WebloggerFactory;
    34  import org.apache.roller.weblogger.business.WeblogManager;
    35  import org.apache.roller.weblogger.pojos.WeblogEntryAttribute;
    36  import org.apache.roller.weblogger.pojos.WeblogCategory;
    37  import org.apache.roller.weblogger.pojos.WeblogEntry;
    38  
    39  
    40  /**
    41   * Bean for managing entry data.
    42   */
         /* 
    P/P   *  Method: void org.apache.roller.weblogger.ui.struts2.editor.EntryBean()
          * 
          *  Postconditions:
          *    this.allowComments == 1
          *    new Integer(EntryBean#1) num objects == 1
          *    this.categoryId == null
          *    this.dateString == null
          *    this.enclosureURL == null
          *    this.id == null
          *    this.locale == null
          *    this.plugins == null
          *    this.status == null
          *    this.summary == null
          *    ...
          */
    43  public class EntryBean {
    44      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.ui.struts2.editor.EntryBean__static_init
              * 
              *  Postconditions:
              *    init'ed(log)
              */
    45      private static Log log = LogFactory.getLog(EntryBean.class);
    46      
    47      private String id = null;
    48      private String title = null;
    49      private String locale = null;
    50      private String categoryId = null;
    51      private String tagsString = null;
    52      private String summary = null;
    53      private String text = null;
    54      private String status = null;
    55      private String weblogHandle = null;
    56      
    57      private String[] plugins = null;
    58      private String dateString = null;
    59      private int hours = 0;
    60      private int minutes = 0;
    61      private int seconds = 0;
    62      private boolean allowComments = true;
    63      private Integer commentDays = new Integer(0);
    64      private boolean rightToLeft = false;
    65      private boolean pinnedToMain = false;
    66      private String enclosureURL = null;
    67      private int commentCount = 0;
    68      
    69      
    70      public String getId() {
                 /* 
    P/P           *  Method: String getId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  * 
                  *  Postconditions:
                  *    return_value == this.id
                  *    init'ed(return_value)
                  */
    71          return this.id;
    72      }
    73      
    74      public void setId( String id ) {
                 /* 
    P/P           *  Method: void setId(String)
                  * 
                  *  Postconditions:
                  *    this.id == id
                  *    init'ed(this.id)
                  */
    75          this.id = id;
    76      }
    77      
    78      public String getTitle() {
                 /* 
    P/P           *  Method: String getTitle()
                  * 
                  *  Preconditions:
                  *    init'ed(this.title)
                  * 
                  *  Postconditions:
                  *    return_value == this.title
                  *    init'ed(return_value)
                  */
    79          return this.title;
    80      }
    81      
    82      public void setTitle( String title ) {
                 /* 
    P/P           *  Method: void setTitle(String)
                  * 
                  *  Postconditions:
                  *    this.title == title
                  *    init'ed(this.title)
                  */
    83          this.title = title;
    84      }
    85      
    86      public String getSummary() {
                 /* 
    P/P           *  Method: String getSummary()
                  * 
                  *  Preconditions:
                  *    init'ed(this.summary)
                  * 
                  *  Postconditions:
                  *    return_value == this.summary
                  *    init'ed(return_value)
                  */
    87          return this.summary;
    88      }
    89      
    90      public void setSummary( String summary ) {
                 /* 
    P/P           *  Method: void setSummary(String)
                  * 
                  *  Postconditions:
                  *    this.summary == summary
                  *    init'ed(this.summary)
                  */
    91          this.summary = summary;
    92      }
    93      
    94      public String getText() {
                 /* 
    P/P           *  Method: String getText()
                  * 
                  *  Preconditions:
                  *    init'ed(this.text)
                  * 
                  *  Postconditions:
                  *    return_value == this.text
                  *    init'ed(return_value)
                  */
    95          return this.text;
    96      }
    97      
    98      public void setText( String text ) {
                 /* 
    P/P           *  Method: void setText(String)
                  * 
                  *  Postconditions:
                  *    this.text == text
                  *    init'ed(this.text)
                  */
    99          this.text = text;
   100      }
   101      
   102      public String getStatus() {
                 /* 
    P/P           *  Method: String getStatus()
                  * 
                  *  Preconditions:
                  *    init'ed(this.status)
                  * 
                  *  Postconditions:
                  *    return_value == this.status
                  *    init'ed(return_value)
                  */
   103          return this.status;
   104      }
   105      
   106      public void setStatus( String status ) {
                 /* 
    P/P           *  Method: void setStatus(String)
                  * 
                  *  Postconditions:
                  *    this.status == status
                  *    init'ed(this.status)
                  */
   107          this.status = status;
   108      }
   109      
   110      public String getLocale() {
                 /* 
    P/P           *  Method: String getLocale()
                  * 
                  *  Preconditions:
                  *    init'ed(this.locale)
                  * 
                  *  Postconditions:
                  *    return_value == this.locale
                  *    init'ed(return_value)
                  */
   111          return this.locale;
   112      }
   113      
   114      public void setLocale( String locale ) {
                 /* 
    P/P           *  Method: void setLocale(String)
                  * 
                  *  Postconditions:
                  *    this.locale == locale
                  *    init'ed(this.locale)
                  */
   115          this.locale = locale;
   116      }
   117      
   118      public String getTagsAsString() {
                 /* 
    P/P           *  Method: String getTagsAsString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.tagsString)
                  * 
                  *  Postconditions:
                  *    return_value == this.tagsString
                  *    init'ed(return_value)
                  */
   119          return this.tagsString;
   120      }
   121      
   122      public void setTagsAsString( String tagsAsString ) {
                 /* 
    P/P           *  Method: void setTagsAsString(String)
                  * 
                  *  Postconditions:
                  *    this.tagsString == tagsAsString
                  *    init'ed(this.tagsString)
                  */
   123          this.tagsString = tagsAsString;
   124      }
   125      
   126      public String getCategoryId() {
                 /* 
    P/P           *  Method: String getCategoryId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.categoryId)
                  * 
                  *  Postconditions:
                  *    return_value == this.categoryId
                  *    init'ed(return_value)
                  */
   127          return categoryId;
   128      }
   129      
   130      public void setCategoryId(String categoryId) {
                 /* 
    P/P           *  Method: void setCategoryId(String)
                  * 
                  *  Postconditions:
                  *    this.categoryId == categoryId
                  *    init'ed(this.categoryId)
                  */
   131          this.categoryId = categoryId;
   132      }
   133      
   134      
   135      public String[] getPlugins() {
                 /* 
    P/P           *  Method: String[] getPlugins()
                  * 
                  *  Preconditions:
                  *    init'ed(this.plugins)
                  * 
                  *  Postconditions:
                  *    return_value == this.plugins
                  *    init'ed(return_value)
                  */
   136          return this.plugins;
   137      }
   138      
   139      public void setPlugins(String[] plugins ) {
                 /* 
    P/P           *  Method: void setPlugins(String[])
                  * 
                  *  Postconditions:
                  *    this.plugins == plugins
                  *    init'ed(this.plugins)
                  */
   140          this.plugins = plugins;
   141      }
   142      
   143      public String getDateString() {
                 /* 
    P/P           *  Method: String getDateString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.dateString)
                  * 
                  *  Postconditions:
                  *    return_value == this.dateString
                  *    init'ed(return_value)
                  */
   144          return dateString;
   145      }
   146      
   147      public void setDateString(String date) {
                 /* 
    P/P           *  Method: void setDateString(String)
                  * 
                  *  Postconditions:
                  *    this.dateString == date
                  *    init'ed(this.dateString)
                  */
   148          this.dateString = date;
   149      }
   150      
   151      public int getHours() {
                 /* 
    P/P           *  Method: int getHours()
                  * 
                  *  Preconditions:
                  *    init'ed(this.hours)
                  * 
                  *  Postconditions:
                  *    return_value == this.hours
                  *    init'ed(return_value)
                  */
   152          return hours;
   153      }
   154      
   155      public void setHours(int hours) {
                 /* 
    P/P           *  Method: void setHours(int)
                  * 
                  *  Postconditions:
                  *    this.hours == hours
                  *    init'ed(this.hours)
                  */
   156          this.hours = hours;
   157      }
   158      
   159      public int getMinutes() {
                 /* 
    P/P           *  Method: int getMinutes()
                  * 
                  *  Preconditions:
                  *    init'ed(this.minutes)
                  * 
                  *  Postconditions:
                  *    return_value == this.minutes
                  *    init'ed(return_value)
                  */
   160          return minutes;
   161      }
   162      
   163      public void setMinutes(int minutes) {
                 /* 
    P/P           *  Method: void setMinutes(int)
                  * 
                  *  Postconditions:
                  *    this.minutes == minutes
                  *    init'ed(this.minutes)
                  */
   164          this.minutes = minutes;
   165      }
   166      
   167      public int getSeconds() {
                 /* 
    P/P           *  Method: int getSeconds()
                  * 
                  *  Preconditions:
                  *    init'ed(this.seconds)
                  * 
                  *  Postconditions:
                  *    return_value == this.seconds
                  *    init'ed(return_value)
                  */
   168          return seconds;
   169      }
   170      
   171      public void setSeconds(int seconds) {
                 /* 
    P/P           *  Method: void setSeconds(int)
                  * 
                  *  Postconditions:
                  *    this.seconds == seconds
                  *    init'ed(this.seconds)
                  */
   172          this.seconds = seconds;
   173      }
   174      
   175      public boolean getAllowComments() {
                 /* 
    P/P           *  Method: bool getAllowComments()
                  * 
                  *  Preconditions:
                  *    init'ed(this.allowComments)
                  * 
                  *  Postconditions:
                  *    return_value == this.allowComments
                  *    init'ed(return_value)
                  */
   176          return this.allowComments;
   177      }
   178      
   179      public void setAllowComments( boolean allowComments ) {
                 /* 
    P/P           *  Method: void setAllowComments(bool)
                  * 
                  *  Postconditions:
                  *    this.allowComments == allowComments
                  *    init'ed(this.allowComments)
                  */
   180          this.allowComments = allowComments;
   181      }
   182      
   183      public Integer getCommentDays() {
                 /* 
    P/P           *  Method: Integer getCommentDays()
                  * 
                  *  Preconditions:
                  *    init'ed(this.commentDays)
                  * 
                  *  Postconditions:
                  *    return_value == this.commentDays
                  *    init'ed(return_value)
                  */
   184          return this.commentDays;
   185      }
   186      
   187      public void setCommentDays(Integer commentDays) {
                 /* 
    P/P           *  Method: void setCommentDays(Integer)
                  * 
                  *  Postconditions:
                  *    this.commentDays == commentDays
                  *    init'ed(this.commentDays)
                  */
   188          this.commentDays = commentDays;
   189      }
   190      
   191      public int getCommentCount() {
                 /* 
    P/P           *  Method: int getCommentCount()
                  * 
                  *  Preconditions:
                  *    init'ed(this.commentCount)
                  * 
                  *  Postconditions:
                  *    return_value == this.commentCount
                  *    init'ed(return_value)
                  */
   192          return commentCount;
   193      }
   194  
   195      public void setCommentCount(int commentCount) {
                 /* 
    P/P           *  Method: void setCommentCount(int)
                  * 
                  *  Postconditions:
                  *    this.commentCount == commentCount
                  *    init'ed(this.commentCount)
                  */
   196          this.commentCount = commentCount;
   197      }
   198  
   199      public boolean getRightToLeft() {
                 /* 
    P/P           *  Method: bool getRightToLeft()
                  * 
                  *  Preconditions:
                  *    init'ed(this.rightToLeft)
                  * 
                  *  Postconditions:
                  *    return_value == this.rightToLeft
                  *    init'ed(return_value)
                  */
   200          return this.rightToLeft;
   201      }
   202      
   203      public void setRightToLeft( boolean rightToLeft ) {
                 /* 
    P/P           *  Method: void setRightToLeft(bool)
                  * 
                  *  Postconditions:
                  *    this.rightToLeft == rightToLeft
                  *    init'ed(this.rightToLeft)
                  */
   204          this.rightToLeft = rightToLeft;
   205      }
   206      
   207      public boolean getPinnedToMain() {
                 /* 
    P/P           *  Method: bool getPinnedToMain()
                  * 
                  *  Preconditions:
                  *    init'ed(this.pinnedToMain)
                  * 
                  *  Postconditions:
                  *    return_value == this.pinnedToMain
                  *    init'ed(return_value)
                  */
   208          return this.pinnedToMain;
   209      }
   210      
   211      public void setPinnedToMain( boolean pinnedToMain ) {
                 /* 
    P/P           *  Method: void setPinnedToMain(bool)
                  * 
                  *  Postconditions:
                  *    this.pinnedToMain == pinnedToMain
                  *    init'ed(this.pinnedToMain)
                  */
   212          this.pinnedToMain = pinnedToMain;
   213      }
   214      
   215      public String getEnclosureURL() {
                 /* 
    P/P           *  Method: String getEnclosureURL()
                  * 
                  *  Preconditions:
                  *    init'ed(this.enclosureURL)
                  * 
                  *  Postconditions:
                  *    return_value == this.enclosureURL
                  *    init'ed(return_value)
                  */
   216          return enclosureURL;
   217      }
   218      
   219      public void setEnclosureURL(String trackbackUrl) {
                 /* 
    P/P           *  Method: void setEnclosureURL(String)
                  * 
                  *  Postconditions:
                  *    this.enclosureURL == trackbackUrl
                  *    init'ed(this.enclosureURL)
                  */
   220          this.enclosureURL = trackbackUrl;
   221      }
   222      
   223      
   224      // a convenient way to get the final pubtime of the entry
   225      public Timestamp getPubTime(Locale locale, TimeZone timezone) {
   226          
                 /* 
    P/P           *  Method: Timestamp getPubTime(Locale, TimeZone)
                  * 
                  *  Preconditions:
                  *    init'ed(this.dateString)
                  *    (soft) log != null
                  *    (soft) init'ed(this.hours)
                  *    (soft) init'ed(this.minutes)
                  *    (soft) init'ed(this.seconds)
                  * 
                  *  Presumptions:
                  *    java.util.Calendar:getInstance(...)@245 != null
                  * 
                  *  Postconditions:
                  *    return_value == One-of{null, &new Timestamp(getPubTime#4)}
                  *    return_value in Addr_Set{null,&new Timestamp(getPubTime#4)}
                  *    new Timestamp(getPubTime#4) num objects <= 1
                  *    new Timestamp(getPubTime#4)._tainted == 0
                  * 
                  *  Test Vectors:
                  *    org.apache.commons.lang.StringUtils:isEmpty(...)@229: {1}, {0}
                  */
   227          Timestamp pubtime = null;
   228          
   229          if(!StringUtils.isEmpty(getDateString())) try {
   230              log.debug("pubtime vals are "+getDateString()+", "+getHours()+", "+getMinutes()+", "+getSeconds());
   231              
   232              // first convert the specified date string into an actual Date obj
   233              // TODO: at some point this date conversion should be locale sensitive,
   234              // however at this point our calendar widget does not take into account
   235              // locales and only operates in the standard English US locale.
   236  
   237              // Don't require user add preceding '0' of month and day.
   238              DateFormat df = new SimpleDateFormat("M/d/yy");
   239              df.setTimeZone(timezone);
   240              Date newDate = df.parse(getDateString());
   241              
   242              log.debug("dateString yields date - "+newDate);
   243              
   244              // Now handle the time from the hour, minute and second combos
   245              Calendar cal = Calendar.getInstance(timezone,locale);
   246              cal.setTime(newDate);
   247              cal.set(Calendar.HOUR_OF_DAY, getHours());
   248              cal.set(Calendar.MINUTE, getMinutes());
   249              cal.set(Calendar.SECOND, getSeconds());
   250              pubtime = new Timestamp(cal.getTimeInMillis());
   251              
   252              log.debug("pubtime is "+pubtime);
   253          } catch(Exception e) {
   254              log.error("Error calculating pubtime", e);
   255          }
   256          
   257          return pubtime;
   258      }
   259      
   260      public boolean isDraft() {
                 /* 
    P/P           *  Method: bool isDraft()
                  * 
                  *  Preconditions:
                  *    this.status != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   261          return status.equals(WeblogEntry.DRAFT);
   262      }
   263      
   264      public boolean isPending() {
                 /* 
    P/P           *  Method: bool isPending()
                  * 
                  *  Preconditions:
                  *    this.status != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   265          return status.equals(WeblogEntry.PENDING);
   266      }
   267      
   268      public boolean isPublished() {
                 /* 
    P/P           *  Method: bool isPublished()
                  * 
                  *  Preconditions:
                  *    this.status != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   269          return status.equals(WeblogEntry.PUBLISHED);
   270      }
   271      
   272      public boolean isScheduled() {
                 /* 
    P/P           *  Method: bool isScheduled()
                  * 
                  *  Preconditions:
                  *    this.status != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   273          return status.equals(WeblogEntry.SCHEDULED);
   274      }
   275      
   276      public void copyTo(WeblogEntry entry) throws WebloggerException {
   277          
                 /* 
    P/P           *  Method: void copyTo(WeblogEntry)
                  * 
                  *  Preconditions:
                  *    entry != null
                  *    init'ed(this.allowComments)
                  *    this.categoryId != null
                  *    init'ed(this.commentDays)
                  *    init'ed(this.locale)
                  *    init'ed(this.plugins)
                  *    init'ed(this.rightToLeft)
                  *    init'ed(this.status)
                  *    init'ed(this.summary)
                  *    init'ed(this.tagsString)
                  *    ...
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.Weblogger:getWeblogManager(...)@289 != null
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@289 != null
                  *    org.apache.roller.weblogger.pojos.Weblog:equals(...)@297 == 1
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite(...)@297 != null
                  */
   278          entry.setTitle(getTitle());
   279          entry.setStatus(getStatus());
   280          entry.setLocale(getLocale());
   281          entry.setSummary(getSummary());
   282          entry.setText(getText());
   283          entry.setTagsAsString(getTagsAsString());
   284          
   285          // figure out the category selected
   286          if (getCategoryId() != null) {
   287              WeblogCategory cat = null;
   288              try {
   289                  WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
   290                  cat = wmgr.getWeblogCategory(getCategoryId());
   291              } catch (WebloggerException ex) {
   292                  log.error("Error getting category by id", ex);
   293              }
   294              
   295              if(cat == null) {
+  296                  throw new WebloggerException("Category could not be found - "+getCategoryId());
   297              } else if(!entry.getWebsite().equals(cat.getWebsite())) {
   298                  throw new WebloggerException("Illegal category, not owned by action weblog");
   299              } else {
   300                  entry.setCategory(cat);
   301              }
   302          } else {
   303              throw new WebloggerException("No category specified");
   304          }
   305          
   306          // join values from all plugins into a single string
   307          entry.setPlugins(StringUtils.join(getPlugins(),","));
   308          
   309          // comment settings & right-to-left option
   310          entry.setAllowComments(getAllowComments());
   311          entry.setCommentDays(getCommentDays());
   312          entry.setRightToLeft(getRightToLeft());
   313          
   314          // NOTE: pubtime and pinned to main attributes are set in action
   315      }
   316      
   317      
   318      /**
   319       * Copy values from WeblogEntryData to this Form.
   320       */
   321      public void copyFrom(WeblogEntry entry, Locale locale) {
   322          
                 /* 
    P/P           *  Method: void copyFrom(WeblogEntry, Locale)
                  * 
                  *  Preconditions:
                  *    entry != null
                  *    (soft) log != null
                  * 
                  *  Presumptions:
                  *    java.util.Calendar:getInstance(...)@345 != null
                  *    java.util.Iterator:next(...)@371 != null
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getAllowComments(...)@363 != null
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getCategory(...)@329 != null
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getComments(...)@333 != null
                  *    ...
                  * 
                  *  Postconditions:
                  *    init'ed(this.allowComments)
                  *    init'ed(this.categoryId)
                  *    init'ed(this.commentCount)
                  *    init'ed(this.commentDays)
                  *    possibly_updated(this.dateString)
                  *    possibly_updated(this.enclosureURL)
                  *    possibly_updated(this.hours)
                  *    init'ed(this.id)
                  *    init'ed(this.locale)
                  *    possibly_updated(this.minutes)
                  *    ...
                  * 
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@372: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@371: {0}, {1}
                  *    java.util.Set:size(...)@370: {-231..0}, {1..232-1}
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getEntryAttributes(...)@369: Addr_Set{null}, Inverse{null}
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getPlugins(...)@336: Addr_Set{null}, Inverse{null}
                  *    org.apache.roller.weblogger.pojos.WeblogEntry:getPubTime(...)@341: Addr_Set{null}, Inverse{null}
                  */
   323          setId(entry.getId());
   324          setTitle(entry.getTitle());
   325          setLocale(entry.getLocale());
   326          setStatus(entry.getStatus());
   327          setSummary(entry.getSummary());
   328          setText(entry.getText());
   329          setCategoryId(entry.getCategory().getId());
   330          setTagsAsString(entry.getTagsAsString());
   331          
   332          // set comment count, ignoreSpam=false, approvedOnly=false
   333          setCommentCount(entry.getComments(false, false).size());
   334          
   335          // init plugins values
   336          if(entry.getPlugins() != null) {
   337              setPlugins(StringUtils.split(entry.getPlugins(), ","));
   338          }
   339          
   340          // init pubtime values
   341          if(entry.getPubTime() != null) {
   342              log.debug("entry pubtime is "+entry.getPubTime());
   343              
   344              //Calendar cal = Calendar.getInstance(locale);
   345              Calendar cal = Calendar.getInstance();
   346              cal.setTime(entry.getPubTime());
   347              cal.setTimeZone(entry.getWebsite().getTimeZoneInstance());
   348              
   349              setHours(cal.get(Calendar.HOUR_OF_DAY));
   350              setMinutes(cal.get(Calendar.MINUTE));
   351              setSeconds(cal.get(Calendar.SECOND));
   352              
   353              // TODO: at some point this date conversion should be locale sensitive,
   354              // however at this point our calendar widget does not take into account
   355              // locales and only operates in the standard English US locale.
   356              DateFormat df = new SimpleDateFormat("MM/dd/yy");
   357              df.setTimeZone(entry.getWebsite().getTimeZoneInstance());
   358              setDateString(df.format(entry.getPubTime()));
   359              
   360              log.debug("pubtime vals are "+getDateString()+", "+getHours()+", "+getMinutes()+", "+getSeconds());
   361          }
   362          
   363          setAllowComments(entry.getAllowComments());
   364          setCommentDays(entry.getCommentDays());
   365          setRightToLeft(entry.getRightToLeft());
   366          setPinnedToMain(entry.getPinnedToMain());
   367          
   368          // enclosure url, if it exists
   369          Set<WeblogEntryAttribute> attrs = entry.getEntryAttributes();
   370          if(attrs != null && attrs.size() > 0) {
   371              for(WeblogEntryAttribute attr : attrs) {
   372                  if("att_mediacast_url".equals(attr.getName())) {
   373                      setEnclosureURL(attr.getValue());
   374                  }
   375              }
   376          }
   377      }
   378      
   379      
   380      public String toString() {
                 /* 
    P/P           *  Method: String toString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.allowComments)
                  *    init'ed(this.categoryId)
                  *    init'ed(this.commentDays)
                  *    init'ed(this.dateString)
                  *    init'ed(this.hours)
                  *    init'ed(this.locale)
                  *    init'ed(this.minutes)
                  *    init'ed(this.plugins)
                  *    init'ed(this.seconds)
                  *    init'ed(this.status)
                  *    ...
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuffer:toString(...)
                  */
   381          StringBuffer buf = new StringBuffer();
   382          
   383          //title,locale,catId,tags,text,summary,dateString,status,comments,plugins
   384          buf.append("title = ").append(getTitle()).append("\n");
   385          buf.append("locale = ").append(getLocale()).append("\n");
   386          buf.append("status = ").append(getStatus()).append("\n");
   387          buf.append("catId = ").append(getCategoryId()).append("\n");
   388          buf.append("tags = ").append(getTagsAsString()).append("\n");
   389          buf.append("date = ").append(getDateString()).append("\n");
   390          buf.append("hours = ").append(getHours()).append("\n");
   391          buf.append("minutes = ").append(getMinutes()).append("\n");
   392          buf.append("seconds = ").append(getSeconds()).append("\n");
   393          buf.append("txt size = ").append(getText()).append("\n");
   394          buf.append("summary size = ").append(getSummary()).append("\n");
   395          buf.append("comments = ").append(getAllowComments()).append("\n");
   396          buf.append("commentDays = ").append(getCommentDays()).append("\n");
   397          buf.append("plugins = ").append(getPlugins()).append("\n");
   398          
   399          return buf.toString();
   400      }
   401  }








SofCheck Inspector Build Version : 2.18479
EntryBean.java 2009-Jan-02 14:25:40
EntryBean.class 2009-Sep-04 03:12:45