StorageConfiguration storageConfiguration = storageConfigurationService.get(id);
if (storageConfiguration != null) {
if (!model.containsAttribute("storageForm")) {
StorageForm storageForm = new StorageForm();
storageForm.setId(storageConfiguration.getId());
storageForm.setBaseLocation(storageConfiguration.getBaseLocation());
storageForm.setName(storageConfiguration.getName());
storageForm.setStorageType(storageConfiguration.getStorageType());
storageForm.setRegistrationDefault(storageConfiguration.isRegistrationDefault());
storageForm.setEditing(true);
if(storageConfiguration instanceof S3StorageConfiguration) {
storageForm.setAccessKey(((S3StorageConfiguration) storageConfiguration).getAccessKey());
storageForm.setSecretKey(((S3StorageConfiguration) storageConfiguration).getSecretKey());
storageForm.setBucketName(((S3StorageConfiguration) storageConfiguration).getBucketName());
}
model.addAttribute("storageForm", storageForm);
} else {
((StorageForm) model.asMap().get("storageForm")).setStorageType(storageConfiguration.getStorageType());