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 eu.dnetlib.enabling.datasources.common.DatasourceManagerException;
|
8
|
import org.apache.commons.lang.StringUtils;
|
9
|
import org.apache.commons.logging.Log;
|
10
|
import org.apache.commons.logging.LogFactory;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.stereotype.Component;
|
13
|
|
14
|
@Component
|
15
|
public class ObjectStoreClient {
|
16
|
|
17
|
private static final Log log = LogFactory.getLog(ObjectStoreClient.class);
|
18
|
|
19
|
@Autowired
|
20
|
private ObjectStoreService objectStoreService;
|
21
|
|
22
|
public Long getObjectStoreSize(final String objectStoreId, final Queue<Throwable> errors) {
|
23
|
log.debug("get size for objectStore " + objectStoreId);
|
24
|
if (StringUtils.isBlank(objectStoreId)) {
|
25
|
return -1L;
|
26
|
}
|
27
|
try {
|
28
|
final long size = objectStoreService.getSize(objectStoreId);
|
29
|
log.debug("got objectStore size: " + size);
|
30
|
return size;
|
31
|
} catch (ObjectStoreServiceException e) {
|
32
|
errors.add(e);
|
33
|
return -1L;
|
34
|
}
|
35
|
}
|
36
|
|
37
|
}
|