Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
[Log
in](https://unlimited.ethz.ch/login.action?os_destination=%2Fdisplay%2FopenBISDoc2010%2FService%2BPlugins)
Linked Applications
Loading…
[](/)
- [Spaces](/spacedirectory/view.action "Spaces")
- [Create ](# "Create from template")
- Hit enter to search
- [Help](# "Help")
- [Online
Help](https://docs.atlassian.com/confluence/docs-82/ "Visit the Confluence documentation home")
- [Keyboard Shortcuts](# "View available keyboard shortcuts")
- [Feed
Builder](/dashboard/configurerssfeed.action "Create your custom RSS feed.")
- [What’s
new](https://confluence.atlassian.com/display/DOC/Confluence+8.2+Release+Notes)
- [Available Gadgets](# "Browse gadgets provided by Confluence")
- [About
Confluence](/aboutconfluencepage.action "Get more information about Confluence")
-
-
-
- [Log
in](/login.action?os_destination=%2Fdisplay%2FopenBISDoc2010%2FService%2BPlugins)
[](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home "openBIS Documentation Rel. 20.10")
[openBIS Documentation Rel.
20.10](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home "openBIS Documentation Rel. 20.10")
- [Pages](/collector/pages.action?key=openBISDoc2010)
- [Blog](/pages/viewrecentblogposts.action?key=openBISDoc2010)
### Page tree
[](/collector/pages.action?key=openBISDoc2010)
Browse pages
ConfigureSpace tools
[](#)
- [ ](#)
- [ Attachments (0)
](/pages/viewpageattachments.action?pageId=53745982 "View Attachments")
- [ Page History
](/pages/viewpreviousversions.action?pageId=53745982)
- [ Page Information ](/pages/viewinfo.action?pageId=53745982)
- [ Resolved comments ](#)
- [ View in Hierarchy
](/pages/reorderpages.action?key=openBISDoc2010&openId=53745982#selectedPageInHierarchy)
- [ View Source
](/plugins/viewsource/viewpagesrc.action?pageId=53745982)
- [ Export to PDF
](/spaces/flyingpdf/pdfpageexport.action?pageId=53745982)
- [ Export to Word ](/exportword?pageId=53745982)
- [ View Visio File
](/plugins/lucidchart/selectVisio.action?contentId=53745982)
- [ Copy
](/pages/copypage.action?idOfPageToCopy=53745982&spaceKey=openBISDoc2010)
1. [Pages](/collector/pages.action?key=openBISDoc2010)
2. [openBIS Documentation Rel. 20.10
Home](/display/openBISDoc2010/openBIS+Documentation+Rel.+20.10+Home)
3. [openBIS 20.10
Documentation](/display/openBISDoc2010/openBIS+20.10+Documentation)
- []( "Unrestricted")
- [Jira links]()
[Service Plugins](/display/openBISDoc2010/Service+Plugins)
----------------------------------------------------------
- Created by [Fuentes Serna Juan Mariano
(ID)](%20%20%20%20/display/~juanf%0A) on [Oct 01,
2020](/pages/viewpreviousversions.action?pageId=53745982 "Show changes")
Introduction
------------
A service plugin runs on a DSS. It is a java servlet that processes
incoming requests and generates the responses. A user can trigger a
service plugin by accessing an url the servlet has been set up for. A
service plugin is configured on the DSS best by introducing a [core
plugin](/display/openBISDoc2010/Core+Plugins) of type services. All
service plugins have the following properties in common:
[TABLE]
Service Plugins
---------------
### ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.OaipmhServlet
A servlet that handles OAI-PMH protocol requests (see
<http://www.openarchives.org/OAI/openarchivesprotocol.html> for more
details on OAI-PMH). The requests are handled in two steps:
- user authentication
- response generation
The user authentication step is handled by
ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.IAuthenticationHandler.
The handler is configured via "authentication-handler" property. The
response generation step is handled
by ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.IRequestHandler.
The handler is configured via "request - handler" property. An example
of such a configuration is presented below:
**Example**:
**plugin.properties**
class = ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.OaipmhServlet
path = /oaipmh/*
request-handler = ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.JythonBasedRequestHandler
request-handler.script-path = handler.py
authentication-handler = ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.BasicHttpAuthenticationHandler
**Configuration**:
[TABLE]
##### ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.BasicHttpAuthenticationHandler
Handler that performs Basic HTTP authentication as described here:
<http://en.wikipedia.org/wiki/Basic_access_authentication>.
##### ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.AnonymousAuthenticationHandler
Handler that allows clients to access the OAI-PMH service without any
authentication. The handler automatically authenticates as a user
specified in the configuration.
**Configuration:**
[TABLE]
##### ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.JythonBasedRequestHandler
OAI-PMH response handler that delegates a response generation to a
Jython script. The script can be configured via "script-path" property.
The script should define a function with a following signature:
**handler.py**
def handle(request, response)
where request is javax.servlet.http.HttpServletRequest request and
response is javax.servlet.http.HttpServletResponse. Following variables
are available in the script:
- searchService
- ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.ISearchService
- searchServiceUnfiltered -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.ISearchService
- mailService -
ch.systemsx.cisd.openbis.dss.generic.server.plugins.jython.api.IMailService
- queryService -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.IDataSourceQueryService
- authorizationService -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.authorization.IAuthorizationService
- sessionWorkspaceProvider -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.ISessionWorkspaceProvider
- contentProvider -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.IDataSetContentProvider
- contentProviderUnfiltered -
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v2.IDataSetContentProvider
- userId
**Configuration:**
[TABLE]
An example of a jython script that can be used for handling OAI-PMH
responses is presented below. The example uses XOAI java library
(see <https://github.com/lyncode/xoai> for more details on the library)
to provide dataset metadata. XOAI library is available in openBIS and
can be used without any additional configuration.
**handler.py**
#! /usr/bin/env python
from java.util import Date
from java.text import SimpleDateFormat
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
from com.lyncode.xoai.dataprovider import DataProvider
from com.lyncode.xoai.dataprovider.model import Context, MetadataFormat, Item
from com.lyncode.xoai.dataprovider.repository import Repository, RepositoryConfiguration
from com.lyncode.xoai.dataprovider.parameters import OAIRequest
from com.lyncode.xoai.dataprovider.handlers.results import ListItemIdentifiersResult, ListItemsResults
from com.lyncode.xoai.model.oaipmh import OAIPMH, DeletedRecord, Granularity, Metadata
from com.lyncode.xoai.xml import XmlWriter
from ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.xoai import SimpleItemIdentifier, SimpleItem, SimpleItemRepository, SimpleSetRepository
from ch.systemsx.cisd.openbis.generic.shared.api.v1.dto import SearchCriteria
from ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria import MatchClause, MatchClauseAttribute, MatchClauseTimeAttribute, CompareMode
DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd")
TIME_ZONE = "0"
def handle(req, resp):
context = Context();
context.withMetadataFormat(MetadataFormat().withPrefix("testPrefix").withTransformer(MetadataFormat.identity()));
configuration = RepositoryConfiguration();
configuration.withMaxListSets(100);
configuration.withMaxListIdentifiers(100);
configuration.withMaxListRecords(100);
configuration.withAdminEmail("test@test");
configuration.withBaseUrl("http://localhost");
configuration.withDeleteMethod(DeletedRecord.NO);
configuration.withEarliestDate(Date(0));
configuration.withRepositoryName("TEST");
configuration.withGranularity(Granularity.Day);
repository = Repository();
repository.withConfiguration(configuration);
repository.withItemRepository(ItemRepository());
repository.withSetRepository(SimpleSetRepository());
provider = DataProvider(context, repository);
params = {}
for param in req.getParameterNames():
values = []
for value in req.getParameterValues(param):
values.append(value)
params[param] = values
request = OAIRequest(params);
response = provider.handle(request);
writer = XmlWriter(resp.getOutputStream());
response.write(writer);
writer.flush();
class ItemRepository(SimpleItemRepository):
def doGetItem(self, identifier):
criteria = SearchCriteria()
criteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, identifier))
dataSets = searchService.searchForDataSets(criteria)
if dataSets:
return createItem(dataSets[0])
else:
return None
def doGetItemIdentifiers(self, filters, offset, length, setSpec, fromDate, untilDate):
results = self.doGetItems(filters, offset, length, setSpec, fromDate, untilDate)
return ListItemIdentifiersResult(results.hasMore(), results.getResults(), results.getTotal())
def doGetItems(self, filters, offset, length, setSpec, fromDate, untilDate):
criteria = SearchCriteria()
if fromDate:
criteria.addMatchClause(MatchClause.createTimeAttributeMatch(MatchClauseTimeAttribute.REGISTRATION_DATE, CompareMode.GREATER_THAN_OR_EQUAL, DATE_FORMAT.format(fromDate), TIME_ZONE))
if untilDate:
criteria.addMatchClause(MatchClause.createTimeAttributeMatch(MatchClauseTimeAttribute.REGISTRATION_DATE, CompareMode.LESS_THAN_OR_EQUAL, DATE_FORMAT.format(untilDate), TIME_ZONE))
dataSets = searchService.searchForDataSets(criteria)
if dataSets:
hasMoreResults = (offset + length) < len(dataSets)
results = [createItem(dataSet) for dataSet in dataSets[offset:(offset + length)]]
total = len(dataSets)
return ListItemsResults(hasMoreResults, results, total)
else:
return ListItemsResults(False, [], 0)
def createItemMetadata(dataSet):
properties = Element("properties")
for propertyCode in dataSet.getAllPropertyCodes():
property = SubElement(properties, "property")
property.set("code", propertyCode)
property.text = dataSet.getPropertyValue(propertyCode)
return Metadata(ElementTree.tostring(properties))
def createItem(dataSet):
item = SimpleItem()
item.setIdentifier(dataSet.getDataSetCode())
item.setDatestamp(Date())
item.setMetadata(createItemMetadata(dataSet))
return item
now assuming that the OaipmhServlet has been configured at /oaipmh path
try accessing the following urls:
- <data store url>/oaipmh/?verb=Identify - returns information
about this OAI-PMH repository
- <data store
url>/oaipmh/?verb=ListIdentifiers&metadataPrefix=testPrefix -
returns the first 100 of data set codes and a resumption token if
there is more than 100 data sets available
- <data store
url>/oaipmh/?verb=ListIdentifiers&resumptionToken=<resumption
token> - returns another 100 of data set codes
- <data store
url>/oaipmh/?verb=ListRecords&metadataPrefix=testPrefix - returns
the first 100 of data set records and a resumption token if there is
more than 100 data sets available
- <data store
url>/oaipmh/?verb=ListRecords&resumptionToken=<resumption
token> - returns another 100 of data set records
- <data store
url>/oaipmh/?verb=GetRecord&metadataPrefix=testPrefix&identifier=<data
set code> - returns a record for a data set with the specified
code
##### ch.systemsx.cisd.openbis.dss.screening.server.oaipmh.ScreeningJythonBasedRequestHandler
Screening version of
ch.systemsx.cisd.openbis.dss.generic.server.oaipmh.JythonBasedRequestHandler.
It works exactly the same as the generic counterpart, but it defines an
additional variable that is available in the script:
- screeningFacade
- ch.systemsx.cisd.openbis.plugin.screening.client.api.v1.IScreeningOpenbisServiceFacade
- No labels
Overview
Content Tools
Apps
- Powered by [Atlassian
Confluence](https://www.atlassian.com/software/confluence) 8.2.0
- Printed by Atlassian Confluence 8.2.0
- [Report a bug](https://support.atlassian.com/confluence-server/)
- [Atlassian News](https://www.atlassian.com/company)
[Atlassian](https://www.atlassian.com/)
{"serverDuration": 138, "requestCorrelationId": "d0d83453e1773ed3"}