-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/opencadc/storage-ui into gm…
…s-lookup # Conflicts: # VERSION
- Loading branch information
Showing
7 changed files
with
34 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## deployable containers have a semantic and build tag | ||
# semantic version tag: major.minor | ||
# build version tag: timestamp | ||
VERSION="1.1.3" | ||
VERSION="1.1.6" | ||
TAGS="${VERSION} ${VERSION}-$(date -u +"%Y%m%dT%H%M%S")" | ||
unset VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,75 +70,36 @@ | |
|
||
import ca.nrc.cadc.util.HexUtil; | ||
import ca.nrc.cadc.util.StringUtil; | ||
import org.opencadc.vospace.Node; | ||
import org.opencadc.vospace.NodeProperty; | ||
import org.opencadc.vospace.VOS; | ||
import net.canfar.storage.UploadVerificationFailedException; | ||
|
||
import java.net.URI; | ||
|
||
|
||
public class UploadVerifier { | ||
|
||
/** | ||
* Verify that each byte is accounted for on the server side. | ||
* | ||
* @param byteCount The count of bytes. | ||
* @param node The node to verify. | ||
* @throws UploadVerificationFailedException Any upload error, such as bad filename. | ||
*/ | ||
public void verifyByteCount(final long byteCount, final Node node) | ||
throws UploadVerificationFailedException { | ||
if (byteCount < 0) { | ||
throw new IllegalArgumentException("The given byte count cannot be a negative value."); | ||
} else if (node == null) { | ||
throw new IllegalArgumentException("The given Node cannot be null."); | ||
} | ||
|
||
final NodeProperty contentLengthProperty = node.getProperty(VOS.PROPERTY_URI_CONTENTLENGTH); | ||
final long contentLength = contentLengthProperty == null | ||
? 0L | ||
: Long.parseLong(contentLengthProperty.getValue()); | ||
|
||
if (byteCount != contentLength) { | ||
throw new UploadVerificationFailedException("** ERROR ** - Upload did not succeed: " | ||
+ String.format("File length counted [%d] does not " | ||
+ "match what the service said it " | ||
+ "should be [%d]", byteCount, | ||
contentLength)); | ||
} | ||
} | ||
|
||
/** | ||
* Verify the given MD5. | ||
* <p> | ||
* Note that the given MD5 will be converted to a Hex string, and then | ||
* the string will be compared to what the returned Node provided. | ||
* | ||
* @param calculatedMD5 The byte array of the calculated MD5. | ||
* @param node The node to verify against. | ||
* @param serverMD5 The server reported MD5. | ||
* @throws UploadVerificationFailedException Any upload error, such as bad filename. | ||
*/ | ||
public void verifyMD5(final byte[] calculatedMD5, final Node node) throws UploadVerificationFailedException { | ||
public void verifyMD5(final byte[] calculatedMD5, final String serverMD5) | ||
throws UploadVerificationFailedException { | ||
if (calculatedMD5 == null) { | ||
throw new IllegalArgumentException("The calculated MD5 cannot be null."); | ||
} else if (node == null) { | ||
throw new IllegalArgumentException("The given Node cannot be null."); | ||
} else if (serverMD5 == null) { | ||
throw new IllegalArgumentException("The server MD5 cannot be null."); | ||
} | ||
|
||
final NodeProperty MD5Property = node.getProperty(VOS.PROPERTY_URI_CONTENTMD5); | ||
final String serverMD5String = MD5Property == null | ||
? null | ||
: MD5Property.getValue(); | ||
|
||
if (!StringUtil.hasLength(serverMD5String)) { | ||
if (!StringUtil.hasLength(serverMD5)) { | ||
throw new UploadVerificationFailedException("** ERROR YOUR UPLOAD DID NOT SUCCEED ** " | ||
+ "MD5 checksum was not produced by " | ||
+ "service! This was not expected, please " | ||
+ "contact [email protected] for " | ||
+ "assistance."); | ||
} else { | ||
if (!HexUtil.toHex(calculatedMD5).equals(serverMD5String)) { | ||
if (!HexUtil.toHex(calculatedMD5).equals(serverMD5)) { | ||
throw new UploadVerificationFailedException( | ||
"** ERROR ** - Upload did not succeed: " | ||
+ "MD5 checksum failed."); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters