Skip to content

Commit

Permalink
fix omit prefix layout bug when delimiter has multiple characters and…
Browse files Browse the repository at this point in the history
… is not found
  • Loading branch information
pwinckles committed Oct 12, 2021
1 parent 3c42ee8 commit b24159a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ public String mapObjectId(String objectId) {

// Use lowercase of delimiter and objectId, per specification
String id = objectId.toLowerCase();

int index = id.lastIndexOf(delim);
String dir = objectId.substring(index + delim.length());
String dir = objectId;

if (index > -1) {
dir = objectId.substring(index + delim.length());
}

if (OcflConstants.EXTENSIONS_DIR.equals(dir) || dir.isEmpty()) {
throw new OcflExtensionException(String.format("The object id <%s> is incompatible with layout extension " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.wisc.library.ocfl.core.extension.storage.layout.impl;
package edu.wisc.library.ocfl.core.extension.storage.layout;

import edu.wisc.library.ocfl.api.exception.OcflExtensionException;
import edu.wisc.library.ocfl.core.extension.storage.layout.FlatLayoutExtension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,13 @@ public void testTwoOccurrencesOfMultiCharDelimiter() {
assertEquals("f8.05v", result);
}

@Test
public void multiCharacterDelemiterNotFound() {
config.setDelimiter("edu/");
ext.init(config);

String result = ext.mapObjectId("https://institution.gov/abc/f8.05v");
assertEquals("https://institution.gov/abc/f8.05v", result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package edu.wisc.library.ocfl.core.extension.storage.layout.impl;
package edu.wisc.library.ocfl.core.extension.storage.layout;

import edu.wisc.library.ocfl.api.exception.OcflExtensionException;
import edu.wisc.library.ocfl.api.model.DigestAlgorithm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package edu.wisc.library.ocfl.core.extension.storage.layout.impl;
package edu.wisc.library.ocfl.core.extension.storage.layout;

import edu.wisc.library.ocfl.api.exception.OcflExtensionException;
import edu.wisc.library.ocfl.api.model.DigestAlgorithm;
Expand Down

0 comments on commit b24159a

Please sign in to comment.