com.webmethods.caf.faces.data.csp
Class CSPAttachmentsProvider

java.lang.Object
  extended by com.webmethods.caf.faces.bean.BaseFacesBean
      extended by com.webmethods.caf.faces.bean.BaseFacesSessionBean
          extended by com.webmethods.caf.faces.data.csp.CSPBaseProvider
              extended by com.webmethods.caf.faces.data.csp.CSPAttachmentsProvider
All Implemented Interfaces:
IPageFlowScopeAdapter, IAttachmentsProvider, IRefreshable, Serializable

public class CSPAttachmentsProvider
extends CSPBaseProvider
implements IRefreshable, IAttachmentsProvider

Attachments provider for fetching files from CSP This attachments provider is intended to be used for exposing files from CSP. However to work properly it should be provided with Session instance and a content id

See Also:
Serialized Form

Field Summary
static String CSP_TMP_DIR
           
 
Fields inherited from class com.webmethods.caf.faces.data.csp.CSPBaseProvider
fRetrievalModule, fSession
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
fExpireWithPageFlow
 
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
DATA_BINDING_CLIENTS, OUTCOME_ERROR, OUTCOME_OK, resourcesProviders
 
Constructor Summary
CSPAttachmentsProvider()
           
 
Method Summary
 void addAttachment(FileItem fileItem, String fileEncoding)
          Add Attachment
protected  void checkState()
          Check if a RetrievalModule has been properly inited.If not it most probably means a session is not set.
 String createHttpUrl(String smiPath)
           
 String getContentId()
          Returns the content id whose children will be listed
 String getDateAsString(Date date)
           
 String getDownloadProtocol()
          Returns the download protocol that will be used when download link is created.
 boolean getHasAttachments()
          Returns whether the attachment provider has any attachments
 int getHttpPort()
          Returns the download port that will be used when download link is created.
 boolean getNeedRefresh()
          Returns true when IRefreshable.isAutoRefresh() is on and the result properties need to be refreshed from the data source by executing IRefreshable.refresh() method.
 Date getStringAsDate(String str)
           
 boolean isAddAttachmentsAvailable()
          Returns whether attachments can be added
 boolean isAutoRefresh()
          Returns true if the provider is currenlty in auto-refresh mode
 boolean isPermanentDelete()
           
 List listAttachments()
          Returns a list of the current attachments
 void refresh()
          (Re)loads data from the data source.
 void removeAttachment(String attachmentID)
          Remove Attachment
 void setAutoRefresh(boolean autorefresh)
          Sets auto refresh mode on.
 void setContentId(String contentId)
          Sets the content id whose children will be listed.
 void setDownloadProtocol(String downloadProtocol)
          Sets the download protocol that will be used when download link is created
 void setHttpPort(int httpPort)
          Sets the download port that will be used when download link is created
 void setNeedRefresh(boolean needRefresh)
          Tells the provider that the input parameters have changed and the output results need to be refreshed the next time any output property is requested via IContentProvider.getValue(Object).
 void setPermanentDelete(boolean permanentDelete)
           
 boolean supportsAutoRefresh()
          Returns true if this content provider supports auto refresh feature.
 void updateAttachment(String attachmentID, FileItem fileItem, String fileEncoding)
          Update an Attachment
static void uploadFileSMI(Session session, FileItem sourceFile)
           
 
Methods inherited from class com.webmethods.caf.faces.data.csp.CSPBaseProvider
getSession, release, setSession
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
getExpireWithPageFlow, setExpireWithPageFlow, valueBound, valueUnbound
 
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
createMethodBinding, createValueBinding, error, error, error, error, error, getBean, getFacesContext, getLocale, getResourceInputStream, getResources, getResourcesProvider, getRootCause, getStackTrace, getTreeAttribute, isUserInRole, log, log, log, putTreeAttribute, resetDataBindingClients, resolveDataBinding, resolveDataBinding, resolveExpression, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CSP_TMP_DIR

public static final String CSP_TMP_DIR
See Also:
Constant Field Values
Constructor Detail

CSPAttachmentsProvider

public CSPAttachmentsProvider()
Method Detail

getNeedRefresh

public boolean getNeedRefresh()
Description copied from interface: IRefreshable

Returns true when IRefreshable.isAutoRefresh() is on and the result properties need to be refreshed from the data source by executing IRefreshable.refresh() method.

Implementations may return an accurate value from this method if they can track the changes to the input parameter properties or they may require the clients to call IRefreshable.setNeedRefresh(boolean) explicitely.

Specified by:
getNeedRefresh in interface IRefreshable
Returns:
true when the output properties are not up-to-date with the current input parameters, i.e. IRefreshable.refresh() needs to be executed manually or automatically.

isAutoRefresh

public boolean isAutoRefresh()
Description copied from interface: IRefreshable
Returns true if the provider is currenlty in auto-refresh mode

Specified by:
isAutoRefresh in interface IRefreshable
Returns:
false if auto-refresh mode is off or not supported

getDownloadProtocol

