ext.tools
Class ContentToolbox

java.lang.Object
  extended by ext.tools.ContentToolbox
All Implemented Interfaces:
wt.method.RemoteAccess

public class ContentToolbox
extends java.lang.Object
implements wt.method.RemoteAccess


Field Summary
static java.lang.String CVSVersion
           
 
Fields inherited from interface wt.method.RemoteAccess
versionID
 
Constructor Summary
ContentToolbox()
           
 
Method Summary
 void createTempDir()
          Creates a temporary directoy under Windchill/temp for use with this ContentToolbox object.
 wt.content.ContentHolder deleteAllContent(wt.content.ContentHolder theHolder)
          Deletes all ContentItems (including Primary) from the ContentHolder.
 void deleteContent(wt.content.ContentHolder theHolder, wt.content.ContentItem theItem)
          Deletes the specified ContentItem from the ContentHolder.
 boolean deleteDirectory(java.io.File d)
          Deletes directory and all subdirs and contained files.
 void deletePrimary(wt.doc.WTDocument theDoc)
          Deletes the primary content of a WTDocument.
 boolean deleteTempDirectory()
          Deletes the temporary directory associated with this toolbox.
static java.io.File doUncompressFile(java.lang.String inFileName, java.lang.String outFileName)
          Uncompress the incoming file.
 java.io.File downloadContent(wt.content.ApplicationData theItem)
          Download the specified ContentItem from the ContentHolder to the temp directory and return it as a File.
 java.io.File downloadContent(wt.content.ApplicationData theItem, java.io.File location)
          Download the specified ContentItem from the ContentHolder to the temp directory and return it as a File.
 java.io.File downloadContent(wt.content.ApplicationData theItem, java.lang.String fn)
           
 java.io.File downloadPrimary(wt.content.FormatContentHolder theDoc)
          Downloads and returns the primary content of the WTDocument.
 java.io.File downloadPrimary(wt.doc.WTDocument theDoc, java.io.File location)
          Downloads and returns the primary content of the WTDocument to the specified location.
 java.util.Enumeration getContents(wt.content.ContentHolder theHolder)
          Returns all secondary contents for an object as an Enumeration.
static java.lang.String getExtension(java.lang.String f)
          Used to extract and return the extension of a given file.
static java.lang.String getFileName(java.lang.String f)
          Used to extract the filename without its extension.
static java.io.InputStream getIsFromContentHolder(wt.content.ContentHolder ch, wt.content.ContentRoleType crt)
          Method getIsFromContentHolder.
static java.io.InputStream getIsFromContentHolder(wt.content.ContentHolder ch, java.lang.String contentName)
          Method getIsFromContentHolder.
 java.io.File getTempDir()
          Returns the currently assigned temporary directory or null if it hasn't been assigned.
 void setTempDir(java.io.File theDirectory)
          Assigns the temporary directory for this toolbox to the specified directory.
 wt.content.ContentHolder updateContent(wt.content.ContentHolder theHolder, java.io.File theFile, java.lang.String filename)
          Replaces an existing secondary ContentItem with the specified File if it has the same name or creates a new ContentItem if it does not.
static void updatePrimary(wt.content.FormatContentHolder theDoc, java.io.File theFile, java.lang.String filename)
          Creates or Updates the primary content of a WTDocument using the specified file.
