use of org.sagebionetworks.repo.model.MigratableObjectCount in project Synapse-Repository-Services by Sage-Bionetworks.
the class AdministrationServiceImpl method getAllBackupObjectsCounts.
/* (non-Javadoc)
* @see org.sagebionetworks.repo.web.service.AdministrationService#getAllBackupObjectsCounts(java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Boolean)
*/
@Override
public PaginatedResults<MigratableObjectCount> getAllBackupObjectsCounts(String userId) throws DatastoreException, UnauthorizedException, NotFoundException {
UserInfo userInfo = userManager.getUserInfo(userId);
if (!userInfo.isAdmin())
throw new UnauthorizedException("Only an administrator may access this service.");
QueryResults<MigratableObjectCount> queryResults = dependencyManager.getAllObjectsCounts();
PaginatedResults<MigratableObjectCount> result = new PaginatedResults<MigratableObjectCount>();
result.setResults(queryResults.getResults());
result.setTotalNumberOfResults(queryResults.getTotalNumberOfResults());
return result;
}
use of org.sagebionetworks.repo.model.MigratableObjectCount in project Synapse-Repository-Services by Sage-Bionetworks.
the class StackStatusPresenter method run.
@Override
public void run() {
// Any work we do here is off of the event dispatch thread, so we will need SwingUtilties to talk to the view.
while (true) {
try {
// Start the progress
int totalProgress = EntityType.values().length + 3;
int current = 0;
resetProgress(current, totalProgress, "Authenticating...");
// Connect
ClientFactoryImpl factory = new ClientFactoryImpl();
SynapseAdministration client = factory.createNewConnection(this.connectionInfo);
// Get the status
setProgressValue(current++, "Getting stack status...");
StackStatus status = client.getCurrentStackStatus();
setStackStatus(status.getStatus().name());
QueryRunner queryRunner = new QueryRunnerImpl(client);
// TODO: Move to query runner to remove dependency on PaginatedResults/MigratableObjectCount
try {
PaginatedResults<MigratableObjectCount> moc = client.getMigratableObjectCounts();
for (MigratableObjectCount oc : moc.getResults()) {
setCountForEntity(MigratableObjectType.valueOf(oc.getObjectType()), oc.getCount());
}
} catch (Exception e) {
log.debug("API getMigratableObjectCounts not implemented on repository" + client.getRepoEndpoint());
}
// Make some progress
setProgressValue(current++, "Querying for total entity count...");
// Count the total number of entities
long total = queryRunner.getTotalEntityCount();
setTotalCount(total);
// Finished
setProgressValue(totalProgress, "Waiting for next run...");
Thread.sleep(20000);
} catch (final Exception e) {
// Log the error and show it to the user
log.error(e);
// Show the error to the user
showError(e);
try {
Thread.sleep(1000 * 60);
} catch (InterruptedException e1) {
// terminate
return;
}
}
}
}
use of org.sagebionetworks.repo.model.MigratableObjectCount in project Synapse-Repository-Services by Sage-Bionetworks.
the class SynapseAdministrationTest method testGetMigratableObjectCounts.
@Test
public void testGetMigratableObjectCounts() throws Exception {
PaginatedResults<MigratableObjectCount> p = new PaginatedResults<MigratableObjectCount>();
String expectedJSONResult = EntityFactory.createJSONStringForEntity(p);
StringEntity responseEntity = new StringEntity(expectedJSONResult);
when(mockResponse.getEntity()).thenReturn(responseEntity);
PaginatedResults<MigratableObjectCount> oc = synapse.getMigratableObjectCounts();
assertNotNull(oc);
assertEquals(p, oc);
}
use of org.sagebionetworks.repo.model.MigratableObjectCount in project Synapse-Repository-Services by Sage-Bionetworks.
the class SynapseAdministration method getMigratableObjectCounts.
public PaginatedResults<MigratableObjectCount> getMigratableObjectCounts() throws SynapseException {
String uri = GET_ALL_BACKUP_COUNTS;
JSONObject o = getEntity(uri);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(o);
PaginatedResults<MigratableObjectCount> rs = new PaginatedResults<MigratableObjectCount>(MigratableObjectCount.class);
try {
rs.initializeFromJSONObject(adapter);
return rs;
} catch (JSONObjectAdapterException e) {
throw new SynapseException(e);
}
}
use of org.sagebionetworks.repo.model.MigratableObjectCount in project Synapse-Repository-Services by Sage-Bionetworks.
the class DependencyManagerImpl method getAllObjectsCounts.
@Override
public QueryResults<MigratableObjectCount> getAllObjectsCounts() throws DatastoreException {
List<MigratableObjectCount> ods = new ArrayList<MigratableObjectCount>();
long total = 0L;
for (MigratableDAO migratableDAO : getMigratableDaos()) {
long c = migratableDAO.getCount();
MigratableObjectCount moc = new MigratableObjectCount();
moc.setCount(c);
moc.setObjectType(migratableDAO.getMigratableObjectType().name());
ods.add(moc);
total += 1;
}
QueryResults<MigratableObjectCount> queryResults = new QueryResults<MigratableObjectCount>();
queryResults.setResults(ods);
queryResults.setTotalNumberOfResults((int) total);
return queryResults;
}
Aggregations