Structuring the file upload and download

You can implement file upload or download functionality through interface contracts in the Web UI Framework. The upload/download implementations can be plugged in either through web.xml as context parameters or programmatically by using the exposed methods.

This enables you to do the following:

  • Customize upload/download functionality in the same way that you can customize authorization, authentication, and other tasks.
  • Implement upload/download functionality for applications that do not use the Application Platform.

These tasks use the following base classes which are present both in the Application Platform (the platform_afc.jar file) and in the base file attachment jar file (platform_fa.jar) that is used when not using the Application Platform:

  • The interfaces IFileUploadProvider and IFileDownloadProvider
  • The abstract class PLTFileUploadProvider
  • The servlets PLTFileUploadservlet and PLTFileDownloadServlet
Note: For applications consuming the platform_afc.jar file, the platform_fa.jar file does not have to be added in the classpath since the file attachment base classes of the platform_fa.jar file are included in the platform_afc.jar file.

Default file upload/download implementations

The following graphic shows the default implementation of upload/download functionality in applications based on the Application Platform but which do not use the Web UI Framework:

In the graphic, Platform and Platform_AFC refer to the Application Platform.

Upload and download graphic based on the Sterling Application Platform

Default implementation classes are as follows:

  • For upload - com.sterlingcommerce.woodstock.util.frame.file.impl.PLTFileUploadProviderImpl
  • For download - com.sterlingcommerce.woodstock.util.frame.file.impl.PLTFileDownloadProviderImpl

The following graphic shows the default implementation of upload/download functionality in applications based on the Application Platform and use the Web UI Framework:

In the graphic, Platform and Platform_AFC refer to the Application Platform.

Graphic displaying the default implementation of the upload and download functionality of the Sterling Application Platform

Default implementation classes are as follows:

  • For upload - com.sterlingcommerce.ui.web.platform.file.SCUIFileUploadProviderImpl
  • For download - com.sterlingcommerce.ui.web.platform.file.SCUIFileDownloadProviderImpl

Plugging in file upload/download implementations through web.xml

The following context parameters are used when plugging in file upload/download implementations through web.xml:

  • For upload - sc-file-upload-provider
  • For download - sc-file-download-provider

The value of the above mentioned context parameters should be a qualified Java™ class path which implements IFileUploadProvider and IFileDownloadProvider for upload and download, respectively.

Sample context parameters to be plugged in applications based on the Application Platform but which do not use the WUF (note the PLT prefix in the method name):

   <context-param>
        <param-name>sc-file-upload-provider</param-name>
        <param-value>
com.sterlingcommerce.woodstock.util.frame.file.impl.PLTFileUploadProviderImpl
        </param-value>
   </context-param>
   <context-param>
        <param-name>sc-file-download-provider</param-name>
        <param-value>
com.sterlingcommerce.woodstock.util.frame.file.impl.PLTFileDownloadProviderImpl
        </param-value>
   </context-param>
Sample context parameters to be plugged in applications based on the Application Platform and are on WUF (note the SCUI prefix in the method name):
   <context-param>
        <param-name>sc-file-upload-provider</param-name>
        <param-value>
com.sterlingcommerce.ui.web.platform.file.SCUIFileUploadProviderImpl
        </param-value>
   </context-param>
   <context-param>
        <param-name>sc-file-download-provider</param-name>
        <param-value>
com.sterlingcommerce.ui.web.platform.file.SCUIFileDownloadProviderImpl
        </param-value>
   </context-param>
Note: By default, the context parameters required to plug in the default implementations will not be provided. Consuming applications will have to add the context parameters in the web.xml file or set it using setFileUploadProvider and setFileDownloadProvider methods exposed in the PLTFileUploadDownloadHelper class.

Plugging in file upload/download implementations programmatically using exposed methods

The methods setFileUploadProvider and setFileDownloadProvider are exposed in the PLTFileUploadDownloadHelper class to plug in file upload/download implementations programmatically using interface contracts.

Sample usage of the above mentioned set methods:
PLTFileUploadDownloadHelper.setUploadProviderImpl(uploadImpl);  
PLTFileUploadDownloadHelper.setDownloadProviderImpl(downloadImpl);

Here, uploadImpl and downloadImpl are class objects which implement IFileUploadProvider and IFileDownloadProvider, respectively.