1
|
package eu.dnetlib.openaire.exporter.datasource.clients;
|
2
|
|
3
|
import java.util.Queue;
|
4
|
|
5
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
|
6
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
|
7
|
import org.apache.commons.lang.StringUtils;
|
8
|
import org.apache.commons.logging.Log;
|
9
|
import org.apache.commons.logging.LogFactory;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
import org.springframework.stereotype.Component;
|
12
|
|
13
|
@Component
|
14
|
public class ObjectStoreClient {
|
15
|
|
16
|
private static final Log log = LogFactory.getLog(ObjectStoreClient.class);
|
17
|
|
18
|
@Autowired
|
19
|
private ObjectStoreService objectStoreService;
|
20
|
|
21
|
public Long getObjectStoreSize(final String objectStoreId, final Queue<Throwable> errors) {
|
22
|
log.debug("get size for objectStore " + objectStoreId);
|
23
|
if (StringUtils.isBlank(objectStoreId)) {
|
24
|
return 0L;
|
25
|
}
|
26
|
try {
|
27
|
final long size = objectStoreService.getSize(objectStoreId);
|
28
|
log.debug("got objectStore size: " + size);
|
29
|
return size;
|
30
|
} catch (ObjectStoreServiceException e) {
|
31
|
errors.add(e);
|
32
|
return 0L;
|
33
|
}
|
34
|
}
|
35
|
|
36
|
}
|