wt.index
Class StandardIndexPolicyManager

java.lang.Object
  extended bywt.services.StandardManager
      extended bywt.index.StandardIndexPolicyManager
All Implemented Interfaces:
IndexPolicyManager, Manager, NetFactor, Serializable

public class StandardIndexPolicyManager
extends StandardManager
implements IndexPolicyManager, Serializable

Interface containing methods for the mainpulation of index policy rules and lists, as well as event dispatching.

Use the newStandardIndexPolicyManager static factory method(s), not the StandardIndexPolicyManager constructor, to construct instances of this class. Instances must be constructed using the static factory(s), in order to ensure proper initialization of the instance.



Supported API: false

Extendable: false

See Also:
Serialized Form

Nested Class Summary
(package private)  class StandardIndexPolicyManager.ContentListener
           
(package private)  class StandardIndexPolicyManager.DomainListener
           
(package private)  class StandardIndexPolicyManager.IdentityListener
           
(package private)  class StandardIndexPolicyManager.IndexEventListener
           
(package private)  class StandardIndexPolicyManager.VCListener
           
 
Field Summary
private static String ADMIN_RESOURCE
           
private static String BULK_INDEX_QUEUE
           
private static PrintWriter bulkIndexLog
           
private static ProcessingQueue bulkIndexQueue
           
private static boolean bulkLog
           
private static String CLASSNAME
           
private static HashMap contentCache
           
private  KeyedEventListener contentListener
           
private static SimpleDateFormat DATE_FORMAT
           
private static IndexServiceDelegateFactory delegateFactory
           
private static String DELETE_EVENT
           
private static String FILE_SEPARATOR
           
private  KeyedEventListener identityListener
           
private static boolean INDEX_ENABLED
           
private static String INDEX_QUEUE_NAME
          Name of the queue for the indexing requests.
private static IndexListCache indexCache
           
private  ProcessingQueue indexQueue
           
private static HashMap libraryCache
           
private static String LINE_SEPARATOR
           
private  KeyedEventListener listener
           
private static int NRETRIES
           
private static WTPrincipal principal
           
private static long QUEUE_INTERVAL
           
private static String RESOURCE
           
private static int SLEEPTIME
           
private static long tempTimer
           
private static boolean USE_QUEUE
           
private  KeyedEventListener vcListener
           
private static boolean VERBOSE_POLICY
           
 
Fields inherited from class wt.services.StandardManager
 
Fields inherited from interface wt.services.Manager
MANAGER_SERVICE, STARTUP_AUTOMATIC, STARTUP_MANUAL, STATUS_EMERGENCY_SHUTDOWN, STATUS_EMERGENCY_SHUTTING_DOWN, STATUS_SHUTDOWN, STATUS_SHUTDOWN_ERRORS, STATUS_SHUTDOWN_FAILURE, STATUS_SHUTTING_DOWN, STATUS_STARTED, STATUS_STARTED_ERRORS, STATUS_STARTING_UP, STATUS_STARTUP_FAILURE
 
Constructor Summary
StandardIndexPolicyManager()
           
 
Method Summary
 IndexPolicyRule addIndexPolicyRule(Selector selector)
          Creates and adds a new index policy rule for the given selector.
private static void addItemsToCache(WTCollection indexableCollection)
           
 Enumeration allIndexers()
          Returns all available indexers.
private  String collectionsToString(Enumeration collections)
           
private static IndexerSet constructIndexerSet(Selector selector)
          Constructs an indexer set for the given selector.
 void createIndexingRule(AdminDomainRef domain_ref, String type_id, String state_key, Vector collections)
          Creates an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.
private static IndexPolicyList createIndexPolicyList(Selector selector)
          Creates index policy list for the given selector.
 void deleteIndexingRule(AdminDomainRef domain_ref, String type_id, String state_key)
          Deletes an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.
 void deleteIndexingRules(AdminDomainRef domain_ref)
          Deletes all indexing rules within a domain.