public String getDownloadProtocol()
Returns the download protocol that will be used when download link is created.

Returns:
The download protocol that will be used when download link is created

setDownloadProtocol

public void setDownloadProtocol(String downloadProtocol)
Sets the download protocol that will be used when download link is created

Parameters:
downloadProtocol - to be used when download link is created

getHttpPort

public int getHttpPort()
Returns the download port that will be used when download link is created.

Returns:
The download port that will be used when download link is created

setHttpPort

public void setHttpPort(int httpPort)
Sets the download port that will be used when download link is created

Parameters:
httpPort - to be used when download link is created

refresh

public void refresh()
             throws ContentProviderException
Description copied from interface: IRefreshable
(Re)loads data from the data source. Implementation specific meaning can be executing a SQL query or a web service call. All current data will be lost and updated with the new results if successful.

Specified by:
refresh in interface IRefreshable
Throws:
ContentProviderException - if error loading data from the data source

setAutoRefresh

public void setAutoRefresh(boolean autorefresh)
                    throws ContentProviderException
Description copied from interface: IRefreshable

Sets auto refresh mode on. When auto refresh mode is on, the provider calls IRefreshable.getNeedRefresh() to determine whether the refresh needs to be done before returning any result properties. If it returns true, the provider calls IRefreshable.refresh() method to updated the result properties.

Specified by:
setAutoRefresh in interface IRefreshable
Parameters:
autorefresh - true to turn it on
Throws:
ContentProviderException - if auto refresh mode is not supported
See Also:
IRefreshable.supportsAutoRefresh(), IRefreshable.getNeedRefresh(), IRefreshable.setNeedRefresh(boolean)

setNeedRefresh

public void setNeedRefresh(boolean needRefresh)
Description copied from interface: IRefreshable
Tells the provider that the input parameters have changed and the output results need to be refreshed the next time any output property is requested via IContentProvider.getValue(Object).

Specified by:
setNeedRefresh in interface IRefreshable
Parameters:
needRefresh - true if the input parameters have changed

supportsAutoRefresh

public boolean supportsAutoRefresh()
Description copied from interface: IRefreshable
Returns true if this content provider supports auto refresh feature.

Specified by:
supportsAutoRefresh in interface IRefreshable
Returns:
true when auto refresh is supported
See Also:
IRefreshable.setAutoRefresh(boolean)

setContentId

public void setContentId(String contentId)
Sets the content id whose children will be listed. This is mandatory property

Parameters:
contentId - Content id whose children will be listed. Mandatory.

getContentId

public String getContentId()
Returns the content id whose children will be listed

Returns:
Content id whose children will be listed

uploadFileSMI

public static void uploadFileSMI(Session session,
                                 FileItem sourceFile)
                          throws Exception
Throws:
Exception

checkState

protected void checkState()
Description copied from class: CSPBaseProvider
Check if a RetrievalModule has been properly inited.If not it most probably means a session is not set.

Overrides:
checkState in class CSPBaseProvider

setPermanentDelete

public void setPermanentDelete(boolean permanentDelete)

isPermanentDelete

public boolean isPermanentDelete()

addAttachment

public void addAttachment(FileItem fileItem,
                          String fileEncoding)
Description copied from interface: IAttachmentsProvider
Add Attachment

Specified by:
addAttachment in interface IAttachmentsProvider
Parameters:
fileItem - the attachment content
fileEncoding - the encoding of the attachment file (if known)

getDateAsString

public String getDateAsString(Date date)

getStringAsDate

public Date getStringAsDate(String str)

getHasAttachments

public boolean getHasAttachments()
Description copied from interface: IAttachmentsProvider
Returns whether the attachment provider has any attachments

Specified by:
getHasAttachments in interface IAttachmentsProvider
Returns:
true or false

isAddAttachmentsAvailable

public boolean isAddAttachmentsAvailable()
Description copied from interface: IAttachmentsProvider
Returns whether attachments can be added

Specified by:
isAddAttachmentsAvailable in interface IAttachmentsProvider
Returns:
true or false

listAttachments

public List listAttachments()
Description copied from interface: IAttachmentsProvider
Returns a list of the current attachments

Specified by:
listAttachments in interface IAttachmentsProvider
Returns:
collection of AttachmentItems

removeAttachment

public void removeAttachment(String attachmentID)
Description copied from interface: IAttachmentsProvider
Remove Attachment

Specified by:
removeAttachment in interface IAttachmentsProvider
Parameters:
attachmentID - the id of the attachment to remove

updateAttachment

public void updateAttachment(String attachmentID,
                             FileItem fileItem,
                             String fileEncoding)
Description copied from interface: IAttachmentsProvider
Update an Attachment

Specified by:
updateAttachment in interface IAttachmentsProvider
Parameters:
attachmentID - the id of the attachment to update
fileItem - the new attachment content
fileEncoding - the encoding of the attachment file (if known)

createHttpUrl

public String createHttpUrl(String smiPath)
                     throws COMM_Exception
Throws:
COMM_Exception