com.ptc.wvs.server.publish
Class PublishQueueHelper

java.lang.Object
  extended bycom.ptc.wvs.server.publish.PublishQueueHelper
All Implemented Interfaces:
RemoteAccess

public class PublishQueueHelper
extends Object
implements RemoteAccess

PublishQueueHelper works with the ProcessingQueues that the Windchill Visualization Service uses to queue jobs for conversion.

Jobs are initially submitted to the PublisherQueue. When a job executes in this queue, it looks for a free ProcessingQueue whose name is of the form PublisherQueue'Number'. The numbers of the queue need not be sequential. When a free queue is located, the executing job in the PublisherQueue, submits itself to the PublisherQueue'Number' queue, where PublishJob should execute immediately. Completed jobs in the PublisherQueue are not kept. PublisherQueue'Number' * completed jobs are kept, so that log information can be accessed.



Supported API: false

Extendable: true


Field Summary
static String AVAILABLE_TIMES
           
private static String[] busyItems
          Locates the next available PublisherQueue'N'

Supported API: false
private static int DISPLAY_LIMIT
           
private static char END_ENTRY_CHAR
           
private static String FIRST_ENTRY
           
private static int FREE_QUEUE_SLEEP
           
private static String NBSP
           
private static String NEXT_ENTRY
           
private static String NEXT_ENTRY_RIGHT
           
private static Integer NUMBER_OF_QUEUES
           
private static String QUEUE_DEFAULT_VAL
           
static String QUEUE_HIGH_SUFFIX
           
static String QUEUE_LOW_SUFFIX
           
static String QUEUE_MEDIUM_SUFFIX
           
static String QUEUE_NAME
          The name of the processing queue
static String QUEUE_NAME_HIGH
           
static String QUEUE_NAME_LOW
           
static String QUEUE_NAME_MEDIUM
           
static String QUEUE_PRIORITIES
           
private static String QUEUE_VAL_SEP
           
private static Hashtable queuePriorities
           
private static String RESOURCE
           
private static String ROW_ENTRY
           
private static String TABLEEVENROWBG
           
private static String TABLEODDROWBG
           
private static boolean VERBOSE
           
private static WVSProperties wvsProperties
           
 
Fields inherited from interface wt.method.RemoteAccess
versionID
 
Constructor Summary
PublishQueueHelper()
           
 
Method Summary
private static Boolean addEntry(WtQueue queue, Collection collection)
          Adds a job to the specified queue

Supported API: false
private static Boolean addEntry(WtQueue queue, PublishJob publishJob)
           
static void addPublishEntry(Collection collection)
           
static Boolean addPublishEntry(PublishJob publishJob)
          First ensures that the Publisher queues exists, then adds a job to the base queue QUEUE_NAME

Supported API: false
static void addToFreeQueue(PublishJob publishJob)
          Adds the publish job to the next free PublisherQueue'n'

Supported API: false
static Map createMultiQueue(String queueName, Integer nqueues)
          Creates all the PublisherQueue's Typically : PublisherQueue, PublisherQueue1 ...
static WtQueue createQueue(String queueName)
          Creates a new processing queue.
static void deleteQueueEntry(boolean deleteWaiting, boolean deleteOnlySuccess, String cRef)
          Deletes All Queue Entries accessible to the user
static void deleteQueueEntry(String cRef)
          Deletes All Queue Entries accessible to the user

Supported API: false
static void deleteQueueEntry(String queueNo, String queueEntryNo)
          Deletes a Queue Entry

Supported API: false
static String displayQueueEntry(String queueNo, String queueEntryNo, Boolean refresh, Locale locale)
          Returns an HTML table of the details of a queue entry

Supported API: false
private static PublishJob extractPublishJob(QueueEntry queueEntry)
          Extracts the PublishJob from the QueueENtry

Supported API: false
private static WtQueue findAvailableQueue(String queueName)
           
private static int formatQueueEntry(StringBuffer buf, QueueEntry queueEntry, String queueNo, boolean waitingJob, boolean urlLinks, boolean details, boolean onlyFailures, WTPrincipal entryPrincipal, String bcol, String[] statusDisplay, ArrayList containers, boolean containerWasSpecified, int count, String trailId, String addArgs, Locale locale)
          Produces an HTML table entry for the specified Queue Entry

Supported API: false
static QueryResult getAllQueueEntries()
          Queries all the queues with a name like QUEUE_NAME, and orders the result by the Queue ntry Number

Supported API: false
private static long getExecutingJobNumber(String queueName)
          Returns the entry number of the executing job in the queue QUEUE_NAME

Supported API: false
static Hashtable getPublisherQueueAvailableTimes()
          reads PublisherQueue available time from wvs.properties used by WorkerOnlineStatus, to start and stop queues

Supported API: false
static QueryResult getQueueEntries(WtQueue queue)
           
private static String getQueueNameForPublishJob(int requestType, int requestSource)
           
