store = imageStoreDao.persist(store);
return store;
}
public ImageStoreVO createImageStore(Map<String, Object> params, Map<String, String> details) {
ImageStoreVO store = imageStoreDao.findByName((String) params.get("name"));
if (store != null) {
return store;
}
store = new ImageStoreVO();
store.setProtocol((String) params.get("protocol"));
store.setProviderName((String) params.get("providerName"));
store.setScope((ScopeType) params.get("scope"));
store.setDataCenterId((Long) params.get("zoneId"));
String uuid = (String) params.get("uuid");
if (uuid != null) {
store.setUuid(uuid);
} else {
store.setUuid(UUID.randomUUID().toString());
}
store.setUrl((String) params.get("url"));
store.setName((String) params.get("name"));
if (store.getName() == null) {
store.setName(store.getUuid());
}
store.setRole((DataStoreRole) params.get("role"));
store = imageStoreDao.persist(store);
// persist details
if (details != null) {
Iterator<String> keyIter = details.keySet().iterator();
while (keyIter.hasNext()) {
String key = keyIter.next().toString();
ImageStoreDetailVO detail = new ImageStoreDetailVO();
detail.setStoreId(store.getId());
detail.setName(key);
detail.setValue(details.get(key));
imageStoreDetailsDao.persist(detail);
}
}