//# 1 errors, 535 messages
//#
/*
    //#staticpageindex.java:1:1: class: net.sourceforge.pebble.index.StaticPageIndex
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.index;

import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.domain.StaticPage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.*;
import java.util.*;

/**
 * Maintains an index of all static pages
 *
 * @author    Simon Brown
 */
public class StaticPageIndex {

  private static final Log log = LogFactory.getLog(StaticPageIndex.class);
    //#staticpageindex.java:49: method: net.sourceforge.pebble.index.StaticPageIndex.net.sourceforge.pebble.index.StaticPageIndex__static_init
    //#staticpageindex.java:49: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: net.sourceforge.pebble.index.StaticPageIndex__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Descendant_Table[net/sourceforge/pebble/index/StaticPageIndex]
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.contains(Ljava/lang/String;)Z
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getIndexFile()Ljava/io/File;
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getNumberOfStaticPages()I
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getStaticPage(Ljava/lang/String;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getStaticPages()Ljava/util/List;
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.index(Lnet/sourceforge/pebble/domain/StaticPage;)V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.lock()Z
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.readIndex()V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.reindex(Ljava/util/Collection;)V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.unindex(Lnet/sourceforge/pebble/domain/StaticPage;)V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.unlock()V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.writeIndex()V
    //#output(net.sourceforge.pebble.index.StaticPageIndex__static_init): log
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Descendant_Table[net/sourceforge/pebble/index/StaticPageIndex] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.contains(Ljava/lang/String;)Z == &contains
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getIndexFile()Ljava/io/File; == &getIndexFile
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getNumberOfStaticPages()I == &getNumberOfStaticPages
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getStaticPage(Ljava/lang/String;)Ljava/lang/String; == &getStaticPage
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.getStaticPages()Ljava/util/List; == &getStaticPages
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.index(Lnet/sourceforge/pebble/domain/StaticPage;)V == &index
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.lock()Z == &lock
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.readIndex()V == &readIndex
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.reindex(Ljava/util/Collection;)V == &reindex
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.unindex(Lnet/sourceforge/pebble/domain/StaticPage;)V == &unindex
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.unlock()V == &unlock
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): __Dispatch_Table.writeIndex()V == &writeIndex
    //#post(net.sourceforge.pebble.index.StaticPageIndex__static_init): init'ed(log)
    //#staticpageindex.java:49: end of method: net.sourceforge.pebble.index.StaticPageIndex.net.sourceforge.pebble.index.StaticPageIndex__static_init

  private static final String PAGES_INDEX_DIRECTORY_NAME = "pages";
  private static final String NAME_TO_ID_INDEX_FILE_NAME = "name.index";
  private static final String LOCK_FILE_NAME = "pages.lock";
  private static final int MAXIMUM_LOCK_ATTEMPTS = 3;

  /** the owning blog */
  private Blog blog;

  /** the collection of all static pages */
  private Map<String,String> index = new HashMap<String,String>();
  private int lockAttempts = 0;

  public StaticPageIndex(Blog blog) {
    //#staticpageindex.java:63: method: void net.sourceforge.pebble.index.StaticPageIndex.net.sourceforge.pebble.index.StaticPageIndex(Blog)
    //#input(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): blog
    //#input(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): log
    //#input(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this
    //#output(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): new HashMap(StaticPageIndex#1) num objects
    //#output(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.blog
    //#output(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.index
    //#output(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.lockAttempts
    //#new obj(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): new HashMap(StaticPageIndex#1)
    //#pre[1] (void net.sourceforge.pebble.index.StaticPageIndex(Blog)): blog != null
    //#post(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.blog == blog
    //#post(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.blog != null
    //#post(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): this.index == &new HashMap(StaticPageIndex#1)
    //#post(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): init'ed(this.lockAttempts)
    //#post(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): new HashMap(StaticPageIndex#1) num objects == 1
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.File
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.util.Map:put
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(void net.sourceforge.pebble.index.StaticPageIndex(Blog)): java.io.File:exists(...)@68: {1}, {0}
    this.blog = blog;

    // create the directory structure if it doesn't exist
    File indexDirectory = new File(blog.getIndexesDirectory(), PAGES_INDEX_DIRECTORY_NAME);
    //#staticpageindex.java:67: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void net.sourceforge.pebble.index.StaticPageIndex(Blog)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    if (!indexDirectory.exists()) {
      indexDirectory.mkdirs();
    }