static String getStatistics(Boolean refresh, Boolean OnlyFailures, Boolean DisplayAll, String cRef, Locale locale)
          Returns an HTML table of the Publisher Queue entries

Supported API: false
private static String[] getStatusDisplay(Locale locale)
           
private static String getStrings(File file)
          Returns the strings from the executing log file

Supported API: false
private static int getValidQueueNumber(ProcessingQueue wtqueue)
          Extracts the queue number.
private static QueryResult getWaitingQueueEntries()
          Queries the queue ordered by the Queue Entry Number

Supported API: false
static Boolean processPublisherQueueAvailableTimes(String queueName, Boolean ns)
           
private static Enumeration queueEntries(ProcessingQueue queue, String queueEntryNo)
          Returns the Queue Entry from the specified queue and entry number there should be either 0 or 1 in the result

Supported API: false
private static String statusDisplayMessage(String statusCode, PublishJob publishJob, String[] statusDisplay)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

NUMBER_OF_QUEUES

private static final Integer NUMBER_OF_QUEUES

VERBOSE

private static boolean VERBOSE

FREE_QUEUE_SLEEP

private static int FREE_QUEUE_SLEEP

DISPLAY_LIMIT

private static int DISPLAY_LIMIT

TABLEODDROWBG

private static String TABLEODDROWBG

TABLEEVENROWBG

private static String TABLEEVENROWBG

wvsProperties

private static WVSProperties wvsProperties

queuePriorities

private static Hashtable queuePriorities

QUEUE_NAME

public static final String QUEUE_NAME
The name of the processing queue

See Also:
Constant Field Values

QUEUE_LOW_SUFFIX

public static final String QUEUE_LOW_SUFFIX
See Also:
Constant Field Values

QUEUE_NAME_LOW

public static final String QUEUE_NAME_LOW
See Also:
Constant Field Values

QUEUE_MEDIUM_SUFFIX

public static final String QUEUE_MEDIUM_SUFFIX
See Also:
Constant Field Values

QUEUE_NAME_MEDIUM

public static final String QUEUE_NAME_MEDIUM
See Also:
Constant Field Values

QUEUE_HIGH_SUFFIX

public static final String QUEUE_HIGH_SUFFIX
See Also:
Constant Field Values

QUEUE_NAME_HIGH

public static final String QUEUE_NAME_HIGH
See Also:
Constant Field Values

AVAILABLE_TIMES

public static final String AVAILABLE_TIMES
See Also:
Constant Field Values

QUEUE_PRIORITIES

public static final String QUEUE_PRIORITIES
See Also:
Constant Field Values

QUEUE_VAL_SEP

private static final String QUEUE_VAL_SEP
See Also:
Constant Field Values

QUEUE_DEFAULT_VAL

private static final String QUEUE_DEFAULT_VAL
See Also:
Constant Field Values

busyItems

private static final String[] busyItems
Locates the next available PublisherQueue'N'

Supported API: false


ROW_ENTRY

private static final String ROW_ENTRY
See Also:
Constant Field Values

FIRST_ENTRY

private static final String FIRST_ENTRY
See Also:
Constant Field Values

NEXT_ENTRY_RIGHT

private static final String NEXT_ENTRY_RIGHT
See Also:
Constant Field Values

NEXT_ENTRY

private static final String NEXT_ENTRY
See Also:
Constant Field Values

END_ENTRY_CHAR

private static final char END_ENTRY_CHAR
See Also:
Constant Field Values

NBSP

private static final String NBSP
See Also:
Constant Field Values
Constructor Detail

PublishQueueHelper

public PublishQueueHelper()
Method Detail

createMultiQueue

public static Map createMultiQueue(String queueName,
                                   Integer nqueues)
Creates all the PublisherQueue's Typically : PublisherQueue, PublisherQueue1 ... PublishQueue'Nqueues'

Supported API: false

Parameters:
queueName - The name of the base queue (QUEUE_NAME)
nqueues - The number of queues to create which will process a PublishJob
Returns:
Boolean Success TRUE

createQueue

public static WtQueue createQueue(String queueName)
Creates a new processing queue. Checks to see if one already exists with the same name, if so returns TRUE Otherwise attempts to create a new queue

Supported API: false

Parameters:
queueName - The name of the queue
Returns:
Boolean Success TRUE

getQueueNameForPublishJob

private static String getQueueNameForPublishJob(int requestType,
                                                int requestSource)

addPublishEntry

public static void addPublishEntry(Collection collection)

addPublishEntry

public static Boolean addPublishEntry(PublishJob publishJob)
First ensures that the Publisher queues exists, then adds a job to the base queue QUEUE_NAME

Supported API: false

Parameters:
publishJob - The job to publish
Returns:
Boolean Success TRUE

addEntry

private static Boolean addEntry(WtQueue queue,
                                Collection collection)
Adds a job to the specified queue

Supported API: false

Returns:
Boolean Success TRUE

addEntry

private static Boolean addEntry(WtQueue queue,
                                PublishJob publishJob)

getWaitingQueueEntries

