Package com.logicaldoc.enterprise.storer
Class StorerEncryption
java.lang.Object
com.logicaldoc.enterprise.storer.StorerEncryption
Utility methods useful for those Storers that supports the encryption
- Since:
- 7.7.1
- Author:
- Marco Meschieri - LogicalDOC
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStream
Retrieves the stream of a resource inside a zip file.static long
getUncompressedSize
(File file, String resource) Retrieves the real size of a resource inside a zipstatic long
Writes a resource into a zip filestatic long
writeZip
(InputStream stream, String resource, File dest, int compressionLevel) Writes the stream of a resource into a zip file
-
Field Details
-
ENCRYPTED_EXT
- See Also:
-
-
Method Details
-
getStream
public static InputStream getStream(File file, String resource, boolean useAutoDelete) throws com.logicaldoc.util.crypt.CryptUtil.EncryptionException, IOException Retrieves the stream of a resource inside a zip file.- Parameters:
file
- The zip fileresource
- Name of the resourceuseAutoDelete
- true to return a stream that deletes the file once completely read- Returns:
- The stream
- Throws:
com.logicaldoc.util.crypt.CryptUtil.EncryptionException
- the file is encryptedIOException
- I/O error
-
getUncompressedSize
public static long getUncompressedSize(File file, String resource) throws IOException, com.logicaldoc.util.crypt.CryptUtil.EncryptionException Retrieves the real size of a resource inside a zip- Parameters:
file
- The zip fileresource
- The name of the resource- Returns:
- The uncompressed size expressed in bytes
- Throws:
IOException
- Error accessing the filecom.logicaldoc.util.crypt.CryptUtil.EncryptionException
- Error in the decryption
-
writeZip
public static long writeZip(InputStream stream, String resource, File dest, int compressionLevel) throws IOException Writes the stream of a resource into a zip file- Parameters:
stream
- The input stream (it will be closed at the end)resource
- The name of the resource inside the zipdest
- The destination filecompressionLevel
- level of compression (between 0 and 9)- Returns:
- the uncompressed size of the resource
- Throws:
IOException
- I/O error reading the stream
-
writeZip
public static long writeZip(File src, String resource, File dest, int compressionLevel) throws IOException Writes a resource into a zip file- Parameters:
src
- The input fileresource
- The name of the resource inside the zipdest
- The destination filecompressionLevel
- level of compression (between 0 and 9)- Returns:
- the uncompressed size of the resource
- Throws:
IOException
- error reading the source or writing the destination
-