com.ptc.windchill.index.indexloader
Class IndexEntryToRware

java.lang.Object
  extended bycom.ptc.windchill.index.indexloader.IndexEntryToRware
All Implemented Interfaces:
Runnable

public class IndexEntryToRware
extends Object
implements Runnable

This class represents the focal point of the indexing program. A new instance is created for each request. This class reads a stream from the indexer and writes a formatted string that uses a RetrievalWare API to initiate the indexing of that file. *



Supported API: false

Extendable: false


Field Summary
private static byte[] arrPcLineSep
           
private  BufferedInputStream bufferedInputStream
           
private  String encoding
           
private static String filesep
           
private  LinkedList indexables
           
private static boolean initialized
           
private  InputStream inputStreamIn
           
private static long lastDeleteFileRan
           
(package private)  int lineno
           
private static byte[] linesep
           
private static RwareInterfaceException logException
           
private  String operation
           
private  OutputStream outputStreamIn
           
private  ServletConstants servletConstants
           
private static File tDir
           
private static String tempDir
           
private  File tempFile
           
private  long tempTimer
           
private  int version
           
 
Constructor Summary
IndexEntryToRware()
          Creates a new IndexEntryToExcalibur object for our http scheme.
 
Method Summary
 void clearInputStream(BufferedInputStream bufferedInputStream)
          This method is used to empty the input stream so that the writer to the stream will not block.
 void clearLob(String number_bytes_string)
          This function is used to empty the InputStream of a LOB when an error occurs.
private  void execute(boolean index)
           
private  String getRestLine(IndexStringTokenizer tokenizer)
           
private  boolean isComment(String token)
          Returns true if the token string is a comment.
 boolean meetsCriteria(long lastModified, long present, long ageInMinutes)
           
private  void performOperation(boolean index)
           
 void processRequest(IndexLoaderRequest request, IndexLoaderResponse response)
          Process request received from the client via http.
private  void readHeader()
          Read the index entry "header" infomation to find the operation.
private  String readLine()
          Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
     DataInputStream d = new DataInputStream(in);
 
with:
     BufferedReader d
          = new BufferedReader(new InputStreamReader(in));
 
 void removeOldFiles(long ageInMinutes)
           
 void run()
          The entry point to the index loading process.
 boolean setServletConstants(ServletConstants sc)
           
private  void update(boolean update)
          Create a file to be used as input to the RetrievalWare supplied method CqdhClient.cqdh_process_file_clnt_1.
private  String writeRemoteLob(String number_bytes_string, String appOID, String contentFileName)
          Write the lob to the stream.
private  void writeTokenStream()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bufferedInputStream

private BufferedInputStream bufferedInputStream

logException

private static RwareInterfaceException logException

inputStreamIn

private InputStream inputStreamIn

outputStreamIn

private OutputStream outputStreamIn

encoding

private final String encoding
See Also:
Constant Field Values

tempFile

private File tempFile

tempDir

private static String tempDir

operation

private String operation

tempTimer

private long tempTimer

lastDeleteFileRan

private static long lastDeleteFileRan

filesep

private static String filesep

linesep

private static byte[] linesep

tDir

private static File tDir

initialized

private static boolean initialized

version

private int version

lineno

int lineno

servletConstants

private ServletConstants servletConstants

indexables

private LinkedList indexables

arrPcLineSep

private static byte[] arrPcLineSep
Constructor Detail

IndexEntryToRware

public IndexEntryToRware()
Creates a new IndexEntryToExcalibur object for our http scheme.

Method Detail

processRequest

public void processRequest(IndexLoaderRequest request,
                           IndexLoaderResponse response)
                    throws IOException
Process request received from the client via http. This is the call that gets things going for http based requests. We don't need a new thread to run this in, don't need to call start, etc. This is already running in a thread via the servlet/cgi. So, we just need to set things up and call run.

Throws:
IOException

clearInputStream

public void clearInputStream(BufferedInputStream bufferedInputStream)
This method is used to empty the input stream so that the writer to the stream will not block. Used when an error occurs before the entire stream is read.


clearLob

public void clearLob(String number_bytes_string)
This function is used to empty the InputStream of a LOB when an error occurs.


run

public void run()
The entry point to the index loading process. It will read the index entry header information. The information obtained from the header indicates whether to insert or delete a library entry.

Specified by:
run in interface Runnable

readHeader

private void readHeader()
                 throws RwareInterfaceException
Read the index entry "header" infomation to find the operation.

Throws:
RwareInterfaceException

isComment

private boolean isComment(String token)
Returns true if the token string is a comment.

Parameters:
token - string to check for comment characters
Returns:
true if the token is a comment, otherwise false

writeRemoteLob

private String writeRemoteLob(String number_bytes_string,
                              String appOID,
                              String contentFileName)
                       throws RwareInterfaceException
Write the lob to the stream.

Throws:
RwareInterfaceException

update

private void update(boolean update)
             throws RwareInterfaceException
Create a file to be used as input to the RetrievalWare supplied method CqdhClient.cqdh_process_file_clnt_1. This method will index the file.

Throws:
RwareInterfaceException

removeOldFiles

public void removeOldFiles(long ageInMinutes)

meetsCriteria

public boolean meetsCriteria(long lastModified,
                             long present,
                             long ageInMinutes)

getRestLine

private String getRestLine(IndexStringTokenizer tokenizer)

writeTokenStream

private void writeTokenStream()
                       throws RwareInterfaceException
Throws:
RwareInterfaceException

performOperation

private void performOperation(boolean index)
                       throws RwareInterfaceException
Throws:
RwareInterfaceException

execute

private void execute(boolean index)
              throws RwareInterfaceException
Throws:
RwareInterfaceException

setServletConstants

public boolean setServletConstants(ServletConstants sc)

readLine

private final String readLine()
                       throws IOException
Deprecated. This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
     DataInputStream d = new DataInputStream(in);
 
with:
     BufferedReader d
          = new BufferedReader(new InputStreamReader(in));
 

See the general contract of the readLine method of DataInput.

Bytes for this operation are read from the contained input stream.

Returns:
the next line of text from this input stream.
Throws:
IOException - if an I/O error occurs.
See Also:
BufferedReader.readLine(), FilterInputStream.in