Skip to content

Commit

Permalink
add local streamingUrl property and setters
Browse files Browse the repository at this point in the history
  • Loading branch information
krwong committed May 9, 2024
1 parent 108e000 commit c1c385b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class SipService {
private MigrationProject project;
private ChompbConfigService.ChompbConfig chompbConfig;
private PermissionsService permissionsService;
private StreamingMetadataService streamingMetadataService;
private PIDMinter pidMinter;
private CdmToDestMapper cdmToDestMapper = new CdmToDestMapper();
private WorkGeneratorFactory workGeneratorFactory;
Expand Down Expand Up @@ -104,6 +105,7 @@ private void initDependencies(SipGenerationOptions options, Connection conn) thr
workGeneratorFactory.setPostMigrationReportService(postMigrationReportService);
workGeneratorFactory.setAggregateTopMappingService(aggregateTopMappingService);
workGeneratorFactory.setAggregateBottomMappingService(aggregateBottomMappingService);
workGeneratorFactory.setStreamingMetadataService(streamingMetadataService);
try {
workGeneratorFactory.setPermissionsInfo(permissionsService.loadMappings(project));
} catch (NoSuchFileException e) {
Expand Down Expand Up @@ -378,6 +380,10 @@ public void setPermissionsService(PermissionsService permissionsService) {
this.permissionsService = permissionsService;
}

public void setStreamingMetadataService(StreamingMetadataService streamingMetadataService) {
this.streamingMetadataService = streamingMetadataService;
}

public void setPidMinter(PIDMinter pidMinter) {
this.pidMinter = pidMinter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static edu.unc.lib.boxc.auth.api.AccessPrincipalConstants.PUBLIC_PRINC;
import static edu.unc.lib.boxc.migration.cdm.util.CLIConstants.outputLogger;
import static edu.unc.lib.boxc.model.api.DatastreamType.ORIGINAL_FILE;
import static org.apache.jena.rdf.model.ResourceFactory.createProperty;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand All @@ -46,6 +47,9 @@
*/
public class WorkGenerator {
private static final Logger log = getLogger(WorkGenerator.class);
// use local streamingUrl property for now because Cdr.streamingUrl only exists in a feature branch
public static final Property streamingUrl = createProperty(
"http://cdr.unc.edu/definitions/model#streamingUrl");
protected PIDMinter pidMinter;
protected RedirectMappingService redirectMappingService;
protected SourceFilesInfo sourceFilesInfo;
Expand Down Expand Up @@ -242,7 +246,7 @@ protected void addStreamingMetadata(String cdmId, Resource resource) {
String streamingFile = streamingMetadata[0];
String streamingUrlValue = "https://durastream.lib.unc.edu/player?spaceId=" + duracloudSpace
+ "&filename=" + streamingFile;
resource.addProperty(Cdr.streamingUrl, streamingUrlValue);
resource.addProperty(streamingUrl, streamingUrlValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import edu.unc.lib.boxc.migration.cdm.services.DescriptionsService;
import edu.unc.lib.boxc.migration.cdm.services.PostMigrationReportService;
import edu.unc.lib.boxc.migration.cdm.services.RedirectMappingService;
import edu.unc.lib.boxc.migration.cdm.services.StreamingMetadataService;
import edu.unc.lib.boxc.model.api.ids.PIDMinter;

import java.io.IOException;
Expand All @@ -34,6 +35,7 @@ public class WorkGeneratorFactory {
private AggregateFileMappingService aggregateBottomMappingService;
private PIDMinter pidMinter;
private PermissionsInfo permissionsInfo;
private StreamingMetadataService streamingMetadataService;

public WorkGenerator create(String cdmId, String cdmCreated, String entryType) throws IOException {
WorkGenerator gen;
Expand All @@ -58,6 +60,7 @@ public WorkGenerator create(String cdmId, String cdmCreated, String entryType) t
gen.redirectMappingService = redirectMappingService;
gen.postMigrationReportService = postMigrationReportService;
gen.permissionsInfo = permissionsInfo;
gen.streamingMetadataService = streamingMetadataService;
return gen;
}

Expand Down Expand Up @@ -116,4 +119,8 @@ public void setAggregateBottomMappingService(AggregateFileMappingService aggrega
public void setPermissionsInfo(PermissionsInfo permissionsInfo) {
this.permissionsInfo = permissionsInfo;
}

public void setStreamingMetadataService(StreamingMetadataService streamingMetadataService) {
this.streamingMetadataService = streamingMetadataService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

import static edu.unc.lib.boxc.auth.api.AccessPrincipalConstants.AUTHENTICATED_PRINC;
import static edu.unc.lib.boxc.auth.api.AccessPrincipalConstants.PUBLIC_PRINC;
import static edu.unc.lib.boxc.migration.cdm.services.sips.WorkGenerator.streamingUrl;
import static edu.unc.lib.boxc.migration.cdm.test.PostMigrationReportTestHelper.assertContainsRow;
import static java.nio.file.StandardOpenOption.APPEND;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -1397,15 +1398,15 @@ public void generateSipsWithStreamingUrl() throws Exception {

Resource workResc1 = testHelper.getResourceByCreateTime(depBagChildren, "2005-11-23");
testHelper.assertObjectPopulatedInSip(workResc1, dirManager, model, stagingLocs.get(0), null, "25");
assertFalse(workResc1.hasProperty(Cdr.streamingUrl, "https://durastream.lib.unc.edu/player?" +
assertFalse(workResc1.hasProperty(streamingUrl, "https://durastream.lib.unc.edu/player?" +
"spaceId=open-hls&filename=gilmer_recording-playlist.m3u8"));
Resource workResc2 = testHelper.getResourceByCreateTime(depBagChildren, "2005-11-24");
testHelper.assertObjectPopulatedInSip(workResc2, dirManager, model, stagingLocs.get(1), null, "26");
assertFalse(workResc2.hasProperty(Cdr.streamingUrl, "https://durastream.lib.unc.edu/player?" +
assertFalse(workResc2.hasProperty(streamingUrl, "https://durastream.lib.unc.edu/player?" +
"spaceId=open-hls&filename=gilmer_recording-playlist.m3u8"));
Resource workResc3 = testHelper.getResourceByCreateTime(depBagChildren, "2005-12-08");
testHelper.assertObjectPopulatedInSip(workResc3, dirManager, model, stagingLocs.get(2), null, "27");
assertTrue(workResc3.hasProperty(Cdr.streamingUrl, "https://durastream.lib.unc.edu/player?" +
assertTrue(workResc3.hasProperty(streamingUrl, "https://durastream.lib.unc.edu/player?" +
"spaceId=open-hls&filename=gilmer_recording-playlist.m3u8"));

assertPersistedSipInfoMatches(sip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import edu.unc.lib.boxc.migration.cdm.services.ChompbConfigService;
import edu.unc.lib.boxc.migration.cdm.services.GroupMappingService;
import edu.unc.lib.boxc.migration.cdm.services.PermissionsService;
import edu.unc.lib.boxc.migration.cdm.services.StreamingMetadataService;
import org.apache.commons.io.FileUtils;
import org.apache.jena.rdf.model.Bag;
import org.apache.jena.rdf.model.Model;
Expand Down Expand Up @@ -91,6 +92,7 @@ public class SipServiceHelper {
private CdmIndexService indexService;
private GroupMappingService groupMappingService;
private PermissionsService permissionsService;
private StreamingMetadataService streamingMetadataService;
private PIDMinter pidMinter;
private PremisLoggerFactoryImpl premisLoggerFactory;
private ChompbConfigService.ChompbConfig chompbConfig;
Expand Down Expand Up @@ -125,6 +127,10 @@ public SipServiceHelper(MigrationProject project, Path filesBasePath) throws IOE
archivalDestinationsService.setDestinationsService(destinationsService);
permissionsService = new PermissionsService();
permissionsService.setProject(project);
streamingMetadataService = new StreamingMetadataService();
streamingMetadataService.setProject(project);
streamingMetadataService.setFieldService(fieldService);
streamingMetadataService.setIndexService(indexService);

Files.createDirectories(project.getExportPath());
}
Expand All @@ -142,6 +148,7 @@ public SipService createSipsService() {
service.setAggregateTopMappingService(getAggregateFileMappingService());
service.setAggregateBottomMappingService(getAggregateBottomMappingService());
service.setPermissionsService(permissionsService);
service.setStreamingMetadataService(streamingMetadataService);
return service;
}

Expand Down

0 comments on commit c1c385b

Please sign in to comment.