Skip to content

Commit ccb66e7

Browse files
committed
First pass documentation review
1 parent 5fa6f85 commit ccb66e7

2 files changed

Lines changed: 66 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#### Changes in 5.0.0
2-
1. Complete rewrite of the library to remove bad practices and to allow for a much better design using java best practices.
3-
2. Removal of creating a zipped bag. There are many good zip (or other serialization) libraries in Java, please use one of them instead. Please see the examples directory for how you might use third-party libraries to do zipping (or other serialization).
4-
3. Removal of fetching. It is impossible to account for all the protocols possible with fetching. Please see the examples directory for how you might use third-party libraries to do fetching.
2+
1. Complete rewrite using Java 8 and modern Java best practices
3+
2. Bagging directly into a ZIP file is no longer a core feature. The examples
4+
directory shows how to support the serialization format and options of
5+
your choice.
6+
3. Integrated support for `fetch.txt` has been removed as a core feature. The
7+
examples directory includes an implementation using the standard library
8+
which can serve as a reference for the more advanced implementations which
9+
most users will require.
510
3. Allow for ignoring hidden files except if specified in manifest.
6-
4. Bagit now uses Java version 8 syntax, thus the minimum requirement for building and running is Java 8
711

812
#### Changes in 4.10.0
913
1. Fixes defect in SimpleResult.add*Message() methods.
@@ -28,15 +32,15 @@
2832

2933
#### Changes in 4.7
3034
1. Handle NPE when encountering improperly formatted bag-info.txt.
31-
2. Added progress reports to bag fetch.
35+
2. Added progress reports to bag fetch.
3236

3337
#### Changes in 4.6
34-
1. Added tag file fetch-progress.txt to support progressive fetch and verification. The file
38+
1. Added tag file fetch-progress.txt to support progressive fetch and verification. The file
3539
will be removed once the bag is successfully fetched. In BagFetcher, added verification
36-
of a fetched file against the checksum in the manifest file. Added switch verify to fill
37-
holey bag and fetch remote bag command-line operations. This option enables bag verification
40+
of a fetched file against the checksum in the manifest file. Added switch verify to fill
41+
holey bag and fetch remote bag command-line operations. This option enables bag verification
3842
before the fetch is resumed.
39-
43+
4044
#### Changes in 4.5.1
4145
1. Added missing braces to conditional blocks in ValidHoleyBagVerifier. This caused false
4246
error message when verifying a holey bag.
@@ -46,7 +50,7 @@
4650

