Search in sources :

Example 11 with ContainmentConstraint

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

Example 12 with ContainmentConstraint

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

Example 13 with ContainmentConstraint

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;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ECSException(com.emc.storageos.ecs.api.ECSException) ObjectBucketACL(com.emc.storageos.db.client.model.ObjectBucketACL)

Example 14 with ContainmentConstraint

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

Example 15 with ContainmentConstraint

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

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