private  void deleteIndexPolicyLists(AdminDomainRef domain_ref)
          Deletes the index policy lists for a domain.
private static void editItemCache(Object key, Object value)
           
protected  com.objectspace.jgl.OrderedSet eventsToListenTo()
          Returns all events that must be subscribed to at startup.
 String getConceptualClassname()
          Deprecated.  
protected static IndexListCache getIndexCache()
          Returns (creates if necessary) index list cache.
 IndexPolicyList getIndexPolicyList(Selector selector)
          

Supported API: false
protected static IndexPolicyList getIndexPolicyList(String event_type, Object target_object)
          Returns the index policy list containing all indexers that apply to the specified object for the specified event type.
static IndexPolicyList getIndexPolicyListStatic(Selector selector)
           
 IndexPolicyRule getIndexPolicyRule(Selector selector)
          Returns the index policy rule for the specified selector.
 Enumeration getIndexPolicyRules(AdminDomainRef domain_ref)
          Returns all the index policy rules for the specified domain in the form of an enumeration.
private static Object getItemFromCache(Object obj)
           
private static String getObjectInfo(Persistable object)
           
private static WTPrincipal getPrincipal()
           
private static Object getPropValueObj(ClassInfo objInfo, String propStr, Persistable object)
           
private  Selector getRuleSelector(AdminDomainRef domain_ref, String type_id, String state_key)
          Gets an indexing rule selector for the specified domain, type, and state.
private  Selector getSelector(long domainRef, String type)
           
 void index(Indexable targetObject)
          

Supported API: false
 void index(WTCollection targetCollection)
          Index targetCollection.
private static void Log(String s)
           
private static void LogBulkIndex(String message, boolean tee, boolean override)
           
private static void LogBulkIndex(Throwable t)
           
static StandardIndexPolicyManager newStandardIndexPolicyManager()
          Constructor.
protected  boolean objectHasRules(ObjectReference or, long domainRef)
           
protected  boolean objectHasRules(VersionReference vr, long domainRef)
           
protected  void performStartupProcess()
          Initialization process: mostly subscribing to events contained in the rules.
private  void printWTCollection(KeyedEvent keyedEvent, WTCollection indexableCollection)
           
static HashMap processRwareRequest(WTCollection targetCollection, boolean bulkIndex)
           
protected  void queueRequest(WTCollection targetCollection, Boolean index)
          Queues the result of an event as a Collection of possible events.
static void removeFromIndexer(LinkedList targetCollection, IndexerSet libraries)
          Method that does an update of an objects entry in a Windchill defined collection.
 void removeIndex(Indexable targetObject)
          

Supported API: false
 void removeIndex(WTCollection targetCollection)
          Remove targetObject from indexes.
 IndexPolicyRule removeIndexPolicyRule(Selector selector)
          Removes the index policy rule for the given selector.
 void subscribe(com.objectspace.jgl.OrderedSet event_list)
          Subscribe to the events contained in the set.
 void testIndexToRware(String refString)
          

Supported API: false
 Void testUpdateIndex(String oid, String collection_name)
          

Supported API: false
 void unsubscribe(com.objectspace.jgl.OrderedSet event_list)
          Removes the subscription to the events in the list.
static void updateIndexer(WTCollection targetCollection)
          Method that does an update of an objects entry in a Windchill defined collection.
 void updateIndexingRule(AdminDomainRef domain_ref, String type_id, String state_key, Vector collections)
          Updates an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.
private  void updateIndexPolicyList(IndexPolicyList list)
          Updates the specified index policy list.
private  void updateIndexPolicyLists(AdminDomainRef domain_ref)
          Updates all existing index policy lists for the domain passed as argument and its descendents.
 void updateIndexPolicyLists(Selector selector)
          Updates the policy list for the given selector and all lists whose selector is more specific than the given one.
 
