1313class OpencastDiscoverVideos extends CronJob
1414{
1515
16+ /**
17+ * @var array The required properties of the event object which will be checked before any operation.
18+ */
19+ private static $ required_event_properties = [
20+ 'archive_version '
21+ ];
22+
1623 public static function getName ()
1724 {
1825 return _ ('Opencast - Neue Videos finden ' );
@@ -26,8 +33,8 @@ public static function getDescription()
2633 public function execute ($ last_result , $ parameters = array ())
2734 {
2835 /*
29- - Neue Videos in OC identifizieren (die Stud.IP noch nicht kennt)
30- - Eintragen der Videos und setzen der Rechte (Queue)
36+ - Neue Videos in OC identifizieren (die Stud.IP noch nicht kennt)
37+ - Eintragen der Videos und setzen der Rechte (Queue)
3138 */
3239 $ db = DBManager::get ();
3340 $ stmt_ids = $ db ->prepare ("
@@ -94,6 +101,12 @@ public function execute($last_result, $parameters = array())
94101 if (!empty ($ oc_events )) foreach ($ oc_events as $ event ) {
95102 $ current_event = null ;
96103
104+ // Check the required properties of the event.
105+ if (!self ::checkEventIntegrity ($ event )) {
106+ echo '[Skipped] The event does not have all required properties, skipping: ' . $ event ->identifier . "\n" ;
107+ continue ;
108+ }
109+
97110 // only add videos / reinspect videos if they are readily processed
98111 if ($ event ->status == 'EVENTS.EVENTS.STATUS.PROCESSED ' ) {
99112 $ event_ids [] = $ event ->identifier ;
@@ -197,6 +210,23 @@ public function execute($last_result, $parameters = array())
197210 echo 'Finished updating videos and workflows ' . "\n" ;
198211 }
199212
213+ /**
214+ * Check if the event has all required properties.
215+ *
216+ * @param object $event The event object to check.
217+ * @return bool True if the event has all required properties, false otherwise.
218+ */
219+ private static function checkEventIntegrity ($ event ) {
220+ // Check if the event has all required properties
221+ foreach (self ::$ required_event_properties as $ property ) {
222+ if (!property_exists ($ event , $ property )) {
223+ return false ;
224+ }
225+ }
226+
227+ return true ;
228+ }
229+
200230 private static function parseEvent ($ event , $ video )
201231 {
202232 if (in_array ($ event ->processing_state , ['FAILED ' , 'STOPPED ' ]) === true ) { // It failed.
0 commit comments