//# 0 errors, 135 messages
//#
/*
    //#RemoveEntryOperation.java:1:1: class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
/* Created on Jul 16, 2003 */
package org.apache.roller.weblogger.business.search.operations;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.Weblogger;
import org.apache.roller.weblogger.business.WeblogManager;
import org.apache.roller.weblogger.business.search.IndexManagerImpl;
import org.apache.roller.weblogger.business.search.FieldConstants;
import org.apache.roller.weblogger.pojos.WeblogEntry;


/**
 * An operation that removes the weblog from the index.
 * @author Mindaugas Idzelis (min@idzelis.com)
 */
public class RemoveEntryOperation extends WriteToIndexOperation {
    
    //~ Static fields/initializers =============================================
    
    private static Log mLogger =
    //#RemoveEntryOperation.java:43: method: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init
    //#RemoveEntryOperation.java:43: Warning: method not available
    //#    -- call on LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init
    //#    unanalyzed callee: LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#RemoveEntryOperation.java:43: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation]
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.beginDeleting()Lorg/apache/lucene/index/IndexReader;
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.beginWriting()Lorg/apache/lucene/index/IndexWriter;
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.doRun()V
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.endDeleting()V
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.endWriting()V
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.getDocument(Lorg/apache/roller/weblogger/pojos/WeblogEntry;)Lorg/apache/lucene/document/Document;
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.run()V
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): mLogger
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): org/apache/roller/weblogger/business/search/operations/IndexOperation.__Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation]
    //#output(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): org/apache/roller/weblogger/business/search/operations/WriteToIndexOperation.__Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation]
    //#presumption(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): org.apache.commons.logging.LogFactory:getFactory(...)@43 != null
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): org/apache/roller/weblogger/business/search/operations/IndexOperation.__Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): org/apache/roller/weblogger/business/search/operations/WriteToIndexOperation.__Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.beginDeleting()Lorg/apache/lucene/index/IndexReader; == &org/apache/roller/weblogger/business/search/operations/IndexOperation.beginDeleting
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.beginWriting()Lorg/apache/lucene/index/IndexWriter; == &org/apache/roller/weblogger/business/search/operations/IndexOperation.beginWriting
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.doRun()V == &doRun
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.endDeleting()V == &org/apache/roller/weblogger/business/search/operations/IndexOperation.endDeleting
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.endWriting()V == &org/apache/roller/weblogger/business/search/operations/IndexOperation.endWriting
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.getDocument(Lorg/apache/roller/weblogger/pojos/WeblogEntry;)Lorg/apache/lucene/document/Document; == &org/apache/roller/weblogger/business/search/operations/IndexOperation.getDocument
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): __Dispatch_Table.run()V == &org/apache/roller/weblogger/business/search/operations/WriteToIndexOperation.run
    //#post(org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init): init'ed(mLogger)
    //#RemoveEntryOperation.java:43: end of method: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation__static_init
            LogFactory.getFactory().getInstance(RemoveEntryOperation.class);
    
    //~ Instance fields ========================================================
    
    private WeblogEntry data;
    private Weblogger roller;
    
    //~ Constructors ===========================================================
    
    public RemoveEntryOperation(Weblogger roller, IndexManagerImpl mgr,WeblogEntry data) {
        super(mgr);
    //#RemoveEntryOperation.java:54: method: void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)
    //#input(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): data
    //#input(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): mgr
    //#input(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): roller
    //#input(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this
    //#output(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.data
    //#output(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.manager
    //#output(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.roller
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.data == data
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): init'ed(this.data)
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.manager == mgr
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): init'ed(this.manager)
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): this.roller == roller
    //#post(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): init'ed(this.roller)
    //#unanalyzed(void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)): Effects-of-calling:org.apache.roller.weblogger.business.search.operations.IndexOperation
        this.roller = roller;
        this.data = data;
    }
    //#RemoveEntryOperation.java:57: end of method: void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation(Weblogger, IndexManagerImpl, WeblogEntry)
    
    //~ Methods ================================================================
    
    public void doRun() {
        
        // since this operation can be run on a separate thread we must treat
        // the weblog object passed in as a detached object which is proned to
        // lazy initialization problems, so requery for the object now
        try {
            WeblogManager wMgr = roller.getWeblogManager();
    //#RemoveEntryOperation.java:67: method: void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.doRun()
    //#RemoveEntryOperation.java:67: Warning: suspicious precondition
    //#    the precondition for this.roller.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    suspicious precondition index: [14]
    //#    Attribs:  Soft
    //#RemoveEntryOperation.java:67: Warning: suspicious precondition
    //#    the precondition for this.roller.weblogManager.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    suspicious precondition index: [16]
    //#    Attribs:  Soft
    //#input(void doRun()): __Descendant_Table[org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation]
    //#input(void doRun()): __Descendant_Table[others]
    //#input(void doRun()): __Dispatch_Table.beginDeleting()Lorg/apache/lucene/index/IndexReader;
    //#input(void doRun()): __Dispatch_Table.endDeleting()V
    //#input(void doRun()): mLogger
    //#input(void doRun()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[org/apache/roller/weblogger/business/WeblogManager]
    //#input(void doRun()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl]
    //#input(void doRun()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[others]
    //#input(void doRun()): org/apache/roller/weblogger/business/WeblogManager.__Dispatch_Table.getWeblogEntry(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/WeblogEntry;
    //#input(void doRun()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerImpl]
    //#input(void doRun()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/Weblogger]
    //#input(void doRun()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl]
    //#input(void doRun()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[others]
    //#input(void doRun()): org/apache/roller/weblogger/business/Weblogger.__Dispatch_Table.getWeblogManager()Lorg/apache/roller/weblogger/business/WeblogManager;
    //#input(void doRun()): org/apache/roller/weblogger/business/WebloggerImpl.__Dispatch_Table.getWeblogManager()Lorg/apache/roller/weblogger/business/WeblogManager;
    //#input(void doRun()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy]
    //#input(void doRun()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[others]
    //#input(void doRun()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Dispatch_Table.load(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
    //#input(void doRun()): org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.__Dispatch_Table.getWeblogEntry(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/WeblogEntry;
    //#input(void doRun()): org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.__Dispatch_Table.getWeblogManager()Lorg/apache/roller/weblogger/business/WeblogManager;
    //#input(void doRun()): org/apache/roller/weblogger/business/search/IndexManagerImpl.__Descendant_Table[org/apache/roller/weblogger/business/search/IndexManagerImpl]
    //#input(void doRun()): org/apache/roller/weblogger/business/search/IndexManagerImpl.__Descendant_Table[others]
    //#input(void doRun()): org/apache/roller/weblogger/business/search/IndexManagerImpl.__Dispatch_Table.getFSDirectory(Z)Lorg/apache/lucene/store/Directory;
    //#input(void doRun()): org/apache/roller/weblogger/business/search/IndexManagerImpl.__Dispatch_Table.getIndexDirectory()Lorg/apache/lucene/store/Directory;
    //#input(void doRun()): org/apache/roller/weblogger/business/search/IndexManagerImpl.mLogger
    //#input(void doRun()): org/apache/roller/weblogger/business/search/operations/IndexOperation.mLogger
    //#input(void doRun()): this
    //#input(void doRun()): this.__Tag
    //#input(void doRun()): this.data
    //#input(void doRun()): this.manager
    //#input(void doRun()): this.manager.__Tag
    //#input(void doRun()): this.manager.fRAMindex
    //#input(void doRun()): this.manager.indexDir
    //#input(void doRun()): this.manager.useRAMIndex
    //#input(void doRun()): this.reader
    //#input(void doRun()): this.roller
    //#input(void doRun()): this.roller.__Tag
    //#input(void doRun()): this.roller.weblogManager
    //#input(void doRun()): this.roller.weblogManager.__Tag
    //#input(void doRun()): this.roller.weblogManager.strategy
    //#input(void doRun()): this.roller.weblogManager.strategy.__Tag
    //#input(void doRun()): this.roller.weblogManager.strategy.emf
    //#input(void doRun()): this.roller.weblogManager.strategy.threadLocalEntityManager
    //#output(void doRun()): this.data
    //#output(void doRun()): this.reader
    //#pre[1] (void doRun()): (soft) mLogger != null
    //#pre[2] (void doRun()): (soft) this.data != null
    //#pre[3] (void doRun()): (soft) init'ed(this.reader)
    //#pre[4] (void doRun()): (soft) org/apache/roller/weblogger/business/search/IndexManagerImpl.mLogger != null
    //#pre[5] (void doRun()): (soft) org/apache/roller/weblogger/business/search/operations/IndexOperation.mLogger != null
    //#pre[7] (void doRun()): (soft) this.__Tag == org/apache/roller/weblogger/business/search/operations/RemoveEntryOperation
    //#pre[8] (void doRun()): (soft) this.manager != null
    //#pre[9] (void doRun()): (soft) this.manager.__Tag == org/apache/roller/weblogger/business/search/IndexManagerImpl
    //#pre[10] (void doRun()): (soft) init'ed(this.manager.fRAMindex)
    //#pre[11] (void doRun()): (soft) init'ed(this.manager.indexDir)
    //#pre[12] (void doRun()): (soft) init'ed(this.manager.useRAMIndex)
    //#pre[13] (void doRun()): (soft) this.roller != null
    //#pre[14] (void doRun()): (soft) this.roller.__Tag in {org/apache/roller/weblogger/business/Weblogger, org/apache/roller/weblogger/business/WebloggerImpl, org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl}
    //#pre[15] (void doRun()): (soft) this.roller.weblogManager != null
    //#pre[16] (void doRun()): (soft) this.roller.weblogManager.__Tag in {org/apache/roller/weblogger/business/WeblogManager, org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl}
    //#pre[17] (void doRun()): (soft) this.roller.weblogManager.strategy != null
    //#pre[18] (void doRun()): (soft) this.roller.weblogManager.strategy.__Tag == org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy
    //#pre[19] (void doRun()): (soft) this.roller.weblogManager.strategy.emf != null
    //#pre[20] (void doRun()): (soft) this.roller.weblogManager.strategy.threadLocalEntityManager != null
    //#presumption(void doRun()): javax.persistence.EntityManager:find(...)@216 != null
    //#post(void doRun()): (soft) this.data != null
    //#post(void doRun()): init'ed(this.reader)
    //#unanalyzed(void doRun()): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void doRun()): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void doRun()): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void doRun()): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void doRun()): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void doRun()): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#unanalyzed(void doRun()): Effects-of-calling:javax.persistence.EntityManager:find
    //#unanalyzed(void doRun()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void doRun()): Effects-of-calling:getIndexDirectory
    //#unanalyzed(void doRun()): Effects-of-calling:org.apache.lucene.index.IndexReader:open
    //#unanalyzed(void doRun()): Effects-of-calling:org.apache.lucene.index.IndexReader:close
    //#unanalyzed(void doRun()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(void doRun()): Effects-of-calling:org.apache.lucene.store.FSDirectory:getDirectory
            this.data = wMgr.getWeblogEntry(this.data.getId());
    //#RemoveEntryOperation.java:68: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntry:getId()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntry:getId()
        } catch (WebloggerException ex) {
            mLogger.error("Error getting weblogentry object", ex);
    //#RemoveEntryOperation.java:70: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
            return;
        }
        
        IndexReader reader = beginDeleting();
        try {
            if (reader != null) {
                Term term = new Term(FieldConstants.ID, data.getId());
    //#RemoveEntryOperation.java:77: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntry:getId()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntry:getId()
    //#RemoveEntryOperation.java:77: Warning: method not available
    //#    -- call on void org.apache.lucene.index.Term(String, String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: void org.apache.lucene.index.Term(String, String)
                reader.delete(term);
    //#RemoveEntryOperation.java:78: Warning: method not available
    //#    -- call on int org.apache.lucene.index.IndexReader:delete(Term)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: int org.apache.lucene.index.IndexReader:delete(Term)
            }
        } catch (IOException e) {
            mLogger.error("Error deleting doc from index", e);
    //#RemoveEntryOperation.java:81: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
    //#    method: void doRun()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object, Throwable)
        } finally {
            endDeleting();
        }
    }
    //#RemoveEntryOperation.java:85: end of method: void org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation.doRun()
    
    
}
    //#RemoveEntryOperation.java:: end of class: org.apache.roller.weblogger.business.search.operations.RemoveEntryOperation
