use of org.opencastproject.mediapackage.MediaPackageException in project opencast by opencast.
the class PublishOaiPmhWorkflowOperationHandler method start.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance,
* JobContext)
*/
@Override
public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException {
logger.debug("Running distribution workflow operation");
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
// Check which tags have been configured
String downloadTags = StringUtils.trimToEmpty(workflowInstance.getCurrentOperation().getConfiguration(DOWNLOAD_TAGS));
String downloadFlavors = StringUtils.trimToEmpty(workflowInstance.getCurrentOperation().getConfiguration(DOWNLOAD_FLAVORS));
String streamingTags = StringUtils.trimToEmpty(workflowInstance.getCurrentOperation().getConfiguration(STREAMING_TAGS));
String streamingFlavors = StringUtils.trimToEmpty(workflowInstance.getCurrentOperation().getConfiguration(STREAMING_FLAVORS));
boolean checkAvailability = option(workflowInstance.getCurrentOperation().getConfiguration(CHECK_AVAILABILITY)).bind(trimToNone).map(toBool).getOrElse(true);
String repository = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration(REPOSITORY));
Opt<String> externalChannel = getOptConfig(workflowInstance.getCurrentOperation(), EXTERNAL_CHANNEL_NAME);
Opt<String> externalTempalte = getOptConfig(workflowInstance.getCurrentOperation(), EXTERNAL_TEMPLATE);
Opt<MimeType> externalMimetype = getOptConfig(workflowInstance.getCurrentOperation(), EXTERNAL_MIME_TYPE).bind(MimeTypes.toMimeType);
if (repository == null)
throw new IllegalArgumentException("No repository has been specified");
String[] sourceDownloadTags = StringUtils.split(downloadTags, ",");
String[] sourceDownloadFlavors = StringUtils.split(downloadFlavors, ",");
String[] sourceStreamingTags = StringUtils.split(streamingTags, ",");
String[] sourceStreamingFlavors = StringUtils.split(streamingFlavors, ",");
if (sourceDownloadTags.length == 0 && sourceDownloadFlavors.length == 0 && sourceStreamingTags.length == 0 && sourceStreamingFlavors.length == 0) {
logger.warn("No tags or flavors have been specified, so nothing will be published to the engage");
return createResult(mediaPackage, Action.CONTINUE);
}
final SimpleElementSelector downloadElementSelector = new SimpleElementSelector();
for (String flavor : sourceDownloadFlavors) {
downloadElementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor));
}
for (String tag : sourceDownloadTags) {
downloadElementSelector.addTag(tag);
}
final Collection<MediaPackageElement> downloadElements = downloadElementSelector.select(mediaPackage, false);
final Collection<MediaPackageElement> streamingElements;
if (distributeStreaming) {
final SimpleElementSelector streamingElementSelector = new SimpleElementSelector();
for (String flavor : sourceStreamingFlavors) {
streamingElementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor));
}
for (String tag : sourceStreamingTags) {
streamingElementSelector.addTag(tag);
}
streamingElements = streamingElementSelector.select(mediaPackage, false);
} else {
streamingElements = list();
}
try {
Set<String> downloadElementIds = new HashSet<>();
Set<String> streamingElementIds = new HashSet<>();
// Look for elements matching the tag
for (MediaPackageElement elem : downloadElements) {
downloadElementIds.add(elem.getIdentifier());
}
for (MediaPackageElement elem : streamingElements) {
streamingElementIds.add(elem.getIdentifier());
}
// Also distribute the security configuration
// -----
// This was removed in the meantime by a fix for MH-8515, but could now be used again.
// -----
Attachment[] securityAttachments = mediaPackage.getAttachments(MediaPackageElements.XACML_POLICY);
if (securityAttachments != null && securityAttachments.length > 0) {
for (Attachment a : securityAttachments) {
downloadElementIds.add(a.getIdentifier());
streamingElementIds.add(a.getIdentifier());
}
}
Job publishJob = null;
try {
publishJob = publicationService.publish(mediaPackage, repository, downloadElementIds, streamingElementIds, checkAvailability);
} catch (MediaPackageException e) {
throw new WorkflowOperationException("Error parsing media package", e);
} catch (PublicationException e) {
throw new WorkflowOperationException("Error parsing media package", e);
}
// Wait until the publication job has returned
if (!waitForStatus(publishJob).isSuccess())
throw new WorkflowOperationException("Mediapackage " + mediaPackage.getIdentifier() + " could not be published to OAI-PMH repository " + repository);
// The job has passed
Job job = serviceRegistry.getJob(publishJob.getId());
// If there is no payload, then the item has not been published.
if (job.getPayload() == null) {
logger.warn("Publish to OAI-PMH repository '{}' failed, no payload from publication job: {}", repository, job);
return createResult(mediaPackage, Action.CONTINUE);
}
Publication newElement = null;
try {
newElement = (Publication) MediaPackageElementParser.getFromXml(job.getPayload());
} catch (MediaPackageException e) {
throw new WorkflowOperationException(e);
}
if (newElement == null) {
logger.warn("Publication to OAI-PMH repository '{}' failed, unable to parse the payload '{}' from job '{}' to a mediapackage element", repository, job.getPayload(), job.toString());
return createResult(mediaPackage, Action.CONTINUE);
}
for (Publication existingPublication : $(mediaPackage.getPublications()).find(ofChannel(newElement.getChannel()).toFn())) {
mediaPackage.remove(existingPublication);
}
mediaPackage.add(newElement);
if (externalChannel.isSome() && externalMimetype.isSome() && externalTempalte.isSome()) {
String template = externalTempalte.get().replace("{event}", mediaPackage.getIdentifier().compact());
if (StringUtils.isNotBlank(mediaPackage.getSeries()))
template = template.replace("{series}", mediaPackage.getSeries());
Publication externalElement = PublicationImpl.publication(UUID.randomUUID().toString(), externalChannel.get(), URI.create(template), externalMimetype.get());
for (Publication existingPublication : $(mediaPackage.getPublications()).find(ofChannel(externalChannel.get()).toFn())) {
mediaPackage.remove(existingPublication);
}
mediaPackage.add(externalElement);
}
logger.debug("Publication to OAI-PMH repository '{}' operation completed", repository);
} catch (Exception e) {
if (e instanceof WorkflowOperationException) {
throw (WorkflowOperationException) e;
} else {
throw new WorkflowOperationException(e);
}
}
return createResult(mediaPackage, Action.CONTINUE);
}
use of org.opencastproject.mediapackage.MediaPackageException in project opencast by opencast.
the class PublishEngageWorkflowOperationHandler method getMediaPackageForSearchIndex.
/**
* Returns a mediapackage that only contains elements that are marked for distribution.
*
* @param current
* the current mediapackage
* @param jobs
* the distribution jobs
* @param downloadSubflavor
* flavor to be applied to elements distributed to download
* @param downloadTargetTags
* tags to be applied to elements distributed to downloads
* @param downloadElementIds
* identifiers for elements that have been distributed to downloads
* @param streamingSubflavor
* flavor to be applied to elements distributed to streaming
* @param streamingElementIds
* identifiers for elements that have been distributed to streaming
* @param streamingTargetTags
* tags to be applied to elements distributed to streaming
* @return the new mediapackage
*/
protected MediaPackage getMediaPackageForSearchIndex(MediaPackage current, List<Job> jobs, MediaPackageElementFlavor downloadSubflavor, String[] downloadTargetTags, Set<String> downloadElementIds, MediaPackageElementFlavor streamingSubflavor, Set<String> streamingElementIds, String[] streamingTargetTags) throws MediaPackageException, NotFoundException, ServiceRegistryException, WorkflowOperationException {
MediaPackage mp = (MediaPackage) current.clone();
// All the jobs have passed, let's update the mediapackage with references to the distributed elements
List<String> elementsToPublish = new ArrayList<String>();
Map<String, String> distributedElementIds = new HashMap<String, String>();
for (Job entry : jobs) {
Job job = serviceRegistry.getJob(entry.getId());
// If there is no payload, then the item has not been distributed.
if (job.getPayload() == null)
continue;
List<MediaPackageElement> distributedElements = null;
try {
distributedElements = (List<MediaPackageElement>) MediaPackageElementParser.getArrayFromXml(job.getPayload());
} catch (MediaPackageException e) {
throw new WorkflowOperationException(e);
}
// kind of element. So we just keep on looping.
if (distributedElements == null || distributedElements.size() < 1)
continue;
for (MediaPackageElement distributedElement : distributedElements) {
String sourceElementId = distributedElement.getIdentifier();
if (sourceElementId != null) {
MediaPackageElement sourceElement = mp.getElementById(sourceElementId);
// Make sure the mediapackage is prompted to create a new identifier for this element
distributedElement.setIdentifier(null);
if (sourceElement != null) {
// Adjust the flavor and tags for downloadable elements
if (downloadElementIds.contains(sourceElementId)) {
if (downloadSubflavor != null) {
MediaPackageElementFlavor flavor = sourceElement.getFlavor();
if (flavor != null) {
MediaPackageElementFlavor newFlavor = new MediaPackageElementFlavor(flavor.getType(), downloadSubflavor.getSubtype());
distributedElement.setFlavor(newFlavor);
}
}
} else // Adjust the flavor and tags for streaming elements
if (streamingElementIds.contains(sourceElementId)) {
if (streamingSubflavor != null && streamingElementIds.contains(sourceElementId)) {
MediaPackageElementFlavor flavor = sourceElement.getFlavor();
if (flavor != null) {
MediaPackageElementFlavor newFlavor = new MediaPackageElementFlavor(flavor.getType(), streamingSubflavor.getSubtype());
distributedElement.setFlavor(newFlavor);
}
}
}
// Copy references from the source elements to the distributed elements
MediaPackageReference ref = sourceElement.getReference();
if (ref != null && mp.getElementByReference(ref) != null) {
MediaPackageReference newReference = (MediaPackageReference) ref.clone();
distributedElement.setReference(newReference);
}
}
}
if (isStreamingFormat(distributedElement))
applyTags(distributedElement, streamingTargetTags);
else
applyTags(distributedElement, downloadTargetTags);
// Add the new element to the mediapackage
mp.add(distributedElement);
elementsToPublish.add(distributedElement.getIdentifier());
distributedElementIds.put(sourceElementId, distributedElement.getIdentifier());
}
}
// Mark everything that is set for removal
List<MediaPackageElement> removals = new ArrayList<MediaPackageElement>();
for (MediaPackageElement element : mp.getElements()) {
if (!elementsToPublish.contains(element.getIdentifier())) {
removals.add(element);
}
}
// Translate references to the distributed artifacts
for (MediaPackageElement element : mp.getElements()) {
if (removals.contains(element))
continue;
// Is the element referencing anything?
MediaPackageReference reference = element.getReference();
if (reference == null)
continue;
// See if the element has been distributed
String distributedElementId = distributedElementIds.get(reference.getIdentifier());
if (distributedElementId == null)
continue;
MediaPackageReference translatedReference = new MediaPackageReferenceImpl(mp.getElementById(distributedElementId));
if (reference.getProperties() != null) {
translatedReference.getProperties().putAll(reference.getProperties());
}
// Set the new reference
element.setReference(translatedReference);
}
// Remove everything we don't want to add to publish
for (MediaPackageElement element : removals) {
mp.remove(element);
}
return mp;
}
use of org.opencastproject.mediapackage.MediaPackageException in project opencast by opencast.
the class PublishEngageWorkflowOperationHandler method start.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance,
* JobContext)
*/
@Override
public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException {
logger.debug("Running engage publication workflow operation");
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
WorkflowOperationInstance op = workflowInstance.getCurrentOperation();
// Check which tags have been configured
String downloadSourceTags = StringUtils.trimToEmpty(op.getConfiguration(DOWNLOAD_SOURCE_TAGS));
String downloadTargetTags = StringUtils.trimToEmpty(op.getConfiguration(DOWNLOAD_TARGET_TAGS));
String downloadSourceFlavors = StringUtils.trimToEmpty(op.getConfiguration(DOWNLOAD_SOURCE_FLAVORS));
String downloadTargetSubflavor = StringUtils.trimToNull(op.getConfiguration(DOWNLOAD_TARGET_SUBFLAVOR));
String streamingSourceTags = StringUtils.trimToEmpty(op.getConfiguration(STREAMING_SOURCE_TAGS));
String streamingTargetTags = StringUtils.trimToEmpty(op.getConfiguration(STREAMING_TARGET_TAGS));
String streamingSourceFlavors = StringUtils.trimToEmpty(op.getConfiguration(STREAMING_SOURCE_FLAVORS));
String streamingTargetSubflavor = StringUtils.trimToNull(op.getConfiguration(STREAMING_TARGET_SUBFLAVOR));
String republishStrategy = StringUtils.trimToEmpty(op.getConfiguration(STRATEGY));
boolean checkAvailability = option(op.getConfiguration(CHECK_AVAILABILITY)).bind(trimToNone).map(toBool).getOrElse(true);
String[] sourceDownloadTags = StringUtils.split(downloadSourceTags, ",");
String[] targetDownloadTags = StringUtils.split(downloadTargetTags, ",");
String[] sourceDownloadFlavors = StringUtils.split(downloadSourceFlavors, ",");
String[] sourceStreamingTags = StringUtils.split(streamingSourceTags, ",");
String[] targetStreamingTags = StringUtils.split(streamingTargetTags, ",");
String[] sourceStreamingFlavors = StringUtils.split(streamingSourceFlavors, ",");
if (sourceDownloadTags.length == 0 && sourceDownloadFlavors.length == 0 && sourceStreamingTags.length == 0 && sourceStreamingFlavors.length == 0) {
logger.warn("No tags or flavors have been specified, so nothing will be published to the engage publication channel");
return createResult(mediaPackage, Action.CONTINUE);
}
// Parse the download target flavor
MediaPackageElementFlavor downloadSubflavor = null;
if (downloadTargetSubflavor != null) {
try {
downloadSubflavor = MediaPackageElementFlavor.parseFlavor(downloadTargetSubflavor);
} catch (IllegalArgumentException e) {
throw new WorkflowOperationException(e);
}
}
// Parse the streaming target flavor
MediaPackageElementFlavor streamingSubflavor = null;
if (streamingTargetSubflavor != null) {
try {
streamingSubflavor = MediaPackageElementFlavor.parseFlavor(streamingTargetSubflavor);
} catch (IllegalArgumentException e) {
throw new WorkflowOperationException(e);
}
}
// Configure the download element selector
SimpleElementSelector downloadElementSelector = new SimpleElementSelector();
for (String flavor : sourceDownloadFlavors) {
downloadElementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor));
}
for (String tag : sourceDownloadTags) {
downloadElementSelector.addTag(tag);
}
// Configure the streaming element selector
SimpleElementSelector streamingElementSelector = new SimpleElementSelector();
for (String flavor : sourceStreamingFlavors) {
streamingElementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor));
}
for (String tag : sourceStreamingTags) {
streamingElementSelector.addTag(tag);
}
// Select the appropriate elements for download and streaming
Collection<MediaPackageElement> downloadElements = downloadElementSelector.select(mediaPackage, false);
Collection<MediaPackageElement> streamingElements = streamingElementSelector.select(mediaPackage, false);
try {
Set<String> downloadElementIds = new HashSet<String>();
Set<String> streamingElementIds = new HashSet<String>();
// Look for elements matching the tag
for (MediaPackageElement elem : downloadElements) {
downloadElementIds.add(elem.getIdentifier());
}
for (MediaPackageElement elem : streamingElements) {
streamingElementIds.add(elem.getIdentifier());
}
// Also distribute the security configuration
// -----
// This was removed in the meantime by a fix for MH-8515, but could now be used again.
// -----
Attachment[] securityAttachments = mediaPackage.getAttachments(MediaPackageElements.XACML_POLICY);
if (securityAttachments != null && securityAttachments.length > 0) {
for (Attachment a : securityAttachments) {
downloadElementIds.add(a.getIdentifier());
streamingElementIds.add(a.getIdentifier());
}
}
removePublicationElement(mediaPackage);
switch(republishStrategy) {
case ("merge"):
// nothing to do here. other publication strategies can be added to this list later on
break;
default:
retractFromEngage(mediaPackage);
}
List<Job> jobs = new ArrayList<Job>();
// distribute Elements
try {
if (downloadElementIds.size() > 0) {
Job job = downloadDistributionService.distribute(CHANNEL_ID, mediaPackage, downloadElementIds, checkAvailability);
if (job != null) {
jobs.add(job);
}
}
if (distributeStreaming) {
for (String elementId : streamingElementIds) {
Job job = streamingDistributionService.distribute(CHANNEL_ID, mediaPackage, elementId);
if (job != null) {
jobs.add(job);
}
}
}
} catch (DistributionException e) {
throw new WorkflowOperationException(e);
}
if (jobs.size() < 1) {
logger.info("No mediapackage element was found for distribution to engage");
return createResult(mediaPackage, Action.CONTINUE);
}
// Wait until all distribution jobs have returned
if (!waitForStatus(jobs.toArray(new Job[jobs.size()])).isSuccess())
throw new WorkflowOperationException("One of the distribution jobs did not complete successfully");
logger.debug("Distribute of mediapackage {} completed", mediaPackage);
String engageUrlString = null;
try {
MediaPackage mediaPackageForSearch = getMediaPackageForSearchIndex(mediaPackage, jobs, downloadSubflavor, targetDownloadTags, downloadElementIds, streamingSubflavor, streamingElementIds, targetStreamingTags);
// MH-10216, check if only merging into existing mediapackage
removePublicationElement(mediaPackage);
switch(republishStrategy) {
case ("merge"):
// merge() returns merged mediapackage or null mediaPackage is not published
mediaPackageForSearch = merge(mediaPackageForSearch);
if (mediaPackageForSearch == null) {
logger.info("Skipping republish for {} since it is not currently published", mediaPackage.getIdentifier().toString());
return createResult(mediaPackage, Action.SKIP);
}
break;
default:
}
if (!isPublishable(mediaPackageForSearch))
throw new WorkflowOperationException("Media package does not meet criteria for publication");
logger.info("Publishing media package {} to search index", mediaPackageForSearch);
URL engageBaseUrl = null;
engageUrlString = StringUtils.trimToNull(workflowInstance.getOrganization().getProperties().get(ENGAGE_URL_PROPERTY));
if (engageUrlString != null) {
engageBaseUrl = new URL(engageUrlString);
} else {
engageBaseUrl = serverUrl;
logger.info("Using 'server.url' as a fallback for the non-existing organization level key '{}' for the publication url", ENGAGE_URL_PROPERTY);
}
// create the publication URI (used by Admin UI for event details link)
URI engageUri = this.createEngageUri(engageBaseUrl.toURI(), mediaPackage);
// Create new distribution element
Publication publicationElement = PublicationImpl.publication(UUID.randomUUID().toString(), CHANNEL_ID, engageUri, MimeTypes.parseMimeType("text/html"));
mediaPackage.add(publicationElement);
// Adding media package to the search index
Job publishJob = null;
try {
publishJob = searchService.add(mediaPackageForSearch);
if (!waitForStatus(publishJob).isSuccess()) {
throw new WorkflowOperationException("Mediapackage " + mediaPackageForSearch.getIdentifier() + " could not be published");
}
} catch (SearchException e) {
throw new WorkflowOperationException("Error publishing media package", e);
} catch (MediaPackageException e) {
throw new WorkflowOperationException("Error parsing media package", e);
}
logger.debug("Publishing of mediapackage {} completed", mediaPackage);
return createResult(mediaPackage, Action.CONTINUE);
} catch (MalformedURLException e) {
logger.error("{} is malformed: {}", ENGAGE_URL_PROPERTY, engageUrlString);
throw new WorkflowOperationException(e);
} catch (Throwable t) {
if (t instanceof WorkflowOperationException)
throw (WorkflowOperationException) t;
else
throw new WorkflowOperationException(t);
}
} catch (Exception e) {
if (e instanceof WorkflowOperationException) {
throw (WorkflowOperationException) e;
} else {
throw new WorkflowOperationException(e);
}
}
}
use of org.opencastproject.mediapackage.MediaPackageException in project opencast by opencast.
the class PublishYouTubeWorkflowOperationHandler method start.
/**
* {@inheritDoc}
*
* @see org.opencastproject.workflow.api.WorkflowOperationHandler#start(org.opencastproject.workflow.api.WorkflowInstance,
* JobContext)
*/
public WorkflowOperationResult start(final WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException {
logger.debug("Running youtube publication workflow operation");
MediaPackage mediaPackage = workflowInstance.getMediaPackage();
// Check which tags have been configured
String sourceTags = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration("source-tags"));
String sourceFlavors = StringUtils.trimToNull(workflowInstance.getCurrentOperation().getConfiguration("source-flavors"));
AbstractMediaPackageElementSelector<MediaPackageElement> elementSelector;
if (sourceTags == null && sourceFlavors == null) {
logger.warn("No tags or flavor have been specified");
return createResult(mediaPackage, Action.CONTINUE);
}
elementSelector = new SimpleElementSelector();
if (sourceFlavors != null) {
for (String flavor : asList(sourceFlavors)) {
elementSelector.addFlavor(MediaPackageElementFlavor.parseFlavor(flavor));
}
}
if (sourceTags != null) {
for (String tag : asList(sourceTags)) {
elementSelector.addTag(tag);
}
}
try {
// Look for elements matching the tag
final Collection<MediaPackageElement> elements = elementSelector.select(mediaPackage, true);
if (elements.size() > 1) {
logger.warn("More than one element has been found for publishing to youtube: {}", elements);
return createResult(mediaPackage, Action.SKIP);
}
if (elements.size() < 1) {
logger.info("No mediapackage element was found for publishing");
return createResult(mediaPackage, Action.CONTINUE);
}
Job youtubeJob;
try {
Track track = mediaPackage.getTrack(elements.iterator().next().getIdentifier());
youtubeJob = publicationService.publish(mediaPackage, track);
} catch (PublicationException e) {
throw new WorkflowOperationException(e);
}
// Wait until the youtube publication job has returned
if (!waitForStatus(youtubeJob).isSuccess())
throw new WorkflowOperationException("The youtube publication jobs did not complete successfully");
// All the jobs have passed
Job job = serviceRegistry.getJob(youtubeJob.getId());
// If there is no payload, then the item has not been published.
if (job.getPayload() == null) {
logger.warn("Publish to youtube failed, no payload from publication job: {}", job);
return createResult(mediaPackage, Action.CONTINUE);
}
Publication newElement = null;
try {
newElement = (Publication) MediaPackageElementParser.getFromXml(job.getPayload());
} catch (MediaPackageException e) {
throw new WorkflowOperationException(e);
}
if (newElement == null) {
logger.warn("Publication to youtube failed, unable to parse the payload '{}' from job '{}' to a mediapackage element", job.getPayload(), job);
return createResult(mediaPackage, Action.CONTINUE);
}
mediaPackage.add(newElement);
logger.debug("Publication to youtube operation completed");
} catch (Exception e) {
if (e instanceof WorkflowOperationException) {
throw (WorkflowOperationException) e;
} else {
throw new WorkflowOperationException(e);
}
}
return createResult(mediaPackage, Action.CONTINUE);
}
use of org.opencastproject.mediapackage.MediaPackageException in project opencast by opencast.
the class RepublishOaiPmhWorkflowOperationHandler method start.
@Override
public WorkflowOperationResult start(WorkflowInstance wi, JobContext context) throws WorkflowOperationException {
final MediaPackage mp = wi.getMediaPackage();
// The flavors of the elements that are to be published
final Set<String> flavors = new HashSet<>();
// Check which flavors have been configured
final List<String> configuredFlavors = getOptConfig(wi, OPT_SOURCE_FLAVORS).bind(trimToNone).map(asList.toFn()).getOr(Collections.<String>nil());
for (String flavor : configuredFlavors) {
flavors.add(flavor);
}
// Get the configured tags
final Set<String> tags = set(getOptConfig(wi, OPT_SOURCE_TAGS).getOr(""));
// repository
final String repository = getConfig(wi, OPT_REPOSITORY);
logger.debug("Start updating metadata of the media package {} in OAI-PMH repository {}", mp.getIdentifier().compact(), repository);
try {
Job updateMetadataJob = oaiPmhPublicationService.updateMetadata(mp, repository, flavors, tags, true);
if (updateMetadataJob == null) {
logger.info("Unable to create an OAI-PMH update metadata job for the media package {} in repository {}", mp.getIdentifier().compact(), repository);
return createResult(mp, Action.CONTINUE);
}
if (!waitForJobs(serviceRegistry, updateMetadataJob).isSuccess()) {
throw new WorkflowOperationException(format("OAI-PMH update metadata job for the media package %s did not end successfully", mp.getIdentifier().compact()));
}
} catch (MediaPackageException | PublicationException | IllegalArgumentException | IllegalStateException e) {
throw new WorkflowOperationException(format("Unable to create an OAI-PMH update metadata job for the media package %s in repository %s", mp.getIdentifier().compact(), repository), e);
}
logger.debug("Updating metadata of the media package {} in OAI-PMH repository {} done", mp.getIdentifier().compact(), repository);
return createResult(mp, Action.CONTINUE);
}
Aggregations