use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method queryExports.
private List<FileExportRule> queryExports(FileShare fs, Snapshot snapshot, boolean isFile) {
try {
ContainmentConstraint containmentConstraint;
if (isFile) {
_log.info("Querying all ExportRules Using FsId {}", fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.getId());
} else {
URI snapshotId = snapshot.getId();
_log.info("Querying all ExportRules Using Snapshot Id {}", snapshotId);
containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshotId);
}
List<FileExportRule> fileExportRules = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileExportRule.class, containmentConstraint);
return fileExportRules;
} catch (Exception e) {
_log.error("Error while querying {}", e);
}
return null;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class NfsACLUtility method queryDBSFileNfsACLs.
/**
* Get the list of DB Object for current file System
*
* @param allDirs if true function will return complete list of ACL including its SubDir
* @return list of NFS ACLs
*/
private List<NFSShareACL> queryDBSFileNfsACLs(boolean allDirs) {
try {
ContainmentConstraint containmentConstraint = null;
if (this.fs != null) {
_log.info("Querying DB for Nfs ACLs of fs{} of filesystemId {} ", this.fs.getPath(), fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileNfsAclsConstraint(this.fs.getId());
} else {
// Snapshot
_log.info("Querying DB for Nfs ACLs of fs {} of snapshotId {} ", this.snapShot.getPath(), this.snapShot.getId());
containmentConstraint = ContainmentConstraint.Factory.getSnapshotNfsAclsConstraint(this.snapShot.getId());
}
List<NFSShareACL> nfsAclList = CustomQueryUtility.queryActiveResourcesByConstraint(this.dbClient, NFSShareACL.class, containmentConstraint);
if (allDirs) {
return nfsAclList;
}
List<NFSShareACL> rootAclList = new ArrayList<NFSShareACL>();
List<NFSShareACL> subDirAclList = new ArrayList<NFSShareACL>();
String absoluteSubdir = "";
if (this.subDir != null && !this.subDir.isEmpty()) {
absoluteSubdir = this.fs.getPath() + "/" + subDir;
}
for (NFSShareACL nfsAcl : nfsAclList) {
if (nfsAcl.getFileSystemPath().equals(fs.getPath())) {
rootAclList.add(nfsAcl);
}
if (!absoluteSubdir.isEmpty()) {
if (nfsAcl.getFileSystemPath().equals(absoluteSubdir)) {
subDirAclList.add(nfsAcl);
}
}
}
if (!absoluteSubdir.isEmpty()) {
_log.info("Found {} Nfs ACLs for subdir {} ", subDirAclList.size(), this.subDir);
return subDirAclList;
}
_log.info("Found {} Nfs ACLs ", rootAclList.size());
return rootAclList;
} catch (Exception e) {
_log.error("Error while querying DB for ACL of a NFS {}", e);
}
return null;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class ECSObjectStorageDevice method queryDbBucketACL.
private List<ObjectBucketACL> queryDbBucketACL(Bucket bucket) {
try {
ContainmentConstraint containmentConstraint = null;
_log.info("Querying DB for ACL of bucket {} ", bucket.getName());
containmentConstraint = ContainmentConstraint.Factory.getBucketAclsConstraint(bucket.getId());
List<ObjectBucketACL> dbBucketBucketAcl = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ObjectBucketACL.class, containmentConstraint);
return dbBucketBucketAcl;
} catch (Exception e) {
_log.error("Error while querying DB for ACL of a bucket {}", e);
}
return null;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileReplicationPolicyUpdateTargetPoolMigration method queryDBReplicationTopologies.
private List<FileReplicationTopology> queryDBReplicationTopologies(FilePolicy policy) {
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileReplicationPolicyTopologyConstraint(policy.getId());
List<FileReplicationTopology> topologies = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileReplicationTopology.class, containmentConstraint);
return topologies;
} catch (Exception e) {
logger.error("Error while querying {}", e);
}
return null;
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class DbIndexTest method verifyRelationDbIndex.
private void verifyRelationDbIndex(DataObject obj, ColumnField field, Object val, boolean indexByKey, DbClient client) {
switch(field.getType()) {
case Primitive:
{
ContainmentConstraint constraint = new ContainmentConstraintImpl((URI) val, obj.getClass(), field);
verifyContain(constraint, obj.getId(), -1, client);
}
break;
case TrackingMap:
for (String key : ((AbstractChangeTrackingMap<String>) val).keySet()) {
ContainmentConstraint constraint = new ContainmentConstraintImpl(URI.create(key), obj.getClass(), field);
verifyContain(constraint, obj.getId(), -1, client);
}
break;
case TrackingSet:
for (String key : (AbstractChangeTrackingSet<String>) val) {
ContainmentConstraint constraint = new ContainmentConstraintImpl(URI.create(key), obj.getClass(), field);
verifyContain(constraint, obj.getId(), -1, client);
}
break;
case Id:
case NamedURI:
case NestedObject:
case TrackingSetMap:
default:
throw new IllegalArgumentException(String.format("Field type %s is not supported by RelationDbIndex", field.getType().toString()));
}
}
Aggregations