virtUOS / edusharing-opencast-importer

This importer harvests episodes (lecture recordings) from Opencast instances and push it as external references to an Edusharing instance.
GNU General Public License v3.0
2 stars 2 forks source link

Check existing nodes in ES before making POST requests #20

Closed jduehring closed 2 years ago

jduehring commented 3 years ago

Do not merge this yet, it still needs some work! --> See update

Refering to #15 the program currently tries to create new ES-nodes for every harvested episode and series, no matter if it is already existent or not. This leads to errors after making unsuccessful POST-requests and prevents the program from saving the corresponding IDs of those nodes.

I propose to solve this, by:

  1. checking if there is already a folder in ES for the corresponding OC instance.
  2. if so, fetch all child nodes including metadata
  3. in src/edu-sharing/create-folders-structure.js check before each request, if the directory already exists -> if so save node ID
  4. in src/edu-sharing/create-children.js check before each request, if the episode already exists

This PR adds the possibility to fetch all relevant, existing nodes and currently filters them by type (only folders are kept). So 1-3 is mostly done. The check still needs to be implemented for the episodes.

We should also discuss, if it makes sense to serialize the fetched data.

Update

Implemented 1-3. Instead of step 4, the programm now tries to create a node for each episode by sending a POST request. If a node with the same filename already exists, it will be skipped and the next one is tried. For future updates, we should target to map the opencast id's to the edusharing nodes, so we can handle deleted nodes or nodes with duplicate names.

This PR should also fix #24, so we can now delete our local storage files and/or the files in Edusharing and the programm will synch/refresh all missing nodes.