static void updatePrimary(wt.content.FormatContentHolder theDoc, java.io.File theFile, java.lang.String filename, boolean iterate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVSVersion

public static final java.lang.String CVSVersion
See Also:
Constant Field Values
Constructor Detail

ContentToolbox

public ContentToolbox()
Method Detail

createTempDir

public void createTempDir()
                   throws java.io.IOException
Creates a temporary directoy under Windchill/temp for use with this ContentToolbox object.

Throws:
java.io.IOException - if there is a problem reading WTProperties

getTempDir

public java.io.File getTempDir()
Returns the currently assigned temporary directory or null if it hasn't been assigned.

Returns:
the current temporary directory.

setTempDir

public void setTempDir(java.io.File theDirectory)
                throws java.io.FileNotFoundException
Assigns the temporary directory for this toolbox to the specified directory.

Parameters:
theDirectory - - existing directory
Throws:
java.io.FileNotFoundException
java.io.FileNotFoundException - if the directory does not exist

deleteDirectory

public boolean deleteDirectory(java.io.File d)
Deletes directory and all subdirs and contained files.

Parameters:
d - File
Returns:
boolean successful

deleteTempDirectory

public boolean deleteTempDirectory()
Deletes the temporary directory associated with this toolbox. If successful returns true. return boolean successful


downloadPrimary

public java.io.File downloadPrimary(wt.content.FormatContentHolder theDoc)
                             throws java.io.IOException,
                                    wt.util.WTException,
                                    java.beans.PropertyVetoException
Downloads and returns the primary content of the WTDocument. Will return null if content does not exist. Will overwrite existing file. Uses server side methods.

Parameters:
theDoc - - WTDocument object to download primary content from
Returns:
the File downloaded
Throws:
java.io.IOException
wt.util.WTException
java.beans.PropertyVetoException
wt.util.WTException

downloadPrimary

public java.io.File downloadPrimary(wt.doc.WTDocument theDoc,
                                    java.io.File location)
                             throws java.io.IOException,
                                    wt.util.WTException,
                                    java.beans.PropertyVetoException
Downloads and returns the primary content of the WTDocument to the specified location. Uses server side methods. Will return null if content does not exist.

Parameters:
theDoc - - WTDocument object to download primary content from
location - - an existing directory to download to
Returns:
the File downloaded
Throws:
java.io.IOException
wt.util.WTException
java.beans.PropertyVetoException
wt.util.WTException

deletePrimary

public void deletePrimary(wt.doc.WTDocument theDoc)
                   throws wt.util.WTException,
                          java.beans.PropertyVetoException
Deletes the primary content of a WTDocument. Uses server side methods. Invoke on working copy and checkin to create a new iteration (recommended).

Parameters:
theDoc - - WTDocument object to download primary content from
Throws:
wt.util.WTException
java.beans.PropertyVetoException
wt.util.WTException

updatePrimary

public static void updatePrimary(wt.content.FormatContentHolder theDoc,
                                 java.io.File theFile,
                                 java.lang.String filename)
                          throws wt.util.WTException,
                                 java.beans.PropertyVetoException,
                                 wt.fc.ObjectNoLongerExistsException,
                                 java.io.FileNotFoundException,
                                 java.io.IOException
Creates or Updates the primary content of a WTDocument using the specified file. Uses server side methods. Invoke on working copy and checkin to create a new iteration (recommended).

Parameters:
theDoc - - WTDocument object to download primary content from
theFile - - the new primary content
filename - - the filename to use when creating the content
Throws:
wt.util.WTException
java.beans.PropertyVetoException
wt.fc.ObjectNoLongerExistsException
java.io.FileNotFoundException
java.io.IOException
wt.fc.ObjectNoLongerExistsException
java.io.FileNotFoundException
wt.util.WTException
java.io.IOException

updatePrimary

public static void updatePrimary(wt.content.FormatContentHolder theDoc,
                                 java.io.File theFile,
                                 java.lang.String filename,
                                 boolean iterate)
                          throws wt.util.WTException,
                                 java.beans.PropertyVetoException,
                                 wt.fc.ObjectNoLongerExistsException,
                                 java.io.FileNotFoundException,
                                 java.io.IOException
Throws:
wt.util.WTException
java.beans.PropertyVetoException
wt.fc.ObjectNoLongerExistsException
java.io.FileNotFoundException
java.io.IOException

getContents

public java.util.Enumeration getContents(wt.content.ContentHolder theHolder)
                                  throws wt.util.WTException,
                                         java.beans.PropertyVetoException
Returns all secondary contents for an object as an Enumeration. Remember ApplicationData objects are a type of ContentItem that represent a physical file as opposed to a URLData object (also a ContentItem) which represents a URL. Use the statement if (object instanceof wt.content.ApplicationData) to test objects for their type.

Parameters:
theHolder - - any ContentHolder
Returns:
an Enumeration of the secondary conetents
Throws:
wt.util.WTException
java.beans.PropertyVetoException
wt.util.WTException

downloadContent

public java.io.File downloadContent(wt.content.ApplicationData theItem)
                             throws wt.util.WTException,
                                    java.io.IOException
Download the specified ContentItem from the ContentHolder to the temp directory and return it as a File.

Parameters:
theItem - - an ApplicationData held by theHolder (remember ApplicationData is a type of ContentItem that represents a file)
Returns:
the File downloaded
Throws:
wt.util.WTException - if the item can't by found
java.io.IOException

downloadContent

public java.io.File downloadContent(wt.content.ApplicationData theItem,
                                    java.lang.String fn)
                             throws wt.util.WTException,
                                    java.io.IOException
Throws:
wt.util.WTException
java.io.IOException

downloadContent

public java.io.File downloadContent(wt.content.ApplicationData theItem,
                                    java.io.File location)
                             throws wt.util.WTException,
                                    java.io.FileNotFoundException,
                                    java.io.IOException
Download the specified ContentItem from the ContentHolder to the temp directory and return it as a File.

Parameters:
theItem - - an ApplicationData held by theHolder (remember ApplicationData is a type of ContentItem that represents a file)
location - - an existing directory to download to
Returns:
the File downloaded
Throws:
wt.util.WTException - if the item can't by found
java.io.FileNotFoundException - if the file doesn't exist
java.io.IOException

deleteContent

public void deleteContent(wt.content.ContentHolder theHolder,
                          wt.content.ContentItem theItem)
                   throws wt.util.WTException,
                          java.beans.PropertyVetoException
Deletes the specified ContentItem from the ContentHolder. Uses server side methods. Invoke on working copy and checkin to create a new iteration (recommended).

Parameters:
theHolder - - any ContentHolder
theItem - - a ContentItem held by theHolder
Throws:
wt.util.WTException - if the item can't by found
java.beans.PropertyVetoException

deleteAllContent

public wt.content.ContentHolder deleteAllContent(wt.content.ContentHolder theHolder)
                                          throws wt.util.WTException,
                                                 java.beans.PropertyVetoException
Deletes all ContentItems (including Primary) from the ContentHolder. Uses server side methods. Invoke on working copy and checkin to create a new iteration (recommended).

Parameters:
theHolder - - any ContentHolder
Returns:
the refreshed ContentHolder
Throws:
wt.util.WTException - if the item can't by found
java.beans.PropertyVetoException

updateContent

public wt.content.ContentHolder updateContent(wt.content.ContentHolder theHolder,
                                              java.io.File theFile,
                                              java.lang.String filename)
                                       throws wt.util.WTException,
                                              java.beans.PropertyVetoException,
                                              java.io.FileNotFoundException,
                                              java.io.IOException
Replaces an existing secondary ContentItem with the specified File if it has the same name or creates a new ContentItem if it does not. Uses server side methods. Invoke on working copy and checkin to create a new iteration (recommended).

Parameters:
theHolder - - any ContentHolder
theFile - - theFile on the server to upload
filename - - the filename to use when adding the content
Returns:
the refreshed ContentHolder
Throws:
wt.util.WTException
java.beans.PropertyVetoException
java.io.FileNotFoundException
java.io.IOException

getIsFromContentHolder

public static java.io.InputStream getIsFromContentHolder(wt.content.ContentHolder ch,
                                                         wt.content.ContentRoleType crt)
                                                  throws wt.util.WTException
Method getIsFromContentHolder.

Parameters:
ch - ContentHolder
crt - ContentRoleType
Returns:
InputStream
Throws:
wt.util.WTException

getIsFromContentHolder

public static java.io.InputStream getIsFromContentHolder(wt.content.ContentHolder ch,
                                                         java.lang.String contentName)
                                                  throws wt.util.WTException
Method getIsFromContentHolder.

Parameters:
ch - ContentHolder
contentName - String
Returns:
InputStream
Throws:
wt.util.WTException

doUncompressFile

public static java.io.File doUncompressFile(java.lang.String inFileName,
                                            java.lang.String outFileName)
Uncompress the incoming file.

Parameters:
inFileName - Name of the file to be uncompressed
outFileName - New file name, if null old - gz is used
Returns:
File

getExtension

public static java.lang.String getExtension(java.lang.String f)
Used to extract and return the extension of a given file.

Parameters:
f - Incoming file to get the extension of
Returns:
String representing the extension of the incoming file.

getFileName

public static java.lang.String getFileName(java.lang.String f)
Used to extract the filename without its extension.

Parameters:
f - Incoming file to get the filename
Returns:
String representing the filename without its extension.