Search in sources :

Example 1 with NameAndModifiedDate

use of com.netflix.exhibitor.core.entities.NameAndModifiedDate in project exhibitor by soabase.

the class IndexResource method getAvailableBackups.

@Path("get-backups")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAvailableBackups() throws Exception {
    Collection<BackupMetaData> backups = context.getExhibitor().getBackupManager().getAvailableBackups();
    Collection<NameAndModifiedDate> transformed = Collections2.transform(backups, new Function<BackupMetaData, NameAndModifiedDate>() {

        @Override
        public NameAndModifiedDate apply(BackupMetaData backup) {
            return new NameAndModifiedDate(backup.getName(), backup.getModifiedDate());
        }
    });
    // move out of Google's TransformingRandomAccessList
    ArrayList<NameAndModifiedDate> cleaned = Lists.newArrayList(transformed);
    GenericEntity<Collection<NameAndModifiedDate>> entity = new GenericEntity<Collection<NameAndModifiedDate>>(cleaned) {
    };
    return Response.ok(entity).build();
}
Also used : BackupMetaData(com.netflix.exhibitor.core.backup.BackupMetaData) GenericEntity(javax.ws.rs.core.GenericEntity) Collection(java.util.Collection) NameAndModifiedDate(com.netflix.exhibitor.core.entities.NameAndModifiedDate) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

BackupMetaData (com.netflix.exhibitor.core.backup.BackupMetaData)1 NameAndModifiedDate (com.netflix.exhibitor.core.entities.NameAndModifiedDate)1 Collection (java.util.Collection)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 GenericEntity (javax.ws.rs.core.GenericEntity)1