private static QueryResult getWaitingQueueEntries()
                                           throws WTException
Queries the queue ordered by the Queue Entry Number

Supported API: false

Returns:
Enumeration queue entries
Throws:
WTException

getQueueEntries

public static QueryResult getQueueEntries(WtQueue queue)
                                   throws WTException
Throws:
WTException

getAllQueueEntries

public static QueryResult getAllQueueEntries()
                                      throws WTException
Queries all the queues with a name like QUEUE_NAME, and orders the result by the Queue ntry Number

Supported API: false

Returns:
QueryResult queue entries
Throws:
WTException

getStatistics

public static String getStatistics(Boolean refresh,
                                   Boolean OnlyFailures,
                                   Boolean DisplayAll,
                                   String cRef,
                                   Locale locale)
Returns an HTML table of the Publisher Queue entries

Supported API: false

Parameters:
refresh - TRUE if table is automatically refreshing
locale - the client locale for the data
Returns:
String HTML table

displayQueueEntry

public static String displayQueueEntry(String queueNo,
                                       String queueEntryNo,
                                       Boolean refresh,
                                       Locale locale)
Returns an HTML table of the details of a queue entry

Supported API: false

Parameters:
queueNo - The Publisher Queue Number
refresh - TRUE if table is automatically refreshing
Returns:
StringBuffer HTML table

deleteQueueEntry

public static void deleteQueueEntry(String queueNo,
                                    String queueEntryNo)
Deletes a Queue Entry

Supported API: false

Parameters:
queueNo - The Publisher Queue Number

deleteQueueEntry

public static void deleteQueueEntry(String cRef)
Deletes All Queue Entries accessible to the user

Supported API: false


deleteQueueEntry

public static void deleteQueueEntry(boolean deleteWaiting,
                                    boolean deleteOnlySuccess,
                                    String cRef)
Deletes All Queue Entries accessible to the user

Parameters:
deleteWaiting - - deletes jobs waiting to execute
deleteOnlySuccess - - only delete completed jobs that were also successfull

Supported API: false

addToFreeQueue

public static void addToFreeQueue(PublishJob publishJob)
Adds the publish job to the next free PublisherQueue'n'

Supported API: false


findAvailableQueue

private static WtQueue findAvailableQueue(String queueName)

getPublisherQueueAvailableTimes

public static Hashtable getPublisherQueueAvailableTimes()
reads PublisherQueue available time from wvs.properties used by WorkerOnlineStatus, to start and stop queues

Supported API: false

Returns:
Hashtable fro each queue name the start/stop/day in a Vector

processPublisherQueueAvailableTimes

public static Boolean processPublisherQueueAvailableTimes(String queueName,
                                                          Boolean ns)

formatQueueEntry

private static int formatQueueEntry(StringBuffer buf,
                                    QueueEntry queueEntry,
                                    String queueNo,
                                    boolean waitingJob,
                                    boolean urlLinks,
                                    boolean details,
                                    boolean onlyFailures,
                                    WTPrincipal entryPrincipal,
                                    String bcol,
                                    String[] statusDisplay,
                                    ArrayList containers,
                                    boolean containerWasSpecified,
                                    int count,
                                    String trailId,
                                    String addArgs,
                                    Locale locale)
Produces an HTML table entry for the specified Queue Entry

Supported API: false

Parameters:
buf - the StringBuffer to append ot
queueEntry - The queue entry to format
queueNo - The queue number where the entry is from
urlLinks - if true add link to see details of job
details - if true display the details of the job eg. Name, description
Returns:
StringBuffer HTML table entry

getStatusDisplay

private static String[] getStatusDisplay(Locale locale)

statusDisplayMessage

private static String statusDisplayMessage(String statusCode,
                                           PublishJob publishJob,
                                           String[] statusDisplay)

getExecutingJobNumber

private static long getExecutingJobNumber(String queueName)
Returns the entry number of the executing job in the queue QUEUE_NAME

Supported API: false

Returns:
Long job number

queueEntries

private static Enumeration queueEntries(ProcessingQueue queue,
                                        String queueEntryNo)
                                 throws WTException
Returns the Queue Entry from the specified queue and entry number there should be either 0 or 1 in the result

Supported API: false

Parameters:
queue - The queue
queueEntryNo - The entry number with the queue
Returns:
Enumeration The QueueEntry result
Throws:
WTException

extractPublishJob

private static PublishJob extractPublishJob(QueueEntry queueEntry)
Extracts the PublishJob from the QueueENtry

Supported API: false

Parameters:
queueEntry - The queueEntry
Returns:
PublishJob The PublishJob from the QueueEntry

getStrings

private static String getStrings(File file)
Returns the strings from the executing log file

Supported API: false

Parameters:
file - The file
Returns:
String All strings from the file

getValidQueueNumber

private static int getValidQueueNumber(ProcessingQueue wtqueue)
Extracts the queue number. Eg, N from PublisherQueue'N'

Supported API: false

Parameters:
wtqueue - The queue
Returns:
int The queue number