LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.web
Class LyFilePartWriter

java.lang.Object
  extended by leon.view.web.LyFilePartWriter
All Implemented Interfaces:
LyFreeInterface

public class LyFilePartWriter
extends java.lang.Object
implements LyFreeInterface

This class saves attachment on server side and retrieve them on request. This class should be overridden to specify location.


Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyFilePartWriter()
          Constructor.
 
Method Summary
 void commit(boolean keep)
          Validates file upload.
 void computeServerFileName()
          Automatically compute a valid server file name from current properties.
 void free()
          Cleans up everything Keep parameters and internal request for later use.
 java.lang.String getAttachmentDirectory()
          Gets the attachment directory from meta-model.
 java.lang.String getClientFileName()
          Gets the original filename on client side.
 java.lang.String getContentType()
          Gets file content type (sent by the client, can't verify).
 java.lang.String getFileLocation()
          Location (address) to access to this file (stored in database) default returns getServerFileName().
 java.lang.String getServerFileName()
          Gets server filename (local name).
 void saveFile(java.io.InputStream iStream)
          Saves the stream to a file on server side Takes current parameters, and if needed compute a serverFileName.
 void setAttachmentDirectory(java.lang.String attachmentDirectory)
          Sets the attachment directory.
 void setClientFileName(java.lang.String fileName)
          Sets the filename on client side.
 void setContentType(java.lang.String contentType)
          Sets file content type.
 void setEnvironment(LyEnvironment environment)
          Gets the environment.
 void setServerFileName(java.lang.String fileName)
          Server filename (local name).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

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

LyFilePartWriter

public LyFilePartWriter()
Constructor.

Method Detail

setEnvironment

public void setEnvironment(LyEnvironment environment)
Gets the environment.

Parameters:
environment - Current environment

saveFile

public void saveFile(java.io.InputStream iStream)
              throws java.io.IOException
Saves the stream to a file on server side Takes current parameters, and if needed compute a serverFileName. File is saved to a temporary file until commit. (handle close / valid)

Parameters:
iStream - input stream to read the data from.
Throws:
java.io.IOException
See Also:
computeServerFileName()

commit

public void commit(boolean keep)
            throws java.io.IOException
Validates file upload. File is stored permanently on server side, or removed if the parameter is false.

Parameters:
keep - true if the file is committed, false otherwise.
Throws:
java.io.IOException

free

public void free()
Cleans up everything Keep parameters and internal request for later use.

Specified by:
free in interface LyFreeInterface

getClientFileName

public java.lang.String getClientFileName()
Gets the original filename on client side.

Returns:
original fileName or null if unknown
See Also:
setClientFileName(String)

setClientFileName

public void setClientFileName(java.lang.String fileName)
Sets the filename on client side.

Parameters:
fileName - the new fileName
See Also:
getClientFileName()

getServerFileName

public java.lang.String getServerFileName()
Gets server filename (local name). This is the actual local location of the file on the server. The value stored in database (client side location) is getFileLocation which return the same value.

Returns:
local file path on server or null if unknown
See Also:
getFileLocation(), setServerFileName(String)

getFileLocation

public java.lang.String getFileLocation()
Location (address) to access to this file (stored in database) default returns getServerFileName().

Returns:
server location or null if unknown
See Also:
getServerFileName()

computeServerFileName

public void computeServerFileName()
Automatically compute a valid server file name from current properties.

May be overriden by subclasses. This method is called when saving data and when no server filename is specified.

See Also:
setServerFileName(String)

setServerFileName

public void setServerFileName(java.lang.String fileName)
Server filename (local name).

Parameters:
fileName - the new server file name
See Also:
getServerFileName()

getContentType

public java.lang.String getContentType()
Gets file content type (sent by the client, can't verify).

Returns:
content type (mime type) or null if unknown
See Also:
setContentType(String)

setContentType

public void setContentType(java.lang.String contentType)
Sets file content type.

Parameters:
contentType - the new content type (mime type). May be null.
See Also:
getContentType()

getAttachmentDirectory

public java.lang.String getAttachmentDirectory()
Gets the attachment directory from meta-model.

Returns:
the attachment directory
See Also:
setAttachmentDirectory(String)

setAttachmentDirectory

public void setAttachmentDirectory(java.lang.String attachmentDirectory)
Sets the attachment directory.

Parameters:
attachmentDirectory - the new attachment directory
See Also:
getAttachmentDirectory()

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com