Methods inherited from class wt.services.StandardManager
emergencyShutdown, emergencyShutdownComplete, emergencyShuttingDown, getClassInfo, getManagerService, getManagerStatus, getName, getStartupType, init, initialize, initialize, isStarted, newStandardManager, newStandardManager, performEmergencyShutdownProcess, performShutdownProcess, registerEvents, setManagerService, shutdown, shutdownFailure, shutdownSuccess, shuttingDown, started, startedErrors, startingUp, startup, startupFailure, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

listener

private KeyedEventListener listener

INDEX_QUEUE_NAME

private static final String INDEX_QUEUE_NAME
Name of the queue for the indexing requests.

See Also:
Constant Field Values

BULK_INDEX_QUEUE

private static final String BULK_INDEX_QUEUE
See Also:
Constant Field Values

indexCache

private static IndexListCache indexCache

indexQueue

private ProcessingQueue indexQueue

ADMIN_RESOURCE

private static final String ADMIN_RESOURCE
See Also:
Constant Field Values

VERBOSE_POLICY

private static boolean VERBOSE_POLICY

bulkLog

private static boolean bulkLog

tempTimer

private static long tempTimer

bulkIndexLog

private static PrintWriter bulkIndexLog

NRETRIES

private static final int NRETRIES
See Also:
Constant Field Values

SLEEPTIME

private static final int SLEEPTIME
See Also:
Constant Field Values

USE_QUEUE

private static boolean USE_QUEUE

QUEUE_INTERVAL

private static long QUEUE_INTERVAL

INDEX_ENABLED

private static boolean INDEX_ENABLED

DELETE_EVENT

private static final String DELETE_EVENT

LINE_SEPARATOR

private static String LINE_SEPARATOR

FILE_SEPARATOR

private static String FILE_SEPARATOR

DATE_FORMAT

private static SimpleDateFormat DATE_FORMAT

bulkIndexQueue

private static ProcessingQueue bulkIndexQueue

principal

private static WTPrincipal principal

vcListener

private KeyedEventListener vcListener

contentListener

private KeyedEventListener contentListener

identityListener

private KeyedEventListener identityListener

contentCache

private static HashMap contentCache

libraryCache

private static HashMap libraryCache

delegateFactory

private static IndexServiceDelegateFactory delegateFactory
Constructor Detail

StandardIndexPolicyManager

public StandardIndexPolicyManager()
Method Detail

getConceptualClassname

public String getConceptualClassname()
Deprecated.  

Returns the conceptual (modeled) name for the class.

Supported API: false

Specified by:
getConceptualClassname in interface NetFactor
Overrides:
getConceptualClassname in class StandardManager
Returns:
String

queueRequest

protected void queueRequest(WTCollection targetCollection,
                            Boolean index)
                     throws WTException,
                            IOException,
                            WTPropertyVetoException
Queues the result of an event as a Collection of possible events. The list of objects is placed on the queue and processed by the indexRequest or removeIndexRequest methods

Supported API: false

Parameters:
targetCollection -
index -
Throws:
WTException
IOException
WTPropertyVetoException

updateIndexer

public static void updateIndexer(WTCollection targetCollection)
                          throws WTException
Method that does an update of an objects entry in a Windchill defined collection.

Supported API: false

Parameters:
targetCollection -
Throws:
WTException

getIndexPolicyList

protected static IndexPolicyList getIndexPolicyList(String event_type,
                                                    Object target_object)
                                             throws WTException
Returns the index policy list containing all indexers that apply to the specified object for the specified event type.

Supported API: false

Parameters:
event_type - Event type used to look up index policy list. Leave this null to get an index policy list requardless of event type. In this case, an index policy list is selected based only on the target object and of that set, one is arbitrarily chosen.
target_object -
Returns:
IndexPolicyList
Throws:
WTException

performStartupProcess

protected void performStartupProcess()
                              throws ManagerException
Initialization process: mostly subscribing to events contained in the rules.

Supported API: false

Overrides:
performStartupProcess in class StandardManager
Throws:
ManagerException

newStandardIndexPolicyManager

