USRE-78 add zip process function

This commit is contained in:
YuCheng Hu 2021-12-02 07:58:49 -05:00
parent 61b824d657
commit 360faf2aa0
No known key found for this signature in database
GPG Key ID: C395DC68EF030B59
5 changed files with 87 additions and 12 deletions

6
.idea/thriftCompiler.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ThriftCompiler">
<compilers />
</component>
</project>

View File

@ -29,7 +29,7 @@ public class RetsMetadataTest extends RetsTestCase {
session = SessionUtils.retsLogin(retsConfigurator); session = SessionUtils.retsLogin(retsConfigurator);
MSystem system = session.getMetadata().getSystem(); MSystem system = session.getMetadata("C:\\WorkDir\\metaData.xml").getSystem();
System.out.println( System.out.println(
"SYSTEM: " + system.getSystemID() + "SYSTEM: " + system.getSystemID() +
" - " + system.getSystemDescription()); " - " + system.getSystemDescription());

View File

@ -36,11 +36,25 @@
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.2.5</version> <version>1.2.5</version>
</dependency> </dependency>
<!-- APACHE COMMONS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency> <dependency>
<groupId>xalan</groupId> <groupId>xalan</groupId>
<artifactId>xalan</artifactId> <artifactId>xalan</artifactId>
<version>2.7.2</version> <version>2.7.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,55 @@
package com.ossez.usreio.common.util;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipUtils;
import org.apache.commons.compress.utils.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* SessionUtils for RETS server session
*
* @author YuCheng Hu
*/
public final class ZIPUtils {
private static final Logger logger = LoggerFactory.getLogger(ZIPUtils.class);
/**
* @param input
* @param output
* @throws IOException
*/
public static void compressGZIP(File input, File output) throws IOException {
try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(output))) {
IOUtils.copy(new FileInputStream(input), out);
} catch (Exception IOException) {
}
}
/**
*
* @param sourceFile
* @return
* @throws IOException
*/
public static File compressGZIP(File sourceFile) throws IOException {
// Check File
if (!sourceFile.exists()) {
return null;
}
// Get gzipped
File gzipFile = new File(sourceFile.getParentFile(), GzipUtils.getCompressedFilename(sourceFile.getName()));
try (GzipCompressorOutputStream out = new GzipCompressorOutputStream(new FileOutputStream(gzipFile))) {
IOUtils.copy(new FileInputStream(gzipFile), out);
}
return gzipFile;
}
}

View File

@ -1,15 +1,15 @@
package com.ossez.usreio.client; package com.ossez.usreio.client;
public abstract class Main extends RetsHttpRequest { /**
/** * Main function for Test and init file.
* Abstract class of subclasses where the Version of RETS is not needed (Password Request, Login Request, etc.) * <p>
*/ * Please don't use it.
public Main() { *
super(); * @author YuCheng Hu
} */
public class Main {
@Override public Main() {
public void setVersion(RetsVersion version) { System.out.println("MAIN");
//noop - I don't care about version }
}
} }