Search in sources :

Example 1 with DriverRegistryRecord

use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.

the class RegistryImpl method clearDriverAttributes.

@Override
public void clearDriverAttributes(String driverName) {
    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);
        dbClient.markForDeletion(registryEntry);
    }
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with DriverRegistryRecord

use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.

the class RegistryImpl method clearDriverAttributeForKey.

@Override
public void clearDriverAttributeForKey(String driverName, String key, String attribute) {
    validateRegistryRequest(driverName, key);
    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)) {
            // remove attribute from registry entry attribute map
            registryEntry.getAttributes().remove(attribute);
            if (registryEntry.getAttributes().isEmpty()) {
                dbClient.markForDeletion(registryEntry);
            } else {
                dbClient.updateObject(registryEntry);
            }
            break;
        }
    }
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with DriverRegistryRecord

use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.

the class RegistryImpl method getDriverAttributesForKey.

@Override
public Map<String, List<String>> getDriverAttributesForKey(String driverName, String key) {
    validateRegistryRequest(driverName, key);
    Map<String, List<String>> attributesMap = new HashMap<>();
    // find existing entry for driver name and a given key
    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)) {
            StringSetMap attributes = registryEntry.getAttributes();
            for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : attributes.entrySet()) {
                attributesMap.put(entry.getKey(), new ArrayList<>(entry.getValue()));
            }
            break;
        }
    }
    return attributesMap;
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 4 with DriverRegistryRecord

use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.

the class RegistryImpl method getDriverAttributes.

@Override
public Map<String, Map<String, List<String>>> getDriverAttributes(String driverName) {
    Map<String, Map<String, List<String>>> keyMap = new HashMap<>();
    // find existing entries for driver name
    URIQueryResultList registryEntriesUris = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
    while (registryEntriesUris.iterator().hasNext()) {
        Map<String, List<String>> attributesMap = new HashMap<>();
        URI registryEntryUri = registryEntriesUris.iterator().next();
        DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
        StringSetMap attributes = registryEntry.getAttributes();
        for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : attributes.entrySet()) {
            attributesMap.put(entry.getKey(), new ArrayList<>(entry.getValue()));
        }
        keyMap.put(registryEntry.getRegistryKey(), attributesMap);
    }
    return keyMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 5 with DriverRegistryRecord

use of com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord in project coprhd-controller by CoprHD.

the class RegistryImpl method clearDriverAttributesForKey.

@Override
public void clearDriverAttributesForKey(String driverName, String key) {
    validateRegistryRequest(driverName, key);
    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)) {
            // remove this entry from db
            dbClient.markForDeletion(registryEntry);
            break;
        }
    }
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 DriverRegistryRecord (com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord)7 URI (java.net.URI)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)2 StringSet (com.emc.storageos.db.client.model.StringSet)2