public static APIGetTrashOnBackupStorageReply __example__() { APIGetTrashOnBackupStorageReply reply = new APIGetTrashOnBackupStorageReply(); StorageTrashSpec spec = new StorageTrashSpec(uuid(), "ImageVO", uuid(), "BackupStorageVO", "/zstack_bs/installpath", 1024000L); spec.setTrashId(1L); spec.setTrashType("MigrateImage"); spec.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); reply.setStorageTrashSpecs(asList(spec)); return reply; } }
public static APIGetTrashOnPrimaryStorageReply __example__() { APIGetTrashOnPrimaryStorageReply reply = new APIGetTrashOnPrimaryStorageReply(); StorageTrashSpec spec1 = new StorageTrashSpec(uuid(), "VolumeVO", uuid(), "PrimaryStorageVO", "/zstack_ps/installpath", 1024000L); spec1.setTrashId(1L); spec1.setTrashType("MigrateVolume"); spec1.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); StorageTrashSpec spec2 = new StorageTrashSpec(uuid(), "VolumeSnapshotVO", uuid(), "PrimaryStorageVO", "/zstack_ps/installpath/snapshot", 1024000L); spec2.setTrashId(2L); spec2.setTrashType("MigrateVolumeSnapshot"); spec2.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); reply.setStorageTrashSpecs(asList(spec1, spec2)); return reply; } }
@Override public Map<String, StorageTrashSpec> getTrashList(String storageUuid, List<TrashType> types) { Map<String, StorageTrashSpec> specs = new HashMap<>(); for (TrashType type: types) { List<JsonLabelVO> labels = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).like(JsonLabelVO_.labelKey, type.toString() + "-%").list(); labels.forEach(l -> { StorageTrashSpec spec = JSONObjectUtil.toObject(l.getLabelValue(), StorageTrashSpec.class); spec.setTrashId(l.getId()); spec.setCreateDate(l.getCreateDate()); if (spec.getTrashType() == null) { spec.setTrashType(type.toString()); } specs.put(l.getLabelKey(), spec); }); } return specs; }
@Override public StorageTrashSpec getTrash(String storageUuid, Long trashId) { JsonLabelVO lable = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).eq(JsonLabelVO_.id, trashId).find(); if (lable == null) { return null; } StorageTrashSpec spec = JSONObjectUtil.toObject(lable.getLabelValue(), StorageTrashSpec.class); spec.setTrashId(trashId); spec.setCreateDate(lable.getCreateDate()); if (spec.getTrashType() == null) { spec.setTrashType(lable.getLabelKey().split("-")[0]); } return spec; }