public static class RevertVolumeFromSnapshotRsp extends AgentRsp { @Validation public String newVolumeInstallPath; @Validation protected long size; }
private void populateExtensions() { for (Validator ext : pluginRgty.getExtensionList(Validator.class)) { for (Class clazz : ext.supportedClasses()) { List<Validator> vs = validators.get(clazz); if (vs == null) { vs = new ArrayList<Validator>(); validators.put(clazz, vs); } vs.add(ext); } } }
private String validate(Object obj, Field f) { try { f.setAccessible(true); Object value = f.get(obj); Validation at = f.getAnnotation(Validation.class); if (at.notNull() && value == null) { return error(obj, f, "field can not be null"); } if (at.notZero() && TypeUtils.isTypeOf(value, Integer.TYPE, Integer.class, Long.TYPE, Long.class)) { if (value != null) { long intValue = Long.valueOf(value.toString()); if (intValue == 0) { return error(obj, f, "field can not be zero"); } } } return null; } catch (Exception e) { throw new CloudRuntimeException(e); } }
@Override public ErrorCode validateErrorByErrorCode(Object obj) { if (obj instanceof ConditionalValidation) { ConditionalValidation cond = (ConditionalValidation) obj; if (!cond.needValidation()) { return null; } } List<Class> classes = TypeUtils.getAllClassOfObject(obj); for (Class clz : classes) { List<Validator> vs = validators.get(clz); if (vs != null) { for (Validator v : vs) { String err = v.validate(obj); if (err != null) { return inerr(err); } } } } return null; }
public static class ReinitImageRsp extends AgentResponse { @Validation private String newVolumeInstallPath; public String getNewVolumeInstallPath() { return newVolumeInstallPath; } public void setNewVolumeInstallPath(String newVolumeInstallPath) { this.newVolumeInstallPath = newVolumeInstallPath; } }
public static class ReInitImageRsp extends NfsPrimaryStorageAgentResponse { @Validation private String newVolumeInstallPath; public String getNewVolumeInstallPath() { return newVolumeInstallPath; } public void setNewVolumeInstallPath(String newVolumeInstallPath) { this.newVolumeInstallPath = newVolumeInstallPath; } }
public static class RollbackSnapshotRsp extends AgentResponse { @Validation long size; public long getSize() { return size; } public void setSize(long size) { this.size = size; } }
public static class ReInitImageRsp extends AgentRsp { @Validation public String newVolumeInstallPath; }
public static class RevertVolumeFromSnapshotResponse extends NfsPrimaryStorageAgentResponse { @Validation private String newVolumeInstallPath; @Validation private long size; public String getNewVolumeInstallPath() { return newVolumeInstallPath; } public void setNewVolumeInstallPath(String newVolumeInstallPath) { this.newVolumeInstallPath = newVolumeInstallPath; } public long getSize() { return size; } public void setSize(long size) { this.size = size; } }
public static class RevertVolumeFromSnapshotRsp extends AgentResponse { @Validation private String newVolumeInstallPath; @Validation private long size; public String getNewVolumeInstallPath() { return newVolumeInstallPath; } public void setNewVolumeInstallPath(String newVolumeInstallPath) { this.newVolumeInstallPath = newVolumeInstallPath; } public long getSize() { return size; } public void setSize(long size) { this.size = size; } }
public static class TakeSnapshotResponse extends AgentResponse { @Validation private String newVolumeInstallPath; @Validation private String snapshotInstallPath; @Validation(notZero = true) private long size; public long getSize() { return size; } public void setSize(long size) { this.size = size; } public String getSnapshotInstallPath() { return snapshotInstallPath; } public void setSnapshotInstallPath(String snapshotInstallPath) { this.snapshotInstallPath = snapshotInstallPath; } public String getNewVolumeInstallPath() { return newVolumeInstallPath; } public void setNewVolumeInstallPath(String newVolumeInstallPath) { this.newVolumeInstallPath = newVolumeInstallPath; } }