Skip to content
Snippets Groups Projects
Commit 229cfd10 authored by vkovtun's avatar vkovtun
Browse files

SSDM-8405 Added dummy metadata for submission.

parent d79c801a
No related branches found
No related tags found
No related merge requests found
...@@ -138,6 +138,11 @@ public class ServiceProvider ...@@ -138,6 +138,11 @@ public class ServiceProvider
return ((IApplicationServerApi) getApplicationContext().getBean(V3_APPLICATION_SERVICE_BEAN)); return ((IApplicationServerApi) getApplicationContext().getBean(V3_APPLICATION_SERVICE_BEAN));
} }
public static IDataStoreServerApi getV3DataStoreService()
{
return ((IDataStoreServerApi) getApplicationContext().getBean(DataStoreServerApi.INTERNAL_SERVICE_NAME));
}
public static IGeneralInformationService getGeneralInformationService() public static IGeneralInformationService getGeneralInformationService()
{ {
return ((IGeneralInformationService) getApplicationContext().getBean( return ((IGeneralInformationService) getApplicationContext().getBean(
......
...@@ -28,12 +28,19 @@ function ZenodoExportView(exportController, exportModel) { ...@@ -28,12 +28,19 @@ function ZenodoExportView(exportController, exportModel) {
}); });
$form.append($formColumn); $form.append($formColumn);
var $infoBox = FormUtil.getInfoBox('You can select any parts of the accessible openBIS structure to export:', [ var $infoBox1 = FormUtil.getInfoBox('You can select any parts of the accessible openBIS structure to export:', [
'If you select a tree node and do not expand it, everything below this node will be exported by default.', 'If you select a tree node and do not expand it, everything below this node will be exported by default.',
'To export selectively only parts of a tree, open the nodes and select what to export.' 'To export selectively only parts of a tree, open the nodes and select what to export.'
]); ]);
$infoBox.css('border', 'none'); $infoBox1.css('border', 'none');
$container.append($infoBox); $container.append($infoBox1);
var $infoBox2 = FormUtil.getInfoBox('Publication time constraint', [
'After the resource has been exported it should be published in Zenodo UI within 2 hours.',
'Otherwise, the publication metadata will not be registered in openBIS.'
]);
$infoBox2.css('border', 'none');
$container.append($infoBox2);
var $tree = $('<div>', { 'id' : 'exportsTree' }); var $tree = $('<div>', { 'id' : 'exportsTree' });
$formColumn.append($('<br>')); $formColumn.append($('<br>'));
......
...@@ -16,10 +16,14 @@ ...@@ -16,10 +16,14 @@
from __future__ import print_function from __future__ import print_function
import json
import traceback import traceback
import time import time
from ch.systemsx.cisd.common.logging import LogCategory from ch.systemsx.cisd.common.logging import LogCategory
from ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id import CustomASServiceCode
from ch.ethz.sis.openbis.generic.asapi.v3.dto.service import CustomASServiceExecutionOptions
from com.sun.xml.internal.ws.policy.privateutil.PolicyUtils import ServiceProvider
from java.io import File from java.io import File
from java.nio.file import Paths from java.nio.file import Paths
from org.apache.commons.io import FileUtils from org.apache.commons.io import FileUtils
...@@ -53,7 +57,26 @@ def expandAndExport(tr, params): ...@@ -53,7 +57,26 @@ def expandAndExport(tr, params):
validateDataSize(entitiesToExport, tr) validateDataSize(entitiesToExport, tr)
operationLog.info('Found ' + str(len(entitiesToExport)) + ' entities to export') operationLog.info('Found ' + str(len(entitiesToExport)) + ' entities to export')
return export(entities=entitiesToExport, tr=tr, params=params) exportUrl = export(entities=entitiesToExport, tr=tr, params=params)
# registerPublicationInOpenbis(params=params, exportUrl=exportUrl)
return exportUrl
def registerPublicationInOpenbis(params, exportUrl):
sessionToken = params.get('sessionToken')
v3 = ServiceProvider.getV3ApplicationService()
id = CustomASServiceCode('publication-api')
options = CustomASServiceExecutionOptions() \
.withParameter('method', 'insertPublication') \
.withParameter('publicationURL', exportUrl)
# .withParameter('openBISRelatedIdentifiers', ...)
# .withParameter('publicationOrganization', ...)
# .withParameter('name', ...)
# .withParameter('publicationType', ...)
# .withParameter('publicationIdentifier', ...)
result = v3.executeCustomASService(sessionToken, id, options)
def export(entities, tr, params): def export(entities, tr, params):
...@@ -102,8 +125,14 @@ def sendToZenodo(tr, tempZipFilePath): ...@@ -102,8 +125,14 @@ def sendToZenodo(tr, tempZipFilePath):
depositionLinks = depositionData.get('links') depositionLinks = depositionData.get('links')
depositUrl = depositionLinks.get('files') depositUrl = depositionLinks.get('files')
selfUrl = depositionLinks.get('self')
publishUrl = depositionLinks.get('publish')
submitFile(tempZipFilePath, accessToken, httpClient.newRequest(depositUrl)) submitFile(httpClient.newRequest(depositUrl), accessToken, tempZipFilePath)
addMetadata(httpClient.newRequest(selfUrl), accessToken)
publish(httpClient.newRequest(publishUrl), accessToken)
retrieve(httpClient.newRequest(selfUrl), accessToken)
result = depositionLinks.get('html') result = depositionLinks.get('html')
return result return result
...@@ -116,7 +145,7 @@ def sendToZenodo(tr, tempZipFilePath): ...@@ -116,7 +145,7 @@ def sendToZenodo(tr, tempZipFilePath):
httpClient.stop() httpClient.stop()
def submitFile(tempZipFilePath, accessToken, request): def submitFile(request, accessToken, tempZipFilePath):
multiPart = MultiPartContentProvider() multiPart = MultiPartContentProvider()
multiPart.addFilePart('file', 'content.zip', PathContentProvider(Paths.get(tempZipFilePath)), None) multiPart.addFilePart('file', 'content.zip', PathContentProvider(Paths.get(tempZipFilePath)), None)
multiPart.close() multiPart.close()
...@@ -124,13 +153,59 @@ def submitFile(tempZipFilePath, accessToken, request): ...@@ -124,13 +153,59 @@ def submitFile(tempZipFilePath, accessToken, request):
response = request.method(HttpMethod.POST).content(multiPart).send() response = request.method(HttpMethod.POST).content(multiPart).send()
checkResponseStatus(response) checkResponseStatus(response)
contentStr = response.getContentAsString() contentStr = response.getContentAsString()
print('submitFile(). contentStr="%s"' % contentStr)
return JSONObject(contentStr) return JSONObject(contentStr)
def addMetadata(request, accessToken):
data = {
'metadata': {
'title': 'Sample upload',
'license': 'cc-zero',
'upload_type': 'poster',
'description': 'This is a sample upload',
'creators': [{'name': userId, 'affiliation': 'Zenodo'}]
}
}
addAuthenticationHeader(accessToken, request)
jsonString = json.dumps(data)
print('addMetadata(). jsonString="%s"' % jsonString)
response = request.method(HttpMethod.PUT).content(StringContentProvider(jsonString), 'application/json').send()
contentStr = response.getContentAsString()
print('addMetadata(). contentStr="%s"' % contentStr)
checkResponseStatus(response)
def retrieve(request, accessToken):
addAuthenticationHeader(accessToken, request)
response = request.method(HttpMethod.GET).send()
contentStr = response.getContentAsString()
print('retrieve(). retrieve="%s"' % contentStr)
checkResponseStatus(response)
def publish(request, accessToken):
addAuthenticationHeader(accessToken, request)
response = request.method(HttpMethod.POST).send()
contentStr = response.getContentAsString()
print('publish(). contentStr="%s"' % contentStr)
checkResponseStatus(response)
def createDepositionResource(request, accessToken): def createDepositionResource(request, accessToken):
addAuthenticationHeader(accessToken, request) addAuthenticationHeader(accessToken, request)
response = request.method(HttpMethod.POST).content(StringContentProvider("{}"), "application/json").send() response = request.method(HttpMethod.POST).content(StringContentProvider('{}'), 'application/json').send()
checkResponseStatus(response) checkResponseStatus(response)
contentStr = response.getContentAsString() contentStr = response.getContentAsString()
return JSONObject(contentStr) return JSONObject(contentStr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment