Search in sources :

Example 1 with BackupSet

use of com.emc.vipr.model.sys.backup.BackupSets.BackupSet in project coprhd-controller by CoprHD.

the class Backup method itemsJson.

/**
 * Get local backup info
 * @param ids
 */
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SYSTEM_MONITOR"), @Restrict("RESTRICTED_SYSTEM_ADMIN") })
public static void itemsJson(@As(",") String[] ids) {
    List<BackupDataTable.Backup> results = Lists.newArrayList();
    if (ids != null) {
        for (String id : ids) {
            if (StringUtils.isNotBlank(id)) {
                BackupSet backupSet = BackupUtils.getBackup(id);
                if (backupSet != null) {
                    BackupDataTable.Backup backup = new BackupDataTable.Backup(backupSet);
                    BackupRestoreStatus restoreStatus = BackupUtils.getRestoreStatus(id, true);
                    backup.alterLocalBackupRestoreStatus(restoreStatus);
                    results.add(backup);
                }
            }
        }
    }
    renderJSON(results);
}
Also used : BackupDataTable(models.datatable.BackupDataTable) BackupRestoreStatus(com.emc.vipr.model.sys.backup.BackupRestoreStatus) BackupSet(com.emc.vipr.model.sys.backup.BackupSets.BackupSet) Restrictions(controllers.deadbolt.Restrictions)

Example 2 with BackupSet

use of com.emc.vipr.model.sys.backup.BackupSets.BackupSet in project coprhd-controller by CoprHD.

the class BackupDataTable method fetch.

public static List<Backup> fetch(Type type) {
    List<Backup> results = Lists.newArrayList();
    if (type == Type.LOCAL) {
        for (BackupSet backupSet : BackupUtils.getBackups()) {
            Backup backup = new Backup(backupSet);
            BackupInfo backupInfo = BackupUtils.getBackupInfo(backupSet.getName(), true);
            backup.alterLocalBackupInfo(backupInfo);
            results.add(backup);
        }
    } else if (type == Type.REMOTE) {
        try {
            for (String name : BackupUtils.getExternalBackups()) {
                results.add(new Backup(name, true));
            }
        } catch (Exception e) {
            // should trim the error message, otherwise datatable.js#getErrorMessage will fail to parse the response
            throw new RuntimeException(e.getMessage().trim());
        }
    }
    return results;
}
Also used : BackupInfo(com.emc.vipr.model.sys.backup.BackupInfo) BackupSet(com.emc.vipr.model.sys.backup.BackupSets.BackupSet) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

BackupSet (com.emc.vipr.model.sys.backup.BackupSets.BackupSet)2 BackupInfo (com.emc.vipr.model.sys.backup.BackupInfo)1 BackupRestoreStatus (com.emc.vipr.model.sys.backup.BackupRestoreStatus)1 Restrictions (controllers.deadbolt.Restrictions)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BackupDataTable (models.datatable.BackupDataTable)1