use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class FileSnapshotService method queryDBSnapshotExports.
private List<FileExportRule> queryDBSnapshotExports(Snapshot snapshot) {
_log.info("Querying all ExportRules Using Snapshot Id {}", snapshot.getId());
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getSnapshotExportRulesConstraint(snapshot.getId());
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 FilePolicyService method queryDBReplicationTopologies.
private List<FileReplicationTopology> queryDBReplicationTopologies(FilePolicy policy) {
_log.info("Querying all DB replication topologies Using policy Id {}", policy.getId());
try {
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileReplicationPolicyTopologyConstraint(policy.getId());
List<FileReplicationTopology> topologies = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileReplicationTopology.class, containmentConstraint);
return topologies;
} 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 ModelClientImpl method findBy.
@Override
public <T extends DataObject> List<NamedElement> findBy(Class<T> clazz, String columnField, URI id) throws DatabaseException {
LOG.debug("findBy({}, {}, {})", new Object[] { clazz, columnField, id });
DataObjectType doType = TypeMap.getDoType(clazz);
ColumnField field = doType.getColumnField(columnField);
ContainmentConstraint constraint = new ContainmentConstraintImpl(id, clazz, field);
return queryNamedElementsByConstraint(constraint);
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class DbClientGeoTest method testLocalRefToGeo.
@Test
public void testLocalRefToGeo() {
_logger.info("Starting testLocalRefToGeo");
// FileShare is local
FileShare fs1 = new FileShare();
fs1.setId(URIUtil.createId(FileShare.class));
fs1.setLabel("testfs1");
fs1.setNativeGuid(UUID.randomUUID().toString());
// project is geo
Project pj1 = new Project();
pj1.setId(URIUtil.createId(Project.class));
pj1.setLabel("testpj1");
pj1.setTenantOrg(new NamedURI(rootTenant.getId(), "testpj1"));
fs1.setProject(new NamedURI(pj1.getId(), "project"));
DbClient dbClient = getDbClient();
dbClient.createObject(pj1);
dbClient.createObject(fs1);
Project queriedPj = dbClient.queryObject(Project.class, pj1.getId());
Assert.assertNotNull(queriedPj);
Assert.assertTrue(queriedPj.getId().equals(pj1.getId()));
Assert.assertTrue(isItWhereItShouldBe(queriedPj));
Assert.assertTrue(getDbClient().queryByType(Project.class, true).iterator().hasNext());
FileShare queriedFs = dbClient.queryObject(FileShare.class, fs1.getId());
Assert.assertNotNull(queriedFs);
Assert.assertTrue(queriedFs.getId().equals(fs1.getId()));
Assert.assertTrue(isItWhereItShouldBe(queriedFs));
Assert.assertTrue(getDbClient().queryByType(FileShare.class, true).iterator().hasNext());
// get fileshare by project tests global index into a local cf
ContainmentConstraint fcc = ContainmentConstraint.Factory.getProjectFileshareConstraint(pj1.getId());
URIQueryResultList flist = new URIQueryResultList();
dbClient.queryByConstraint(fcc, flist);
Assert.assertTrue(flist.iterator().hasNext());
// get project by tenant tests global index into another global cf
ContainmentConstraint pcc = ContainmentConstraint.Factory.getTenantOrgProjectConstraint(rootTenant.getId());
URIQueryResultList plist = new URIQueryResultList();
dbClient.queryByConstraint(pcc, plist);
Assert.assertTrue(plist.iterator().hasNext());
dbClient.removeObject(fs1);
URIQueryResultList flist2 = new URIQueryResultList();
dbClient.queryByConstraint(fcc, flist2);
Assert.assertFalse(flist2.iterator().hasNext());
dbClient.removeObject(pj1);
URIQueryResultList plist2 = new URIQueryResultList();
dbClient.queryByConstraint(pcc, plist2);
Iterator<URI> pjItr = plist2.iterator();
while (pjItr.hasNext()) {
if (pjItr.next().equals(pj1.getId())) {
Assert.fail("project found after delete");
}
}
Assert.assertNull(dbClient.queryObject(FileShare.class, fs1.getId()));
Assert.assertNull(dbClient.queryObject(Project.class, pj1.getId()));
}
use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.
the class CifsShareUtility method queryDBShareACLs.
private List<CifsShareACL> queryDBShareACLs() {
try {
ContainmentConstraint containmentConstraint = null;
if (this.fs != null) {
_log.info("Querying DB for Share ACLs of share {} of filesystemId {} ", this.shareName, fs.getId());
containmentConstraint = ContainmentConstraint.Factory.getFileCifsShareAclsConstraint(this.fs.getId());
} else {
// Snapshot
_log.info("Querying DB for Share ACLs of share {} of snapshotId {} ", this.shareName, this.snapshot.getId());
containmentConstraint = ContainmentConstraint.Factory.getSnapshotCifsShareAclsConstraint(this.snapshot.getId());
}
List<CifsShareACL> shareAclList = CustomQueryUtility.queryActiveResourcesByConstraint(this.dbClient, CifsShareACL.class, containmentConstraint);
return shareAclList;
} catch (Exception e) {
_log.error("Error while querying DB for ACL of a share {}", e);
}
return null;
}
Aggregations