Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature-57: deleteObject Refactor #58

Merged
merged 288 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
288 commits
Select commit Hold shift + click to select a range
d1aaf32
Clean-up code
doulikecookiedough Feb 5, 2024
d56b9b1
Add new methods 'renamePathForDeletion' and 'deleteListItems' in File…
doulikecookiedough Feb 5, 2024
20a2092
Refactor 'deleteObject' to improve atomicity of the process (rename a…
doulikecookiedough Feb 5, 2024
c86bb10
Update 'HashStore' interface javadocs and clean up code
doulikecookiedough Feb 5, 2024
c66b5a1
Clean up code, javadocs and fix minor bug in ObjectMetadata class con…
doulikecookiedough Feb 5, 2024
97cc255
Refactor 'deleteMetadata(String pid)' to remove all metadata related …
doulikecookiedough Feb 5, 2024
5297773
Update README.md
doulikecookiedough Feb 5, 2024
90b4d5a
Fix typo in 'renamePathForDeletion' javadoc
doulikecookiedough Feb 6, 2024
f3e4fea
Refactor 'tagObject' to handle scenarios where exceptions are unneces…
doulikecookiedough Feb 8, 2024
786f81e
Add TODO item
doulikecookiedough Feb 15, 2024
fd605a8
Fix inaccurate javadoc return description in 'ObjectMetadata' class
doulikecookiedough May 9, 2024
7a343cb
Swallow file already exists exception when creating directories in 'm…
doulikecookiedough May 9, 2024
519f9b6
Synchronize 'deleteObjectByCid' method with other delete methods for …
doulikecookiedough May 9, 2024
6fb8abe
Fix typos in 'FileHashStore' class
doulikecookiedough May 9, 2024
4c9348a
Remove TODO item
doulikecookiedough May 9, 2024
0c3fc66
Improve clarity in comments for 'getExpectedPath' method
doulikecookiedough May 9, 2024
5fa19f8
Update comment formatting, revise javadoc and fix typo
doulikecookiedough May 9, 2024
bc0be54
Move initial synchronization block to within try statement to prevent…
doulikecookiedough May 10, 2024
1a3835d
Revise comments and extract 'checkObjectEquality' method from FileHas…
doulikecookiedough May 10, 2024
9aef583
Refactor 'deleteObject' to delete metadata in respective blocks for s…
doulikecookiedough May 10, 2024
645d3e7
Refactor 'tagObject' to synchronize based on new array list 'referenc…
doulikecookiedough May 10, 2024
644eae5
Refactor 'deleteObject' with pids to synchronize based on pids shared…
doulikecookiedough May 10, 2024
14062e5
Fix bug in 'getExpectedPath' where metadata document id was not corre…
doulikecookiedough May 10, 2024
3189118
Add comments to catch blocks in 'deleteObject' to help with debugging
doulikecookiedough May 10, 2024
a76fe7a
Revert 'deleteObject' order of operations to debug changes
doulikecookiedough May 13, 2024
6261abc
Revert changes to synchronization for tagObject and deleteObject for …
doulikecookiedough May 13, 2024
71cbae8
Revert changes to synchronization placement for debugging
doulikecookiedough May 13, 2024
059fee1
Replace usage of 'notifyAll' to 'notify' with synchronization blocks
doulikecookiedough May 13, 2024
c01d2f3
Revert usage of 'notify' back to 'notifyAll'
doulikecookiedough May 13, 2024
0bc5c06
Fix bug in sychronization with incorrect value (used pid instead of cid)
doulikecookiedough May 13, 2024
702f90f
Replace usage of 'notifyAll' to 'notify' as we have implemented mutua…
doulikecookiedough May 13, 2024
fa17489
Add missing synchronization in 'deleteObject' on pid, and when access…
doulikecookiedough May 14, 2024
321a44e
Refactor 'deleteObjectByCid'
doulikecookiedough May 14, 2024
e397cbb
Remove unused import statement
doulikecookiedough May 14, 2024
3f3f828
Fix inaccurate debug statements and revise sync process in 'OrphanRef…
doulikecookiedough May 14, 2024
09b6549
Add additional comments in javadoc for 'TestDataHarness'
doulikecookiedough May 15, 2024
e53f782
Refactor 'deleteObject(String, String)' to improve clarity
doulikecookiedough May 15, 2024
5e8b98e
Apply formatting to 'deleteObject' method
doulikecookiedough May 15, 2024
1a1f75f
Fix bug when creating cid refs file where hashed value was used inste…
doulikecookiedough May 20, 2024
67f7862
Add new junit tests for 'getExpectedPath' method in FileHashStore
doulikecookiedough May 21, 2024
898920c
Add new class 'HashStoreServiceRequest'
doulikecookiedough Jun 10, 2024
0ffc8a6
Add 'storeObject' and 'deleteObject' switch case options in HashStore…
doulikecookiedough Jun 10, 2024
e376f5d
Add new 'hsr' option to test hashstore service in 'HashStoreClient'
doulikecookiedough Jun 10, 2024
752fbe3
Remove 'hsr' option from 'HashStoreClient' class, rename 'HashStoreSe…
doulikecookiedough Jun 10, 2024
2e71f8f
Revise exception log message in 'writeToTmpFileAndGenerateChecksums' …
doulikecookiedough Jun 10, 2024
d7d79ca
Refactor newly added junit test 'storeObject_50Pids_1Obj_viaRunnable'
doulikecookiedough Jun 10, 2024
fe1621a
Add new junit test 'deleteObject_50Pids_1Obj_viaRunnable'
doulikecookiedough Jun 10, 2024
63828e5
Remove unused variable and fix incorrect assert statement in 'FileHas…
doulikecookiedough Jun 10, 2024
0680809
Rename 'refs' subdirectories from 'pid' to 'pids' and 'cid' to 'cids'…
doulikecookiedough Jun 11, 2024
b3d7a56
Merge pull request #63 from DataONEorg/feature-60-rename-refsdir
doulikecookiedough Jun 11, 2024
b0c23d8
Update sysmeta 'formatId' used in junit tests and 'README.md'
doulikecookiedough Jun 13, 2024
87ac4b2
Update README.md examples and fix typos
doulikecookiedough Jun 13, 2024
be50903
Update synchronization value in 'storeMetadata' to be the hash of the…
doulikecookiedough Jun 13, 2024
d6e1647
Add thread safety to 'deleteMetadata(pid, formatId)' and update hashs…
doulikecookiedough Jun 13, 2024
93225e4
Add thread safety to 'deleteMetadata(pid)' method
doulikecookiedough Jun 13, 2024
7780992
Refactor 'deleteObject(pid)' to call 'deleteMetadata(pid)' instead of…
doulikecookiedough Jun 13, 2024
f59507f
Fix typos in 'hashstore' interface
doulikecookiedough Jun 13, 2024
3a2a845
Merge pull request #64 from DataONEorg/feature-61-metadata-threadsafety
doulikecookiedough Jun 13, 2024
5db413f
Add new custom exception classes to be thrown by 'verifyObject'
doulikecookiedough Jun 14, 2024
0b9b6aa
Update 'verifyObject' to throw custom exceptions when there is an iss…
doulikecookiedough Jun 14, 2024
d0eeea2
Add new logic to 'verifyObject' to attempt to calculate the checksum …
doulikecookiedough Jun 14, 2024
45c844a
Clean up test classes 'FileHashStoreInterfaceTest' and 'FileHashStore…
doulikecookiedough Jun 14, 2024
0875de3
Adjust spacing for consistency in new custom exception classes
doulikecookiedough Jun 14, 2024
94d5109
Update test classes to explicitly close new stream objects after they…
doulikecookiedough Jun 14, 2024
ec1e9f3
Merge pull request #66 from DataONEorg/feature-65-verifyobj-update
doulikecookiedough Jun 17, 2024
f192ae4
Cleanup 'deleteObject' by deleting now irrelevant code related to ret…
doulikecookiedough Jun 17, 2024
2ec1616
Revise 'HashStoreFactory' .getHashStore method exception occurence to…
doulikecookiedough Jun 18, 2024
2d20d82
Fix malformed 'hashstore.yaml' base template (had redundant key value)
doulikecookiedough Jun 18, 2024
44a5598
Fix incorrect extends exception type in 'NonMatchingChecksumException…
doulikecookiedough Jun 18, 2024
0bfb95b
Add missing javadocs to new custom exception classes
doulikecookiedough Jun 18, 2024
e2bceee
Add .printStackTrace() method to 'HashStoreFactory' exception scenari…
doulikecookiedough Jun 18, 2024
8f3d5d9
Update 'HashStoreFactory' exception scenarios to call '.getCause' ins…
doulikecookiedough Jun 18, 2024
c35be2a
Refactor 'FileHashStore' init process when checking a given 'storePat…
doulikecookiedough Jun 18, 2024
a1d0ef4
Add and revise logging statements in 'verifyHashStoreProperties'
doulikecookiedough Jun 18, 2024
7dba739
Update junit test classes for 'storePath' and sysmeta namespace clarity
doulikecookiedough Jun 18, 2024
d91aa8f
Update README.md
doulikecookiedough Jun 18, 2024
8b57caf
Merge pull request #70 from DataONEorg/feature-69-hashstore-initupdate
doulikecookiedough Jun 18, 2024
d1d048e
Update 'pom.xml' to create a specific shaded-jar file which contains …
doulikecookiedough Jun 18, 2024
d49ce47
Re-add 'SNAPSHOT' to version name in 'pom.xml' to represent project i…
doulikecookiedough Jun 18, 2024
a8f3753
Merge pull request #71 from DataONEorg/feature-67-maven-jarfile
doulikecookiedough Jun 18, 2024
eb01034
Initial update to 'findObject' to return a map, update the 'HashStore…
doulikecookiedough Jun 19, 2024
738c2f3
Add 'object_path' key to map returned from 'findObject' and add new j…
doulikecookiedough Jun 19, 2024
fe21ef9
Add remaining refs paths and sysmeta path keys and values to map retu…
doulikecookiedough Jun 19, 2024
8f7f26d
Update variable names in 'findObject' method, update 'HashStoreClient…
doulikecookiedough Jun 19, 2024
2149abd
Clean up 'TestDataHarness' class for clarity, fix bug in 'HashStoreCl…
doulikecookiedough Jun 19, 2024
ccc2a6e
Remove unnecessary return statement in 'ObjectMetadata' class for met…
doulikecookiedough Jun 19, 2024
7c3bf4c
Cleanup test classes for typos, unused imports and other minor warnings
doulikecookiedough Jun 19, 2024
011f609
Merge pull request #73 from DataONEorg/feature-72-findobject-update
doulikecookiedough Jun 19, 2024
9529973
Update 'verifyHashStoreProperties' javadoc and debug message
doulikecookiedough Jun 20, 2024
f1211ce
Update README.md hashstore layout formatting
doulikecookiedough Jun 20, 2024
cdab02a
Clean up 'FileHashStore' Pt.1 (debug message typo), spacing and revis…
doulikecookiedough Jun 20, 2024
f1f6b75
Revise 'verifyHashStoreRefsFiles' method exceptions types to improve …
doulikecookiedough Jun 20, 2024
7d2b576
Update 'tagObject' to check for existence of ref files in the if bloc…
doulikecookiedough Jun 21, 2024
8818765
Cleanup 'tagObject'
doulikecookiedough Jun 21, 2024
df96c67
Cleanup 'verifyHashStoreRefsFiles'
doulikecookiedough Jun 21, 2024
7202868
Merge pull request #76 from DataONEorg/feature-75-cidrefs-threadsafety
doulikecookiedough Jun 21, 2024
8e42e4d
All new custom exception 'HashStoreRefsAlreadyExistException'
doulikecookiedough Jun 21, 2024
af95ea7
Revise 'tagObject' to throw new custom exception when refs file alrea…
doulikecookiedough Jun 21, 2024
4206c45
Add missing javadocs to newly created custom exception classes
doulikecookiedough Jun 21, 2024
1a93682
Merge pull request #77 from DataONEorg/feature-74-tagobject-hsobjclarity
doulikecookiedough Jun 21, 2024
b2a98fb
Update README.md for HashStoreClient examples to call the correct .ja…
doulikecookiedough Jun 21, 2024
d412ad9
Update 'storeObject_objectLockedIds_FiveThreads' to catch newly added…
doulikecookiedough Jun 21, 2024
e9d5956
Removed redundant 'storeObject' overload methos from 'HashStore' inte…
doulikecookiedough Jul 4, 2024
d986b7b
Remove now obsolete 'storeObject' overload methods from 'FileHashStor…
doulikecookiedough Jul 4, 2024
c9e5d51
Merge pull request #84 from DataONEorg/feature-82-remove-overloads
doulikecookiedough Jul 4, 2024
f56b3cf
Add new utility method 'isValidString', which is now called by 'check…
doulikecookiedough Jul 4, 2024
7e007f1
Add new junit tests to check that illegal characters in a given 'pid'…
doulikecookiedough Jul 4, 2024
4739abb
Merge pull request #85 from DataONEorg/feature-81-check-addchars
doulikecookiedough Jul 4, 2024
05ca2c8
Update 'findObject' javadoc for inaccurate return description
doulikecookiedough Jul 4, 2024
e0b6a6b
Update 'HashStore' interface & 'FileHashStore' with new 'verifyObject…
doulikecookiedough Jul 4, 2024
c2b148c
Refactor 'getExpectedPath' - extract new method 'getHashStoreRefsPath'
doulikecookiedough Jul 4, 2024
11dea30
Refactor 'getExpectedPath' - extract new method 'getHashStoreMetadata…
doulikecookiedough Jul 4, 2024
1afce09
Refactor 'getExpectedPath' - extract new method 'getHashStoreDataObject'
doulikecookiedough Jul 4, 2024
1694d32
Cleanup 'getExpectedPath' and related extracted methods
doulikecookiedough Jul 4, 2024
4c3afaf
Delete 'getExpectedPath' method and replace codebase calls to it with…
doulikecookiedough Jul 4, 2024
076e7a3
Remove 'deleteObject(String, String)' overload method that was leakin…
doulikecookiedough Jul 4, 2024
52a7568
Update 'HashStore' interface javadocs for 'verifyObject'
doulikecookiedough Jul 4, 2024
9b65a37
Implement updated 'verifyObject' functionality when boolean 'deleteIn…
doulikecookiedough Jul 4, 2024
f17c967
Cleanup 'validateTmpObject' javadoc
doulikecookiedough Jul 4, 2024
2f7b790
Update README.md
doulikecookiedough Jul 4, 2024
83a3e8f
Merge pull request #86 from DataONEorg/feature-80-verifyobj-sigupdate
doulikecookiedough Jul 4, 2024
9b4d57c
Revise 'junit' test for 'RunnableTest' to check runtime for number of…
doulikecookiedough Jul 4, 2024
25a970b
Update 'deleteObject' Runnable test to check for 1000 pids instead of 50
doulikecookiedough Jul 4, 2024
2734f03
Update 'HashStoreRunnable' test class exception messaging to 'e.getCa…
doulikecookiedough Jul 5, 2024
9a99113
Clean up 'HashStoreRunnable' and add/revise logging statements
doulikecookiedough Jul 5, 2024
9e1d9e2
Extract new protected method 'storeHashStoreRefsFiles' from 'tagObject'
doulikecookiedough Jul 9, 2024
d890db6
Organize new 'storeHashStoreRefsFile' method in 'FileHashStore' class…
doulikecookiedough Jul 9, 2024
9020775
Revise junit tests for 'tagObject', add new junit tests for 'storeHas…
doulikecookiedough Jul 9, 2024
6c727fa
Add new method 'unTagObject'
doulikecookiedough Jul 9, 2024
bfe2f27
Revise comment for accuracy
doulikecookiedough Jul 9, 2024
5a69daf
Add new junit test for 'unTagObject' and fix bug in existing 'tagObje…
doulikecookiedough Jul 9, 2024
259bf54
Add new junit tests for 'unTagObject'
doulikecookiedough Jul 9, 2024
b06d8c6
Revise 'findObject' to throw custom exception 'PidRefsFileNotFoundExc…
doulikecookiedough Jul 9, 2024
18d2e25
Add new junit test for 'unTagObject' and revise 'findObject' junit te…
doulikecookiedough Jul 9, 2024
cbd494d
Add clean-up code to 'unTagObject' when a pid refs file does not exis…
doulikecookiedough Jul 9, 2024
30e1e09
Revise 'unTagObject' javadoc and comments
doulikecookiedough Jul 9, 2024
5e2e7f1
Add print statements to 'HashStoreRunnable' to assist with debugging …
doulikecookiedough Jul 10, 2024
742eeac
Add 'unTagObject' to 'tagObject' process
doulikecookiedough Jul 10, 2024
e96a517
Add new junit tests for 'updateRefsFile'
doulikecookiedough Jul 10, 2024
b6d56cc
Add new junit tests for 'tagObject' and fix bug where a pid refs is d…
doulikecookiedough Jul 10, 2024
9eef991
Revise comments and add additional print statement to assist with deb…
doulikecookiedough Jul 10, 2024
355dd1b
Fix inaccurate argument string in 'verifyChecksumParameters'
doulikecookiedough Jul 10, 2024
81cb5ed
Cleanup 'FileHashStoreReferencesTest' class
doulikecookiedough Jul 10, 2024
84f8dc7
Merge pull request #89 from DataONEorg/feature-83-tagobject-cleanup
doulikecookiedough Jul 10, 2024
60127a4
Remove 'findObject' from 'HashStore' interface and move javadoc to 'F…
doulikecookiedough Jul 10, 2024
08e7c7e
Remove 'findObject' from 'HashStoreClient' and update README.md
doulikecookiedough Jul 10, 2024
bb47568
Cleanup test classes for ide warnings and re-organize junit tests
doulikecookiedough Jul 10, 2024
e0c3bb7
Move 'findObject' code in 'FileHashStore' to core and supporting meth…
doulikecookiedough Jul 10, 2024
47841f1
Merge pull request #90 from DataONEorg/feature-87-removefo-publicapi
doulikecookiedough Jul 10, 2024
a60586c
Code clean-up: Review/revise comments, refactor 'retrieveMetadata' me…
doulikecookiedough Jul 11, 2024
fd290ea
Code clean-up: Review/revise comments, refactor 'deleteMetadata' meth…
doulikecookiedough Jul 11, 2024
ccda4c5
Code clean-up: Revise deleteMetadata to call existing method to get p…
doulikecookiedough Jul 11, 2024
947459a
Code clean-up: Remove unused 'deleteRefsFile' method & update junit t…
doulikecookiedough Jul 11, 2024
487bbce
Resolve linting warning in 'putObject' by replacing .delete() call on…
doulikecookiedough Jul 11, 2024
c2b67de
Clean-up 'deleteObject' and 'unTagObject', refactor to begin with rem…
doulikecookiedough Jul 11, 2024
3b5b7d6
Rename method 'getMetadataDocInputStream' to 'getHashStoreMetadataInp…
doulikecookiedough Jul 11, 2024
83382f9
Code clean-up: remove redundant logging texts
doulikecookiedough Jul 11, 2024
cebdd2f
Accept IDE warning suggestion to weaken specific list types to a Coll…
doulikecookiedough Jul 11, 2024
c778e2d
Code clean-up: fix ide warnings for 'FileHashStoreUtility' class
doulikecookiedough Jul 11, 2024
261ca00
Code clean-up: fix ide warnings for 'ObjectMetadata' class
doulikecookiedough Jul 11, 2024
75b56c2
Code clean-up: remove redundant printstacktrace statement in 'HashSto…
doulikecookiedough Jul 11, 2024
cc1a43b
Code clean-up: address warnings for HashStore interface
doulikecookiedough Jul 11, 2024
207937a
Code clean-up: address warnings for HashStoreClient class
doulikecookiedough Jul 12, 2024
9010843
Code clean-up: Address additional warnigs from test classes
doulikecookiedough Jul 12, 2024
67bd37c
Accept ide warning to Weaken type from List to Collection in 'FileHas…
doulikecookiedough Jul 12, 2024
e6e1018
Refactor public api methods in 'FileHashStore' by extracting synchron…
doulikecookiedough Jul 12, 2024
3ccc3eb
Remove unused parameter from 'syncRenameMetadataDocForDeletion' and f…
doulikecookiedough Jul 12, 2024
f92ccca
Deactivate known intermittently failing test which issue has been cre…
doulikecookiedough Jul 12, 2024
c2098d3
Update storeObject HashStoreRunnable junit test
doulikecookiedough Jul 12, 2024
b0c5414
Fix warning for 'verifyObject' with boolean value in signature by rem…
doulikecookiedough Jul 12, 2024
d2f73b4
Remove todo item and add new junit tests for 'getHashStoreMetadataInp…
doulikecookiedough Jul 12, 2024
8cd0d34
Add missing junit tests for 'verifyChecksumParameters'
doulikecookiedough Jul 12, 2024
f649697
Add missing junit tests for 'shouldCalculateAlgorithm'
doulikecookiedough Jul 12, 2024
3d00b4b
Delete 'FileHashStoreReferencesTest' class, move and organize junit t…
doulikecookiedough Jul 12, 2024
7474db3
Rename 'FileHashStorePublicTest' to 'FileHashStoreInitTest' for accuracy
doulikecookiedough Jul 12, 2024
0e0dfcf
Add missing junit tests for 'isStringInRefsFile' in 'FileHashStorePro…
doulikecookiedough Jul 12, 2024
6c7e151
Fix bug in 'validateTmpObject' and add missing 'validateTmpObject' ju…
doulikecookiedough Jul 12, 2024
e9b4b24
Reword javadoc for 'HashStoreClient' class
doulikecookiedough Jul 12, 2024
6ad3c01
Re-activate disabled runnable test, update 'putObject' to delete redu…
doulikecookiedough Jul 17, 2024
30d7f88
Rework/optimize 'putObject' routine and update junit tests
doulikecookiedough Jul 17, 2024
8f323f5
Revise error statement in 'putObject' and variable name in intermitte…
doulikecookiedough Jul 17, 2024
9d096f3
Merge pull request #91 from DataONEorg/bug-88-tmpfile-cleanup
doulikecookiedough Jul 17, 2024
6ff1336
Update README.md
doulikecookiedough Jul 17, 2024
8bee29d
Update HashStore interface, rename 'verifyObject' to 'deleteInvalidOb…
doulikecookiedough Jul 17, 2024
8617f17
Merge pull request #93 from DataONEorg/feature-92-deleteinvalidobject
doulikecookiedough Jul 17, 2024
71dc486
Move synchronization code calls into try blocks
doulikecookiedough Jul 19, 2024
28cfa7a
Add missing synchronization for data object cid when data object is a…
doulikecookiedough Jul 19, 2024
b0f86a5
Rename synchronization array from 'objectLockedIds' to 'objectLockedP…
doulikecookiedough Jul 19, 2024
2fc6721
Rename synchronization array from 'metadataLockedIds' to 'metadataLoc…
doulikecookiedough Jul 19, 2024
08f2c79
Rename synchronization array from 'referenceLockedCids' to 'objectLoc…
doulikecookiedough Jul 19, 2024
7aa852d
Add new synchronization code for 'tagObject' which can be called dire…
doulikecookiedough Jul 19, 2024
2ea427b
Revise 'tagObject' unexpected exception process to release locks befo…
doulikecookiedough Jul 19, 2024
38d0924
Check 'deleteInvalidObject' for when ObjectMetadata passed does not i…
doulikecookiedough Jul 19, 2024
f76a13c
Rename FileHashStoreUtility 'checkForEmptyString' to 'checkForEmptyAn…
doulikecookiedough Jul 19, 2024
b044728
Rework FileHashStoreUtility 'deleteListItems' method to attempt to de…
doulikecookiedough Jul 19, 2024
8442d66
Add logic to Public API store methods to try-finally .close the suppl…
doulikecookiedough Jul 19, 2024
2cbec48
Refactor 'deleteMetadata' with logic to revert the process if there i…
doulikecookiedough Jul 19, 2024
9f3dac9
Clean up code for recently reworked deleteMetadata process
doulikecookiedough Jul 19, 2024
489f4db
Merge pull request #94 from DataONEorg/feature-57-delobjref-jingcrch
doulikecookiedough Jul 19, 2024
1a12765
Revert process to restore metadata documents from 'deleteMetadata' me…
doulikecookiedough Jul 19, 2024
f28b522
Add revert metadata deletion process to 'syncRenameMetadataDocForDele…
doulikecookiedough Jul 19, 2024
2012a2a
Add guard rails to 'syncRenameMetadataDocForDeletion' and new junit t…
doulikecookiedough Jul 19, 2024
41375e0
Update postgres version to 42.7.2 to resolve vulnerability warning
doulikecookiedough Aug 9, 2024
1da579c
Update README.md for clarity
doulikecookiedough Aug 9, 2024
8b8ef2d
Rename 'deleteInvalidObject' method to 'deleteIfInvalidObject' and up…
doulikecookiedough Aug 12, 2024
a306271
Update .idea's .gitignore and 'README.md'
doulikecookiedough Aug 12, 2024
96235b8
Revise javadoc usage of backticks to '{@code ... }'
doulikecookiedough Aug 12, 2024
4d382a5
Update maven and idea settings java target to 17 from 1.8
doulikecookiedough Aug 12, 2024
1f33e7d
Add new junit test to check for when pid is simply a new line
doulikecookiedough Aug 12, 2024
4770050
Refactor FileHashStoreUtility 'checkNotNegativeOrZero' to 'checkPosit…
doulikecookiedough Aug 12, 2024
2fea9ff
Rename logging variable in 'HashStoreRunnable'
doulikecookiedough Aug 12, 2024
e327e91
Clean up 'FileHashStoreUtility' logging and exception statements
doulikecookiedough Aug 12, 2024
a1870cc
Update maven.yml workflow to use JDK 17
doulikecookiedough Aug 12, 2024
b58b26c
Add missing javadocs in 'HashStoreRunnable' class and missing javadocs
doulikecookiedough Aug 12, 2024
9e75b30
Refactor 'FileHashStoreProtected' junit tests to create InputStreams …
doulikecookiedough Aug 12, 2024
58e73ab
Refactor 'FileHashStoreInit' junit tests to create InputStreams in tr…
doulikecookiedough Aug 12, 2024
252cefa
Refactor 'FileHashStoreClient' junit tests to create InputStreams in …
doulikecookiedough Aug 12, 2024
d961d35
Refactor 'HashStore' junit tests to create InputStreams in try statem…
doulikecookiedough Aug 12, 2024
5542a9c
Refactor 'FileHashStoreUtility' class' calculateHexDigest method to u…
doulikecookiedough Aug 12, 2024
1c61165
Refactor 'FileHashStore' to use try statements for automatic resource…
doulikecookiedough Aug 12, 2024
6591f44
Refactor 'FileHashStoreInterface' junit tests to create InputStreams …
doulikecookiedough Aug 13, 2024
dd9a2a7
Add new enum 'HashStoreRefUpdateTypes' and refactor affected code in …
doulikecookiedough Aug 13, 2024
56afebc
Refactor 'updateRefsFile' and 'getHashStoreRefsPath' to require enum …
doulikecookiedough Aug 13, 2024
38ebd81
Rename 'checkForEmptyAndValidString' method to 'checkForNotEmptyAndVa…
doulikecookiedough Aug 13, 2024
d1d2559
Apply autoformatting to 'syncPutObject'
doulikecookiedough Aug 13, 2024
da143f3
Apply autoformatting to 'deleteMetadata'
doulikecookiedough Aug 13, 2024
5309243
Apply autoformatting to 'findObject'
doulikecookiedough Aug 13, 2024
d842a59
Apply autoformatting to 'putObject'
doulikecookiedough Aug 13, 2024
0181107
Apply autoformatting to 'getHashStoreMetadataPath'
doulikecookiedough Aug 13, 2024
b3d0ea1
Remove redundant code in 'getHashStoreRefsPath' method
doulikecookiedough Aug 13, 2024
b884303
Add default case to 'getHashStoreRefsPath'
doulikecookiedough Aug 13, 2024
906ea73
Refactor 'ObjectMetadata' to be a record instead of a custom class, a…
doulikecookiedough Aug 13, 2024
ce07581
Cleanup 'ObjectMetadata' class
doulikecookiedough Aug 13, 2024
5bce0ce
Add new record 'objectInfo', refactor 'findObject' to return an 'obje…
doulikecookiedough Aug 13, 2024
75ba6c0
Refactor 'checkForNotEmptyAndValidString' to call '.isBlank()' instea…
doulikecookiedough Aug 13, 2024
f5ca23d
Refactor 'HashStoreRunnable' run's switch case per formatter suggestion
doulikecookiedough Aug 13, 2024
84846f4
Update README.md
doulikecookiedough Aug 15, 2024
f369441
Update javadocs in 'HashStore' interface
doulikecookiedough Aug 15, 2024
dc6a6fb
Refactor and simplify usage of enum objects 'HashStoreIdTypes' and 'H…
doulikecookiedough Aug 15, 2024
7ba3b73
Add missing javadocs for enum objects to add clarity
doulikecookiedough Aug 15, 2024
1eabe79
Rename 'objectInfo' record to 'ObjectInfo'
doulikecookiedough Aug 15, 2024
0bd9a3f
Rename references of 'deleteInvalidObject' to 'deleteIfInvalidObject'
doulikecookiedough Aug 15, 2024
189eaf3
Refactor 'tagObject' by moving synchronization code to be closer to c…
doulikecookiedough Aug 15, 2024
8ceb641
Refactor 'checkForNotEmptyAndValidString' to get method name via thre…
doulikecookiedough Aug 15, 2024
b94eb2c
Refactor 'ensureNotNull' to get method name via thread and update sig…
doulikecookiedough Aug 15, 2024
4561f79
Refactor 'checkPositive' to get method name via thread and update sig…
doulikecookiedough Aug 15, 2024
962ed5b
Fix typo in 'HashStore' interface
doulikecookiedough Aug 15, 2024
a9fce58
Revise comments in 'tagObject'
doulikecookiedough Aug 15, 2024
6a0c32b
Move synchronized call to within try statement in 'unTagObject' to im…
doulikecookiedough Aug 15, 2024
d61d9c3
Apply IntelliJ automatic formatting to entire codebase for linting co…
doulikecookiedough Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

255 changes: 169 additions & 86 deletions README.md
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this first, to re-familiarize myself with the project & design, which is why I've flagged a few things that may be confusing to the reader. I am that confused reader 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for reviewing this first (and great idea to get a refresher)! I do not wish to be that confusing writer, so your feedback is much appreciated. I've made the changes and agree with your suggestions.

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pom.xml
artntek marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.3</version>
<version>42.7.2</version>
</dependency>
</dependencies>

Expand All @@ -71,8 +71,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -86,6 +86,8 @@
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${basedir}/target/${project.name}-${project.version}-shaded.jar</outputFile>
<outputDirectory>${basedir}</outputDirectory>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
Expand Down
227 changes: 95 additions & 132 deletions src/main/java/org/dataone/hashstore/HashStore.java
artntek marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

38 changes: 14 additions & 24 deletions src/main/java/org/dataone/hashstore/HashStoreClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.sql.Connection;
Expand All @@ -21,7 +21,6 @@
import java.sql.Statement;

import org.dataone.hashstore.filehashstore.FileHashStoreUtility;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
Expand All @@ -35,8 +34,8 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

/**
* HashStoreClient is a command line interface that allows a developer to create a new HashStore or
* interact directly with an existing HashStore. See 'README.md' for usage examples.
* HashStoreClient is a development tool used to create a new HashStore or interact directly with
* an existing HashStore through the command line. See 'README.md' for usage examples.
*/
public class HashStoreClient {
private static HashStore hashStore;
Expand Down Expand Up @@ -142,13 +141,6 @@ public static void main(String[] args) throws Exception {
String hexDigest = hashStore.getHexDigest(pid, algo);
System.out.println(hexDigest);

} else if (cmd.hasOption("findobject")) {
String pid = cmd.getOptionValue("pid");
FileHashStoreUtility.ensureNotNull(pid, "-pid", "HashStoreClient");

String cid = hashStore.findObject(pid);
System.out.println(cid);

} else if (cmd.hasOption("storeobject")) {
System.out.println("Storing object");
String pid = cmd.getOptionValue("pid");
Expand Down Expand Up @@ -181,7 +173,7 @@ public static void main(String[] args) throws Exception {
);
pidObjStream.close();
System.out.println("Object Info for pid (" + pid + "):");
System.out.println(objInfo.getHexDigests());
System.out.println(objInfo.hexDigests());

} else if (cmd.hasOption("storemetadata")) {
String pid = cmd.getOptionValue("pid");
Expand Down Expand Up @@ -230,6 +222,7 @@ public static void main(String[] args) throws Exception {
} else if (cmd.hasOption("deleteobject")) {
String pid = cmd.getOptionValue("pid");
FileHashStoreUtility.ensureNotNull(pid, "-pid", "HashStoreClient");

hashStore.deleteObject(pid);
System.out.println("Object for pid (" + pid + ") has been deleted.");

Expand Down Expand Up @@ -282,10 +275,6 @@ private static Options addHashStoreClientOptions() {
"getchecksum", "client_getchecksum", false,
"Flag to get the hex digest of a data object in a HashStore."
);
options.addOption(
"findobject", "client_findobject", false,
"Flag to get the hex digest of a data object in a HashStore."
);
options.addOption(
"storeobject", "client_storeobject", false, "Flag to store objs to a HashStore."
);
Expand Down Expand Up @@ -351,6 +340,7 @@ private static Options addHashStoreClientOptions() {
options.addOption(
"dfs", "delfromhs", false, "(knbvm) Test flag to delete objs from a HashStore"
);
options.addOption("hsr", "hsservicerequest", false, "Dev option to test threading.");
return options;
}

Expand Down Expand Up @@ -502,7 +492,7 @@ private static void testWithKnbvm(

// For each row, get guid, docid, rev, checksum and checksum_algorithm
// and create a List to loop over
List<Map<String, String>> resultObjList = new ArrayList<>();
Collection<Map<String, String>> resultObjList = new ArrayList<>();
while (resultSet.next()) {
String guid = resultSet.getString("guid");
String docid = resultSet.getString("docid");
Expand Down Expand Up @@ -576,7 +566,7 @@ private static void testWithKnbvm(
* @param resultObjList List containing items with the following properties: 'pid', 'path',
* 'algorithm', 'checksum'
*/
private static void storeObjsWithChecksumFromDb(List<Map<String, String>> resultObjList) {
private static void storeObjsWithChecksumFromDb(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand All @@ -587,7 +577,7 @@ private static void storeObjsWithChecksumFromDb(List<Map<String, String>> result

// Store object
System.out.println("Storing object for guid: " + guid);
hashStore.storeObject(objStream, guid, checksum, algorithm);
hashStore.storeObject(objStream, guid, null, checksum, algorithm, -1);

} catch (PidRefsFileExistsException poee) {
String errMsg = "Unexpected Error: " + poee.fillInStackTrace();
Expand Down Expand Up @@ -633,7 +623,7 @@ private static void storeObjsWithChecksumFromDb(List<Map<String, String>> result
* @param resultObjList List containing items with the following properties: 'pid', 'algorithm',
* 'checksum'
*/
private static void retrieveAndValidateObjs(List<Map<String, String>> resultObjList) {
private static void retrieveAndValidateObjs(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand Down Expand Up @@ -693,7 +683,7 @@ private static void retrieveAndValidateObjs(List<Map<String, String>> resultObjL
*
* @param resultObjList List containing items with the following property: 'pid'
*/
private static void deleteObjectsFromStore(List<Map<String, String>> resultObjList) {
private static void deleteObjectsFromStore(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand Down Expand Up @@ -737,7 +727,7 @@ private static void deleteObjectsFromStore(List<Map<String, String>> resultObjLi
* @param resultObjList List containing items that have the following properties: 'pid', 'path'
* and 'namespace'
*/
private static void storeMetadataFromDb(List<Map<String, String>> resultObjList) {
private static void storeMetadataFromDb(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand Down Expand Up @@ -783,7 +773,7 @@ private static void storeMetadataFromDb(List<Map<String, String>> resultObjList)
* @param resultObjList List containing items with the following properties: 'pid', 'namespace',
* 'algorithm', 'checksum'
*/
private static void retrieveAndValidateMetadata(List<Map<String, String>> resultObjList) {
private static void retrieveAndValidateMetadata(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand Down Expand Up @@ -848,7 +838,7 @@ private static void retrieveAndValidateMetadata(List<Map<String, String>> result
*
* @param resultObjList List containing items with the following property: 'pid'
*/
private static void deleteMetadataFromStore(List<Map<String, String>> resultObjList) {
private static void deleteMetadataFromStore(Collection<Map<String, String>> resultObjList) {
resultObjList.parallelStream().forEach(item -> {
String guid = null;
try {
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/dataone/hashstore/HashStoreFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,32 @@ public static HashStore getHashStore(String classPackage, Properties storeProper

} catch (ClassNotFoundException cnfe) {
String errMsg = "HashStoreFactory - Unable to find 'FileHashStore' classPackage: "
+ classPackage + " - " + cnfe.fillInStackTrace();
+ classPackage + " - " + cnfe.getCause();
logHashStore.error(errMsg);
throw new HashStoreFactoryException(errMsg);

} catch (NoSuchMethodException nsme) {
String errMsg = "HashStoreFactory - Constructor not found for 'FileHashStore': "
+ classPackage + " - " + nsme.fillInStackTrace();
+ classPackage + " - " + nsme.getCause();
logHashStore.error(errMsg);
throw new HashStoreFactoryException(errMsg);

} catch (IllegalAccessException iae) {
String errMsg =
"HashStoreFactory - Executing method does not have access to the definition of"
+ " the specified class , field, method or constructor. " + iae
.fillInStackTrace();
.getCause();
logHashStore.error(errMsg);
throw new HashStoreFactoryException(errMsg);

} catch (InstantiationException ie) {
String errMsg = "HashStoreFactory - Error instantiating 'FileHashStore'"
+ "(likely related to `.newInstance()`): " + ie.fillInStackTrace();
+ "(likely related to `.newInstance()`): " + ie.getCause();
logHashStore.error(errMsg);
throw new HashStoreFactoryException(errMsg);

} catch (InvocationTargetException ite) {
String errMsg = "HashStoreFactory - Error creating 'FileHashStore' instance: " + ite
.fillInStackTrace();
String errMsg = "HashStoreFactory - Error creating 'FileHashStore' instance: " + ite.getCause();
logHashStore.error(errMsg);
throw new HashStoreFactoryException(errMsg);

Expand Down
54 changes: 5 additions & 49 deletions src/main/java/org/dataone/hashstore/ObjectMetadata.java
artntek marked this conversation as resolved.
Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOVE seeing a whole file be collapsed down to one line 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too, it's so clean now!

Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,10 @@
import java.util.Map;

/**
* ObjectMetadata is a class that models a unique identifier for an object in the HashStore. It
* encapsulates information about a file's content identifier (cid), size, and associated hash
* digest values. By using ObjectMetadata objects, client code can easily obtain metadata of a store
* object in HashStore without needing to know the underlying file system details.
* ObjectMetadata is a record that that contains metadata about an object in the HashStore. It
* encapsulates information about a file's authority-based/persistent identifier (pid), content
* identifier (cid), size, and associated hash digest values.
*/
public class ObjectMetadata {
private final String cid;
private final long size;
private final Map<String, String> hexDigests;
public record ObjectMetadata(String pid, String cid, long size, Map<String, String> hexDigests) {

/**
* Creates a new instance of ObjectMetadata with the given properties.
*
* @param cid Unique identifier for the file
* @param size Size of stored file
* @param hexDigests A map of hash algorithm names to their hex-encoded digest values for the
* file
*/
public ObjectMetadata(String cid, long size, Map<String, String> hexDigests) {
this.cid = cid;
this.size = size;
this.hexDigests = hexDigests;
}

/**
* Return the cid (content identifier) of the file
*
* @return cid
*/
public String getCid() {
return cid;
}

/**
* Return the size of the file
*
* @return size
*/
public long getSize() {
return size;
}

/**
* Return a map of hex digests (checksums)
*
* @return hexDigests
*/
public Map<String, String> getHexDigests() {
return hexDigests;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.dataone.hashstore.exceptions;

/**
* Custom exception class for FileHashStore when the expected cid is not found in the pid refs file.
*/
public class CidNotFoundInPidRefsFileException extends IllegalArgumentException {

public CidNotFoundInPidRefsFileException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.dataone.hashstore.exceptions;

import java.nio.file.FileAlreadyExistsException;

/**
* Custom exception thrown when called to tag a pid and cid, and reference files already exist
*/
public class HashStoreRefsAlreadyExistException extends FileAlreadyExistsException {

public HashStoreRefsAlreadyExistException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.dataone.hashstore.exceptions;

/**
* An exception that encapsulates errors from the HashStore Runnable Test Class
*/
public class HashStoreServiceException extends Exception {
public HashStoreServiceException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.dataone.hashstore.exceptions;

import java.util.NoSuchElementException;

/**
* An exception thrown when hexDigests from a supplied ObjectMetadata object is empty.
*/
public class MissingHexDigestsException extends NoSuchElementException {

public MissingHexDigestsException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.dataone.hashstore.exceptions;

/**
* An exception thrown when a checksum does not match what is expected.
*/

public class NonMatchingChecksumException extends IllegalArgumentException {

public NonMatchingChecksumException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.dataone.hashstore.exceptions;

/**
* An exception thrown when a data object size does not match what is expected.
*/

public class NonMatchingObjSizeException extends IllegalArgumentException {

public NonMatchingObjSizeException(String message) {
super(message);
}

}

Loading
Loading