public static StandardIndexPolicyManager newStandardIndexPolicyManager()
                                                                throws WTException
Constructor.

Supported API: false

Returns:
StandardIndexPolicyManager
Throws:
WTException

getIndexCache

protected static IndexListCache getIndexCache()
Returns (creates if necessary) index list cache.

Supported API: false

Returns:
IndexListCache

index

public void index(Indexable targetObject)
           throws WTException


Supported API: false

Specified by:
index in interface IndexPolicyManager
Parameters:
targetObject -
Throws:
WTException

removeFromIndexer

public static void removeFromIndexer(LinkedList targetCollection,
                                     IndexerSet libraries)
                              throws WTException
Method that does an update of an objects entry in a Windchill defined collection.

Supported API: false

Parameters:
targetCollection -
libraries -
Throws:
WTException

createIndexingRule

public void createIndexingRule(AdminDomainRef domain_ref,
                               String type_id,
                               String state_key,
                               Vector collections)
                        throws WTException
Creates an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.

Supported API: false

Specified by:
createIndexingRule in interface IndexPolicyManager
Parameters:
domain_ref - reference to the domain the rule is for
type_id - logical or persisted type identifier
state_key - life cycle state key (State.toString() value, or null for all states)
collections - collection names (Vector of String)
Throws:
WTException

deleteIndexingRule

public void deleteIndexingRule(AdminDomainRef domain_ref,
                               String type_id,
                               String state_key)
                        throws WTException
Deletes an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.

Supported API: false

Specified by:
deleteIndexingRule in interface IndexPolicyManager
Parameters:
domain_ref - reference to the domain the rule is for
type_id - logical or persisted type identifier
state_key - life cycle state key (State.toString() value, or null for all states)
Throws:
WTException

deleteIndexingRules

public void deleteIndexingRules(AdminDomainRef domain_ref)
                         throws WTException
Deletes all indexing rules within a domain.

This method is intended for testing purposes only, to support automated tests that need to reinitialize the testing environment.

Supported API: false

Specified by:
deleteIndexingRules in interface IndexPolicyManager
Parameters:
domain_ref - reference to the domain the rule is for
Throws:
WTException

updateIndexingRule

public void updateIndexingRule(AdminDomainRef domain_ref,
                               String type_id,
                               String state_key,
                               Vector collections)
                        throws WTException
Updates an indexing rule defining which collections objects of a specified type should be entered into when the objects move to a specified life cycle state, within a domain.

Supported API: false

Specified by:
updateIndexingRule in interface IndexPolicyManager
Parameters:
domain_ref - reference to the domain the rule is for
type_id - logical or persisted type identifier
state_key - life cycle state key (State.toString() value, or null for all states)
collections - collection names (Vector of String)
Throws:
WTException

updateIndexPolicyLists

public void updateIndexPolicyLists(Selector selector)
                            throws WTException
Updates the policy list for the given selector and all lists whose selector is more specific than the given one. This method should be used after a rule is updated so that the lists are kept in synch with the rules.

Supported API: false

Specified by:
updateIndexPolicyLists in interface IndexPolicyManager
Parameters:
selector -
Throws:
WTException

addIndexPolicyRule

public IndexPolicyRule addIndexPolicyRule(Selector selector)
                                   throws WTException
Creates and adds a new index policy rule for the given selector. If the rule already exists it is returned.

Supported API: false

Specified by:
addIndexPolicyRule in interface IndexPolicyManager
Parameters:
selector -
Returns:
IndexPolicyRule
Throws:
WTException

getIndexPolicyRule

public IndexPolicyRule getIndexPolicyRule(Selector selector)
                                   throws WTException
Returns the index policy rule for the specified selector. Returns null if the rule doesn't exist.

Supported API: false

Specified by:
getIndexPolicyRule in interface IndexPolicyManager
Parameters:
selector -
Returns:
IndexPolicyRule
Throws:
WTException

getIndexPolicyRules

public Enumeration getIndexPolicyRules(AdminDomainRef domain_ref)
                                throws WTException
Returns all the index policy rules for the specified domain in the form of an enumeration.

Supported API: false

Specified by:
getIndexPolicyRules in interface IndexPolicyManager
Parameters:
domain_ref -
Returns:
Enumeration
Throws:
WTException

removeIndexPolicyRule

public IndexPolicyRule removeIndexPolicyRule(Selector selector)
                                      throws WTException
Removes the index policy rule for the given selector.

Supported API: false

Specified by:
removeIndexPolicyRule in interface IndexPolicyManager
Parameters:
selector -
Returns:
IndexPolicyRule
Throws:
WTException

allIndexers

public Enumeration allIndexers()
                        throws WTException
Returns all available indexers.

Supported API: false

Specified by:
allIndexers in interface IndexPolicyManager
Returns:
Enumeration
Throws:
WTException

subscribe

public void subscribe(com.objectspace.jgl.OrderedSet event_list)
               throws WTException
Subscribe to the events contained in the set. This method is called after a rule is created or modified. If the event is already subscribed to nothing happens.

Supported API: false

Specified by:
subscribe in interface IndexPolicyManager
Parameters:
event_list -
Throws:
WTException

unsubscribe

public void unsubscribe(com.objectspace.jgl.OrderedSet event_list)
                 throws WTException
Removes the subscription to the events in the list. This method is called after a rule is modified or deleted. If the event is referred to by another rule, nothing happens.

Supported API: false

Specified by:
unsubscribe in interface IndexPolicyManager
Parameters:
event_list -
Throws:
WTException

testUpdateIndex

public Void testUpdateIndex(String oid,
                            String collection_name)
                     throws WTException,
                            WTPropertyVetoException,
                            IOException


Supported API: false

Specified by:
testUpdateIndex in interface IndexPolicyManager
Parameters:
oid -
collection_name -
Returns:
Void
Throws:
WTException
WTPropertyVetoException
IOException

testIndexToRware

public void testIndexToRware(String refString)
                      throws WTException


Supported API: false

Specified by:
testIndexToRware in interface IndexPolicyManager
Parameters:
refString -
Throws:
WTException

index

public void index(WTCollection targetCollection)
           throws WTException
Index targetCollection. This is the method that is called when an event occurs (e.g. check-in) that requires indexing to be performed. It can also be called at any time to force indexing, although this is not recommended practice. The recommended practice is to allow the event listeners to index objects at the correct time, or by running the BulkIndexTool.

Supported API: false

Specified by:
index in interface IndexPolicyManager
Parameters:
targetCollection - The targetCollection is the collection of objects that are going to be indexed based on an event or from the bulk index tool
Throws:
WTException

removeIndex

public void removeIndex(WTCollection targetCollection)
                 throws WTException
Remove targetObject from indexes. This is the method that is called when an Indexable object is deleted. This method assumes targetObject has been deleted and should only be called when that is the case. Otherwise, indexing and the indexing rules will be inconsistent.

Supported API: false

Specified by:
removeIndex in interface IndexPolicyManager
Parameters:
targetCollection - The targetCollection is the collection of objects that are going to be removed from the indexes based on an event
Throws:
WTException

removeIndex

public void removeIndex(Indexable targetObject)
                 throws WTException


Supported API: false

Specified by:
removeIndex in interface IndexPolicyManager
Parameters:
targetObject -
Throws:
WTException

getIndexPolicyList

public IndexPolicyList getIndexPolicyList(Selector selector)
                                   throws WTException


Supported API: false

Specified by:
getIndexPolicyList in interface IndexPolicyManager
Parameters:
selector -
Returns:
IndexPolicyList
Throws:
WTException

eventsToListenTo

protected com.objectspace.jgl.OrderedSet eventsToListenTo()
                                                   throws WTException
Returns all events that must be subscribed to at startup.

Returns:
Enumeration
Throws:
WTException

