use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.
the class RegistryImpl method addDriverAttributeForKey.
@Override
public void addDriverAttributeForKey(String driverName, String key, String attribute, List<String> value) {
validateRegistryRequest(driverName, key);
DriverRegistryRecord registryEntryForKey = null;
// find existing entry for a driver name and a given key
boolean existingKey = false;
URIQueryResultList registryEntriesUris = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
while (registryEntriesUris.iterator().hasNext()) {
URI registryEntryUri = registryEntriesUris.iterator().next();
registryEntryForKey = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
if (registryEntryForKey.getRegistryKey().equals(key)) {
existingKey = true;
StringSetMap attributes = registryEntryForKey.getAttributes();
StringSet attributeValue = new StringSet(value);
updateAttributeInMap(attributes, attribute, attributeValue);
break;
}
}
if (existingKey == false) {
// no entry for this key in the registry, create a new entry
registryEntryForKey = new DriverRegistryRecord();
registryEntryForKey.setId(URIUtil.createId(DriverRegistryRecord.class));
registryEntryForKey.setDriverName(driverName);
registryEntryForKey.setRegistryKey(key);
StringSetMap attributesMap = new StringSetMap();
StringSet values = new StringSet(value);
updateAttributeInMap(attributesMap, attribute, values);
registryEntryForKey.setAttributes(attributesMap);
}
// update db
if (existingKey) {
dbClient.updateObject(registryEntryForKey);
} else {
dbClient.createObject(registryEntryForKey);
}
}
use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.
the class RegistryImpl method setDriverAttributesForKey.
@Override
public void setDriverAttributesForKey(String driverName, String key, Map<String, List<String>> attributes) {
validateRegistryRequest(driverName, key);
DriverRegistryRecord registryEntryForKey = null;
// find existing entry for driver name and a given key
boolean existingEntry = false;
URIQueryResultList registryEntriesUris = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
while (registryEntriesUris.iterator().hasNext()) {
URI registryEntryUri = registryEntriesUris.iterator().next();
DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
if (registryEntry.getRegistryKey().equals(key)) {
registryEntryForKey = registryEntry;
existingEntry = true;
break;
}
}
// have not find existing driver registry entry for a key, create a new entry for this key
if (registryEntryForKey == null) {
registryEntryForKey = new DriverRegistryRecord();
registryEntryForKey.setId(URIUtil.createId(DriverRegistryRecord.class));
registryEntryForKey.setDriverName(driverName);
registryEntryForKey.setRegistryKey(key);
}
// update/add attribute map for the key entry
StringSetMap attributesMap = new StringSetMap();
for (Map.Entry<String, List<String>> entry : attributes.entrySet()) {
StringSet values = new StringSet(entry.getValue());
updateAttributeInMap(attributesMap, entry.getKey(), values);
}
registryEntryForKey.setAttributes(attributesMap);
if (existingEntry) {
dbClient.updateObject(registryEntryForKey);
} else {
dbClient.createObject(registryEntryForKey);
}
}
Aggregations