4751
#### Changes in 4.4
4852
1. Attempt to correct for unicode normalization form in filepaths. Note: Java has
49-
problems dealing with differences in unicode normalization form
53+
problems dealing with differences in unicode normalization form
5054
(http://www.unicode.org/reports/tr15/tr15-23.html) in filepaths.
5155
In particular, it is sometimes the case that a java.io.File is that produced
5256
by java.io.File.listFiles() will fail java.io.File.exists(). This attempts to
@@ -57,7 +61,7 @@
5761
is now to copy (instead of writing the stream exposed by BagFile). Added support
5862
for specifying move in CommandLineBagDriver (--move).
5963
4. Added setUsername()/setPassword() interfaces to all bag fetchers to support
60-
concurrent clients; each client's credentials will be local to each instance of bag fetcher.
64+
concurrent clients; each client's credentials will be local to each instance of bag fetcher.
6165

6266
#### Changes in 4.3.1
6367
1. Changes to pom for maven 3.
@@ -87,7 +91,7 @@
8791
2. Removes Commons VFS.
8892
3. Deprecates support for reading/writing tar, tar bz2, and tar gz.
8993
4. Deprecates support for transferring SWORD and BOB.
90-
5. Added close() method to Bag for closing IO resources.
94+
5. Added close() method to Bag for closing IO resources.
9195
6. Clarified logging messages for CompleteVerifier and ValidVerifier.
9296
7. Changed so that bagging-in-place throws an exception if a prebag contains a data directory and tag directories
9397
for pre-0.97 bags.
@@ -164,7 +168,7 @@
164168
3. Changed socket timeout from infinity to 20 seconds for http fetches.
165169
4. Made adding data to payload progress monitorable and cancellable (AddFilesToPayloadOperation)
166170
5. Made whitespace used in creating manifests configurable.
167-
6. Smarter handling of relative paths in manifests.
171+
6. Smarter handling of relative paths in manifests.
168172

169173
#### Changes in 3.2
170174
1. Fixed handling of bag-info.txt with colons in the value.
@@ -218,4 +222,4 @@
218222
3. Made bag-info.txt labels case-insensitive.
219223
4. Added additional bag-info.txt methods for Bagging-Date, Bag-Count, Bag-Size, and Payload-Oxum.
220224
5. Changed to only include the tar-related classes from Ant, rather than the entire dependency.
221-
6. Added version-aware handling of filepath delimiters.
225+
6. Added version-aware handling of filepath delimiters.

README.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[//]: # (see https://github.com/moznion/javadocio-badges for automatic javadoc)
1111

1212
## Description
13-
The BAGIT LIBRARY is a software library intended to support the creation,
13+
The BAGIT LIBRARY is a software library intended to support the creation,
1414
manipulation, and validation of bags. Its current version is 0.97. It is version aware with the earliest
1515
supported version being 0.93.
1616

@@ -25,49 +25,73 @@ supported version being 0.93.
2525
4. If you would like to contribute, please submit a [pull request](https://help.github.com/articles/creating-a-pull-request/)
2626

2727
## Major differences between version 5 and 4.*
28-
##### Commandline
29-
The 4.x versions of the bagit command line are still available for [download](https://github.com/LibraryOfCongress/bagit-java/releases/download/v4.12.1/bagit-4.12.1.zip). However, starting with the 5.x versions we will not longer be creating a java command line application. If you would like to use a currently supported command line application please see our [bagit-python implementation](https://github.com/LibraryOfCongress/bagit-python)
28+
##### Command Line Interface
29+
30+
The 5.x versions do not include a command-line interface.
31+
Users who need a command-line utility can continue to use the latest 4.x release
32+
([download 4.12.1](https://github.com/LibraryOfCongress/bagit-java/releases/download/v4.12.1/bagit-4.12.1.zip)
33+
or switch to an alternative implementation such as
34+
[bagit-python](https://github.com/LibraryOfCongress/bagit-python) or
35+
[BagIt for Ruby](https://github.com/tipr/bagit).
3036

3137
##### Serialization
32-
Starting with the 5.x versions we no longer support directly serializing a bag. Check out the [zip](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/serialization/CreateZipBagExample.java) or [tar](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/serialization/CreateTarBagExample.java) examples for implementing it yourself.
38+
Starting with the 5.x versions bagit-java no longer supports directly
39+
serializing a bag to an archive file. The examples show how to implement a
40+
custom serializer for the
41+
[zip](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/serialization/CreateZipBagExample.java)
42+
and
43+
[tar](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/serialization/CreateTarBagExample.java)
44+
formats.
3345

3446
##### Fetching
35-
Starting with the 5.x versions we no longer support fetching. Check out the [standard java library](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/fetching/FetchHttpFileExample.java) example as one way you could implement it yourself.
47+
The 5.x versions do not include a core `fetch.txt` implementation. If you need
48+
this functionality, the
49+
[`FetchHttpFileExample` example](https://github.com/LibraryOfCongress/bagit-java/blob/master/src/test/java/gov/loc/repository/bagit/examples/fetching/FetchHttpFileExample.java)
50+
demonstrates how you can implement this feature with your additional application
51+
and workflow requirements.
3652

3753
##### New Interfaces
38-
The 5.x version is a complete rewrite of the bagit-java library. Because we were rewriting it, we decided it would be a good time to update the interface to be more intuitive. As such, there are some breaking changes and code will need to be migrated.
54+
55+
The 5.x version is a complete rewrite of the bagit-java library which attempts
56+
to follow modern Java practices and will require some changes to existing code:
3957

4058
### Examples of using the new bagit-java library
59+
4160
##### Create a bag from a folder using version 0.97
4261
```java
4362
Path folder = Paths.get("FolderYouWantToBag");
4463
StandardSupportedAlgorithms algorithm = StandardSupportedAlgorithms.MD5;
4564
boolean includeHiddenFiles = false;
4665
Bag bag = BagCreator.bagInPlace(folder, algorithm, includeHiddenFiles);
4766
```
67+
4868
##### Read an existing bag (version 0.93 and higher)
4969
```java
5070
Path rootDir = Paths.get("RootDirectoryOfExistingBag");
5171
BagReader reader = new BagReader();
5272
Bag bag = reader.read(rootDir);
5373
```
74+
5475
##### Write a Bag object to disk
5576
```java
5677
Path outputDir = Paths.get("WhereYouWantToWriteTheBagTo");
5778
BagWriter.write(bag, outputDir); //where bag is a Bag object
5879
```
80+
5981
##### Verify Complete
6082
```java
6183
boolean ignoreHiddenFiles = true;
6284
BagVerifier verifier = new BagVerifier();
6385
verifier.isComplete(bag, ignoreHiddenFiles);
6486
```
87+
6588
##### Verify Valid
6689
```java
6790
boolean ignoreHiddenFiles = true;
6891
BagVerifier verifier = new BagVerifier();
6992
verifier.isValid(bag, ignoreHiddenFiles);
7093
```
94+
7195
##### Quickly verify by payload-oxum
7296
```java
7397
boolean ignoreHiddenFiles = true;
@@ -77,8 +101,11 @@ if(verifier.canQuickVerify(bag)){
77101
verifier.quicklyVerify(bag, ignoreHiddenFiles);
78102
}
79103
```
104+
80105
##### Add other checksum algorithms
81-
You only need to implement 2 interfaces
106+
107+
You only need to implement 2 interfaces:
108+
82109
```java
83110
public class MyNewSupportedAlgorithm implements SupportedAlgorithm {
84111
@Override
@@ -97,22 +124,30 @@ public class MyNewNameMapping implements BagitAlgorithmNameToSupportedAlgorithmM
97124
if("sha3256".equals(bagitAlgorithmName)){
98125
return new MyNewSupportedAlgorithm();
99126
}
100-
127+
101128
return StandardSupportedAlgorithms.valueOf(bagitAlgorithmName.toUpperCase());
102129
}
103130
}
104131
```
105-
and then add the implemented BagitAlgorithmNameToSupportedAlgorithmMapping class to your BagReader or bagVerifier object before using their methods
132+
133+
and then add the implemented `BagitAlgorithmNameToSupportedAlgorithmMapping`
134+
class to your `BagReader` or `bagVerifier` object before using their methods.
106135

107136
#### Check for potential problems
108-
The BagIt format is extremely flexible, and allows for many different implementations. While something may technically be correct there are known issues that can be avoided. That is why we created a Bag Linter, which checks for very well known issues that can occur. Here is an example where we check for all known issues:
137+
138+
The BagIt format is extremely flexible and allows for some conditions which are
139+
technically allowed but should be avoided to minimize confusion and maximize
140+
portability. The `BagLinter` class allows you to easily check a bag for
141+
warnings:
142+
109143
```java
110144
Path rootDir = Paths.get("RootDirectoryOfExistingBag");
111145
BagLinter linter = new BagLinter();
112146
List<BagitWarning> warnings = linter.lintBag(rootDir, Collections.emptyList());
113147
```
114148

115-
You can also ignore any of the warnings by passing them into the list like so:
149+
You can provide a list of specific warnings to ignore:
150+
116151
```java
117152
dependencycheckth rootDir = Paths.get("RootDirectoryOfExistingBag");
118153
BagLinter linter = new BagLinter();
@@ -127,8 +162,8 @@ Inside the bagit-java root directory, run `gradle check`.
127162
1. Follow their guides
128163
1. http://central.sonatype.org/pages/releasing-the-deployment.html
129164
2. https://issues.sonatype.org/secure/Dashboard.jspa
130-
2. Once you have access, to create an office release and upload it you should specify the version by running `gradle -Pversion=<VERSION> uploadArchives`
131-
1. *Don't forget to tag the repository!*
165+
2. Once you have access, to create an office release and upload it you should specify the version by running `gradle -Pversion=<VERSION> uploadArchives`
166+
1. *Don't forget to tag the repository!*
132167
133168
### Note if using with Eclipse
134169
Simply run `gradle eclipse` and it will automatically create a eclipse project for you that you can import.

0 commit comments

Comments
 (0)