getRuleSelector

private Selector getRuleSelector(AdminDomainRef domain_ref,
                                 String type_id,
                                 String state_key)
                          throws WTException
Gets an indexing rule selector for the specified domain, type, and state.

Parameters:
domain_ref - reference to the domain the rule is for
type_id - logical or persisted type identifier
state_key - life cycle state key (State.toString() value, or null for all states)
Returns:
Selector indexing rule selector
Throws:
WTException

collectionsToString

private String collectionsToString(Enumeration collections)

constructIndexerSet

private static IndexerSet constructIndexerSet(Selector selector)
                                       throws WTException
Constructs an indexer set for the given selector. The set is constructed by combining all sets of rules whose selector is a parent selector of the given one.

Parameters:
selector - selector.
Returns:
IndexerSet indexer set constructed
Throws:
WTException - if the selector is not appropriate for a list or if there was a problem retrieving or creating the list.

createIndexPolicyList

private static IndexPolicyList createIndexPolicyList(Selector selector)
                                              throws WTException
Creates index policy list for the given selector. List is constructed by combining all rules whose selector is a parent selector of the given one.

Parameters:
selector - selector to be associated with the list.
Returns:
IndexPolicyList index policy list created.
Throws:
WTException - if the selector is not appropriate for a list or if there was a problem retrieving or creating the list.

deleteIndexPolicyLists

private void deleteIndexPolicyLists(AdminDomainRef domain_ref)
                             throws WTException
Deletes the index policy lists for a domain.

Parameters:
domain_ref -
Throws:
WTException

updateIndexPolicyList

private void updateIndexPolicyList(IndexPolicyList list)
                            throws WTException
Updates the specified index policy list.

Parameters:
list -
Throws:
WTException - if there was a problem retrieving or creating the list.

updateIndexPolicyLists

private void updateIndexPolicyLists(AdminDomainRef domain_ref)
                             throws WTException
Updates all existing index policy lists for the domain passed as argument and its descendents. This method is called after a domain has been moved in the domain hierarchy.

Supported API: false

Parameters:
domain_ref -
Throws:
WTException

Log

private static void Log(String s)

getObjectInfo

private static String getObjectInfo(Persistable object)
                             throws WTIntrospectionException,
                                    WTException
Throws:
WTIntrospectionException
WTException

getPropValueObj

private static Object getPropValueObj(ClassInfo objInfo,
                                      String propStr,
                                      Persistable object)
                               throws WTException
Throws:
WTException

objectHasRules

protected boolean objectHasRules(VersionReference vr,
                                 long domainRef)
                          throws WTException
Throws:
WTException

objectHasRules

protected boolean objectHasRules(ObjectReference or,
                                 long domainRef)
                          throws WTException
Throws:
WTException

getSelector

private Selector getSelector(long domainRef,
                             String type)
                      throws WTException
Throws:
WTException

LogBulkIndex

private static void LogBulkIndex(String message,
                                 boolean tee,
                                 boolean override)

LogBulkIndex

private static void LogBulkIndex(Throwable t)

getPrincipal

private static WTPrincipal getPrincipal()
                                 throws IndexPolicyException,
                                        WTException
Throws:
IndexPolicyException
WTException

getIndexPolicyListStatic

public static IndexPolicyList getIndexPolicyListStatic(Selector selector)
                                                throws WTException
Throws:
WTException

processRwareRequest

public static HashMap processRwareRequest(WTCollection targetCollection,
                                          boolean bulkIndex)
                                   throws WTException
Throws:
WTException

printWTCollection

private void printWTCollection(KeyedEvent keyedEvent,
                               WTCollection indexableCollection)

addItemsToCache

private static void addItemsToCache(WTCollection indexableCollection)
                             throws WTException,
                                    PropertyVetoException
Throws:
WTException
PropertyVetoException

editItemCache

private static void editItemCache(Object key,
                                  Object value)

getItemFromCache

private static Object getItemFromCache(Object obj)