Search in sources :

Example 36 with ContainmentConstraint

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;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 37 with ContainmentConstraint

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;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) FileReplicationTopology(com.emc.storageos.db.client.model.FileReplicationTopology)

Example 38 with ContainmentConstraint

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);
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ContainmentConstraintImpl(com.emc.storageos.db.client.constraint.impl.ContainmentConstraintImpl)

Example 39 with ContainmentConstraint

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()));
}
Also used : Project(com.emc.storageos.db.client.model.Project) DbClient(com.emc.storageos.db.client.DbClient) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) NamedURI(com.emc.storageos.db.client.model.NamedURI) FileShare(com.emc.storageos.db.client.model.FileShare) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Test(org.junit.Test)

Example 40 with ContainmentConstraint

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;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Aggregations

ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)47 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)18 ArrayList (java.util.ArrayList)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)15 URI (java.net.URI)15 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)11 URISyntaxException (java.net.URISyntaxException)11 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 FileShare (com.emc.storageos.db.client.model.FileShare)7 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 WorkflowException (com.emc.storageos.workflow.WorkflowException)6 ContainmentConstraintImpl (com.emc.storageos.db.client.constraint.impl.ContainmentConstraintImpl)5 FileMountInfo (com.emc.storageos.db.client.model.FileMountInfo)5 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)4 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)4 ExportRule (com.emc.storageos.model.file.ExportRule)4 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)4