1
|
package eu.dnetlib.data.objectstore.modular;
|
2
|
|
3
|
import java.io.InputStream;
|
4
|
|
5
|
import javax.annotation.Resource;
|
6
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
7
|
|
8
|
import org.springframework.beans.factory.annotation.Required;
|
9
|
|
10
|
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
|
11
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
|
12
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
|
13
|
import eu.dnetlib.enabling.resultset.ResultSetFactory;
|
14
|
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
|
15
|
|
16
|
/**
|
17
|
* The Class ModularObjectStoreDeliver is responsible of delivering data from the object Store.
|
18
|
*/
|
19
|
public class ModularObjectStoreDeliver {
|
20
|
|
21
|
/** The dao. */
|
22
|
private ObjectStoreDao dao;
|
23
|
|
24
|
/** The result set factory. */
|
25
|
@Resource
|
26
|
private ResultSetFactory resultSetFactory;
|
27
|
|
28
|
/** The result set client factory. */
|
29
|
private ResultSetClientFactory resultSetClientFactory;
|
30
|
|
31
|
/**
|
32
|
* Gets the dao.
|
33
|
*
|
34
|
* @return the dao
|
35
|
*/
|
36
|
public ObjectStoreDao getDao() {
|
37
|
return dao;
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Sets the dao.
|
42
|
*
|
43
|
* @param dao
|
44
|
* the new dao
|
45
|
*/
|
46
|
@Required
|
47
|
public void setDao(final ObjectStoreDao dao) {
|
48
|
this.dao = dao;
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Deliver.
|
53
|
*
|
54
|
* @param objectStoreID
|
55
|
* the object store id
|
56
|
* @param from
|
57
|
* the from
|
58
|
* @param until
|
59
|
* the until
|
60
|
* @return the w3 c endpoint reference
|
61
|
* @throws ObjectStoreServiceException
|
62
|
*/
|
63
|
public W3CEndpointReference deliver(final String objectStoreID, final Long from, final Long until) throws ObjectStoreServiceException {
|
64
|
return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliver(from, until));
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* Deliver records by tags.
|
69
|
*
|
70
|
* @param obsId
|
71
|
* the obs id
|
72
|
* @param tags
|
73
|
* the tags
|
74
|
* @return the string
|
75
|
*/
|
76
|
public W3CEndpointReference deliverRecordsByTags(final String obsId, final Iterable<String> tags) {
|
77
|
return resultSetFactory.createResultSet(dao.getObjectStore(obsId).deliverRecordsByTag(tags));
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* Deliver ids.
|
82
|
*
|
83
|
* @param objectStoreID
|
84
|
* the object store id
|
85
|
* @param eprId
|
86
|
* the epr id
|
87
|
* @return the w3 c endpoint reference
|
88
|
* @throws ObjectStoreServiceException
|
89
|
*/
|
90
|
public W3CEndpointReference deliverIds(final String objectStoreID, final W3CEndpointReference eprId) throws ObjectStoreServiceException {
|
91
|
|
92
|
Iterable<String> ids = resultSetClientFactory.getClient(eprId);
|
93
|
return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliverIds(ids));
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* Exist id starts with.
|
98
|
*
|
99
|
* @param obsId
|
100
|
* the obs id
|
101
|
* @param startId
|
102
|
* the start id
|
103
|
* @return true, if successful
|
104
|
* @throws ObjectStoreServiceException
|
105
|
*/
|
106
|
public boolean existIDStartsWith(final String obsId, final String startId) throws ObjectStoreServiceException {
|
107
|
return dao.getObjectStore(obsId).existIDStartsWith(startId);
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* Deliver object.
|
112
|
*
|
113
|
* @param objectStoreID
|
114
|
* the object store id
|
115
|
* @param objectId
|
116
|
* the object id
|
117
|
* @return the object store file
|
118
|
* @throws ObjectStoreServiceException
|
119
|
*/
|
120
|
public ObjectStoreFile deliverObject(final String objectStoreID, final String objectId) throws ObjectStoreServiceException {
|
121
|
return dao.getObjectStore(objectStoreID).deliverObject(objectId);
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* Deliver stream.
|
126
|
*
|
127
|
* @param objectStoreID
|
128
|
* the object store id
|
129
|
* @param objectId
|
130
|
* the object id
|
131
|
* @return the input stream
|
132
|
* @throws ObjectStoreServiceException
|
133
|
*/
|
134
|
public InputStream deliverStream(final String objectStoreID, final String objectId) throws ObjectStoreServiceException {
|
135
|
return dao.getObjectStore(objectStoreID).deliverStream(objectId);
|
136
|
}
|
137
|
|
138
|
/**
|
139
|
* Gets the result set client factory.
|
140
|
*
|
141
|
* @return the result set client factory
|
142
|
*/
|
143
|
public ResultSetClientFactory getResultSetClientFactory() {
|
144
|
return resultSetClientFactory;
|
145
|
}
|
146
|
|
147
|
/**
|
148
|
* Sets the result set client factory.
|
149
|
*
|
150
|
* @param resultSetClientFactory
|
151
|
* the new result set client factory
|
152
|
*/
|
153
|
@Required
|
154
|
public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
|
155
|
this.resultSetClientFactory = resultSetClientFactory;
|
156
|
}
|
157
|
|
158
|
}
|