Skip to content

Commit

Permalink
Copied message properties from ARC to GZip. Changed and added some re…
Browse files Browse the repository at this point in the history
…portable properties to GZip Module.
  • Loading branch information
nclarkekb committed Aug 5, 2012
1 parent 6bbac71 commit 4fdbdbe
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 30 deletions.
25 changes: 25 additions & 0 deletions config/messages/gzip_messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@
# Message templates for class org.jhove2.module.format.gzip.GzipModule
# ##############################################################################
#
org.jhove2.module.format.gzip.GzipModule.duplicate = \
Duplicate {0}: ''{1}''
org.jhove2.module.format.gzip.GzipModule.empty = \
Empty {0}
org.jhove2.module.format.gzip.GzipModule.error_expected = \
Empty {0}, expected ''{1}''
org.jhove2.module.format.gzip.GzipModule.invalid = \
Invalid {0}
org.jhove2.module.format.gzip.GzipModule.invalid_data = \
Invalid {0}, ''{1}''
org.jhove2.module.format.gzip.GzipModule.invalid_encoding = \
Invalid encoded {0}, value: ''{1}'', encoding: ''{2}''
org.jhove2.module.format.gzip.GzipModule.invalid_expected = \
Invalid {0}, value: ''{1}'', expected: ''{2}''
org.jhove2.module.format.gzip.GzipModule.recommended = \
Invalid {0}: ''{1}''
org.jhove2.module.format.gzip.GzipModule.required_invalid = \
Invalid {0}: ''{1}''
org.jhove2.module.format.gzip.GzipModule.reserved = \
Invalid {0}: ''{1}''
org.jhove2.module.format.gzip.GzipModule.undesired_data = \
Invalid {0}: ''{1}''
org.jhove2.module.format.gzip.GzipModule.unknown = \
Invalid {0}: ''{1}''
#
org.jhove2.module.format.gzip.GzipModule.invalidGzipFile = \
Invalid GZIP file: fatal error encountered (current offset={0, number, integer}): {1}
#
Expand Down
2 changes: 1 addition & 1 deletion config/spring/module/format/arc/jhove2-arc-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ref bean="BnFAgent"/>
</list>
</property>
<property name="recurse" value="false"/>
<property name="recurse" value="true"/>
<property name="computeBlockDigest" value="true"/>
<property name="blockDigestAlgorithm" value="sha1"/>
<property name="blockDigestEncoding" value="base32"/>
Expand Down
2 changes: 1 addition & 1 deletion config/spring/module/format/warc/jhove2-warc-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ref bean="BnFAgent"/>
</list>
</property>
<property name="recurse" value="false"/>
<property name="recurse" value="true"/>
<property name="computeBlockDigest" value="true"/>
<property name="blockDigestAlgorithm" value="sha1"/>
<property name="blockDigestEncoding" value="base32"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public void run() {
++deflateMemberCount;
}
// Check member validity.
if (! gzipEntry.isValid()) {
if (! gzipEntry.isCompliant()) {
//this.invalidMembers.incrementAndGet();
++invalidMembers;
isValid = Validity.False;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@Persistent
public class GzipEntryData {

protected boolean isNonCompliant;
protected int index;
protected long offset;
protected CompressionMethod method;
Expand Down Expand Up @@ -43,6 +44,7 @@ public GzipEntryData() {
}

public GzipEntryData(GzipEntry entry) {
this.isNonCompliant = !entry.isCompliant();
this.offset = entry.getStartOffset();
this.method = CompressionMethod.fromValue(entry.cm);
this.extraFlags = CompressionType.fromValue(entry.xfl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ public int getIndex() {
return entry.index;
}

/**
* Returns whether the entry is compliant or not.
* @return whether the entry is compliant or not
*/
@ReportableProperty(order = 1, value = "Is non compliancy.")
public boolean getIsNonCompliant() {
return entry.isNonCompliant;
}

/**
* Returns the offset of the beginning of this entry in the GZip
* file.
* @return the offset of this entry, as a number of bytes from the
* start of the GZip file.
*/
@ReportableProperty(order = 1, value = "Offset value.")
@ReportableProperty(order = 2, value = "Offset value.")
public long getOffset() {
return entry.offset;
}
Expand All @@ -95,7 +104,7 @@ public long getOffset() {
* @return the name of the compressed file or <code>null</code> if
* the compressed data did not come from a file.
*/
@ReportableProperty(order = 2, value = "GZip entry name.")
@ReportableProperty(order = 3, value = "GZip entry name.")
public String getName() {
return entry.fileName;
}
Expand All @@ -104,7 +113,7 @@ public String getName() {
* Returns the GZip member comment.
* @return the GZip member comment or <code>null</code> if absent.
*/
@ReportableProperty(order = 3, value = "GZip entry comment.")
@ReportableProperty(order = 4, value = "GZip entry comment.")
public String getComment() {
return entry.comment;
}
Expand All @@ -116,7 +125,7 @@ public String getComment() {
* @return last modification date of the compressed file or
* <code>null</code> if none is present in the GZip header.
*/
@ReportableProperty(order = 4, value = "GZip entry date.")
@ReportableProperty(order = 5, value = "GZip entry date.")
public Date getDate() {
return (entry.date != null)? new Date(entry.date.getTime()): null;
}
Expand All @@ -136,7 +145,7 @@ public long getTime() {
* Returns the compression method used for this entry.
* @return the compression method.
*/
@ReportableProperty(order = 5, value = "GZip entry compression method.")
@ReportableProperty(order = 6, value = "GZip entry compression method.")
public CompressionMethod getCompressionMethod() {
return entry.method;
}
Expand All @@ -159,7 +168,7 @@ public CompressionType getCompressionFlags() {
*
* @see #isOperatingSystemValid
*/
@ReportableProperty(order = 6, value = "GZip entry operating system.")
@ReportableProperty(order = 7, value = "GZip entry operating system.")
public OperatingSystem getOperatingSystem() {
return entry.os;
}
Expand Down Expand Up @@ -193,7 +202,7 @@ public byte[] getExtra() {
* @see #getComputedHeaderCrc
* @see #isHeaderCrcValid
*/
@ReportableProperty(order = 7, value = "GZip entry header crc16.")
@ReportableProperty(order = 8, value = "GZip entry header crc16.")
public String getCrc16() {
String crc16;
if (entry.readCrc16 != null) {
Expand Down Expand Up @@ -224,7 +233,7 @@ public long getComputedCrc16() {
* @see #getComputedDataCrc
* @see #isDataCrcValid
*/
@ReportableProperty(order = 8, value = "GZip entry crc32.")
@ReportableProperty(order = 9, value = "GZip entry crc32.")
public String getCrc32() {
return "0x" + Integer.toHexString(entry.readCrc32);
}
Expand All @@ -242,13 +251,27 @@ public long getComputedCrc32() {
return entry.computedCrc32;
}

/**
* Returns the ISIZE of the GZip member trailer, i.e. the announced
* compressed size of the member data modulo 32.
* @return the ISIZE value of the member trailer or
* <code>-1</code> if the member trailer has not yet
* been read.
*
* @see #isISizeValid
*/
@ReportableProperty(order = 10, value = "GZip entry extracted size (ISIZE) value.")
public long getISize() {
return entry.readISize;
}

/**
* Returns the (computed) uncompressed size of the member data.
* @return the uncompressed size of the member data or
* <code>-1</code> if the member trailer has not yet
* been read.
*/
@ReportableProperty(order = 9, value = "GZip entry (computed) uncompressed size, in bytes.")
@ReportableProperty(order = 11, value = "GZip entry (computed) uncompressed size, in bytes.")
public long getSize() {
return entry.size;
}
Expand All @@ -259,25 +282,11 @@ public long getSize() {
* <code>-1</code> if the member trailer has not yet
* been read.
*/
@ReportableProperty(order = 10, value = "GZip entry (computed) compressed size, in bytes.")
@ReportableProperty(order = 12, value = "GZip entry (computed) compressed size, in bytes.")
public long getCompressedSize() {
return entry.csize;
}

/**
* Returns the ISIZE of the GZip member trailer, i.e. the announced
* compressed size of the member data modulo 32.
* @return the ISIZE value of the member trailer or
* <code>-1</code> if the member trailer has not yet
* been read.
*
* @see #isISizeValid
*/
@ReportableProperty(order = 11, value = "GZip entry extracted size (ISIZE) value.")
public long getISize() {
return entry.readISize;
}

/**
* Returns the (computed) ISIZE of the GZip member trailer, i.e.
* the compressed size of the member data modulo 32.
Expand All @@ -291,9 +300,17 @@ public long getComputedISize() {
return entry.computedISize;
}

@ReportableProperty(order = 12, value = "GZip entry (computed) compression ration.")
public String getCompressionRatio() {
return Float.toString((float)entry.size / (float)entry.csize);
@ReportableProperty(order = 13, value = "GZip entry (computed) compression ratio.")
public double getCompressionRatio() {
double ratio = -1.0;
long size = entry.size;
long csize = entry.csize;
if ((size > 0L) && (csize > 0L)) {
// Compute compression ratio with 2 decimals only.
long l = ((size - csize) * 10000L) / size;
ratio = l / 100.00;
}
return ratio;
}

/**
Expand Down

0 comments on commit 4fdbdbe

Please sign in to comment.