From f3485e6d45bb2c41764a755316410f2bb219f4fa Mon Sep 17 00:00:00 2001 From: "Kevin S. Clarke" Date: Tue, 27 Apr 2021 12:31:37 -0400 Subject: [PATCH 1/2] Expand A/V server template options This provides a way to create a generic A/V server URL that another process (in our case, Fester) can append information onto. This provides a way for Fester to create a choice of video streams, rather than hardcode just one stream (mpd, for instance). --- .../edu/ucla/library/avpairtree/Config.java | 6 ++ .../avpairtree/verticles/WatcherVerticle.java | 88 +++++++++++++++++-- src/main/resources/av-pairtree_messages.xml | 2 + .../verticles/WatcherVerticleTest.java | 4 +- src/test/resources/test-config.properties | 7 +- 5 files changed, 96 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/ucla/library/avpairtree/Config.java b/src/main/java/edu/ucla/library/avpairtree/Config.java index 7504fbe..c77caa6 100644 --- a/src/main/java/edu/ucla/library/avpairtree/Config.java +++ b/src/main/java/edu/ucla/library/avpairtree/Config.java @@ -66,6 +66,12 @@ public final class Config { */ public static final String ACCESS_URL_PATTERN = "iiif.access.url"; + /** + * The configuration property for which substitution pattern in iiif.access.url should be the ID; this is 1-based, + * not zero-based. + */ + public static final String ACCESS_URL_ID_INDEX = "iiif.access.url.id.index"; + /** * The number of workers that should work to do media file conversions. */ diff --git a/src/main/java/edu/ucla/library/avpairtree/verticles/WatcherVerticle.java b/src/main/java/edu/ucla/library/avpairtree/verticles/WatcherVerticle.java index 0469cf6..0ee077d 100644 --- a/src/main/java/edu/ucla/library/avpairtree/verticles/WatcherVerticle.java +++ b/src/main/java/edu/ucla/library/avpairtree/verticles/WatcherVerticle.java @@ -9,6 +9,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.csveed.api.CsvClient; import org.csveed.api.CsvClientImpl; @@ -45,6 +47,8 @@ public class WatcherVerticle extends AbstractVerticle { private static final Logger LOGGER = LoggerFactory.getLogger(WatcherVerticle.class, MessageCodes.BUNDLE); + private static final String SUBSTITUTION_PATTERN = "{}"; + @Override public void start(final Promise aPromise) { final DeliveryOptions options = new DeliveryOptions().setSendTimeout(Integer.MAX_VALUE); @@ -152,7 +156,7 @@ private Future updateCSV(final String aCsvFilePath, final Map updateCSV(final String aCsvFilePath, final Map{}) + * @return The number of substitution patterns in the supplied string + */ + private int countSubstitutionPatterns(final String aString) { + final Pattern pattern = Pattern.compile(SUBSTITUTION_PATTERN, Pattern.LITERAL); + final Matcher matcher = pattern.matcher(aString); + + int startIndex = 0; + int count = 0; + + while (matcher.find(startIndex)) { + startIndex = matcher.start() + 1; + count += 1; + } + + return count; + } } diff --git a/src/main/resources/av-pairtree_messages.xml b/src/main/resources/av-pairtree_messages.xml index 9e39f8a..5421b58 100644 --- a/src/main/resources/av-pairtree_messages.xml +++ b/src/main/resources/av-pairtree_messages.xml @@ -17,5 +17,7 @@ IIIF access URL created for '{}': {} {} worker starting in: {} {} worker pool size set to '{}' workers + Index for IIIF access URL doesn't correspond to number of substitution patterns: {} + IIIF access URL pattern doesn't contain a supported number of substitution patterns diff --git a/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java b/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java index 4cdb345..7e384d8 100644 --- a/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java +++ b/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java @@ -136,7 +136,7 @@ private Future checkOutput(final String aFileName, final int aLatchCount, final AtomicInteger counter = new AtomicInteger(0); reader.lines().forEach(line -> { - if (line.contains(avServer)) { + if (line.contains(avServer) && line.contains(".mp4{}")) { counter.incrementAndGet(); } }); @@ -147,7 +147,7 @@ private Future checkOutput(final String aFileName, final int aLatchCount, promise.fail(details); } - // Delete the test artifact after we've checked it to determine success + // final Delete the test final artifact after we've checked it to determine success myContext.vertx().fileSystem().delete(aFileName).onComplete(deletion -> { if (deletion.succeeded()) { promise.complete(); diff --git a/src/test/resources/test-config.properties b/src/test/resources/test-config.properties index 15a7d62..b8fbd39 100644 --- a/src/test/resources/test-config.properties +++ b/src/test/resources/test-config.properties @@ -20,8 +20,11 @@ audio.codec = aac audio.bit.rate = 320000 audio.channels = 2 -# The URL pattern for our streaming A/V server -iiif.access.url = https://wowza.library.ucla.edu/iiif_av_public/definst/mp4:{}/manifest.mpd +# The URL pattern for our streaming A/V server; it can have up to three substitution patterns (i.e., "{}") +iiif.access.url = https://wowza.library.ucla.edu/iiif_av_public/definst/mp4:{}{} + +# The 1-based position of the substitution pattern to use for the Pairtree path +iiif.access.url.id.index = 1 # The number of threads working on media file conversions conversion.workers = 2 From 0b8d2ac18bc9d9b07176e128a03887a237e76f5b Mon Sep 17 00:00:00 2001 From: "Kevin S. Clarke" Date: Wed, 28 Apr 2021 13:33:02 -0400 Subject: [PATCH 2/2] Fix typos --- .../ucla/library/avpairtree/verticles/WatcherVerticleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java b/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java index 7e384d8..0e82051 100644 --- a/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java +++ b/src/test/java/edu/ucla/library/avpairtree/verticles/WatcherVerticleTest.java @@ -147,7 +147,7 @@ private Future checkOutput(final String aFileName, final int aLatchCount, promise.fail(details); } - // final Delete the test final artifact after we've checked it to determine success + // Delete the test artifact after we've checked it to determine success myContext.vertx().fileSystem().delete(aFileName).onComplete(deletion -> { if (deletion.succeeded()) { promise.complete();