Skip to content

Commit

Permalink
ark: get rid of archetype
Browse files Browse the repository at this point in the history
* Adds a Ark NAAN configuration into organisation.
* Disallows Ark NAAN configuration modification for non super user.
* Mints an ark identifier if the document organisation contains a NAAN.
* Removes legacy code.
* Closes rero#652.
* Adds the cli to create an ARK in existing documents.
* Removes unused file.
* Adds document Dublin Core export format.
* Moves ark in identifiedBy.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed May 17, 2023
1 parent 6074c83 commit 8676b5b
Show file tree
Hide file tree
Showing 39 changed files with 698 additions and 817 deletions.
1 change: 1 addition & 0 deletions data/organisations/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"code": "rero",
"name": "RERO",
"isShared": true,
"arkNAAN": "99999",
"files": [
{
"key": "rero.jpg",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ theme = "sonar.theme.views:blueprint"
validation = "sonar.modules.validation.views:blueprint"
users = "sonar.modules.users.views:blueprint"
sitemap = "sonar.modules.sitemap.views:blueprint"
ark = "sonar.modules.ark.views:blueprint"

[tool.poetry.plugins."invenio_base.api_blueprints"]
deposits = "sonar.modules.deposits.rest:api_blueprint"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if $import; then
message "Size of import sets is set to \"$size\"" "info"
fi

# Try to create database and tables if does not exists
# Try to create database and tables if does not exist
invenio db init create || true

# Purge celery
Expand Down
17 changes: 16 additions & 1 deletion sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def _(x):
},
}
"""Records UI for sonar."""
REST_MIMETYPE_QUERY_ARG_NAME = 'format'

RECORDS_REST_ENDPOINTS = {
'doc':
Expand All @@ -382,10 +383,24 @@ def _(x):
record_serializers={
'application/json': ('sonar.modules.documents.serializers'
':json_v1_response'),
'application/xml': ('sonar.modules.documents.serializers'
':dc_v1_response'),
},
record_serializers_aliases={
'json': 'application/json',
'xml': 'application/xml',
'dc': 'application/dc+xml',
},
search_serializers={
'application/json': ('sonar.modules.documents.serializers'
':json_v1_search'),
'application/xml': ('sonar.modules.documents.serializers'
':dc_v1_search'),
},
search_serializers_aliases={
'json': 'application/json',
'xml': 'application/xml',
'dc': 'application/dc+xml',
},
record_loaders={
'application/json': ('sonar.modules.documents.loaders'
Expand Down Expand Up @@ -874,7 +889,7 @@ def _(x):
'oai_dc': {
'namespace': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'schema': 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'serializer': 'sonar.modules.documents.serializers.dc.sonar_dublin_core',
'serializer': 'sonar.modules.documents.serializers.oai_dc.sonar_dublin_core',
}
}
#: Number of records to return per page in OAI-PMH results.
Expand Down
14 changes: 3 additions & 11 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,19 +565,11 @@
# ARK
# ===

# SONAR_APP_ARK_USER = 'test'
"""Username for the NMA server."""
# SONAR_APP_ARK_PASSWORD = 'test'
"""Password for the NMA server."""
# SONAR_APP_ARK_RESOLVER = 'https://n2t.net'
SONAR_APP_ARK_RESOLVER = 'https://localhost:5000'
"""ARK resolver URL."""
# SONAR_APP_ARK_NMA = 'https://www.arketype.ch'
"""ARK Name Mapping Authority: a service provider server."""
# SONAR_APP_ARK_NAAN = '99999'
"""ARK prefix corresponding to an organisation."""
# SONAR_APP_ARK_SCHEME = 'ark:'
SONAR_APP_ARK_SCHEME = 'ark:'
"""ARK scheme."""
# SONAR_APP_ARK_SHOULDER = 'ffk3'
SONAR_APP_ARK_SHOULDER = 'ffk3'
"""ARK Shoulder, can be multiple for a given organisation."""

SONAR_APP_SWISSCOVERY_SEARCH_URL = 'https://swisscovery.slsp.ch/view/sru/41SLSP_NETWORK'
Expand Down
8 changes: 8 additions & 0 deletions sonar/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ def init_config(self, app):
'SONAR_APP_SITEMAP_FOLDER_PATH',
os.path.join(app.instance_path, 'sitemap'))

# add keep alive support for angular application
# NOTE: this will not work for werkzeug> 2.1.2
# https://werkzeug.palletsprojects.com/en/2.2.x/changes/#version-2-1-2
if app.config.get('DEBUG'): # pragma: no cover
# debug code do not need to be cover by the tests
from werkzeug.serving import WSGIRequestHandler
WSGIRequestHandler.protocol_version = "HTTP/1.1"

def init_views(self, app):
"""Initialize the main flask views."""
app.url_map.converters['org_code'] = OrganisationCodeConverter
Expand Down
2 changes: 1 addition & 1 deletion sonar/json_schemas/organisations_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def process(self):
# Remove modes fields if user does not have superuser role.
if not current_user_record.is_superuser:
propertiesOrder = schema.get('propertiesOrder', []);
for field in ['isDedicated', 'isShared']:
for field in ['isDedicated', 'isShared', 'arkNAAN']:
if field in propertiesOrder:
schema['propertiesOrder'].remove(field)

Expand Down
Loading

0 comments on commit 8676b5b

Please sign in to comment.