File Source: WeblogBookmarkFolder.java

         /* 
    P/P   *  Method: void readObject(ObjectInputStream)
          * 
          *  Preconditions:
          *    Param_1 != null
          * 
          *  Presumptions:
          *    init'ed(org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED)
          * 
          *  Postconditions:
          *    Param_0.pcDetachedState == org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED
          *    (soft) init'ed(Param_0.pcDetachedState)
          */
     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.pojos;
    20  
    21  import java.io.Serializable;
    22  import java.util.Iterator;
    23  import java.util.List;
    24  import java.util.Set;
    25  import java.util.TreeSet;
    26  import org.apache.commons.lang.builder.EqualsBuilder;
    27  import org.apache.commons.lang.builder.HashCodeBuilder;
    28  import org.apache.commons.logging.Log;
    29  import org.apache.commons.logging.LogFactory;
    30  
    31  import org.apache.roller.weblogger.WebloggerException;
    32  import org.apache.roller.weblogger.business.BookmarkManager;
    33  import org.apache.roller.weblogger.business.WebloggerFactory;
    34  import org.apache.roller.util.UUIDGenerator;
    35  
    36  
    37  /**
    38   * <p>Folder that holds Bookmarks and other Folders. A Roller Website has a
    39   * set of Folders (there is no one root folder) and each Folder may contain
    40   * Folders or Bookmarks. Don't construct one of these yourself, instead use
    41   * the create method in your BookmarkManager implementation.</p>
    42   */
    43  public class WeblogBookmarkFolder implements Serializable, Comparable {
    44      
    45      public static final long serialVersionUID = -6272468884763861944L;
    46      
             /* 
    P/P       *  Method: org.apache.roller.weblogger.pojos.WeblogBookmarkFolder__static_init
              * 
              *  Postconditions:
              *    init'ed(log)
              *    pcFieldFlags == &new byte[](WeblogBookmarkFolder__static_init#3)
              *    pcFieldNames == &new String[](WeblogBookmarkFolder__static_init#1)
              *    pcFieldTypes == &new Class[](WeblogBookmarkFolder__static_init#2)
              *    new Class[](WeblogBookmarkFolder__static_init#2) num objects == 1
              *    new String[](WeblogBookmarkFolder__static_init#1) num objects == 1
              *    new byte[](WeblogBookmarkFolder__static_init#3) num objects == 1
              *    pcFieldTypes.length == 8
              *    pcFieldNames.length == 8
              *    pcFieldFlags.length == 8
              *    ...
              */
    47      private static Log log = LogFactory.getLog(WeblogBookmarkFolder.class);
    48      
    49      
    50      // attributes
    51      private String id = UUIDGenerator.generateUUID();
    52      private String name = null;
    53      private String description = null;
    54      private String path = null;
    55      
    56      // associations
    57      private Weblog website = null;
    58      private WeblogBookmarkFolder parentFolder = null;
    59      private Set childFolders = new TreeSet();
    60      private Set bookmarks = new TreeSet();
    61      
    62      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.pojos.WeblogBookmarkFolder()
              * 
              *  Postconditions:
              *    this.bookmarks == &new TreeSet(WeblogBookmarkFolder#2)
              *    this.childFolders == &new TreeSet(WeblogBookmarkFolder#1)
              *    this.description == null
              *    this.name == null
              *    this.parentFolder == null
              *    this.path == null
              *    this.website == null
              *    init'ed(this.id)
              *    new TreeSet(WeblogBookmarkFolder#1) num objects == 1
              *    new TreeSet(WeblogBookmarkFolder#2) num objects == 1
              */
    63      public WeblogBookmarkFolder() {
    64      }
    65      
    66      public WeblogBookmarkFolder(
    67              WeblogBookmarkFolder parent,
    68              String name,
    69              String desc,
                     /* 
    P/P               *  Method: void org.apache.roller.weblogger.pojos.WeblogBookmarkFolder(WeblogBookmarkFolder, String, String, Weblog)
                      * 
                      *  Preconditions:
                      *    (soft) init'ed(parent.path)
                      *    (soft) init'ed(parent.pcStateManager)
                      *    (soft) pcInheritedFieldCount <= 232-7
                      * 
                      *  Postconditions:
                      *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                      *    this.bookmarks == &new TreeSet(WeblogBookmarkFolder#2)
                      *    this.childFolders == &new TreeSet(WeblogBookmarkFolder#1)
                      *    this.description == desc
                      *    init'ed(this.description)
                      *    init'ed(this.id)
                      *    this.name == name
                      *    init'ed(this.name)
                      *    this.parentFolder == parent
                      *    init'ed(this.parentFolder)
                      *    ...
                      * 
                      *  Test Vectors:
                      *    parent: Inverse{null}, Addr_Set{null}
                      *    java.lang.String:equals(...)@81: {0}, {1}
                      */
    70              Weblog website) {
    71          
    72          this.name = name;
    73          this.description = desc;
    74          
    75          this.website = website;
    76          this.parentFolder = parent;
    77          
    78          // calculate path
    79          if(parent == null) {
    80              this.path = "/";
    81          } else if("/".equals(parent.getPath())) {
    82              this.path = "/"+name;
    83          } else {
    84              this.path = parent.getPath() + "/" + name;
    85          }
    86      }
    87      
    88          
    89      //------------------------------------------------------- Good citizenship
    90  
    91      public String toString() {
                 /* 
    P/P           *  Method: String toString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  *    init'ed(this.path)
                  * 
                  *  Postconditions:
                  *    java.lang.StringBuffer:toString(...)._tainted == this.id._tainted | this.path._tainted
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuffer:toString(...)
                  */
    92          StringBuffer buf = new StringBuffer();
    93          buf.append("{");
    94          buf.append(this.id);
    95          buf.append(", ").append(this.path);
    96          buf.append("}");
    97          return buf.toString();
    98      }
    99      
   100      public boolean equals(Object other) {
   101          
                 /* 
    P/P           *  Method: bool equals(Object)
                  * 
                  *  Preconditions:
                  *    (soft) init'ed(other.path)
                  *    (soft) init'ed(other.pcStateManager)
                  *    (soft) pcInheritedFieldCount <= 232-7
                  *    (soft) init'ed(this.path)
                  *    (soft) init'ed(this.pcStateManager)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.EqualsBuilder:append(...)@106 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    other: Inverse{null}, Addr_Set{null}
                  */
   102          if (other == null) return false;
   103          
   104          if (other instanceof WeblogBookmarkFolder) {
   105              WeblogBookmarkFolder o = (WeblogBookmarkFolder) other;
   106              return new EqualsBuilder()
   107                  .append(getPath(), o.getPath()) 
   108                  //.append(getWebsite(), o.getWebsite()) 
   109                  .isEquals();
   110          }
   111          
   112          return false;
   113      }    
   114      
   115      
   116      public int hashCode() {
                 /* 
    P/P           *  Method: int hashCode()
                  * 
                  *  Preconditions:
                  *    init'ed(this.path)
                  *    init'ed(this.pcStateManager)
                  *    (soft) pcInheritedFieldCount <= 232-7
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.HashCodeBuilder:append(...)@117 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   117          return new HashCodeBuilder()
   118              .append(getPath())
   119              //.append(getWebsite())
   120              .toHashCode();
   121      }
   122      
   123      /**
   124       * @see java.lang.Comparable#compareTo(java.lang.Object)
   125       */
   126      public int compareTo(Object o) {
                 /* 
    P/P           *  Method: int compareTo(Object)
                  * 
                  *  Preconditions:
                  *    o != null
                  *    init'ed(o.name)
                  *    init'ed(o.pcStateManager)
                  *    this.name != null
                  *    init'ed(this.pcStateManager)
                  *    (soft) pcInheritedFieldCount <= 232-5
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   127          WeblogBookmarkFolder other = (WeblogBookmarkFolder)o;
   128          return getName().compareTo(other.getName());
   129      }
   130      
   131      
   132      /**
   133       * Database surrogate key.
   134       *
   135       * @roller.wrapPojoMethod type="simple"
   136       *
   137       * @hibernate.id column="id"
   138       *     generator-class="assigned"  
   139       */
   140      public String getId() {
                 /* 
    P/P           *  Method: String pcgetId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  * 
                  *  Postconditions:
                  *    return_value == this.id
                  *    init'ed(return_value)
                  */
   141          return this.id;
   142      }
   143      
   144      public void setId(String id) {
   145          // Form bean workaround: empty string is never a valid id
                 /* 
    P/P           *  Method: void pcsetId(String)
                  * 
                  *  Postconditions:
                  *    this.id == One-of{old this.id, Param_1}
                  * 
                  *  Test Vectors:
                  *    Param_1: Addr_Set{null}, Inverse{null}
                  *    java.lang.String:length(...)@146: {1..232-1}, {0}
                  */
   146          if (id != null && id.trim().length() == 0) return; 
   147          this.id = id;
   148      }
   149      
   150      
   151      /**
   152       * The short name for this folder.
   153       *
   154       * @roller.wrapPojoMethod type="simple"
   155       *
   156       * @struts.validator type="required" msgkey="errors.required"
   157       * @struts.validator type="mask" msgkey="errors.noslashes"
   158       * @struts.validator-var name="mask" value="${noslashes}"
   159       * @struts.validator-args arg0resource="folderForm.name"
   160       *
   161       * @hibernate.property column="name" non-null="true" unique="false"
   162       */
   163      public String getName() {
                 /* 
    P/P           *  Method: String pcgetName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.name)
                  * 
                  *  Postconditions:
                  *    return_value == this.name
                  *    init'ed(return_value)
                  */
   164          return this.name;
   165      }
   166      
   167      public void setName(String name) {
                 /* 
    P/P           *  Method: void pcsetName(String)
                  * 
                  *  Postconditions:
                  *    this.name == Param_1
                  *    init'ed(this.name)
                  */
   168          this.name = name;
   169      }
   170      
   171      
   172      /**
   173       * A full description for this folder.
   174       *
   175       * @roller.wrapPojoMethod type="simple"
   176       *
   177       * @hibernate.property column="description" non-null="true" unique="false"
   178       */
   179      public String getDescription() {
                 /* 
    P/P           *  Method: String pcgetDescription()
                  * 
                  *  Preconditions:
                  *    init'ed(this.description)
                  * 
                  *  Postconditions:
                  *    return_value == this.description
                  *    init'ed(return_value)
                  */
   180          return this.description;
   181      }
   182      
   183      public void setDescription(String description) {
                 /* 
    P/P           *  Method: void pcsetDescription(String)
                  * 
                  *  Postconditions:
                  *    this.description == Param_1
                  *    init'ed(this.description)
                  */
   184          this.description = description;
   185      }
   186      
   187      
   188      /**
   189       * The full path to this folder in the hierarchy.
   190       *
   191       * @roller.wrapPojoMethod type="simple"
   192       *
   193       * @hibernate.property column="path" non-null="true" unique="false"
   194       */
   195      public String getPath() {
                 /* 
    P/P           *  Method: String pcgetPath()
                  * 
                  *  Preconditions:
                  *    init'ed(this.path)
                  * 
                  *  Postconditions:
                  *    return_value == this.path
                  *    init'ed(return_value)
                  */
   196          return this.path;
   197      }
   198      
   199      public void setPath(String path) {
                 /* 
    P/P           *  Method: void pcsetPath(String)
                  * 
                  *  Postconditions:
                  *    this.path == Param_1
                  *    init'ed(this.path)
                  */
   200          this.path = path;
   201      }
   202      
   203      
   204      /**
   205       * Get the weblog which owns this folder.
   206       *
   207       * @roller.wrapPojoMethod type="pojo"
   208       *
   209       * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
   210       */
   211      public Weblog getWebsite() {
                 /* 
    P/P           *  Method: Weblog pcgetWebsite()
                  * 
                  *  Preconditions:
                  *    init'ed(this.website)
                  * 
                  *  Postconditions:
                  *    return_value == this.website
                  *    init'ed(return_value)
                  */
   212          return website;
   213      }
   214      
   215      public void setWebsite( Weblog website ) {
                 /* 
    P/P           *  Method: void pcsetWebsite(Weblog)
                  * 
                  *  Postconditions:
                  *    this.website == Param_1
                  *    init'ed(this.website)
                  */
   216          this.website = website;
   217      }
   218      
   219      
   220      /**
   221       * Return parent folder, or null if folder is root of hierarchy.
   222       *
   223       * @roller.wrapPojoMethod type="pojo"
   224       *
   225       * @hibernate.many-to-one column="parentid" cascade="none" not-null="false"
   226       */
   227      public WeblogBookmarkFolder getParent() {
                 /* 
    P/P           *  Method: WeblogBookmarkFolder pcgetParent()
                  * 
                  *  Preconditions:
                  *    init'ed(this.parentFolder)
                  * 
                  *  Postconditions:
                  *    return_value == this.parentFolder
                  *    init'ed(return_value)
                  */
   228          return this.parentFolder;
   229      }
   230      
   231      public void setParent(WeblogBookmarkFolder parent) {
                 /* 
    P/P           *  Method: void pcsetParent(WeblogBookmarkFolder)
                  * 
                  *  Postconditions:
                  *    this.parentFolder == Param_1
                  *    init'ed(this.parentFolder)
                  */
   232          this.parentFolder = parent;
   233      }
   234      
   235      
   236      /**
   237       * Get child folders of this folder.
   238       *
   239       * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.weblogger.pojos.WeblogBookmarkFolder"
   240       *
   241       * @hibernate.set lazy="true" inverse="true" cascade="delete" 
   242       * @hibernate.collection-key column="parentid"
   243       * @hibernate.collection-one-to-many class="org.apache.roller.weblogger.pojos.WeblogBookmarkFolder"
   244       */
   245      public Set getFolders() {
                 /* 
    P/P           *  Method: Set pcgetFolders()
                  * 
                  *  Preconditions:
                  *    init'ed(this.childFolders)
                  * 
                  *  Postconditions:
                  *    return_value == this.childFolders
                  *    init'ed(return_value)
                  */
   246          return this.childFolders;
   247      }
   248      
   249      private void setFolders(Set folders) {
                 /* 
    P/P           *  Method: void pcsetFolders(Set)
                  * 
                  *  Postconditions:
                  *    this.childFolders == Param_1
                  *    init'ed(this.childFolders)
                  */
   250          this.childFolders = folders;
   251      }
   252      
   253      
   254      /**
   255       * Get bookmarks contained in this folder.
   256       *
   257       * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.weblogger.pojos.WeblogBookmark"
   258       *
   259       * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all"
   260       * @hibernate.collection-key column="folderid"
   261       * @hibernate.collection-one-to-many class="org.apache.roller.weblogger.pojos.WeblogBookmark"
   262       */
   263      public Set getBookmarks() {
                 /* 
    P/P           *  Method: Set pcgetBookmarks()
                  * 
                  *  Preconditions:
                  *    init'ed(this.bookmarks)
                  * 
                  *  Postconditions:
                  *    return_value == this.bookmarks
                  *    init'ed(return_value)
                  */
   264          return this.bookmarks;
   265      }
   266      
   267      // this is private to force the use of add/remove bookmark methods.
   268      private void setBookmarks(Set bookmarks) {
                 /* 
    P/P           *  Method: void pcsetBookmarks(Set)
                  * 
                  *  Postconditions:
                  *    this.bookmarks == Param_1
                  *    init'ed(this.bookmarks)
                  */
   269          this.bookmarks = bookmarks;
   270      }
   271      
   272      
   273      /**
   274       * Add a folder as a child of this folder.
   275       */
   276      public void addFolder(WeblogBookmarkFolder folder) {
   277          
   278          // make sure folder is not null
                 /* 
    P/P           *  Method: void addFolder(WeblogBookmarkFolder)
                  * 
                  *  Preconditions:
                  *    folder != null
                  *    init'ed(folder.pcStateManager)
                  *    this.childFolders != null
                  *    init'ed(this.pcStateManager)
                  *    (soft) folder.name != null
                  *    (soft) init'ed(folder.parentFolder)
                  *    (soft) pcInheritedFieldCount <= 232-6
                  * 
                  *  Presumptions:
                  *    java.util.Iterator:hasNext(...)@325 == 0
                  * 
                  *  Postconditions:
                  *    folder.parentFolder == One-of{this, old folder.parentFolder}
                  *    (soft) init'ed(folder.parentFolder)
                  */
   279          if(folder == null || folder.getName() == null) {
   280              throw new IllegalArgumentException("Folder cannot be null and must have a valid name");
   281          }
   282          
   283          // make sure we don't already have a folder with that name
   284          if(this.hasFolder(folder.getName())) {
   285              throw new IllegalArgumentException("Duplicate folder name '"+folder.getName()+"'");
   286          }
   287          
   288          // set ourselves as the parent of the folder
   289          folder.setParent(this);
   290          
   291          // add it to our list of child folder
   292          getFolders().add(folder);
   293      }
   294      
   295      
   296      /** 
   297       * Add a bookmark to this folder.
   298       */
   299      public void addBookmark(WeblogBookmark bookmark) throws WebloggerException {
                 /* 
    P/P           *  Method: void addBookmark(WeblogBookmark)
                  * 
                  *  Preconditions:
                  *    bookmark != null
                  *    init'ed(bookmark.pcStateManager)
                  *    this.bookmarks != null
                  *    init'ed(this.pcStateManager)
                  *    (soft) init'ed(bookmark.folder)
                  *    (soft) org/apache/roller/weblogger/pojos/WeblogBookmark.pcInheritedFieldCount <= 232-3
                  *    (soft) init'ed(pcInheritedFieldCount)
                  * 
                  *  Postconditions:
                  *    bookmark.folder == One-of{this, old bookmark.folder}
                  *    (soft) init'ed(bookmark.folder)
                  */
   300          bookmark.setFolder(this);
   301          getBookmarks().add(bookmark);
   302      }
   303      
   304      
   305      /**
   306       * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.weblogger.pojos.WeblogBookmark"
   307       *
   308       * @param subfolders
   309       */
   310      public List retrieveBookmarks(boolean subfolders) throws WebloggerException {
                 /* 
    P/P           *  Method: List retrieveBookmarks(bool)
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.Weblogger:getBookmarkManager(...)@311 != null
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@311 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   311          BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
   312          return bmgr.getBookmarks(this, subfolders);
   313      }
   314      
   315      
   316      /**
   317       * Does this folder have a child folder with the specified name?
   318       *
   319       * @param name The name of the folder to check for.
   320       * @return boolean true if child folder exists, false otherwise.
   321       */
   322      public boolean hasFolder(String name) {
                 /* 
    P/P           *  Method: bool hasFolder(String)
                  * 
                  *  Preconditions:
                  *    this.childFolders != null
                  *    init'ed(this.pcStateManager)
                  *    (soft) name != null
                  *    (soft) pcInheritedFieldCount <= 232-5
                  * 
                  *  Presumptions:
                  *    java.util.Iterator:next(...)@326 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@327: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@325: {0}, {1}
                  */
   323          Iterator folders = this.getFolders().iterator();
   324          WeblogBookmarkFolder folder = null;
   325          while(folders.hasNext()) {
   326              folder = (WeblogBookmarkFolder) folders.next();
   327              if(name.equals(folder.getName())) {
   328                  return true;
   329              }
   330          }
   331          return false;
   332      }
   333      
   334      
   335      /**
   336       * Is this folder a descendent of the other folder?
   337       *
   338       * @roller.wrapPojoMethod type="simple"
   339       */
   340      public boolean descendentOf(WeblogBookmarkFolder ancestor) {
   341          
   342          // if this is a root node then we can't be a descendent
                 /* 
    P/P           *  Method: bool descendentOf(WeblogBookmarkFolder)
                  * 
                  *  Preconditions:
                  *    init'ed(this.parentFolder)
                  *    init'ed(this.pcStateManager)
                  *    (soft) ancestor != null
                  *    (soft) init'ed(ancestor.path)
                  *    (soft) init'ed(ancestor.pcStateManager)
                  *    (soft) pcInheritedFieldCount <= 232-7
                  *    (soft) this.path != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    this.parentFolder: Inverse{null}, Addr_Set{null}
                  */
   343          if(getParent() == null) {
   344              return false;
   345          } else {
   346              // if our path starts with our parents path then we are a descendent
   347              return this.path.startsWith(ancestor.getPath());
   348          }
   349      }
   350      
   351      
   352      // convenience method for updating the folder name, which triggers a path tree rebuild
   353      public void updateName(String newName) throws WebloggerException {
   354          
   355          // update name
                 /* 
    P/P           *  Method: void updateName(String)
                  * 
                  *  Preconditions:
                  *    log != null
                  *    this.childFolders != null
                  *    init'ed(this.parentFolder)
                  *    init'ed(this.pcStateManager)
                  *    (soft) init'ed(this.name)
                  *    (soft) init'ed(this.path)
                  *    (soft) pcInheritedFieldCount <= 232-7
                  *    (soft) init'ed(this...path)
                  *    (soft) init'ed(this...pcStateManager)
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    this.name == One-of{newName, old this.name}
                  *    (soft) init'ed(this.name)
                  *    this.path == One-of{&".", old this.path, &java.lang.StringBuilder:toString(...)}
                  *    init'ed(this.path)
                  * 
                  *  Test Vectors:
                  *    this.parentFolder: Inverse{null}, Addr_Set{null}
                  *    java.lang.String:equals(...)@361: {0}, {1}
                  */
   356          setName(newName);
   357          
   358          // calculate path
   359          if(getParent() == null) {
   360              setPath("/");
   361          } else if("/".equals(getParent().getPath())) {
   362              setPath("/"+getName());
   363          } else {
   364              setPath(getParent().getPath() + "/" + getName());
   365          }
   366          
   367          // update path tree for all children
   368          updatePathTree(this);
   369      }
   370      
   371      
   372      // update the path tree for a given folder
   373      public static void updatePathTree(WeblogBookmarkFolder folder) 
   374              throws WebloggerException {
   375          
                 /* 
    P/P           *  Method: void updatePathTree(WeblogBookmarkFolder)
                  * 
                  *  Preconditions:
                  *    folder != null
                  *    folder.childFolders != null
                  *    init'ed(folder.path)
                  *    init'ed(folder.pcStateManager)
                  *    log != null
                  *    (soft) pcInheritedFieldCount <= 232-7
                  * 
                  *  Presumptions:
                  *    childFolder.childFolders@393 != null
                  *    java.util.Iterator:next(...)@381 != null
                  *    org.apache.roller.weblogger.business.Weblogger:getBookmarkManager(...)@391 != null
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@391 != null
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    possibly_updated(java.lang.StringBuilder:toString(...)._tainted)
                  * 
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@386: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@380: {0}, {1}
                  */
   376          log.debug("Updating path tree for folder "+folder.getPath());
   377          
   378          WeblogBookmarkFolder childFolder = null;
   379          Iterator childFolders = folder.getFolders().iterator();
   380          while(childFolders.hasNext()) {
   381              childFolder = (WeblogBookmarkFolder) childFolders.next();
   382              
   383              log.debug("OLD child folder path was "+childFolder.getPath());
   384              
   385              // update path and save
   386              if("/".equals(folder.getPath())) {
   387                  childFolder.setPath("/" + childFolder.getName());
   388              } else {
   389                  childFolder.setPath(folder.getPath() + "/" + childFolder.getName());
   390              }
   391              WebloggerFactory.getWeblogger().getBookmarkManager().saveFolder(childFolder);
   392              
   393              log.debug("NEW child folder path is "+ childFolder.getPath());
   394              
   395              // then make recursive call to update this folders children
   396              updatePathTree(childFolder);
   397          }
   398      }
   399      
   400  }
+  401  Other Messages








SofCheck Inspector Build Version : 2.18479
WeblogBookmarkFolder.java 2009-Jan-02 14:25:46
WeblogBookmarkFolder.class 2009-Sep-04 03:12:38