Create Implementation for YoutubeDistributionContextStrategy Using Old API

Description

uses workflow to access media package.

Activity

Show:
Kristofor Amundson
June 23, 2011, 11:05 PM

Still have not been able to get it to succeed from ingestion. It seems to have problems finding the files in the workspace to distribute. I am trying to go about it by having the directory set in the activate() method and then searching the directory for the right files. So far I haven't been successful, however I have not been able to figure out the optimal way to do this. I have tried using the Workspace, ServiceRegistry, OrganizationDirectoryService, UserDirectoryService, and have remained unsuccessful. Any suggestions?

Josh Holtzman
June 23, 2011, 11:25 PM

[4:20p] jholtzman:
WorkflowService.find() or something like that
[4:21p]kristofor:
OK
[4:21p]jholtzman:
you'll construct a WorkflowQuery with the mediapackage ID
there should be only one resulting workflow from that query
if there is more than one, take the last workflow created, since that's presumably the one we're working with
make sense so far?
[4:21p]kristofor:
Yes it does.
[4:22p]jholtzman:
great. once you have a WorkflowInstance, call getmediaPackage() on that, then you can look for the catalog with episode/dublincore flavor

Kristofor Amundson
June 24, 2011, 11:12 PM

Conceptually I understand this technique perfectly, but there must be something I am missing in terms of implementation. I am unable to get an instance of the WorkflowService within the YoutubeService without having to create one myself, which obviously does not have the data I need. I have been working on getting access to the service through the component and bundle context. There are certain services, like the WorkflowOperationHandler, that I can get the ServiceReference for to use to rebuild that object upon the call to the activate method. So far I have not been able to find a registered service that will actually give me the WorkflowInstance that I need.

Are there any examples of other services accessing WorkflowInstances?

Josh Holtzman
June 25, 2011, 2:03 PM
Edited

Do not try to use the low-level OSGI APIs from within your Java code, since you'd then need to deal with all of the dynamism of the OSGI environment. Instead, use the OSGI declarative services feature to do dependency injection.

YouTubeDistributionService should include a reference to WorkflowService and a setter: protected void setWorkflowService(WorkflowService workflowService) {this.workflowService=workflowService;}. It is not your job to call this setter, it will be called for you.

In the service registration (src/main/resources/OSGI-INF/distribution-service-youtube.xml), you'll need to add a reference to the workflow service:

<reference name="WORKFLOW" interface="org.opencastproject.workflow.api.WorkflowService" cardinality="1..1" policy="static" bind="setWorkflowService"/>

These inter-service references are all over the place, in almost every service in Matterhorn, so pick any OSGI-INF folder to find examples.

Kristofor Amundson
July 7, 2011, 10:57 PM

Uploads and retracts fine right now, in my environment. A few weird bugs still crop up though. Not sure how to explain one in particular that happens every time. The manifest is defined with one track "track-1" yet every single time I try to distribute this specific media package it will throw this exception:

16:46:37 INFO (IngestServiceImpl:250) - Ingesting zipped media package to /tmp/opencast/ingest/d4fb008b-cf1b-4fcc-a085-d1af3c2b25dc/2001.zip
16:46:38 WARN (IngestServiceImpl:678) - Failed to find a workflow with id '34'
16:46:48 INFO (InspectWorkflowOperationHandler:128) - Inspecting track 'track-1' of kristest
16:46:53 INFO (MediaInspectionServiceImpl:417) - Successfully inspected track http://localhost:8080/files/mediapackage/kristest/track-1/media.mov
16:47:03 INFO (DistributeWorkflowOperationHandler:118) - Distributing 'track-2' to the local repository
16:47:08 ERROR (WorkflowOperationWorker:158) - Workflow operation 'distribute-youtube' failed
org.opencastproject.workflow.api.WorkflowOperationException: One of the distribution jobs did not complete successfully
at org.opencastproject.workflow.handler.DistributeWorkflowOperationHandler.start(DistributeWorkflowOperationHandler.java:151)
at org.opencastproject.workflow.impl.WorkflowOperationWorker.start(WorkflowOperationWorker.java:216)
at org.opencastproject.workflow.impl.WorkflowOperationWorker.execute(WorkflowOperationWorker.java:138)
at org.opencastproject.workflow.impl.WorkflowServiceImpl.runWorkflowOperation(WorkflowServiceImpl.java:707)
at org.opencastproject.workflow.impl.WorkflowServiceImpl.process(WorkflowServiceImpl.java:1415)
at org.opencastproject.workflow.impl.WorkflowServiceImpl$JobRunner.call(WorkflowServiceImpl.java:1720)
at org.opencastproject.workflow.impl.WorkflowServiceImpl$JobRunner.call(WorkflowServiceImpl.java:1693)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
16:47:18 INFO (ZipWorkflowOperationHandler:158) - Archiving mediapackage kristest in workflow Workflow {2002}
16:47:18 INFO (ZipWorkflowOperationHandler:176) - Adding zipped mediapackage kristest to the failed.zips archive
16:47:18 INFO (ZipWorkflowOperationHandler:190) - Zipped mediapackage kristest moved to the failed.zips archive
16:47:44 INFO (YoutubeDistributionService:277) - Creating playlist Climate 101
16:47:45 INFO (YoutubeDistributionService:289) - Upload succeeded. URL of video: http://gdata.youtube.com/feeds/api/users/utubedelivery/uploads/SWsncMpL-x8?client=abcde

The reference to "track-2" is simply beyond me at this point. That track is not defined anywhere in the metadata being ingested. So the exception that is thrown only relates to the faux distribution job trying to upload a nonexistent file. It uploads the proper and only track every time.

Assignee

Kristofor Amundson

Reporter

A

Tags (folksonomy)

None

Components

Fix versions

Affects versions

Priority

Major
Configure