    readIndex();
  }
    //#staticpageindex.java:73: end of method: void net.sourceforge.pebble.index.StaticPageIndex.net.sourceforge.pebble.index.StaticPageIndex(Blog)

  /**
   * Indexes one or more blog entries.
   *
   * @param staticPages   a List of Page instances
   */
  public synchronized void reindex(Collection<StaticPage> staticPages) {
    if (lock()) {
    //#staticpageindex.java:81: method: void net.sourceforge.pebble.index.StaticPageIndex.reindex(Collection)
    //#input(void reindex(Collection)): log
    //#input(void reindex(Collection)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[net/sourceforge/pebble/domain/StaticPage]
    //#input(void reindex(Collection)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[others]
    //#input(void reindex(Collection)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void reindex(Collection)): staticPages
    //#input(void reindex(Collection)): this
    //#input(void reindex(Collection)): this.blog
    //#input(void reindex(Collection)): this.lockAttempts
    //#output(void reindex(Collection)): new HashMap(reindex#1) num objects
    //#output(void reindex(Collection)): this.index
    //#output(void reindex(Collection)): this.lockAttempts
    //#new obj(void reindex(Collection)): new HashMap(reindex#1)
    //#pre[5] (void reindex(Collection)): this.blog != null
    //#pre[2] (void reindex(Collection)): (soft) this.lockAttempts <= 4_294_967_294
    //#pre[3] (void reindex(Collection)): (soft) staticPages != null
    //#presumption(void reindex(Collection)): java.util.Iterator:next(...).__Tag@84 == net/sourceforge/pebble/domain/StaticPage
    //#presumption(void reindex(Collection)): java.util.Iterator:next(...)@84 != null
    //#post(void reindex(Collection)): this.index == One-of{old this.index, &new HashMap(reindex#1)}
    //#post(void reindex(Collection)): this.lockAttempts == One-of{old this.lockAttempts, old this.lockAttempts + 1, 0}
    //#post(void reindex(Collection)): init'ed(this.lockAttempts)
    //#post(void reindex(Collection)): new HashMap(reindex#1) num objects <= 1
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.File
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.File:createNewFile
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.FileWriter
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.BufferedWriter
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.BufferedWriter:write
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.BufferedWriter:newLine
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.BufferedWriter:flush
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.BufferedWriter:close
    //#unanalyzed(void reindex(Collection)): Effects-of-calling:java.io.File:delete
    //#test_vector(void reindex(Collection)): java.util.Iterator:hasNext(...)@84: {1}, {0}
      // clear the index and add all static pages
      index = new HashMap<String,String>();
      for (StaticPage staticPage : staticPages) {
        index.put(staticPage.getName(), staticPage.getId());
    //#staticpageindex.java:85: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.StaticPage:getId()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void reindex(Collection)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.StaticPage:getId()
      }

      // and finally, write the index
      writeIndex();
      unlock();
    }
  }
    //#staticpageindex.java:92: end of method: void net.sourceforge.pebble.index.StaticPageIndex.reindex(Collection)

  /**
   * Indexes a single page.
   *
   * @param staticPage    a Page instance
   */
  public synchronized void index(StaticPage staticPage) {
    if (lock()) {
    //#staticpageindex.java:100: method: void net.sourceforge.pebble.index.StaticPageIndex.index(StaticPage)
    //#input(void index(StaticPage)): __Descendant_Table[net/sourceforge/pebble/index/StaticPageIndex]
    //#input(void index(StaticPage)): __Descendant_Table[others]
    //#input(void index(StaticPage)): __Dispatch_Table.index(Lnet/sourceforge/pebble/domain/StaticPage;)V
    //#input(void index(StaticPage)): log
    //#input(void index(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[net/sourceforge/pebble/domain/StaticPage]
    //#input(void index(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[others]
    //#input(void index(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void index(StaticPage)): staticPage
    //#input(void index(StaticPage)): staticPage.__Tag
    //#input(void index(StaticPage)): staticPage.name
    //#input(void index(StaticPage)): this
    //#input(void index(StaticPage)): this.__Tag
    //#input(void index(StaticPage)): this.blog
    //#input(void index(StaticPage)): this.index
    //#input(void index(StaticPage)): this.lockAttempts
    //#output(void index(StaticPage)): this.lockAttempts
    //#pre[7] (void index(StaticPage)): this.blog != null
    //#pre[1] (void index(StaticPage)): (soft) this.lockAttempts <= 4_294_967_294
    //#pre[2] (void index(StaticPage)): (soft) staticPage != null
    //#pre[3] (void index(StaticPage)): (soft) staticPage.__Tag == net/sourceforge/pebble/domain/StaticPage
    //#pre[4] (void index(StaticPage)): (soft) init'ed(staticPage.name)
    //#pre[6] (void index(StaticPage)): (soft) this.__Tag == net/sourceforge/pebble/index/StaticPageIndex
    //#pre[8] (void index(StaticPage)): (soft) this.index != null
    //#presumption(void index(StaticPage)): java.util.Map:get(...)@107 != null
    //#presumption(void index(StaticPage)): java.util.Map:keySet(...)@104 != null
    //#post(void index(StaticPage)): init'ed(this.lockAttempts)
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.File
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Map:put
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.File:createNewFile
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.FileWriter
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedWriter
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedWriter:write
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedWriter:newLine
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedWriter:flush
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.BufferedWriter:close
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.io.File:delete
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:getName
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.Thread:sleep
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.StaticPage:getId
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:java.util.Iterator:remove
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:index
    //#unanalyzed(void index(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:error
    //#test_vector(void index(StaticPage)): java.lang.String:equals(...)@108: {0}, {1}
    //#test_vector(void index(StaticPage)): java.util.Iterator:hasNext(...)@105: {1}, {0}
      readIndex();

      // remove the old entry for this static page
      Iterator it = index.keySet().iterator();
      while (it.hasNext()) {
        String key = (String)it.next();
        String value = index.get(key);
        if (value.equals(staticPage.getId())) {
    //#staticpageindex.java:108: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.StaticPage:getId()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void index(StaticPage)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.StaticPage:getId()
          it.remove();
        }
      }

      // and now add the new entry for this page
      index.put(staticPage.getName(), staticPage.getId());
    //#staticpageindex.java:114: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.StaticPage:getId()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void index(StaticPage)
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.StaticPage:getId()
      writeIndex();
      unlock();
    } else {
      if (lockAttempts <= MAXIMUM_LOCK_ATTEMPTS) {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {
          // ignore
        }
        index(staticPage);
      } else {
        blog.error("Could not index static page - try <a href=\"utilities.secureaction?action=buildIndexes\">rebuilding the indexes</a>.");
    //#staticpageindex.java:126: Warning: method not available
    //#    -- call on void net.sourceforge.pebble.domain.Blog:error(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void index(StaticPage)
    //#    unanalyzed callee: void net.sourceforge.pebble.domain.Blog:error(String)
      }
    }
  }
    //#staticpageindex.java:129: end of method: void net.sourceforge.pebble.index.StaticPageIndex.index(StaticPage)

  /**
   * Unindexes a single page.
   *
   * @param staticPage    a Page instance
   */
  public synchronized void unindex(StaticPage staticPage) {
    if (lock()) {
    //#staticpageindex.java:137: method: void net.sourceforge.pebble.index.StaticPageIndex.unindex(StaticPage)
    //#staticpageindex.java:137: Warning: suspicious precondition
    //#    the precondition for net/sourceforge/pebble/dao/DAOFactory.configuredFactory.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void unindex(StaticPage)
    //#    suspicious precondition index: [2]
    //#    Attribs:  Soft
    //#input(void unindex(StaticPage)): __Descendant_Table[net/sourceforge/pebble/index/StaticPageIndex]
    //#input(void unindex(StaticPage)): __Descendant_Table[others]
    //#input(void unindex(StaticPage)): __Dispatch_Table.reindex(Ljava/util/Collection;)V
    //#input(void unindex(StaticPage)): __Dispatch_Table.unindex(Lnet/sourceforge/pebble/domain/StaticPage;)V
    //#input(void unindex(StaticPage)): log
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/Configuration.__Descendant_Table[net/sourceforge/pebble/Configuration]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/Configuration.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/Configuration.__Dispatch_Table.getUrl()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/Configuration.__Dispatch_Table.isVirtualHostingEnabled()Z
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/api/permalink/PermalinkProvider.__Descendant_Table[net/sourceforge/pebble/api/permalink/PermalinkProvider]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/api/permalink/PermalinkProvider.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/api/permalink/PermalinkProvider.__Dispatch_Table.getPermalink(Lnet/sourceforge/pebble/domain/BlogEntry;)Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.__Descendant_Table[net/sourceforge/pebble/dao/DAOFactory]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.__Descendant_Table[net/sourceforge/pebble/dao/file/FileDAOFactory]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.__Dispatch_Table.getStaticPageDAO()Lnet/sourceforge/pebble/dao/StaticPageDAO;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory.__Tag
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory.staticPageDAO
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory.staticPageDAO.__Tag
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/StaticPageDAO.__Descendant_Table[net/sourceforge/pebble/dao/StaticPageDAO]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/StaticPageDAO.__Descendant_Table[net/sourceforge/pebble/dao/file/FileStaticPageDAO]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/StaticPageDAO.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/StaticPageDAO.__Dispatch_Table.loadStaticPages(Lnet/sourceforge/pebble/domain/Blog;)Ljava/util/Collection;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/file/FileDAOFactory.__Dispatch_Table.getStaticPageDAO()Lnet/sourceforge/pebble/dao/StaticPageDAO;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/file/FileStaticPageDAO.__Descendant_Table[net/sourceforge/pebble/dao/file/FileStaticPageDAO]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/file/FileStaticPageDAO.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/file/FileStaticPageDAO.__Dispatch_Table.loadStaticPage(Lnet/sourceforge/pebble/domain/Blog;Ljava/lang/String;)Lnet/sourceforge/pebble/domain/StaticPage;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/dao/file/FileStaticPageDAO.__Dispatch_Table.loadStaticPages(Lnet/sourceforge/pebble/domain/Blog;)Ljava/util/Collection;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/AbstractBlog.log
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[net/sourceforge/pebble/domain/Blog]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.error(Ljava/lang/String;)V
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getId()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getLuceneAnalyzer()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getPermalinkProvider()Lnet/sourceforge/pebble/api/permalink/PermalinkProvider;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getUrl()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.info(Ljava/lang/String;)V
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.reindexStaticPages()V
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Blog.log
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getBody()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getLocalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getOriginalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.isAggregated()Z
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.__Descendant_Table[net/sourceforge/pebble/domain/BlogManager]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.__Dispatch_Table.isMultiBlog()Z
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.instance
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.instance.__Tag
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.instance.multiBlog
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getBody()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/Content]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/PageBasedContent]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/Response]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/StaticPage]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Content.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Message.__Descendant_Table[net/sourceforge/pebble/domain/Message]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Message.__Dispatch_Table.getText()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/MessageType.ERROR
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/MessageType.INFO
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Descendant_Table[net/sourceforge/pebble/domain/PageBasedContent]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Descendant_Table[net/sourceforge/pebble/domain/StaticPage]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Dispatch_Table.getLocalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Dispatch_Table.getOriginalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/PageBasedContent.__Dispatch_Table.isAggregated()Z
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[net/sourceforge/pebble/domain/StaticPage]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getAuthor()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getBody()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getDate()Ljava/util/Date;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getId()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getLocalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getOriginalPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getPermalink()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getTitle()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.getTruncatedContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/StaticPage.__Dispatch_Table.isAggregated()Z
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getExcerpt()Ljava/lang/String;
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/index/SearchIndex.__Descendant_Table[net/sourceforge/pebble/index/SearchIndex]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/index/SearchIndex.__Descendant_Table[others]
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/index/SearchIndex.__Dispatch_Table.indexStaticPages(Ljava/util/Collection;)V
    //#input(void unindex(StaticPage)): net/sourceforge/pebble/index/SearchIndex.log
    //#input(void unindex(StaticPage)): staticPage
    //#input(void unindex(StaticPage)): staticPage.__Tag
    //#input(void unindex(StaticPage)): staticPage.name
    //#input(void unindex(StaticPage)): this
    //#input(void unindex(StaticPage)): this...__Tag
    //#input(void unindex(StaticPage)): this...blog
    //#input(void unindex(StaticPage)): this...lockAttempts
    //#input(void unindex(StaticPage)): this.__Tag
    //#input(void unindex(StaticPage)): this.blog
    //#input(void unindex(StaticPage)): this.blog...__Tag
    //#input(void unindex(StaticPage)): this.blog...properties
    //#input(void unindex(StaticPage)): this.blog.__Tag
    //#input(void unindex(StaticPage)): this.blog.messages
    //#input(void unindex(StaticPage)): this.blog.searchIndex
    //#input(void unindex(StaticPage)): this.blog.searchIndex.__Tag
    //#input(void unindex(StaticPage)): this.blog.searchIndex.blog
    //#input(void unindex(StaticPage)): this.blog.staticPageIndex
    //#input(void unindex(StaticPage)): this.index
    //#input(void unindex(StaticPage)): this.lockAttempts
    //#output(void unindex(StaticPage)): new HashMap(reindex#1) num objects
    //#output(void unindex(StaticPage)): this...index
    //#output(void unindex(StaticPage)): this...lockAttempts
    //#output(void unindex(StaticPage)): this.blog.messages
    //#output(void unindex(StaticPage)): this.lockAttempts
    //#new obj(void unindex(StaticPage)): new HashMap(reindex#1)
    //#pre[21] (void unindex(StaticPage)): this.blog != null
    //#pre[1] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/dao/DAOFactory.configuredFactory != null
    //#pre[2] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/dao/DAOFactory.configuredFactory.__Tag in {net/sourceforge/pebble/dao/DAOFactory, net/sourceforge/pebble/dao/file/FileDAOFactory}
    //#pre[3] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/dao/DAOFactory.configuredFactory.staticPageDAO != null
    //#pre[5] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/domain/AbstractBlog.log != null
    //#pre[6] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/domain/BlogManager.instance != null
    //#pre[7] (void unindex(StaticPage)): (soft) net/sourceforge/pebble/domain/BlogManager.instance.__Tag == net/sourceforge/pebble/domain/BlogManager
    //#pre[8] (void unindex(StaticPage)): (soft) init'ed(net/sourceforge/pebble/domain/BlogManager.instance.multiBlog)
    //#pre[10] (void unindex(StaticPage)): (soft) this...lockAttempts <= 4_294_967_294
    //#pre[11] (void unindex(StaticPage)): (soft) this.blog.messages != null
    //#pre[12] (void unindex(StaticPage)): (soft) this.lockAttempts <= 4_294_967_294
    //#pre[13] (void unindex(StaticPage)): (soft) staticPage != null
    //#pre[14] (void unindex(StaticPage)): (soft) staticPage.__Tag == net/sourceforge/pebble/domain/StaticPage
    //#pre[15] (void unindex(StaticPage)): (soft) init'ed(staticPage.name)
    //#pre[18] (void unindex(StaticPage)): (soft) this...__Tag == net/sourceforge/pebble/index/StaticPageIndex
    //#pre[19] (void unindex(StaticPage)): (soft) this...blog != null
    //#pre[20] (void unindex(StaticPage)): (soft) this.__Tag == net/sourceforge/pebble/index/StaticPageIndex
    //#pre[22] (void unindex(StaticPage)): (soft) this.blog...__Tag == net/sourceforge/pebble/domain/Blog
    //#pre[23] (void unindex(StaticPage)): (soft) this.blog...properties != null
    //#pre[24] (void unindex(StaticPage)): (soft) this.blog.__Tag == net/sourceforge/pebble/domain/Blog
    //#pre[25] (void unindex(StaticPage)): (soft) this.blog.searchIndex != null
    //#pre[26] (void unindex(StaticPage)): (soft) this.blog.searchIndex.__Tag == net/sourceforge/pebble/index/SearchIndex
    //#pre[27] (void unindex(StaticPage)): (soft) this.blog.searchIndex.blog != null
    //#pre[28] (void unindex(StaticPage)): (soft) this.blog.staticPageIndex != null
    //#pre[29] (void unindex(StaticPage)): (soft) this.index != null
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory.__Tag@145 in {net/sourceforge/pebble/dao/DAOFactory, net/sourceforge/pebble/dao/file/FileDAOFactory}
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory.staticPageDAO@145 != null
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/dao/DAOFactory.configuredFactory@145 != null
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/domain/AbstractBlog.log@145 != null
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.instance.__Tag@145 == net/sourceforge/pebble/domain/BlogManager
    //#presumption(void unindex(StaticPage)): net/sourceforge/pebble/domain/BlogManager.instance@145 != null
    //#post(void unindex(StaticPage)): possibly_updated(this...index)
    //#post(void unindex(StaticPage)): (soft) init'ed(this...lockAttempts)
    //#post(void unindex(StaticPage)): init'ed(this.blog.messages)
    //#post(void unindex(StaticPage)): init'ed(this.lockAttempts)
    //#post(void unindex(StaticPage)): new HashMap(reindex#1) num objects <= 1
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:info
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.FileReader
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.String:split
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Map:put
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.HashMap
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File:createNewFile
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.FileWriter
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedWriter
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Map:keySet
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedWriter:write
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedWriter:newLine
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedWriter:flush
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.BufferedWriter:close
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File:delete
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getName
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Map:remove
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Thread:sleep
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:unindex
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:reindexStaticPages
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.StaticPage:getId
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Collection:iterator
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getId
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.List:size
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.List:subList
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.util.SecurityUtils:getUsername
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Date
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.List:add
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getSearchIndexDirectory
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Exception:getMessage
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getAnalyzer
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.index.IndexWriter:close
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getLuceneAnalyzer
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Class:forName
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Class:newInstance
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getDate
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getAuthor
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getTitle
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.index.IndexWriter
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Document
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Field:Keyword
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Document:add
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Field:Text
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getPermalink
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.DateField:dateToString
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Field:UnIndexed
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getBody
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.document.Field:UnStored
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getTruncatedContent
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuffer:append
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:org.apache.lucene.index.IndexWriter:addDocument
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Object:getClass
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.Class:getName
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.util.StringUtils:transformHTML
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getStaticPageDAO
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:loadStaticPages
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getRoot
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:loadStaticPage
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File:getName
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:index
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.util.Properties:getProperty
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getBlog
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getLocalPermalink
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getUrl
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getContent
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.util.StringUtils:truncate
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.String:indexOf
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.PebbleContext:getInstance
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:net.sourceforge.pebble.PebbleContext:getConfiguration
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(void unindex(StaticPage)): Effects-of-calling:getPermalinkProvider
      readIndex();
      index.remove(staticPage.getName());
      writeIndex();
      unlock();
    } else {
      if (lockAttempts <= MAXIMUM_LOCK_ATTEMPTS) {
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {
          // ignore
        }
        unindex(staticPage);
      } else {
        blog.reindexStaticPages();
    //#staticpageindex.java:151: ?precondition failure
    //#    net/sourceforge/pebble/domain/Blog.reindexStaticPages: (soft) this.staticPageIndex.lockAttempts <= 4_294_967_294
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void unindex(StaticPage)
    //#    basic block: bb_8
    //#    assertion: (soft) this.blog.staticPageIndex.lockAttempts <= 4_294_967_294
    //#    callee: void net/sourceforge/pebble/domain/Blog.reindexStaticPages()
    //#    callee assertion: (soft) this.staticPageIndex.lockAttempts <= 4_294_967_294
    //#    callee file: blog.java
    //#    callee precondition index: [10]
    //#    callee srcpos: 1771
    //#    VN: this.blog.staticPageIndex.lockAttempts
    //#    Expected: {-2_147_483_648..4_294_967_294}
    //#    Bad: {4_294_967_295}
    //#    Attribs:  Int  Bad singleton  Soft  Bad > Exp
      }
    }
  }
    //#staticpageindex.java:154: end of method: void net.sourceforge.pebble.index.StaticPageIndex.unindex(StaticPage)

  /**
   * Helper method to load the index.
   */
  private void readIndex() {
    log.info("Reading index from disk");
    //#staticpageindex.java:160: method: void net.sourceforge.pebble.index.StaticPageIndex.readIndex()
    //#staticpageindex.java:160: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void readIndex()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
    //#input(void readIndex()): log
    //#input(void readIndex()): this
    //#input(void readIndex()): this.blog
    //#input(void readIndex()): this.index
    //#pre[2] (void readIndex()): this.blog != null
    //#pre[3] (void readIndex()): (soft) this.index != null
    //#presumption(void readIndex()): org.apache.commons.logging.LogFactory:getLog(...)@49 != null
    //#presumption(void readIndex()): parts.length@167 >= 2
    //#unanalyzed(void readIndex()): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void readIndex()): Effects-of-calling:java.io.File
    //#test_vector(void readIndex()): java.io.File:exists(...)@162: {0}, {1}
    File indexFile = getIndexFile();
    if (indexFile.exists()) {
      try {
        BufferedReader reader = new BufferedReader(new FileReader(indexFile));
        String indexEntry = reader.readLine();
        while (indexEntry != null) {
          String[] parts = indexEntry.split("=");
          index.put(parts[0], parts[1]);

          indexEntry = reader.readLine();
        }

        reader.close();
      } catch (Exception e) {
        log.error("Error while reading index", e);
    //#staticpageindex.java:175: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void readIndex()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
      }
    }
  }
    //#staticpageindex.java:178: end of method: void net.sourceforge.pebble.index.StaticPageIndex.readIndex()

  /**
   * Helper method to write out the index to disk.
   */
  private void writeIndex() {
    try {
      File indexFile = getIndexFile();
    //#staticpageindex.java:185: method: void net.sourceforge.pebble.index.StaticPageIndex.writeIndex()
    //#input(void writeIndex()): log
    //#input(void writeIndex()): this
    //#input(void writeIndex()): this.blog
    //#input(void writeIndex()): this.index
    //#pre[2] (void writeIndex()): (soft) this.blog != null
    //#pre[3] (void writeIndex()): (soft) this.index != null
    //#presumption(void writeIndex()): java.util.Map:keySet(...)@188 != null
    //#presumption(void writeIndex()): org.apache.commons.logging.LogFactory:getLog(...)@49 != null
    //#unanalyzed(void writeIndex()): Effects-of-calling:net.sourceforge.pebble.domain.Blog:getIndexesDirectory
    //#unanalyzed(void writeIndex()): Effects-of-calling:java.io.File
    //#test_vector(void writeIndex()): java.util.Iterator:hasNext(...)@188: {1}, {0}
      BufferedWriter writer = new BufferedWriter(new FileWriter(indexFile));

      for (String name : index.keySet()) {
        writer.write(name + "=" + index.get(name));
        writer.newLine();
      }

      writer.flush();
      writer.close();
    } catch (Exception e) {
      log.error("Error while writing index", e);
    //#staticpageindex.java:196: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void writeIndex()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
    }
  }
    //#staticpageindex.java:198: end of method: void net.sourceforge.pebble.index.StaticPageIndex.writeIndex()

  /**
   * Gets the page ID for the specified named page.
   *
   * @param name    a String
   * @return  a String instance, or null if no page exists
   *          with the specified name
   */
  public String getStaticPage(String name) {
    return index.get(name);
    //#staticpageindex.java:208: method: String net.sourceforge.pebble.index.StaticPageIndex.getStaticPage(String)
    //#input(String getStaticPage(String)): name
    //#input(String getStaticPage(String)): this
    //#input(String getStaticPage(String)): this.index
    //#output(String getStaticPage(String)): return_value
    //#pre[3] (String getStaticPage(String)): this.index != null
    //#post(String getStaticPage(String)): init'ed(return_value)
    //#staticpageindex.java:208: end of method: String net.sourceforge.pebble.index.StaticPageIndex.getStaticPage(String)
  }

  /**
   * Gets the list of static page IDs.
   *
   * @return    a List<String>
   */
  public List<String> getStaticPages() {
    return new LinkedList<String>(index.values());
    //#staticpageindex.java:217: method: List net.sourceforge.pebble.index.StaticPageIndex.getStaticPages()
    //#input(List getStaticPages()): this
    //#input(List getStaticPages()): this.index
    //#output(List getStaticPages()): new LinkedList(getStaticPages#1) num objects
    //#output(List getStaticPages()): return_value
    //#new obj(List getStaticPages()): new LinkedList(getStaticPages#1)
    //#pre[2] (List getStaticPages()): this.index != null
    //#post(List getStaticPages()): return_value == &new LinkedList(getStaticPages#1)
    //#post(List getStaticPages()): new LinkedList(getStaticPages#1) num objects == 1
    //#staticpageindex.java:217: end of method: List net.sourceforge.pebble.index.StaticPageIndex.getStaticPages()
  }

  /**
   * Determines whether a page with the specified permalink exists.
   *
   * @param name   the name as a String
   * @return  true if the page exists, false otherwise
   */
  public boolean contains(String name) {
    return index.containsKey(name);
    //#staticpageindex.java:227: method: bool net.sourceforge.pebble.index.StaticPageIndex.contains(String)
    //#input(bool contains(String)): name
    //#input(bool contains(String)): this
    //#input(bool contains(String)): this.index
    //#output(bool contains(String)): return_value
    //#pre[3] (bool contains(String)): this.index != null
    //#post(bool contains(String)): init'ed(return_value)
    //#staticpageindex.java:227: end of method: bool net.sourceforge.pebble.index.StaticPageIndex.contains(String)
  }

  /**
   * Gets the number of static pages.
   *
   * @return  an int
   */
  public int getNumberOfStaticPages() {
    return index.size();
    //#staticpageindex.java:236: method: int net.sourceforge.pebble.index.StaticPageIndex.getNumberOfStaticPages()
    //#input(int getNumberOfStaticPages()): this
    //#input(int getNumberOfStaticPages()): this.index
    //#output(int getNumberOfStaticPages()): return_value
    //#pre[2] (int getNumberOfStaticPages()): this.index != null
    //#post(int getNumberOfStaticPages()): init'ed(return_value)
    //#staticpageindex.java:236: end of method: int net.sourceforge.pebble.index.StaticPageIndex.getNumberOfStaticPages()
  }

  private File getIndexFile() {
    File indexDirectory = new File(blog.getIndexesDirectory(), PAGES_INDEX_DIRECTORY_NAME);
    //#staticpageindex.java:240: method: File net.sourceforge.pebble.index.StaticPageIndex.getIndexFile()
    //#staticpageindex.java:240: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: File getIndexFile()
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#input(File getIndexFile()): this
    //#input(File getIndexFile()): this.blog
    //#output(File getIndexFile()): new File(getIndexFile#2) num objects
    //#output(File getIndexFile()): return_value
    //#new obj(File getIndexFile()): new File(getIndexFile#2)
    //#pre[2] (File getIndexFile()): this.blog != null
    //#post(File getIndexFile()): return_value == &new File(getIndexFile#2)
    //#post(File getIndexFile()): new File(getIndexFile#2) num objects == 1
    return new File(indexDirectory, NAME_TO_ID_INDEX_FILE_NAME);
    //#staticpageindex.java:241: end of method: File net.sourceforge.pebble.index.StaticPageIndex.getIndexFile()
  }

  private boolean lock() {
    File lockFile = new File(blog.getIndexesDirectory(), LOCK_FILE_NAME);
    //#staticpageindex.java:245: method: bool net.sourceforge.pebble.index.StaticPageIndex.lock()
    //#staticpageindex.java:245: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: bool lock()
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#input(bool lock()): log
    //#input(bool lock()): this
    //#input(bool lock()): this.blog
    //#input(bool lock()): this.lockAttempts
    //#output(bool lock()): return_value
    //#output(bool lock()): this.lockAttempts
    //#pre[3] (bool lock()): this.blog != null
    //#pre[1] (bool lock()): (soft) this.lockAttempts <= 4_294_967_294
    //#presumption(bool lock()): org.apache.commons.logging.LogFactory:getLog(...)@49 != null
    //#post(bool lock()): init'ed(return_value)
    //#post(bool lock()): this.lockAttempts == One-of{old this.lockAttempts, old this.lockAttempts + 1}
    //#post(bool lock()): (soft) init'ed(this.lockAttempts)
    //#test_vector(bool lock()): java.io.File:createNewFile(...)@248: {1}, {0}
    boolean success = false;
    try {
      success = lockFile.createNewFile();
      if (!success) {
        lockAttempts++;
      }
    } catch (IOException ioe) {
      log.warn("Error while creating lock file", ioe);
    //#staticpageindex.java:253: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: bool lock()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object, Throwable)
    }

    return success;
    //#staticpageindex.java:256: end of method: bool net.sourceforge.pebble.index.StaticPageIndex.lock()
  }

  private void unlock() {
    File lockFile = new File(blog.getIndexesDirectory(), LOCK_FILE_NAME);
    //#staticpageindex.java:260: method: void net.sourceforge.pebble.index.StaticPageIndex.unlock()
    //#staticpageindex.java:260: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.index.StaticPageIndex
    //#    method: void unlock()
    //#    unanalyzed callee: String net.sourceforge.pebble.domain.Blog:getIndexesDirectory()
    //#input(void unlock()): this
    //#input(void unlock()): this.blog
    //#output(void unlock()): this.lockAttempts
    //#pre[2] (void unlock()): this.blog != null
    //#post(void unlock()): this.lockAttempts == 0
    lockFile.delete();
    lockAttempts = 0;
  }
    //#staticpageindex.java:263: end of method: void net.sourceforge.pebble.index.StaticPageIndex.unlock()

}    //#staticpageindex.java:: end of class: net.sourceforge.pebble.index.StaticPageIndex
