Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Upload of a content newsitem to Open Content
This section will show how an upload to Open Content is performed
To be able to do the exercises you may to prepare your system. You need an Open Content Server to perform upload request towards.
You need a bash terminal for execution of the scripts
The prepare Windows section explains how to enable a bash terminal for Windows
Need to have following installed;
aws cli
imagemagick
unzip
jq
The examples will use show how to upload all objects types referenced from an Article.
Concepts
Images
Article
The article has relations to 6 different concepts and 3 images. Certain conventions must be known before uploading these to an Open Content.
Search client (XLibris) http://localhost/client
Admin client, http://localhost/admin
Rest-Api Swagger documentation, http://localhost:8080/opencontent/apidocs/
Use the links above to verify and study what happens in Open Content during the exercises below!
Study the scripts and try to understand what they do, modify files, script and execute them. If not expected behaviour, start a discussion.
This exercise will upload 6 concepts to Open Content. These Concept are referenced from the article which will be uploaded in lab 3
The script ./upload-concepts.sh will upload 6 concepts to Open Content using a curl multipart POST request.
For more details how this is done take a look at the script:
​
Image upload to Open Content calculating the correct filename for proper use when Open Content is used as the content storage for Writer Articles.
This exercise shows :
Calculate the filename when image is used by writer
Using openssl
Create preview and thumb to be used by Open Content
Create xml metadata file
Upload of Image with preview, thumb and metadata file
For more details see the ./upload-image.sh
file.
When uploading images for Digital Writer the image file needs to be upload to an internal S3 bucket and also be copied to an external S3 bucket with a calculated filename.
Remove all objects uploaded so that it can be done again
This exercise shows how to delete objects in Open Content.
./delete.sh [uuid]
will delete object with the specified uuid
will delete objects with source set to ./delete-mine.shlab-$(whoami)
the script in this exercise sets the source to lab-$(whoami)
The exercise will upload the Article holding reference to previous uploaded objects.
This exercise shows :
Upload of an article with correct filename, script will insert the uuid and filename for the 3 images
Learn how to perform search towards Open Content /search/ endpoint
A small tool for Open Content API test can be used for easier learning of Open Content search API. The UI can be accessed from the url http://localhost:8800
when Open Content docker-compose is started. T
This tool purpose is to make it easier to design search questions towards Open Content. It is not used in production environments.
The configuration in these exercises uses nested properties and assumes that you have the content from lab 1-3 uploaded.
Show how to use the Open Content event log
In this exercise you will start a script which will poll the Open Content event log every 5th second. If any events are found the script will print information of the event.
The script will persist the last event to a file (lastevent
) which holds the last event id processed by the script. When started next time and lastevent
file exists the script will start processing events with id larger than the lastevent
processed . This means that even if the listener is off. It will continue from last event next time the listener is started. This way no event is missed.
This is how to get the /eventlog/
endpoint response:
Response
Get the last event id use event=-1
In folder 6-event-sourcing
is an example of a bash script which will poll the event log every 5 seconds and print information about what is happening. To try this :
Now the script polls the event log every 5 second and print out the events.
Have the listener in a terminal window and add/modify/delete the items in Open Content and see the events.
Update of the settings file
Upload and activate the configuration for an Open Content using Newsitem
This lab configures Open Content using editorial standard config
The script ./configure.sh
in ~/oc-lab/opencontent-configs
will configure Open Content:
Verify the configuration in Open Content admin UI (http://localhost/admin)
Activate the config either using the admin UI or curl below:
Examine the + Configuration menu and more in Open Content admin UI
History
Compare (remove something)
Import/Export
Undo configuration
Upload can be done by using the curl command
Field
M/O
Description
-F id=<uuid>
O
The desired Uiid for the uploaded content object. Open Content will return the given id for the uploaded content.
-F batch=<boolean>
O
Default = false, used to upload content that should be indexed later using the batch indexing mechanism.
-F file=<file>
M
The File Name of the uploaded content.
-F file-mimetype=<mimetype>
M
Mime type for the uploaded content.
-F <file>=@<file>
M
<file> is the same as the given file=<file>, the file itself
-F metadata=<metadata>
M
Meta Data file
-F metadata-mimetype=<metadata-mimetype>
M
Meta Data Mime type
-F <metadata>=@<metadata>
M
The Meta Data file
-F metadata2=<metadata2>
O
If multiple meta data files should be uploaded, use this syntax with index starting at 2.
-F metadata2-mimetype2=npexchange/article
O
-F <metadata2>=@<metadata2>
O
-F preview=<preview>.jpg
File name for preview image
-F preview-mimetype=<mimetype>
Mime type for the preview image
-F <preview>.jpg=@<preview>.jpg
The Preview image
-F thumb=.jpg
File Name for the image thumbnail
-F thumb-mimetype=<mime.type>
Mime type for the image thumbnail
-F <thumb>.jpg=@<thumb>.jpg
The image thumbnail
-F source=<source>
Set the property source to the given value. Please note that the value of this property not can be re-created during a re-index process.
-F reuseFiles=<boolean>
(*)
If true, the object will get its files from one of the registered storages. Any files in the HTTP request will be ignored. This is used in eventlog replication for example.
-F version=<version>
(*)
The version of the of the object where files should be reused
-F created=<created-date>
(*)
The created date of the of the object where files should be reused, format: YYYY-MM-ddTHH:mm:ssZ, example: 2017-05-15T04:41:45Z
-F updated=<updated-date>
(*)
The updated date of the of the object where files should be reused, format: YYYY-MM-ddTHH:mm:ssZ, example: 2017-05-15T04:41:45Z
-F eventtype=<eventtype>
(*)
Possible values: ADD UPDATE DELETE
-H "If-Match:<hexdecimal etag>"
Enables optimistic locking. This upload will fail if the current object checksum does not match this e-tag. After upload the new e-tag will be returned in response header "ETag"
Http statuscode
Description
200
Upload was successful and the object has been updated. The HTTP response body contains the uuid.
201
Upload was successful and an object has been created. The HTTP response body contains the uuid.
400
Upload failed because of an invalid request. The HTTP response body contains the error message.
401
Authentication is missing or is incorrect
409
Upload failed because it is part of batch indexing.
412
Upload failed because the E-Tag doesn't match the checksum of the object.
500
Internal server error, unexpected error. The HTTP response body contains the error message.