[Minor] cleaned up warnings in code and cleaned up pom.xml
This commit is contained in:
parent
bb7042524f
commit
2fc807fe11
315
pom.xml
315
pom.xml
|
@ -1,192 +1,151 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>ch.eitchnet</groupId>
|
<groupId>ch.eitchnet</groupId>
|
||||||
<artifactId>ch.eitchnet.utils</artifactId>
|
<artifactId>ch.eitchnet.utils</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<name>ch.eitchnet.utils</name>
|
<name>ch.eitchnet.utils</name>
|
||||||
<url>https://github.com/eitch/ch.eitchnet.utils</url>
|
<url>https://github.com/eitch/ch.eitchnet.utils</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- POM Reference: http://maven.apache.org/pom.html#Licenses -->
|
<!-- POM Reference: http://maven.apache.org/pom.html#Licenses -->
|
||||||
|
|
||||||
<inceptionYear>2011</inceptionYear>
|
<inceptionYear>2011</inceptionYear>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU Lesser General Public License</name>
|
<name>GNU Lesser General Public License</name>
|
||||||
<url>http://www.gnu.org/licenses/lgpl.html</url>
|
<url>http://www.gnu.org/licenses/lgpl.html</url>
|
||||||
<distribution>repo</distribution>
|
<distribution>repo</distribution>
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<organization>
|
<organization>
|
||||||
<name>eitchnet.ch</name>
|
<name>eitchnet.ch</name>
|
||||||
<url>http://blog.eitchnet.ch</url>
|
<url>http://blog.eitchnet.ch</url>
|
||||||
</organization>
|
</organization>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>eitch</id>
|
<id>eitch</id>
|
||||||
<name>Robert von Vurg</name>
|
<name>Robert von Vurg</name>
|
||||||
<email>eitch@eitchnet.ch</email>
|
<email>eitch@eitchnet.ch</email>
|
||||||
<url>http://blog.eitchnet.ch</url>
|
<url>http://blog.eitchnet.ch</url>
|
||||||
<organization>eitchnet.ch</organization>
|
<organization>eitchnet.ch</organization>
|
||||||
<organizationUrl>http://blog.eitchnet.ch</organizationUrl>
|
<organizationUrl>http://blog.eitchnet.ch</organizationUrl>
|
||||||
<roles>
|
<roles>
|
||||||
<role>architect</role>
|
<role>architect</role>
|
||||||
<role>developer</role>
|
<role>developer</role>
|
||||||
</roles>
|
</roles>
|
||||||
<timezone>+1</timezone>
|
<timezone>+1</timezone>
|
||||||
<properties>
|
<properties>
|
||||||
<picUrl>http://localhost</picUrl>
|
<picUrl>http://localhost</picUrl>
|
||||||
</properties>
|
</properties>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>Github Issues</system>
|
<system>Github Issues</system>
|
||||||
<url>https://github.com/eitch/ch.eitchnet.utils/issues</url>
|
<url>https://github.com/eitch/ch.eitchnet.utils/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<!--
|
<!-- <ciManagement> <system>continuum</system> <url>http://127.0.0.1:8080/continuum</url>
|
||||||
<ciManagement>
|
<notifiers> <notifier> <type>mail</type> <sendOnError>true</sendOnError>
|
||||||
<system>continuum</system>
|
<sendOnFailure>true</sendOnFailure> <sendOnSuccess>false</sendOnSuccess>
|
||||||
<url>http://127.0.0.1:8080/continuum</url>
|
<sendOnWarning>false</sendOnWarning> <configuration><address>continuum@127.0.0.1</address></configuration>
|
||||||
<notifiers>
|
</notifier> </notifiers> </ciManagement> <mailingLists> <mailingList> <name>User
|
||||||
<notifier>
|
List</name> <subscribe>user-subscribe@127.0.0.1</subscribe> <unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe>
|
||||||
<type>mail</type>
|
<post>user@127.0.0.1</post> <archive>http://127.0.0.1/user/</archive> <otherArchives>
|
||||||
<sendOnError>true</sendOnError>
|
<otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive> </otherArchives>
|
||||||
<sendOnFailure>true</sendOnFailure>
|
</mailingList> </mailingLists> -->
|
||||||
<sendOnSuccess>false</sendOnSuccess>
|
|
||||||
<sendOnWarning>false</sendOnWarning>
|
|
||||||
<configuration><address>continuum@127.0.0.1</address></configuration>
|
|
||||||
</notifier>
|
|
||||||
</notifiers>
|
|
||||||
</ciManagement>
|
|
||||||
|
|
||||||
<mailingLists>
|
<scm>
|
||||||
<mailingList>
|
<connection>scm:git:https://github.com/eitch/ch.eitchnet.utils.git</connection>
|
||||||
<name>User List</name>
|
<developerConnection>scm:git:git@github.com:eitch/ch.eitchnet.utils.git</developerConnection>
|
||||||
<subscribe>user-subscribe@127.0.0.1</subscribe>
|
<url>https://github.com/eitch/ch.eitchnet.utils</url>
|
||||||
<unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe>
|
</scm>
|
||||||
<post>user@127.0.0.1</post>
|
|
||||||
<archive>http://127.0.0.1/user/</archive>
|
|
||||||
<otherArchives>
|
|
||||||
<otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive>
|
|
||||||
</otherArchives>
|
|
||||||
</mailingList>
|
|
||||||
</mailingLists>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<scm>
|
<!-- <repositories> <repository> <releases> <enabled>false</enabled> <updatePolicy>always</updatePolicy>
|
||||||
<connection>scm:git:https://github.com/eitch/ch.eitchnet.utils.git</connection>
|
<checksumPolicy>warn</checksumPolicy> </releases> <snapshots> <enabled>true</enabled>
|
||||||
<developerConnection>scm:git:git@github.com:eitch/ch.eitchnet.utils.git</developerConnection>
|
<updatePolicy>never</updatePolicy> <checksumPolicy>fail</checksumPolicy>
|
||||||
<url>https://github.com/eitch/ch.eitchnet.utils</url>
|
</snapshots> <id>codehausSnapshots</id> <name>Codehaus Snapshots</name> <url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||||
</scm>
|
<layout>default</layout> </repository> </repositories> <pluginRepositories>
|
||||||
|
... </pluginRepositories> -->
|
||||||
|
|
||||||
<!--
|
<dependencies>
|
||||||
<repositories>
|
<dependency>
|
||||||
<repository>
|
<groupId>junit</groupId>
|
||||||
<releases>
|
<artifactId>junit</artifactId>
|
||||||
<enabled>false</enabled>
|
<version>4.10</version>
|
||||||
<updatePolicy>always</updatePolicy>
|
<scope>test</scope>
|
||||||
<checksumPolicy>warn</checksumPolicy>
|
</dependency>
|
||||||
</releases>
|
<dependency>
|
||||||
<snapshots>
|
<groupId>log4j</groupId>
|
||||||
<enabled>true</enabled>
|
<artifactId>log4j</artifactId>
|
||||||
<updatePolicy>never</updatePolicy>
|
<version>1.2.17</version>
|
||||||
<checksumPolicy>fail</checksumPolicy>
|
</dependency>
|
||||||
</snapshots>
|
</dependencies>
|
||||||
<id>codehausSnapshots</id>
|
|
||||||
<name>Codehaus Snapshots</name>
|
|
||||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
|
||||||
<layout>default</layout>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<pluginRepositories>
|
|
||||||
...
|
|
||||||
</pluginRepositories>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<dependencies>
|
<build>
|
||||||
<dependency>
|
<plugins>
|
||||||
<groupId>junit</groupId>
|
<plugin>
|
||||||
<artifactId>junit</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>4.10</version>
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
<scope>test</scope>
|
<version>2.9</version>
|
||||||
</dependency>
|
<configuration>
|
||||||
<dependency>
|
<downloadJavadocs>true</downloadJavadocs>
|
||||||
<groupId>log4j</groupId>
|
<downloadSources>true</downloadSources>
|
||||||
<artifactId>log4j</artifactId>
|
</configuration>
|
||||||
<version>1.2.17</version>
|
</plugin>
|
||||||
</dependency>
|
<plugin>
|
||||||
</dependencies>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.6</source>
|
||||||
|
<target>1.6</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>2.1.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<build>
|
<plugin>
|
||||||
<plugins>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
|
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
|
||||||
|
<!--mainClass>ch.eitchnet.App</mainClass -->
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-eclipse-plugin</artifactId>
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
<version>2.9</version>
|
<version>2.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<downloadJavadocs>true</downloadJavadocs>
|
<outputEncoding>UTF-8</outputEncoding>
|
||||||
<downloadSources>true</downloadSources>
|
</configuration>
|
||||||
</configuration>
|
</plugin>
|
||||||
</plugin>
|
</plugins>
|
||||||
|
</build>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>2.3.2</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>2.1.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-sources</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifest>
|
|
||||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
|
||||||
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
|
|
||||||
<!--mainClass>ch.eitchnet.App</mainClass-->
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-site-plugin</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<configuration>
|
|
||||||
<outputEncoding>UTF-8</outputEncoding>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -47,13 +47,13 @@ public class RmiFileDeletion implements Serializable {
|
||||||
* @return the fileType
|
* @return the fileType
|
||||||
*/
|
*/
|
||||||
public String getFileType() {
|
public String getFileType() {
|
||||||
return fileType;
|
return this.fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the fileName
|
* @return the fileName
|
||||||
*/
|
*/
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return this.fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class RmiFileHandler {
|
||||||
validateFileType(fileType);
|
validateFileType(fileType);
|
||||||
|
|
||||||
// evaluate the path where the file should reside
|
// evaluate the path where the file should reside
|
||||||
File file = new File(basePath + "/" + fileType, filePart.getFileName());
|
File file = new File(this.basePath + "/" + fileType, filePart.getFileName());
|
||||||
|
|
||||||
// now evaluate the file exists
|
// now evaluate the file exists
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
|
@ -102,9 +102,9 @@ public class RmiFileHandler {
|
||||||
// variables defining the part of the file we're going to return
|
// variables defining the part of the file we're going to return
|
||||||
long requestOffset = filePart.getPartOffset();
|
long requestOffset = filePart.getPartOffset();
|
||||||
int requestSize = filePart.getPartLength();
|
int requestSize = filePart.getPartLength();
|
||||||
if (requestSize > MAX_PART_SIZE) {
|
if (requestSize > RmiFileHandler.MAX_PART_SIZE) {
|
||||||
throw new RuntimeException("The requested part size " + requestSize + " is greater than the allowed "
|
throw new RuntimeException("The requested part size " + requestSize + " is greater than the allowed "
|
||||||
+ MAX_PART_SIZE);
|
+ RmiFileHandler.MAX_PART_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate lengths and offsets
|
// validate lengths and offsets
|
||||||
|
@ -125,7 +125,7 @@ public class RmiFileHandler {
|
||||||
long l = Math.min(requestSize, remaining);
|
long l = Math.min(requestSize, remaining);
|
||||||
|
|
||||||
// this is a fail safe
|
// this is a fail safe
|
||||||
if (l > MAX_PART_SIZE)
|
if (l > RmiFileHandler.MAX_PART_SIZE)
|
||||||
throw new RuntimeException("Something went wrong. Min of requestSize and remaining is > MAX_PART_SIZE!");
|
throw new RuntimeException("Something went wrong. Min of requestSize and remaining is > MAX_PART_SIZE!");
|
||||||
|
|
||||||
// this is the size of the array we want to return
|
// this is the size of the array we want to return
|
||||||
|
@ -163,7 +163,7 @@ public class RmiFileHandler {
|
||||||
try {
|
try {
|
||||||
fin.close();
|
fin.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Error while closing FileInputStream: " + e.getLocalizedMessage());
|
RmiFileHandler.logger.error("Error while closing FileInputStream: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class RmiFileHandler {
|
||||||
validateFileType(fileType);
|
validateFileType(fileType);
|
||||||
|
|
||||||
// evaluate the path where the file should reside
|
// evaluate the path where the file should reside
|
||||||
File dstFile = new File(basePath + "/" + fileType, filePart.getFileName());
|
File dstFile = new File(this.basePath + "/" + fileType, filePart.getFileName());
|
||||||
|
|
||||||
// if the file already exists, then this may not be a start part
|
// if the file already exists, then this may not be a start part
|
||||||
if (filePart.getPartOffset() == 0 && dstFile.exists()) {
|
if (filePart.getPartOffset() == 0 && dstFile.exists()) {
|
||||||
|
@ -231,7 +231,7 @@ public class RmiFileHandler {
|
||||||
validateFileType(fileType);
|
validateFileType(fileType);
|
||||||
|
|
||||||
// evaluate the path where the file should reside
|
// evaluate the path where the file should reside
|
||||||
File fileToDelete = new File(basePath + "/" + fileType, fileDeletion.getFileName());
|
File fileToDelete = new File(this.basePath + "/" + fileType, fileDeletion.getFileName());
|
||||||
|
|
||||||
// delete the file
|
// delete the file
|
||||||
return FileHelper.deleteFiles(new File[] { fileToDelete }, true);
|
return FileHelper.deleteFiles(new File[] { fileToDelete }, true);
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the fileLength
|
* @return the fileLength
|
||||||
*/
|
*/
|
||||||
public long getFileLength() {
|
public long getFileLength() {
|
||||||
return fileLength;
|
return this.fileLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the fileHash
|
* @return the fileHash
|
||||||
*/
|
*/
|
||||||
public String getFileHash() {
|
public String getFileHash() {
|
||||||
return fileHash;
|
return this.fileHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,14 +94,14 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the fileType
|
* @return the fileType
|
||||||
*/
|
*/
|
||||||
public String getFileType() {
|
public String getFileType() {
|
||||||
return fileType;
|
return this.fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the partOffset
|
* @return the partOffset
|
||||||
*/
|
*/
|
||||||
public long getPartOffset() {
|
public long getPartOffset() {
|
||||||
return partOffset;
|
return this.partOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +116,7 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the partLength
|
* @return the partLength
|
||||||
*/
|
*/
|
||||||
public int getPartLength() {
|
public int getPartLength() {
|
||||||
return partLength;
|
return this.partLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +131,7 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the partBytes
|
* @return the partBytes
|
||||||
*/
|
*/
|
||||||
public byte[] getPartBytes() {
|
public byte[] getPartBytes() {
|
||||||
return partBytes;
|
return this.partBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +146,7 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the lastPart
|
* @return the lastPart
|
||||||
*/
|
*/
|
||||||
public boolean isLastPart() {
|
public boolean isLastPart() {
|
||||||
return lastPart;
|
return this.lastPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,6 +161,6 @@ public class RmiFilePart implements Serializable {
|
||||||
* @return the fileName
|
* @return the fileName
|
||||||
*/
|
*/
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return this.fileName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,10 @@ public class RmiHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param rmiFileClient
|
* @param rmiFileClient
|
||||||
* @param filePart
|
* @param origFilePart
|
||||||
* @param dstFile
|
* @param dstFile
|
||||||
*/
|
*/
|
||||||
public static void downloadFile(RMIFileClient rmiFileClient, RmiFilePart filePart, File dstFile) {
|
public static void downloadFile(RMIFileClient rmiFileClient, RmiFilePart origFilePart, File dstFile) {
|
||||||
|
|
||||||
// here we don't overwrite, the caller must make sure the destination file does not exist
|
// here we don't overwrite, the caller must make sure the destination file does not exist
|
||||||
if (dstFile.exists())
|
if (dstFile.exists())
|
||||||
|
@ -51,56 +51,59 @@ public class RmiHelper {
|
||||||
+ " already exists. Delete it first, if you want to overwrite it!");
|
+ " already exists. Delete it first, if you want to overwrite it!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
RmiFilePart tmpPart = origFilePart;
|
||||||
|
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
int startLength = filePart.getPartLength();
|
int startLength = tmpPart.getPartLength();
|
||||||
while (true) {
|
while (true) {
|
||||||
loops += 1;
|
loops += 1;
|
||||||
|
|
||||||
// get the next part
|
// get the next part
|
||||||
filePart = rmiFileClient.requestFile(filePart);
|
tmpPart = rmiFileClient.requestFile(tmpPart);
|
||||||
|
|
||||||
// validate length of data
|
// validate length of data
|
||||||
if (filePart.getPartLength() != filePart.getPartBytes().length)
|
if (tmpPart.getPartLength() != tmpPart.getPartBytes().length)
|
||||||
throw new RuntimeException("Invalid FilePart. Part length is not as long as the bytes passed "
|
throw new RuntimeException("Invalid tmpPart. Part length is not as long as the bytes passed "
|
||||||
+ filePart.getPartLength() + " / " + filePart.getPartBytes().length);
|
+ tmpPart.getPartLength() + " / " + tmpPart.getPartBytes().length);
|
||||||
|
|
||||||
// validate offset is size of file
|
// validate offset is size of file
|
||||||
if (filePart.getPartOffset() != dstFile.length()) {
|
if (tmpPart.getPartOffset() != dstFile.length()) {
|
||||||
throw new RuntimeException("The part offset $offset is not at the end of the file "
|
throw new RuntimeException("The part offset $offset is not at the end of the file "
|
||||||
+ filePart.getPartOffset() + " / " + dstFile.length());
|
+ tmpPart.getPartOffset() + " / " + dstFile.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
// append the part
|
// append the part
|
||||||
FileHelper.appendFilePart(dstFile, filePart.getPartBytes());
|
FileHelper.appendFilePart(dstFile, tmpPart.getPartBytes());
|
||||||
|
|
||||||
// update the offset
|
// update the offset
|
||||||
filePart.setPartOffset(filePart.getPartOffset() + filePart.getPartBytes().length);
|
tmpPart.setPartOffset(tmpPart.getPartOffset() + tmpPart.getPartBytes().length);
|
||||||
|
|
||||||
// break if the offset is past the length of the file
|
// break if the offset is past the length of the file
|
||||||
if (filePart.getPartOffset() >= filePart.getFileLength())
|
if (tmpPart.getPartOffset() >= tmpPart.getFileLength())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Requested " + loops
|
RmiHelper.logger.info(tmpPart.getFileType() + ": " + tmpPart.getFileName() + ": Requested " + loops
|
||||||
+ " parts. StartSize: " + startLength + " EndSize: " + filePart.getPartLength());
|
+ " parts. StartSize: " + startLength + " EndSize: " + tmpPart.getPartLength());
|
||||||
|
|
||||||
// validate that the offset is at the end of the file
|
// validate that the offset is at the end of the file
|
||||||
if (filePart.getPartOffset() != filePart.getFileLength()) {
|
if (tmpPart.getPartOffset() != origFilePart.getFileLength()) {
|
||||||
throw new RuntimeException("Offset " + filePart.getPartOffset() + " is not at file length "
|
throw new RuntimeException("Offset " + tmpPart.getPartOffset() + " is not at file length "
|
||||||
+ filePart.getFileLength() + " after reading all the file parts!");
|
+ origFilePart.getFileLength() + " after reading all the file parts!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// now validate hashes
|
// now validate hashes
|
||||||
String dstFileHash = StringHelper.getHexString(FileHelper.hashFileSha256(dstFile));
|
String dstFileHash = StringHelper.getHexString(FileHelper.hashFileSha256(dstFile));
|
||||||
if (!dstFileHash.equals(filePart.getFileHash())) {
|
if (!dstFileHash.equals(origFilePart.getFileHash())) {
|
||||||
throw new RuntimeException("Downloading the file " + filePart.getFileName()
|
throw new RuntimeException("Downloading the file " + origFilePart.getFileName()
|
||||||
+ " failed because the hashes don't match. Expected: " + filePart.getFileHash() + " / Actual: "
|
+ " failed because the hashes don't match. Expected: " + origFilePart.getFileHash()
|
||||||
+ dstFileHash);
|
+ " / Actual: " + dstFileHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof RuntimeException)
|
if (e instanceof RuntimeException)
|
||||||
throw (RuntimeException) e;
|
throw (RuntimeException) e;
|
||||||
throw new RuntimeException("Downloading the file " + filePart.getFileName()
|
throw new RuntimeException("Downloading the file " + origFilePart.getFileName()
|
||||||
+ " failed because of an underlying exception " + e.getLocalizedMessage());
|
+ " failed because of an underlying exception " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +197,7 @@ public class RmiHelper {
|
||||||
offset = nextOffset;
|
offset = nextOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Sent " + loops
|
RmiHelper.logger.info(filePart.getFileType() + ": " + filePart.getFileName() + ": Sent " + loops
|
||||||
+ " parts. StartSize: " + startLength + " EndSize: " + filePart.getPartLength());
|
+ " parts. StartSize: " + startLength + " EndSize: " + filePart.getPartLength());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -207,7 +210,7 @@ public class RmiHelper {
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception while closing FileInputStream " + e.getLocalizedMessage());
|
RmiHelper.logger.error("Exception while closing FileInputStream " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class FileHelper {
|
||||||
try {
|
try {
|
||||||
bufferedReader.close();
|
bufferedReader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Failed to close BufferedReader: " + e.getLocalizedMessage());
|
FileHelper.logger.error("Failed to close BufferedReader: " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class FileHelper {
|
||||||
* @return true if all went well, and false if it did not work. The log will contain the problems encountered
|
* @return true if all went well, and false if it did not work. The log will contain the problems encountered
|
||||||
*/
|
*/
|
||||||
public final static boolean deleteFile(File file, boolean log) {
|
public final static boolean deleteFile(File file, boolean log) {
|
||||||
return deleteFiles(new File[] { file }, log);
|
return FileHelper.deleteFiles(new File[] { file }, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,28 +132,28 @@ public class FileHelper {
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
File file = files[i];
|
File file = files[i];
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
boolean done = deleteFiles(file.listFiles(), log);
|
boolean done = FileHelper.deleteFiles(file.listFiles(), log);
|
||||||
if (!done) {
|
if (!done) {
|
||||||
worked = false;
|
worked = false;
|
||||||
logger.warn("Could not empty the directory: " + file.getAbsolutePath());
|
FileHelper.logger.warn("Could not empty the directory: " + file.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
done = file.delete();
|
done = file.delete();
|
||||||
if (done) {
|
if (done) {
|
||||||
if (log)
|
if (log)
|
||||||
logger.info("Deleted DIR " + file.getAbsolutePath());
|
FileHelper.logger.info("Deleted DIR " + file.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
worked = false;
|
worked = false;
|
||||||
logger.warn("Could not delete the directory: " + file.getAbsolutePath());
|
FileHelper.logger.warn("Could not delete the directory: " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean done = file.delete();
|
boolean done = file.delete();
|
||||||
if (done) {
|
if (done) {
|
||||||
if (log)
|
if (log)
|
||||||
logger.info("Deleted FILE " + file.getAbsolutePath());
|
FileHelper.logger.info("Deleted FILE " + file.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
worked = false;
|
worked = false;
|
||||||
logger.warn(("Could not delete the file: " + file.getAbsolutePath()));
|
FileHelper.logger.warn(("Could not delete the file: " + file.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class FileHelper {
|
||||||
String fromFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(fromFile));
|
String fromFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(fromFile));
|
||||||
String toFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(toFile));
|
String toFileMD5 = StringHelper.getHexString(FileHelper.hashFileMd5(toFile));
|
||||||
if (!fromFileMD5.equals(toFileMD5)) {
|
if (!fromFileMD5.equals(toFileMD5)) {
|
||||||
logger.error("Copying failed, as MD5 sums are not equal: " + fromFileMD5 + " / " + toFileMD5);
|
FileHelper.logger.error("Copying failed, as MD5 sums are not equal: " + fromFileMD5 + " / " + toFileMD5);
|
||||||
toFile.delete();
|
toFile.delete();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -204,7 +204,7 @@ public class FileHelper {
|
||||||
|
|
||||||
// cleanup if files are not the same length
|
// cleanup if files are not the same length
|
||||||
if (fromFile.length() != toFile.length()) {
|
if (fromFile.length() != toFile.length()) {
|
||||||
logger.error("Copying failed, as new files are not the same length: " + fromFile.length() + " / "
|
FileHelper.logger.error("Copying failed, as new files are not the same length: " + fromFile.length() + " / "
|
||||||
+ toFile.length());
|
+ toFile.length());
|
||||||
toFile.delete();
|
toFile.delete();
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class FileHelper {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
logger.error(e, e);
|
FileHelper.logger.error(e, e);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -222,7 +222,7 @@ public class FileHelper {
|
||||||
try {
|
try {
|
||||||
inBuffer.close();
|
inBuffer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Error closing BufferedInputStream" + e);
|
FileHelper.logger.error("Error closing BufferedInputStream" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class FileHelper {
|
||||||
try {
|
try {
|
||||||
outBuffer.close();
|
outBuffer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Error closing BufferedOutputStream" + e);
|
FileHelper.logger.error("Error closing BufferedOutputStream" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,11 +254,11 @@ public class FileHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("Simple File.renameTo failed, trying copy/delete...");
|
FileHelper.logger.warn("Simple File.renameTo failed, trying copy/delete...");
|
||||||
|
|
||||||
// delete if copy was successful, otherwise move will fail
|
// delete if copy was successful, otherwise move will fail
|
||||||
if (FileHelper.copy(fromFile, toFile, true)) {
|
if (FileHelper.copy(fromFile, toFile, true)) {
|
||||||
logger.info("Deleting fromFile: " + fromFile.getAbsolutePath());
|
FileHelper.logger.info("Deleting fromFile: " + fromFile.getAbsolutePath());
|
||||||
return fromFile.delete();
|
return fromFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ public class FileHelper {
|
||||||
* @return the humanized form of the files size
|
* @return the humanized form of the files size
|
||||||
*/
|
*/
|
||||||
public final static String humanizeFileSize(File file) {
|
public final static String humanizeFileSize(File file) {
|
||||||
return humanizeFileSize(file.length());
|
return FileHelper.humanizeFileSize(file.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,7 +407,7 @@ public class FileHelper {
|
||||||
* @return the hash as a byte array
|
* @return the hash as a byte array
|
||||||
*/
|
*/
|
||||||
public static byte[] hashFileMd5(File file) {
|
public static byte[] hashFileMd5(File file) {
|
||||||
return hashFile(file, "MD5");
|
return FileHelper.hashFile(file, "MD5");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -420,7 +420,7 @@ public class FileHelper {
|
||||||
* @return the hash as a byte array
|
* @return the hash as a byte array
|
||||||
*/
|
*/
|
||||||
public static byte[] hashFileSha1(File file) {
|
public static byte[] hashFileSha1(File file) {
|
||||||
return hashFile(file, "SHA-1");
|
return FileHelper.hashFile(file, "SHA-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,7 +433,7 @@ public class FileHelper {
|
||||||
* @return the hash as a byte array
|
* @return the hash as a byte array
|
||||||
*/
|
*/
|
||||||
public static byte[] hashFileSha256(File file) {
|
public static byte[] hashFileSha256(File file) {
|
||||||
return hashFile(file, "SHA-256");
|
return FileHelper.hashFile(file, "SHA-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,7 +492,7 @@ public class FileHelper {
|
||||||
try {
|
try {
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception while closing FileOutputStream " + e.getLocalizedMessage());
|
FileHelper.logger.error("Exception while closing FileOutputStream " + e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,9 @@ public class Log4jConfigurator {
|
||||||
* Configures log4j with the default {@link ConsoleAppender}
|
* Configures log4j with the default {@link ConsoleAppender}
|
||||||
*/
|
*/
|
||||||
public static synchronized void configure() {
|
public static synchronized void configure() {
|
||||||
cleanupOldWatchdog();
|
Log4jConfigurator.cleanupOldWatchdog();
|
||||||
BasicConfigurator.resetConfiguration();
|
BasicConfigurator.resetConfiguration();
|
||||||
BasicConfigurator.configure(new ConsoleAppender(getDefaulLayout()));
|
BasicConfigurator.configure(new ConsoleAppender(Log4jConfigurator.getDefaulLayout()));
|
||||||
Logger.getRootLogger().setLevel(Level.INFO);
|
Logger.getRootLogger().setLevel(Level.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,13 +119,13 @@ public class Log4jConfigurator {
|
||||||
+ log4JPath.getAbsolutePath());
|
+ log4JPath.getAbsolutePath());
|
||||||
|
|
||||||
// now perform the loading
|
// now perform the loading
|
||||||
loadLog4jConfiguration(log4JPath);
|
Log4jConfigurator.loadLog4jConfiguration(log4JPath);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
Log4jConfigurator.configure();
|
Log4jConfigurator.configure();
|
||||||
logger.error(e, e);
|
Log4jConfigurator.logger.error(e, e);
|
||||||
logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file exists at "
|
Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file exists at "
|
||||||
+ log4JPath.getAbsolutePath());
|
+ log4JPath.getAbsolutePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class Log4jConfigurator {
|
||||||
throw new RuntimeException("log4jConfigPath may not be null!");
|
throw new RuntimeException("log4jConfigPath may not be null!");
|
||||||
|
|
||||||
// first clean up any old watch dog in case of a programmatic re-load of the configuration
|
// first clean up any old watch dog in case of a programmatic re-load of the configuration
|
||||||
cleanupOldWatchdog();
|
Log4jConfigurator.cleanupOldWatchdog();
|
||||||
|
|
||||||
// get the root directory
|
// get the root directory
|
||||||
String userDir = System.getProperty("user.dir");
|
String userDir = System.getProperty("user.dir");
|
||||||
|
@ -184,16 +184,16 @@ public class Log4jConfigurator {
|
||||||
// XXX if the server is in a web context, then we may not use the
|
// XXX if the server is in a web context, then we may not use the
|
||||||
// FileWatchDog
|
// FileWatchDog
|
||||||
BasicConfigurator.resetConfiguration();
|
BasicConfigurator.resetConfiguration();
|
||||||
watchDog = new Log4jPropertyWatchDog(pathNameToLog4jTemp);
|
Log4jConfigurator.watchDog = new Log4jPropertyWatchDog(pathNameToLog4jTemp);
|
||||||
watchDog.start();
|
Log4jConfigurator.watchDog.start();
|
||||||
|
|
||||||
logger.info("Log4j is configured to use and watch file " + pathNameToLog4jTemp);
|
Log4jConfigurator.logger.info("Log4j is configured to use and watch file " + pathNameToLog4jTemp);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
Log4jConfigurator.configure();
|
Log4jConfigurator.configure();
|
||||||
logger.error(e, e);
|
Log4jConfigurator.logger.error(e, e);
|
||||||
logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file at "
|
Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check the log4j configuration file at "
|
||||||
+ log4jConfigPath);
|
+ log4jConfigPath);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -201,14 +201,14 @@ public class Log4jConfigurator {
|
||||||
try {
|
try {
|
||||||
fin.close();
|
fin.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception closing input file: " + e, e);
|
Log4jConfigurator.logger.error("Exception closing input file: " + e, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fout != null) {
|
if (fout != null) {
|
||||||
try {
|
try {
|
||||||
fout.close();
|
fout.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Exception closing output file: " + e, e);
|
Log4jConfigurator.logger.error("Exception closing output file: " + e, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,9 +229,9 @@ public class Log4jConfigurator {
|
||||||
if (clazz == null)
|
if (clazz == null)
|
||||||
throw new RuntimeException("clazz may not be null!");
|
throw new RuntimeException("clazz may not be null!");
|
||||||
|
|
||||||
InputStream resourceAsStream = clazz.getResourceAsStream("/" + FILE_LOG4J);
|
InputStream resourceAsStream = clazz.getResourceAsStream("/" + Log4jConfigurator.FILE_LOG4J);
|
||||||
if (resourceAsStream == null) {
|
if (resourceAsStream == null) {
|
||||||
throw new RuntimeException("The resource '" + FILE_LOG4J + "' could not be found for class "
|
throw new RuntimeException("The resource '" + Log4jConfigurator.FILE_LOG4J + "' could not be found for class "
|
||||||
+ clazz.getName());
|
+ clazz.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,13 +240,13 @@ public class Log4jConfigurator {
|
||||||
log4jProperties.load(resourceAsStream);
|
log4jProperties.load(resourceAsStream);
|
||||||
|
|
||||||
// and then
|
// and then
|
||||||
loadLog4jConfiguration(log4jProperties);
|
Log4jConfigurator.loadLog4jConfiguration(log4jProperties);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log4jConfigurator.configure();
|
Log4jConfigurator.configure();
|
||||||
logger.error(e, e);
|
Log4jConfigurator.logger.error(e, e);
|
||||||
logger.error("Log4j COULD NOT BE INITIALIZED. Please check that the log4j configuration file '"
|
Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. Please check that the log4j configuration file '"
|
||||||
+ FILE_LOG4J + "' exists as a resource for class " + clazz.getName()
|
+ Log4jConfigurator.FILE_LOG4J + "' exists as a resource for class " + clazz.getName()
|
||||||
+ " and is a valid properties configuration");
|
+ " and is a valid properties configuration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,19 +272,19 @@ public class Log4jConfigurator {
|
||||||
throw new RuntimeException("log4jProperties may not be null!");
|
throw new RuntimeException("log4jProperties may not be null!");
|
||||||
|
|
||||||
// first clean up any old watch dog in case of a programmatic re-load of the configuration
|
// first clean up any old watch dog in case of a programmatic re-load of the configuration
|
||||||
cleanupOldWatchdog();
|
Log4jConfigurator.cleanupOldWatchdog();
|
||||||
|
|
||||||
// replace any variables
|
// replace any variables
|
||||||
StringHelper.replaceProperties(log4jProperties, System.getProperties());
|
StringHelper.replaceProperties(log4jProperties, System.getProperties());
|
||||||
|
|
||||||
// now configure log4j
|
// now configure log4j
|
||||||
PropertyConfigurator.configure(log4jProperties);
|
PropertyConfigurator.configure(log4jProperties);
|
||||||
logger.info("Log4j is configured using the given properties.");
|
Log4jConfigurator.logger.info("Log4j is configured using the given properties.");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log4jConfigurator.configure();
|
Log4jConfigurator.configure();
|
||||||
logger.error(e, e);
|
Log4jConfigurator.logger.error(e, e);
|
||||||
logger.error("Log4j COULD NOT BE INITIALIZED. The given log4jProperties seem not to be valid!");
|
Log4jConfigurator.logger.error("Log4j COULD NOT BE INITIALIZED. The given log4jProperties seem not to be valid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,17 +293,17 @@ public class Log4jConfigurator {
|
||||||
*/
|
*/
|
||||||
public static synchronized void cleanupOldWatchdog() {
|
public static synchronized void cleanupOldWatchdog() {
|
||||||
// clean up an old watch dog
|
// clean up an old watch dog
|
||||||
if (watchDog != null) {
|
if (Log4jConfigurator.watchDog != null) {
|
||||||
logger.info("Stopping old Log4j watchdog.");
|
Log4jConfigurator.logger.info("Stopping old Log4j watchdog.");
|
||||||
watchDog.interrupt();
|
Log4jConfigurator.watchDog.interrupt();
|
||||||
try {
|
try {
|
||||||
watchDog.join(1000l);
|
Log4jConfigurator.watchDog.join(1000l);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("Oops. Could not terminate an old WatchDog.");
|
Log4jConfigurator.logger.error("Oops. Could not terminate an old WatchDog.");
|
||||||
} finally {
|
} finally {
|
||||||
watchDog = null;
|
Log4jConfigurator.watchDog = null;
|
||||||
}
|
}
|
||||||
logger.info("Done.");
|
Log4jConfigurator.logger.info("Done.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class Log4jPropertyWatchDog extends Thread {
|
||||||
/**
|
/**
|
||||||
* The delay to observe between every check. By default set {@link #DEFAULT_DELAY}.
|
* The delay to observe between every check. By default set {@link #DEFAULT_DELAY}.
|
||||||
*/
|
*/
|
||||||
protected long delay = DEFAULT_DELAY;
|
protected long delay = Log4jPropertyWatchDog.DEFAULT_DELAY;
|
||||||
|
|
||||||
protected File file;
|
protected File file;
|
||||||
protected long lastModif = 0;
|
protected long lastModif = 0;
|
||||||
|
@ -57,7 +57,7 @@ public class Log4jPropertyWatchDog extends Thread {
|
||||||
protected Log4jPropertyWatchDog(String filename) {
|
protected Log4jPropertyWatchDog(String filename) {
|
||||||
super("FileWatchdog");
|
super("FileWatchdog");
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
file = new File(filename);
|
this.file = new File(filename);
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
checkAndConfigure();
|
checkAndConfigure();
|
||||||
}
|
}
|
||||||
|
@ -75,24 +75,24 @@ public class Log4jPropertyWatchDog extends Thread {
|
||||||
protected void checkAndConfigure() {
|
protected void checkAndConfigure() {
|
||||||
boolean fileExists;
|
boolean fileExists;
|
||||||
try {
|
try {
|
||||||
fileExists = file.exists();
|
fileExists = this.file.exists();
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
LogLog.warn("Was not allowed to read check file existance, file:[" + filename + "].");
|
LogLog.warn("Was not allowed to read check file existance, file:[" + this.filename + "].");
|
||||||
interrupted = true; // there is no point in continuing
|
this.interrupted = true; // there is no point in continuing
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileExists) {
|
if (fileExists) {
|
||||||
long l = file.lastModified(); // this can also throw a SecurityException
|
long l = this.file.lastModified(); // this can also throw a SecurityException
|
||||||
if (l > lastModif) { // however, if we reached this point this
|
if (l > this.lastModif) { // however, if we reached this point this
|
||||||
lastModif = l; // is very unlikely.
|
this.lastModif = l; // is very unlikely.
|
||||||
doOnChange();
|
doOnChange();
|
||||||
warnedAlready = false;
|
this.warnedAlready = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!warnedAlready) {
|
if (!this.warnedAlready) {
|
||||||
LogLog.debug("[" + filename + "] does not exist.");
|
LogLog.debug("[" + this.filename + "] does not exist.");
|
||||||
warnedAlready = true;
|
this.warnedAlready = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class Log4jPropertyWatchDog extends Thread {
|
||||||
*/
|
*/
|
||||||
public void doOnChange() {
|
public void doOnChange() {
|
||||||
PropertyConfigurator propertyConfigurator = new PropertyConfigurator();
|
PropertyConfigurator propertyConfigurator = new PropertyConfigurator();
|
||||||
propertyConfigurator.doConfigure(filename, LogManager.getLoggerRepository());
|
propertyConfigurator.doConfigure(this.filename, LogManager.getLoggerRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,12 +110,12 @@ public class Log4jPropertyWatchDog extends Thread {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (!interrupted) {
|
while (!this.interrupted) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(delay);
|
Thread.sleep(this.delay);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// no interruption expected
|
// no interruption expected
|
||||||
interrupted = true;
|
this.interrupted = true;
|
||||||
}
|
}
|
||||||
checkAndConfigure();
|
checkAndConfigure();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ProcessHelper {
|
||||||
Thread errorIn = new Thread("errorIn") {
|
Thread errorIn = new Thread("errorIn") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
readStream(sb, "[ERROR] ", errorStream);
|
ProcessHelper.readStream(sb, "[ERROR] ", errorStream);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
errorIn.start();
|
errorIn.start();
|
||||||
|
@ -55,7 +55,7 @@ public class ProcessHelper {
|
||||||
Thread infoIn = new Thread("infoIn") {
|
Thread infoIn = new Thread("infoIn") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
readStream(sb, "[INFO] ", inputStream);
|
ProcessHelper.readStream(sb, "[INFO] ", inputStream);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
infoIn.start();
|
infoIn.start();
|
||||||
|
@ -72,7 +72,7 @@ public class ProcessHelper {
|
||||||
throw new RuntimeException("Failed to perform command: "
|
throw new RuntimeException("Failed to perform command: "
|
||||||
+ e.getLocalizedMessage(), e);
|
+ e.getLocalizedMessage(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("Interrupted!");
|
ProcessHelper.logger.error("Interrupted!");
|
||||||
sb.append("[FATAL] Interrupted");
|
sb.append("[FATAL] Interrupted");
|
||||||
return new ProcessResult(-1, sb.toString(), e);
|
return new ProcessResult(-1, sb.toString(), e);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class ProcessHelper {
|
||||||
Thread errorIn = new Thread("errorIn") {
|
Thread errorIn = new Thread("errorIn") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
readStream(sb, "[ERROR] ", errorStream);
|
ProcessHelper.readStream(sb, "[ERROR] ", errorStream);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
errorIn.start();
|
errorIn.start();
|
||||||
|
@ -112,7 +112,7 @@ public class ProcessHelper {
|
||||||
Thread infoIn = new Thread("infoIn") {
|
Thread infoIn = new Thread("infoIn") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
readStream(sb, "[INFO] ", inputStream);
|
ProcessHelper.readStream(sb, "[INFO] ", inputStream);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
infoIn.start();
|
infoIn.start();
|
||||||
|
@ -129,7 +129,7 @@ public class ProcessHelper {
|
||||||
throw new RuntimeException("Failed to perform command: "
|
throw new RuntimeException("Failed to perform command: "
|
||||||
+ e.getLocalizedMessage(), e);
|
+ e.getLocalizedMessage(), e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("Interrupted!");
|
ProcessHelper.logger.error("Interrupted!");
|
||||||
sb.append("[FATAL] Interrupted");
|
sb.append("[FATAL] Interrupted");
|
||||||
return new ProcessResult(-1, sb.toString(), e);
|
return new ProcessResult(-1, sb.toString(), e);
|
||||||
}
|
}
|
||||||
|
@ -165,33 +165,33 @@ public class ProcessHelper {
|
||||||
|
|
||||||
ProcessResult processResult;
|
ProcessResult processResult;
|
||||||
if (SystemHelper.isLinux()) {
|
if (SystemHelper.isLinux()) {
|
||||||
processResult = runCommand("xdg-open " + pdfPath.getAbsolutePath());
|
processResult = ProcessHelper.runCommand("xdg-open " + pdfPath.getAbsolutePath());
|
||||||
} else if (SystemHelper.isMacOS()) {
|
} else if (SystemHelper.isMacOS()) {
|
||||||
processResult = runCommand("open " + pdfPath.getAbsolutePath());
|
processResult = ProcessHelper.runCommand("open " + pdfPath.getAbsolutePath());
|
||||||
} else if (SystemHelper.isWindows()) {
|
} else if (SystemHelper.isWindows()) {
|
||||||
// remove the first char (/) from the report path (/D:/temp.....)
|
// remove the first char (/) from the report path (/D:/temp.....)
|
||||||
String pdfFile = pdfPath.getAbsolutePath();
|
String pdfFile = pdfPath.getAbsolutePath();
|
||||||
if (pdfFile.charAt(0) == '/')
|
if (pdfFile.charAt(0) == '/')
|
||||||
pdfFile = pdfFile.substring(1);
|
pdfFile = pdfFile.substring(1);
|
||||||
processResult = runCommand("rundll32 url.dll,FileProtocolHandler "
|
processResult = ProcessHelper.runCommand("rundll32 url.dll,FileProtocolHandler "
|
||||||
+ pdfFile);
|
+ pdfFile);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Unexpected OS: "
|
throw new UnsupportedOperationException("Unexpected OS: "
|
||||||
+ SystemHelper.osName);
|
+ SystemHelper.osName);
|
||||||
}
|
}
|
||||||
|
|
||||||
logProcessResult(processResult);
|
ProcessHelper.logProcessResult(processResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logProcessResult(ProcessResult processResult) {
|
public static void logProcessResult(ProcessResult processResult) {
|
||||||
if (processResult.returnValue == 0) {
|
if (processResult.returnValue == 0) {
|
||||||
logger.info("Process executed successfully");
|
ProcessHelper.logger.info("Process executed successfully");
|
||||||
} else if (processResult.returnValue == -1) {
|
} else if (processResult.returnValue == -1) {
|
||||||
logger.error("Process execution failed:\n"
|
ProcessHelper.logger.error("Process execution failed:\n"
|
||||||
+ processResult.processOutput);
|
+ processResult.processOutput);
|
||||||
logger.error(processResult.t, processResult.t);
|
ProcessHelper.logger.error(processResult.t, processResult.t);
|
||||||
} else {
|
} else {
|
||||||
logger.info("Process execution was not successful with return value:"
|
ProcessHelper.logger.info("Process execution was not successful with return value:"
|
||||||
+ processResult.returnValue
|
+ processResult.returnValue
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ processResult.processOutput);
|
+ processResult.processOutput);
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class StringHelper {
|
||||||
|
|
||||||
for (byte b : raw) {
|
for (byte b : raw) {
|
||||||
int v = b & 0xFF;
|
int v = b & 0xFF;
|
||||||
hex[index++] = HEX_CHAR_TABLE[v >>> 4];
|
hex[index++] = StringHelper.HEX_CHAR_TABLE[v >>> 4];
|
||||||
hex[index++] = HEX_CHAR_TABLE[v & 0xF];
|
hex[index++] = StringHelper.HEX_CHAR_TABLE[v & 0xF];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String(hex, "ASCII");
|
return new String(hex, "ASCII");
|
||||||
|
@ -103,7 +103,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashMd5(String string) {
|
public static byte[] hashMd5(String string) {
|
||||||
return hashMd5(string.getBytes());
|
return StringHelper.hashMd5(string.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +116,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashMd5(byte[] bytes) {
|
public static byte[] hashMd5(byte[] bytes) {
|
||||||
return hash("MD5", bytes);
|
return StringHelper.hash("MD5", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +129,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashSha1(String string) {
|
public static byte[] hashSha1(String string) {
|
||||||
return hashSha1(string.getBytes());
|
return StringHelper.hashSha1(string.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashSha1(byte[] bytes) {
|
public static byte[] hashSha1(byte[] bytes) {
|
||||||
return hash("SHA-1", bytes);
|
return StringHelper.hash("SHA-1", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +155,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashSha256(String string) {
|
public static byte[] hashSha256(String string) {
|
||||||
return hashSha256(string.getBytes());
|
return StringHelper.hashSha256(string.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +168,7 @@ public class StringHelper {
|
||||||
* @return the hash or null, if an exception was thrown
|
* @return the hash or null, if an exception was thrown
|
||||||
*/
|
*/
|
||||||
public static byte[] hashSha256(byte[] bytes) {
|
public static byte[] hashSha256(byte[] bytes) {
|
||||||
return hash("SHA-256", bytes);
|
return StringHelper.hash("SHA-256", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +209,7 @@ public class StringHelper {
|
||||||
* @return the new string
|
* @return the new string
|
||||||
*/
|
*/
|
||||||
public static String normalizeLength(String value, int length, boolean beginning, char c) {
|
public static String normalizeLength(String value, int length, boolean beginning, char c) {
|
||||||
return normalizeLength(value, length, beginning, false, c);
|
return StringHelper.normalizeLength(value, length, beginning, false, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,20 +235,21 @@ public class StringHelper {
|
||||||
|
|
||||||
if (value.length() < length) {
|
if (value.length() < length) {
|
||||||
|
|
||||||
while (value.length() != length) {
|
String tmp = value;
|
||||||
|
while (tmp.length() != length) {
|
||||||
if (beginning) {
|
if (beginning) {
|
||||||
value = c + value;
|
tmp = c + tmp;
|
||||||
} else {
|
} else {
|
||||||
value = value + c;
|
tmp = tmp + c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return tmp;
|
||||||
|
|
||||||
} else if (shorten) {
|
} else if (shorten) {
|
||||||
|
|
||||||
logger.warn("Shortening length of value: " + value);
|
StringHelper.logger.warn("Shortening length of value: " + value);
|
||||||
logger.warn("Length is: " + value.length() + " max: " + length);
|
StringHelper.logger.warn("Length is: " + value.length() + " max: " + length);
|
||||||
|
|
||||||
return value.substring(0, length);
|
return value.substring(0, length);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +264,7 @@ public class StringHelper {
|
||||||
* returned
|
* returned
|
||||||
*/
|
*/
|
||||||
public static String replaceSystemPropertiesIn(String value) {
|
public static String replaceSystemPropertiesIn(String value) {
|
||||||
return replacePropertiesIn(System.getProperties(), value);
|
return StringHelper.replacePropertiesIn(System.getProperties(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,41 +279,41 @@ public class StringHelper {
|
||||||
*
|
*
|
||||||
* @return a new string with all defined properties replaced or if an error occurred the original value is returned
|
* @return a new string with all defined properties replaced or if an error occurred the original value is returned
|
||||||
*/
|
*/
|
||||||
public static String replacePropertiesIn(Properties properties, String value) {
|
public static String replacePropertiesIn(Properties properties, String alue) {
|
||||||
|
|
||||||
// keep copy of original value
|
// get a copy of the value
|
||||||
String origValue = value;
|
String tmpValue = alue;
|
||||||
|
|
||||||
// get first occurrence of $ character
|
// get first occurrence of $ character
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
int stop = 0;
|
int stop = 0;
|
||||||
|
|
||||||
// loop on $ character positions
|
// loop on $ character positions
|
||||||
while ((pos = value.indexOf('$', pos + 1)) != -1) {
|
while ((pos = tmpValue.indexOf('$', pos + 1)) != -1) {
|
||||||
|
|
||||||
// if pos+1 is not { character then continue
|
// if pos+1 is not { character then continue
|
||||||
if (value.charAt(pos + 1) != '{') {
|
if (tmpValue.charAt(pos + 1) != '{') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find end of sequence with } character
|
// find end of sequence with } character
|
||||||
stop = value.indexOf('}', pos + 1);
|
stop = tmpValue.indexOf('}', pos + 1);
|
||||||
|
|
||||||
// if no stop found, then break as another sequence should be able to start
|
// if no stop found, then break as another sequence should be able to start
|
||||||
if (stop == -1) {
|
if (stop == -1) {
|
||||||
logger.error("Sequence starts at offset " + pos + " but does not end!");
|
StringHelper.logger.error("Sequence starts at offset " + pos + " but does not end!");
|
||||||
value = origValue;
|
tmpValue = alue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get sequence enclosed by pos and stop
|
// get sequence enclosed by pos and stop
|
||||||
String sequence = value.substring(pos + 2, stop);
|
String sequence = tmpValue.substring(pos + 2, stop);
|
||||||
|
|
||||||
// make sure sequence doesn't contain $ { } characters
|
// make sure sequence doesn't contain $ { } characters
|
||||||
if (sequence.contains("$") || sequence.contains("{") || sequence.contains("}")) {
|
if (sequence.contains("$") || sequence.contains("{") || sequence.contains("}")) {
|
||||||
logger.error("Enclosed sequence in offsets " + pos + " - " + stop
|
StringHelper.logger.error("Enclosed sequence in offsets " + pos + " - " + stop
|
||||||
+ " contains one of the illegal chars: $ { }: " + sequence);
|
+ " contains one of the illegal chars: $ { }: " + sequence);
|
||||||
value = origValue;
|
tmpValue = alue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,10 +327,10 @@ public class StringHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// property exists, so replace in value
|
// property exists, so replace in value
|
||||||
value = value.replace("${" + sequence + "}", property);
|
tmpValue = tmpValue.replace("${" + sequence + "}", property);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return tmpValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -340,7 +341,7 @@ public class StringHelper {
|
||||||
* the properties in which the values must have any ${...} replaced by values of the respective key
|
* the properties in which the values must have any ${...} replaced by values of the respective key
|
||||||
*/
|
*/
|
||||||
public static void replaceProperties(Properties properties) {
|
public static void replaceProperties(Properties properties) {
|
||||||
replaceProperties(properties, null);
|
StringHelper.replaceProperties(properties, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SystemHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SystemHelper getInstance() {
|
public static SystemHelper getInstance() {
|
||||||
return instance;
|
return SystemHelper.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String osName = System.getProperty("os.name");
|
public static final String osName = System.getProperty("os.name");
|
||||||
|
@ -55,7 +55,7 @@ public class SystemHelper {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return asString();
|
return SystemHelper.asString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,15 +63,15 @@ public class SystemHelper {
|
||||||
*/
|
*/
|
||||||
public static String asString() {
|
public static String asString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(osName);
|
sb.append(SystemHelper.osName);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(osArch);
|
sb.append(SystemHelper.osArch);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(osVersion);
|
sb.append(SystemHelper.osVersion);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append("on Java " + javaVendor);
|
sb.append("on Java " + SystemHelper.javaVendor);
|
||||||
sb.append(" version ");
|
sb.append(" version ");
|
||||||
sb.append(javaVersion);
|
sb.append(SystemHelper.javaVersion);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,23 +80,23 @@ public class SystemHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMacOS() {
|
public static boolean isMacOS() {
|
||||||
return osName.startsWith("Mac");
|
return SystemHelper.osName.startsWith("Mac");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWindows() {
|
public static boolean isWindows() {
|
||||||
return osName.startsWith("Win");
|
return SystemHelper.osName.startsWith("Win");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLinux() {
|
public static boolean isLinux() {
|
||||||
return osName.startsWith("Lin");
|
return SystemHelper.osName.startsWith("Lin");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is32bit() {
|
public static boolean is32bit() {
|
||||||
return osArch.equals("x86") || osArch.equals("i386") || osArch.equals("i686");
|
return SystemHelper.osArch.equals("x86") || SystemHelper.osArch.equals("i386") || SystemHelper.osArch.equals("i686");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is64bit() {
|
public static boolean is64bit() {
|
||||||
return osArch.equals("x86_64") || osArch.equals("amd64");
|
return SystemHelper.osArch.equals("x86_64") || SystemHelper.osArch.equals("amd64");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMaxMemory() {
|
public static String getMaxMemory() {
|
||||||
|
@ -112,7 +112,7 @@ public class SystemHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMemorySummary() {
|
public static String getMemorySummary() {
|
||||||
return "Memory available " + getMaxMemory() + " / Used: " + getUsedMemory() + " / Free:" + getFreeMemory();
|
return "Memory available " + SystemHelper.getMaxMemory() + " / Used: " + SystemHelper.getUsedMemory() + " / Free:" + SystemHelper.getFreeMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,7 +150,7 @@ public class SystemHelper {
|
||||||
* if the property is not set and def is null
|
* if the property is not set and def is null
|
||||||
*/
|
*/
|
||||||
public static Boolean getPropertyBool(String context, String key, Boolean def) throws RuntimeException {
|
public static Boolean getPropertyBool(String context, String key, Boolean def) throws RuntimeException {
|
||||||
return Boolean.valueOf(getProperty(context, key, def == null ? null : def.toString()));
|
return Boolean.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ public class SystemHelper {
|
||||||
* if the property is not set and def is null
|
* if the property is not set and def is null
|
||||||
*/
|
*/
|
||||||
public static Integer getPropertyInt(String context, String key, Integer def) throws RuntimeException {
|
public static Integer getPropertyInt(String context, String key, Integer def) throws RuntimeException {
|
||||||
return Integer.valueOf(getProperty(context, key, def == null ? null : def.toString()));
|
return Integer.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,6 +176,6 @@ public class SystemHelper {
|
||||||
* if the property is not set and def is null
|
* if the property is not set and def is null
|
||||||
*/
|
*/
|
||||||
public static Double getPropertyDouble(String context, String key, Double def) throws RuntimeException {
|
public static Double getPropertyDouble(String context, String key, Double def) throws RuntimeException {
|
||||||
return Double.valueOf(getProperty(context, key, def == null ? null : def.toString()));
|
return Double.valueOf(SystemHelper.getProperty(context, key, def == null ? null : def.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,8 @@ public class ObjectCache<T extends ITransactionObject> {
|
||||||
this.object = object;
|
this.object = object;
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (ObjectCache.logger.isDebugEnabled()) {
|
||||||
logger.debug("Instanciated Cache: ID" + this.id + " / " + key + " OP: " + this.operation + " / "
|
ObjectCache.logger.debug("Instanciated Cache: ID" + this.id + " / " + key + " OP: " + this.operation + " / "
|
||||||
+ object.toString());
|
+ object.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ public class ObjectCache<T extends ITransactionObject> {
|
||||||
* @param object
|
* @param object
|
||||||
*/
|
*/
|
||||||
public void setObject(T object) {
|
public void setObject(T object) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (ObjectCache.logger.isDebugEnabled()) {
|
||||||
logger.debug("Updating ID " + this.id + " to value " + object.toString());
|
ObjectCache.logger.debug("Updating ID " + this.id + " to value " + object.toString());
|
||||||
}
|
}
|
||||||
this.object = object;
|
this.object = object;
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,8 @@ public class ObjectCache<T extends ITransactionObject> {
|
||||||
* @param newOperation
|
* @param newOperation
|
||||||
*/
|
*/
|
||||||
public void setOperation(Operation newOperation) {
|
public void setOperation(Operation newOperation) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (ObjectCache.logger.isDebugEnabled()) {
|
||||||
logger.debug("Updating Operation of ID " + this.id + " from " + this.operation + " to " + newOperation);
|
ObjectCache.logger.debug("Updating Operation of ID " + this.id + " from " + this.operation + " to " + newOperation);
|
||||||
}
|
}
|
||||||
this.operation = newOperation;
|
this.operation = newOperation;
|
||||||
}
|
}
|
||||||
|
@ -105,27 +105,27 @@ public class ObjectCache<T extends ITransactionObject> {
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the key
|
* @return the key
|
||||||
*/
|
*/
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the object
|
* @return the object
|
||||||
*/
|
*/
|
||||||
public T getObject() {
|
public T getObject() {
|
||||||
return object;
|
return this.object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the operation
|
* @return the operation
|
||||||
*/
|
*/
|
||||||
public Operation getOperation() {
|
public Operation getOperation() {
|
||||||
return operation;
|
return this.operation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,11 +117,11 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public void add(String key, T objectToAdd) {
|
public void add(String key, T objectToAdd) {
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (ObjectFilter.logger.isDebugEnabled())
|
||||||
logger.debug("add object " + objectToAdd + " with key " + key);
|
ObjectFilter.logger.debug("add object " + objectToAdd + " with key " + key);
|
||||||
|
|
||||||
// add the key to the set
|
// add the key to the set
|
||||||
keySet.add(key);
|
this.keySet.add(key);
|
||||||
|
|
||||||
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
||||||
long id = objectToAdd.getTransactionID();
|
long id = objectToAdd.getTransactionID();
|
||||||
|
@ -131,14 +131,14 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
id = dispenseID();
|
id = dispenseID();
|
||||||
objectToAdd.setTransactionID(id);
|
objectToAdd.setTransactionID(id);
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToAdd, Operation.ADD);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToAdd, Operation.ADD);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
ObjectCache<T> cached = cache.get(Long.valueOf(objectToAdd.getTransactionID()));
|
ObjectCache<T> cached = this.cache.get(Long.valueOf(objectToAdd.getTransactionID()));
|
||||||
if (cached == null) {
|
if (cached == null) {
|
||||||
// The object got an ID during this run, but was not added to the cache.
|
// The object got an ID during this run, but was not added to the cache.
|
||||||
// Hence, we add it now, with the current operation.
|
// Hence, we add it now, with the current operation.
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToAdd, Operation.ADD);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToAdd, Operation.ADD);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
String existingKey = cached.getKey();
|
String existingKey = cached.getKey();
|
||||||
if (!existingKey.equals(key)) {
|
if (!existingKey.equals(key)) {
|
||||||
|
@ -197,11 +197,11 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public void update(String key, T objectToUpdate) {
|
public void update(String key, T objectToUpdate) {
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (ObjectFilter.logger.isDebugEnabled())
|
||||||
logger.debug("update object " + objectToUpdate + " with key " + key);
|
ObjectFilter.logger.debug("update object " + objectToUpdate + " with key " + key);
|
||||||
|
|
||||||
// add the key to the keyset
|
// add the key to the keyset
|
||||||
keySet.add(key);
|
this.keySet.add(key);
|
||||||
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
||||||
|
|
||||||
long id = objectToUpdate.getTransactionID();
|
long id = objectToUpdate.getTransactionID();
|
||||||
|
@ -209,14 +209,14 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
id = dispenseID();
|
id = dispenseID();
|
||||||
objectToUpdate.setTransactionID(id);
|
objectToUpdate.setTransactionID(id);
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToUpdate, Operation.MODIFY);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToUpdate, Operation.MODIFY);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
ObjectCache<T> cached = cache.get(Long.valueOf(objectToUpdate.getTransactionID()));
|
ObjectCache<T> cached = this.cache.get(Long.valueOf(objectToUpdate.getTransactionID()));
|
||||||
if (cached == null) {
|
if (cached == null) {
|
||||||
// The object got an ID during this run, but was not added to this cache.
|
// The object got an ID during this run, but was not added to this cache.
|
||||||
// Hence, we add it now, with the current operation.
|
// Hence, we add it now, with the current operation.
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToUpdate, Operation.MODIFY);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToUpdate, Operation.MODIFY);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
String existingKey = cached.getKey();
|
String existingKey = cached.getKey();
|
||||||
if (!existingKey.equals(key)) {
|
if (!existingKey.equals(key)) {
|
||||||
|
@ -275,25 +275,25 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public void remove(String key, T objectToRemove) {
|
public void remove(String key, T objectToRemove) {
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (ObjectFilter.logger.isDebugEnabled())
|
||||||
logger.debug("remove object " + objectToRemove + " with key " + key);
|
ObjectFilter.logger.debug("remove object " + objectToRemove + " with key " + key);
|
||||||
|
|
||||||
// add the key to the keyset
|
// add the key to the keyset
|
||||||
keySet.add(key);
|
this.keySet.add(key);
|
||||||
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
// BEWARE: you fix a bug here, be sure to update BOTH tables on the logic.
|
||||||
long id = objectToRemove.getTransactionID();
|
long id = objectToRemove.getTransactionID();
|
||||||
if (id == ITransactionObject.UNSET) {
|
if (id == ITransactionObject.UNSET) {
|
||||||
id = dispenseID();
|
id = dispenseID();
|
||||||
objectToRemove.setTransactionID(id);
|
objectToRemove.setTransactionID(id);
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToRemove, Operation.REMOVE);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToRemove, Operation.REMOVE);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
ObjectCache<T> cached = cache.get(Long.valueOf(id));
|
ObjectCache<T> cached = this.cache.get(Long.valueOf(id));
|
||||||
if (cached == null) {
|
if (cached == null) {
|
||||||
// The object got an ID during this run, but was not added to this cache.
|
// The object got an ID during this run, but was not added to this cache.
|
||||||
// Hence, we add it now, with the current operation.
|
// Hence, we add it now, with the current operation.
|
||||||
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToRemove, Operation.REMOVE);
|
ObjectCache<T> cacheObj = new ObjectCache<T>(key, objectToRemove, Operation.REMOVE);
|
||||||
cache.put(id, cacheObj);
|
this.cache.put(id, cacheObj);
|
||||||
} else {
|
} else {
|
||||||
String existingKey = cached.getKey();
|
String existingKey = cached.getKey();
|
||||||
if (!existingKey.equals(key)) {
|
if (!existingKey.equals(key)) {
|
||||||
|
@ -315,7 +315,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
case ADD:
|
case ADD:
|
||||||
// this is a case where we're removing the object from the cache, since we are
|
// this is a case where we're removing the object from the cache, since we are
|
||||||
// removing it now and it was added previously.
|
// removing it now and it was added previously.
|
||||||
cache.remove(Long.valueOf(id));
|
this.cache.remove(Long.valueOf(id));
|
||||||
break;
|
break;
|
||||||
case MODIFY:
|
case MODIFY:
|
||||||
cached.setObject(objectToRemove);
|
cached.setObject(objectToRemove);
|
||||||
|
@ -448,7 +448,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public List<T> getAdded(String key) {
|
public List<T> getAdded(String key) {
|
||||||
List<T> addedObjects = new LinkedList<T>();
|
List<T> addedObjects = new LinkedList<T>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
|
||||||
addedObjects.add(objectCache.getObject());
|
addedObjects.add(objectCache.getObject());
|
||||||
|
@ -468,7 +468,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public <V extends T> List<V> getAdded(Class<V> clazz, String key) {
|
public <V extends T> List<V> getAdded(Class<V> clazz, String key) {
|
||||||
List<V> addedObjects = new LinkedList<V>();
|
List<V> addedObjects = new LinkedList<V>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.ADD && (objectCache.getKey().equals(key))) {
|
||||||
if (objectCache.getObject().getClass() == clazz) {
|
if (objectCache.getObject().getClass() == clazz) {
|
||||||
|
@ -490,7 +490,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public List<T> getUpdated(String key) {
|
public List<T> getUpdated(String key) {
|
||||||
List<T> updatedObjects = new LinkedList<T>();
|
List<T> updatedObjects = new LinkedList<T>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
|
||||||
updatedObjects.add(objectCache.getObject());
|
updatedObjects.add(objectCache.getObject());
|
||||||
|
@ -508,7 +508,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public <V extends T> List<V> getUpdated(Class<V> clazz, String key) {
|
public <V extends T> List<V> getUpdated(Class<V> clazz, String key) {
|
||||||
List<V> updatedObjects = new LinkedList<V>();
|
List<V> updatedObjects = new LinkedList<V>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.MODIFY && (objectCache.getKey().equals(key))) {
|
||||||
if (objectCache.getObject().getClass() == clazz) {
|
if (objectCache.getObject().getClass() == clazz) {
|
||||||
|
@ -530,7 +530,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public List<T> getRemoved(String key) {
|
public List<T> getRemoved(String key) {
|
||||||
List<T> removedObjects = new LinkedList<T>();
|
List<T> removedObjects = new LinkedList<T>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
|
||||||
removedObjects.add(objectCache.getObject());
|
removedObjects.add(objectCache.getObject());
|
||||||
|
@ -548,7 +548,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public <V extends T> List<V> getRemoved(Class<V> clazz, String key) {
|
public <V extends T> List<V> getRemoved(Class<V> clazz, String key) {
|
||||||
List<V> removedObjects = new LinkedList<V>();
|
List<V> removedObjects = new LinkedList<V>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
|
if (objectCache.getOperation() == Operation.REMOVE && (objectCache.getKey().equals(key))) {
|
||||||
if (objectCache.getObject().getClass() == clazz) {
|
if (objectCache.getObject().getClass() == clazz) {
|
||||||
|
@ -571,7 +571,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public List<T> getAll(String key) {
|
public List<T> getAll(String key) {
|
||||||
List<T> allObjects = new LinkedList<T>();
|
List<T> allObjects = new LinkedList<T>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getKey().equals(key)) {
|
if (objectCache.getKey().equals(key)) {
|
||||||
allObjects.add(objectCache.getObject());
|
allObjects.add(objectCache.getObject());
|
||||||
|
@ -590,7 +590,7 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
*/
|
*/
|
||||||
public List<ObjectCache<T>> getCache(String key) {
|
public List<ObjectCache<T>> getCache(String key) {
|
||||||
List<ObjectCache<T>> allCache = new LinkedList<ObjectCache<T>>();
|
List<ObjectCache<T>> allCache = new LinkedList<ObjectCache<T>>();
|
||||||
Collection<ObjectCache<T>> allObjs = cache.values();
|
Collection<ObjectCache<T>> allObjs = this.cache.values();
|
||||||
for (ObjectCache<T> objectCache : allObjs) {
|
for (ObjectCache<T> objectCache : allObjs) {
|
||||||
if (objectCache.getKey().equals(key)) {
|
if (objectCache.getKey().equals(key)) {
|
||||||
allCache.add(objectCache);
|
allCache.add(objectCache);
|
||||||
|
@ -605,26 +605,26 @@ public class ObjectFilter<T extends ITransactionObject> {
|
||||||
* @return The set containing the keys of that have been added to the filter.
|
* @return The set containing the keys of that have been added to the filter.
|
||||||
*/
|
*/
|
||||||
public Set<String> keySet() {
|
public Set<String> keySet() {
|
||||||
return keySet;
|
return this.keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the cache.
|
* Clear the cache.
|
||||||
*/
|
*/
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
cache.clear();
|
this.cache.clear();
|
||||||
keySet.clear();
|
this.keySet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return get a unique transaction ID
|
* @return get a unique transaction ID
|
||||||
*/
|
*/
|
||||||
public synchronized long dispenseID() {
|
public synchronized long dispenseID() {
|
||||||
id++;
|
ObjectFilter.id++;
|
||||||
if (id == Long.MAX_VALUE) {
|
if (ObjectFilter.id == Long.MAX_VALUE) {
|
||||||
logger.error("Rolling IDs of objectFilter back to 1. Hope this is fine.");
|
ObjectFilter.logger.error("Rolling IDs of objectFilter back to 1. Hope this is fine.");
|
||||||
id = 1;
|
ObjectFilter.id = 1;
|
||||||
}
|
}
|
||||||
return id;
|
return ObjectFilter.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue