Package nl.nn.adapterframework.pipes
Class UnzipPipe
- java.lang.Object
-
- nl.nn.adapterframework.core.TransactionAttributes
-
- nl.nn.adapterframework.pipes.AbstractPipe
-
- nl.nn.adapterframework.pipes.FixedForwardPipe
-
- nl.nn.adapterframework.pipes.UnzipPipe
-
- All Implemented Interfaces:
HasTransactionAttribute
,IConfigurable
,IConfigurationAware
,IExtendedPipe
,IForwardTarget
,INamedObject
,IPipe
,IScopeProvider
,EventThrowing
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
@ElementType(TRANSLATOR) public class UnzipPipe extends FixedForwardPipe
Assumes input to be the file name of a ZIP archive, and unzips it to a directory and/or an XML message.
The output of each unzipped item is returned in XML as follows when collectFileContents is false:<results count="num_of_items"> <result item="1"> <zipEntry>name in ZIP archive of first item</zipEntry> <fileName>filename of first item</fileName> </result> <result item="2"> <zipEntry>name in ZIP archive of second item</zipEntry> <fileName>filename of second item</fileName> </result> ... </results>
The output of each unzipped item is returned in XML as follows when collectFileContents is true:<results count="num_of_items"> <result item="1"> <zipEntry>name in ZIP archive of first item</zipEntry> <fileContent>content of first item</fileContent> </result> <result item="2"> <zipEntry>name in ZIP archive of second item</zipEntry> <fileContent>content of second item</fileContent> </result> ... </results>
By default, this pipe takes care to produce unique file names, as follows. When the filename within the archive is:<basename> + "." + <extension>
then the extracted filename (path omitted) becomes<basename> + <unique number> + "." + <extension>
- Since:
- 4.9
- Author:
- Gerrit van Brakel
-
-
Field Summary
-
Fields inherited from class nl.nn.adapterframework.pipes.AbstractPipe
parameterNamesMustBeUnique
-
Fields inherited from class nl.nn.adapterframework.core.TransactionAttributes
log
-
Fields inherited from interface nl.nn.adapterframework.core.IExtendedPipe
LONG_DURATION_MONITORING_EVENT, MESSAGE_SIZE_MONITORING_EVENT, PIPE_EXCEPTION_MONITORING_EVENT
-
-
Constructor Summary
Constructors Constructor Description UnzipPipe()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
configure()
checks for correct configuration of forwardPipeRunResult
doPipe(Message message, PipeLineSession session)
This is where the action takes place.String
getCollectFileContentsBase64Encoded()
String
getDirectory()
String
getDirectorySessionKey()
protected InputStream
getInputStream(Message message, PipeLineSession session)
boolean
isAssumeDirectoryExists()
boolean
isCollectFileContents()
boolean
isCollectResults()
boolean
isDeleteOnExit()
Deprecated.boolean
isKeepOriginalFileName()
boolean
isKeepOriginalFilePath()
boolean
isProcessFile()
void
setAssumeDirectoryExists(boolean assumeDirectoryExists)
If settrue
, validation of directory is ignoredvoid
setCheckDirectory(boolean checkDirectory)
Deprecated.void
setCollectFileContents(boolean b)
If settrue
, the contents of the files in the zip are returned in the result xml message of this pipe.void
setCollectFileContentsBase64Encoded(String string)
Comma separated list of file extensions.void
setCollectResults(boolean b)
If setfalse
, only a small summary (count of items in zip) is returnedvoid
setCreateSubDirectories(boolean b)
Deprecated.void
setDeleteOnExit(boolean b)
Deprecated.void
setDirectory(String string)
Directory to extract the archive tovoid
setDirectorySessionKey(String directorySessionKey)
Sessionkey with a directory value to extract the archive tovoid
setKeepOriginalFileName(boolean b)
If setfalse
, a suffix is added to the original filename to be sure it is uniquevoid
setKeepOriginalFilePath(boolean b)
If settrue
, the path of the zip entry will be preserved.void
setProcessFile(boolean b)
Deprecated.-
Methods inherited from class nl.nn.adapterframework.pipes.FixedForwardPipe
getIfParam, getIfValue, getOnlyIfSessionKey, getOnlyIfValue, getParameterValue, getSuccessForward, getUnlessSessionKey, getUnlessValue, isSkipOnEmptyInput, setIfParam, setIfValue, setOnlyIfSessionKey, setOnlyIfValue, setSkipOnEmptyInput, setUnlessSessionKey, setUnlessValue, skipPipe
-
Methods inherited from class nl.nn.adapterframework.pipes.AbstractPipe
addParameter, consumesSessionVariable, createBean, findForward, getAdapter, getApplicationContext, getChompCharSize, getConfigurationClassLoader, getDurationThreshold, getElementToMove, getElementToMoveChain, getElementToMoveSessionKey, getEmptyInputReplacement, getEventSourceName, getForwards, getGetInputFromFixedValue, getGetInputFromSessionKey, getHideRegex, getInSizeStatDummyObject, getLocker, getLogIntermediaryResults, getMaxThreads, getName, getOutSizeStatDummyObject, getParameterList, getPipeLine, getSecLogSessionKeys, getStoreResultInSessionKey, hasSizeStatistics, isPreserveInput, isRemoveCompactMsgNamespaces, isRestoreMovedElements, isWriteToSecLog, registerEvent, registerForward, setApplicationContext, setChompCharSize, setDurationThreshold, setElementToMove, setElementToMoveChain, setElementToMoveSessionKey, setEmptyInputReplacement, setEventPublisher, setGetInputFromFixedValue, setGetInputFromSessionKey, setHideRegex, setLocker, setLogIntermediaryResults, setMaxThreads, setName, setPipeLine, setPreserveInput, setRemoveCompactMsgNamespaces, setRestoreMovedElements, setSecLogSessionKeys, setSizeStatistics, setStoreResultInSessionKey, setWriteToSecLog, start, stop, throwEvent
-
Methods inherited from class nl.nn.adapterframework.core.TransactionAttributes
configureTransactionAttributes, getTransactionAttribute, getTransactionTimeout, getTxDef, isTransacted, isTransacted, setTransacted, setTransactionAttribute, setTransactionTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface nl.nn.adapterframework.core.IExtendedPipe
throwEvent
-
-
-
-
Method Detail
-
configure
public void configure() throws ConfigurationException
Description copied from class:FixedForwardPipe
checks for correct configuration of forward- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIPipe
- Overrides:
configure
in classFixedForwardPipe
- Throws:
ConfigurationException
-
getInputStream
protected InputStream getInputStream(Message message, PipeLineSession session) throws PipeRunException
- Throws:
PipeRunException
-
doPipe
public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException
Description copied from interface:IPipe
This is where the action takes place. Pipes may only throw a PipeRunException, to be handled by the caller of this object. Implementations must either consume the message, or pass it on to the next Pipe in the PipeRunResult. If the result of the Pipe does not depend on the input, like for theFixedResultPipe
, the Pipe can schedule the input to be closed at session exit, by callingMessage.closeOnCloseOf(PipeLineSession, String)
This allows the previous Pipe to release any resources (e.g. connections) that it might have kept open until the message was consumed. Doing so avoids connections leaking from pools, while it enables efficient streaming processing of data while it is being read from a stream.- Throws:
PipeRunException
-
setDirectory
public void setDirectory(String string)
Directory to extract the archive to
-
setDirectorySessionKey
public void setDirectorySessionKey(String directorySessionKey)
Sessionkey with a directory value to extract the archive to
-
setDeleteOnExit
@Deprecated @ConfigurationWarning("This flag is no longer supported as it leaks server memory. Temporary files should be removed by other means.") public void setDeleteOnExit(boolean b)
Deprecated.If true, file is automatically deleted upon normal JVM termination- Default value
- true
-
setCollectResults
public void setCollectResults(boolean b)
If setfalse
, only a small summary (count of items in zip) is returned- Default value
- true
-
setCollectFileContents
public void setCollectFileContents(boolean b)
If settrue
, the contents of the files in the zip are returned in the result xml message of this pipe. Please note this can consume a lot of memory for large files or a large number of files- Default value
- false
-
setCollectFileContentsBase64Encoded
public void setCollectFileContentsBase64Encoded(String string)
Comma separated list of file extensions. Files with an extension which is part of this list will be base64 encoded. All other files are assumed to have UTF-8 when reading it from the zip and are added as escaped xml with non-unicode-characters being replaced by inverted question mark appended with #, the character number and ;- Default value
- false
-
setKeepOriginalFileName
public void setKeepOriginalFileName(boolean b)
If setfalse
, a suffix is added to the original filename to be sure it is unique- Default value
- false
-
setCreateSubDirectories
@Deprecated @ConfigurationWarning("the attribute \'createSubDirectories\' has been renamed to \'keepOriginalFilePath\'") public void setCreateSubDirectories(boolean b)
Deprecated.
-
setKeepOriginalFilePath
public void setKeepOriginalFilePath(boolean b)
If settrue
, the path of the zip entry will be preserved. Otherwise, the zip entries will be extracted to the root folder- Default value
- false
-
setAssumeDirectoryExists
public void setAssumeDirectoryExists(boolean assumeDirectoryExists)
If settrue
, validation of directory is ignored- Default value
- false
-
setCheckDirectory
@Deprecated @ConfigurationWarning("the attribute \'checkDirectory\' has been renamed to \'assumeDirectoryExists\'") public void setCheckDirectory(boolean checkDirectory)
Deprecated.
-
setProcessFile
@Deprecated @ConfigurationWarning("Please add a LocalFileSystemPipe with action=read in front of this pipe instead") public void setProcessFile(boolean b)
Deprecated.If settrue
, the input is assumed to be the name of a file to be processed. Otherwise, the input itself is used.- Default value
- false
-
getDirectory
public String getDirectory()
-
getDirectorySessionKey
public String getDirectorySessionKey()
-
isDeleteOnExit
@Deprecated public boolean isDeleteOnExit()
Deprecated.
-
isCollectResults
public boolean isCollectResults()
-
isCollectFileContents
public boolean isCollectFileContents()
-
getCollectFileContentsBase64Encoded
public String getCollectFileContentsBase64Encoded()
-
isKeepOriginalFileName
public boolean isKeepOriginalFileName()
-
isKeepOriginalFilePath
public boolean isKeepOriginalFilePath()
-
isAssumeDirectoryExists
public boolean isAssumeDirectoryExists()
-
isProcessFile
public boolean isProcessFile()
-
-