Revision 45126
Added by Claudio Atzori over 7 years ago
ISStoreServiceImpl.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.enabling.is.store; |
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 |
import java.util.Iterator; |
|
4 | 5 |
import java.util.List; |
5 | 6 |
|
6 | 7 |
import javax.annotation.Resource; |
7 | 8 |
import javax.jws.WebService; |
8 | 9 |
import javax.xml.ws.Endpoint; |
9 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
10 | 10 |
|
11 |
import com.google.common.collect.Iterators; |
|
11 | 12 |
import org.apache.commons.logging.Log; |
12 | 13 |
import org.apache.commons.logging.LogFactory; |
13 | 14 |
import org.quartz.Job; |
... | ... | |
15 | 16 |
import org.springframework.beans.factory.annotation.Required; |
16 | 17 |
import org.xmldb.api.base.XMLDBException; |
17 | 18 |
|
18 |
import eu.dnetlib.common.rmi.UnimplementedException; |
|
19 | 19 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreException; |
20 | 20 |
import eu.dnetlib.enabling.is.store.rmi.ISStoreService; |
21 | 21 |
import eu.dnetlib.enabling.resultset.ResultSetFactory; |
22 | 22 |
import eu.dnetlib.enabling.tools.AbstractBaseService; |
23 | 23 |
import eu.dnetlib.soap.EndpointReferenceBuilder; |
24 |
import eu.dnetlib.xml.database.XMLDBResultSet; |
|
25 | 24 |
import eu.dnetlib.xml.database.XMLDatabase; |
26 | 25 |
|
27 | 26 |
/** |
... | ... | |
108 | 107 |
/** |
109 | 108 |
* {@inheritDoc} |
110 | 109 |
* |
111 |
* @see eu.dnetlib.enabling.is.store.rmi.ISStoreService#deleteArrayXML(java.util.List, java.lang.String) |
|
112 |
*/ |
|
113 |
@Override |
|
114 |
public boolean deleteArrayXML(final List<String> fileNames, final String fileColl) throws ISStoreException { |
|
115 |
throw new UnimplementedException(); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* {@inheritDoc} |
|
120 |
* |
|
121 | 110 |
* @see eu.dnetlib.enabling.is.store.rmi.ISStoreService#deleteFileColl(java.lang.String) |
122 | 111 |
*/ |
123 | 112 |
@Override |
... | ... | |
207 | 196 |
log.debug(query); |
208 | 197 |
|
209 | 198 |
try { |
210 |
final XMLDBResultSet res = xmlDatabase.xquery(query);
|
|
199 |
final Iterator<String> res = xmlDatabase.xquery(query);
|
|
211 | 200 |
if (res == null) return null; |
212 |
if (res.getSize() < 1) return null;
|
|
213 |
return res.get(0);
|
|
201 |
if (!res.hasNext()) return null;
|
|
202 |
return res.next();
|
|
214 | 203 |
} catch (XMLDBException e) { |
215 | 204 |
throw new ISStoreException(e); |
216 | 205 |
} |
... | ... | |
240 | 229 |
public List<String> quickSearchXML(final String query) throws ISStoreException { |
241 | 230 |
log.debug(query); |
242 | 231 |
try { |
243 |
final XMLDBResultSet res = xmlDatabase.xquery(query);
|
|
244 |
if (res == null) return new ArrayList<String>();
|
|
232 |
final Iterator<String> res = xmlDatabase.xquery(query);
|
|
233 |
if (res == null) return new ArrayList<>(); |
|
245 | 234 |
|
246 | 235 |
final ArrayList<String> ans = new ArrayList<String>(); |
247 |
for (int i = 0; i < res.getSize(); i++) { |
|
248 |
ans.add(res.get(i)); |
|
249 |
} |
|
236 |
Iterators.addAll(ans, res); |
|
250 | 237 |
return ans; |
251 | 238 |
} catch (XMLDBException e) { |
252 | 239 |
log.fatal("searching", e); |
... | ... | |
267 | 254 |
/** |
268 | 255 |
* {@inheritDoc} |
269 | 256 |
* |
270 |
* @see eu.dnetlib.enabling.is.store.rmi.ISStoreService#searchXML(java.lang.String) |
|
271 |
*/ |
|
272 |
@Override |
|
273 |
public W3CEndpointReference searchXML(final String query) throws ISStoreException { |
|
274 |
log.debug(query); |
|
275 |
try { |
|
276 |
return resultSetFactory.createResultSet(new ISStoreResultSetListener(xmlDatabase.xquery(query))); |
|
277 |
} catch (XMLDBException e) { |
|
278 |
throw new ISStoreException(e); |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* {@inheritDoc} |
|
284 |
* |
|
285 | 257 |
* @see eu.dnetlib.enabling.is.store.rmi.ISStoreService#sync() |
286 | 258 |
*/ |
287 | 259 |
@Override |
Also available in: Unified diff
migrated to dnet45, using updated mockito version in tests