Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make the FixityResult computedChecksum a URI, and pass it consistentl…
…y through the stack.
  • Loading branch information
cbeer committed Mar 13, 2013
1 parent 9521529 commit b22a74c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
Expand Up @@ -503,7 +503,7 @@ private DatastreamFixity validatedDatastreamFixity(Datastream ds) throws Reposit
logger.debug("Computed checksum: " + result.computedChecksum);
logger.debug("Computed size is " + result.computedSize);

if (result.computedChecksum.toString().equals(dsChecksumStr)) {
if (result.computedChecksum.equals(dsChecksum)) {
status.validChecksum = true;
}
if (result.computedSize == dsSize) {
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class FixityStatus {
public long computedSize;

@XmlElement
public String computedChecksum;
public URI computedChecksum;

@XmlElement
public long dsSize;
Expand Down
Expand Up @@ -87,7 +87,7 @@ public FixityResult transformEntry(LowLevelCacheStore store,
encodeHexString(ds.getMessageDigest()
.digest());

result.computedChecksum = ContentDigest.asURI(digest.getAlgorithm(), calculatedDigest).toString();
result.computedChecksum = ContentDigest.asURI(digest.getAlgorithm(), calculatedDigest);
result.computedSize = ds.getByteCount();

} catch (CloneNotSupportedException e) {
Expand Down
Expand Up @@ -10,7 +10,7 @@
public class ContentDigest {

public final static Map<String, String> algorithmToScheme = ImmutableMap
.of("SHA-1", "urn:sha1");
.of("SHA-1", "urn:sha1","SHA1", "urn:sha1");

public static URI asURI(String algorithm, String value) {
try {
Expand Down
@@ -1,9 +1,11 @@
package org.fcrepo.utils;

import java.net.URI;

public class FixityResult {
public long computedSize;

public String computedChecksum;
public URI computedChecksum;

public boolean equals(Object obj) {

Expand Down
Expand Up @@ -57,7 +57,7 @@ public void testChecksumBlobs() throws Exception {
assertNotEquals(0, fixityResultMap.size());

for (FixityResult fixityResult : fixityResultMap.values()) {
assertTrue(fixityResult.computedChecksum.equals("urn:sha1:87acec17cd9dcd20a716cc2cf67417b71c8a7016"));
assertEquals("urn:sha1:87acec17cd9dcd20a716cc2cf67417b71c8a7016", fixityResult.computedChecksum.toString());
}
}

Expand Down
Expand Up @@ -15,4 +15,10 @@ public void testSHA_1() {
.create("urn:sha1:fake"), ContentDigest.asURI("SHA-1", "fake"));
}

@Test
public void testSHA1() {
assertEquals("Failed to produce a proper content digest URI!", URI
.create("urn:sha1:fake"), ContentDigest.asURI("SHA1", "fake"));
}

}

0 comments on commit b22a74c

Please sign in to comment.