Search in sources :

Example 26 with ContainmentConstraint

use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.

the class FileOperationUtils method queryDBFSExports.

public static List<FileExportRule> queryDBFSExports(FileShare fs, DbClient dbClient) {
    _log.info("Querying all ExportRules Using FsId {}", fs.getId());
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileExportRulesConstraint(fs.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)

Example 27 with ContainmentConstraint

use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.

the class InternalDbClientImpl method getReferUris.

public List<URI> getReferUris(URI targetUri, Class<? extends DataObject> type, Dependency dependency) {
    List<URI> references = new ArrayList<>();
    if (targetUri == null) {
        return references;
    }
    ContainmentConstraint constraint = new ContainmentConstraintImpl(targetUri, dependency.getType(), dependency.getColumnField());
    URIQueryResultList result = new URIQueryResultList();
    this.queryByConstraint(constraint, result);
    Iterator<URI> resultIt = result.iterator();
    if (resultIt.hasNext()) {
        references.add(resultIt.next());
    }
    return references;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ContainmentConstraintImpl(com.emc.storageos.db.client.constraint.impl.ContainmentConstraintImpl) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 28 with ContainmentConstraint

use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.

the class BourneDbClient method findBy.

public <T extends DataObject> List<NamedElement> findBy(Class<T> clazz, String columnField, URI id) throws DataAccessException {
    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) ColumnField(com.emc.storageos.db.client.impl.ColumnField) DataObjectType(com.emc.storageos.db.client.impl.DataObjectType)

Example 29 with ContainmentConstraint

use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.

the class FileOrchestrationUtils method queryShareACLs.

/**
 * This method queries ACLs for File System share.
 *
 * @param shareName Name of the share.
 * @param fs URI of the file system.
 * @param dbClient
 * @return ListShareACL
 */
public static List<ShareACL> queryShareACLs(String shareName, URI fs, DbClient dbClient) {
    List<ShareACL> aclList = new ArrayList<ShareACL>();
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileCifsShareAclsConstraint(fs);
    List<CifsShareACL> shareAclList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, CifsShareACL.class, containmentConstraint);
    if (shareAclList != null) {
        Iterator<CifsShareACL> shareAclIter = shareAclList.iterator();
        while (shareAclIter.hasNext()) {
            CifsShareACL dbShareAcl = shareAclIter.next();
            if (shareName.equals(dbShareAcl.getShareName())) {
                ShareACL acl = new ShareACL();
                acl.setShareName(shareName);
                acl.setDomain(dbShareAcl.getDomain());
                acl.setUser(dbShareAcl.getUser());
                acl.setGroup(dbShareAcl.getGroup());
                acl.setPermission(dbShareAcl.getPermission());
                acl.setFileSystemId(fs);
                aclList.add(acl);
            }
        }
    }
    return aclList;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) CifsShareACL(com.emc.storageos.db.client.model.CifsShareACL)

Example 30 with ContainmentConstraint

use of com.emc.storageos.db.client.constraint.ContainmentConstraint in project coprhd-controller by CoprHD.

the class FileOrchestrationUtils method queryNFSACL.

public static Map<String, List<NfsACE>> queryNFSACL(FileShare fs, DbClient dbClient) {
    Map<String, List<NfsACE>> map = new HashMap<String, List<NfsACE>>();
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileNfsAclsConstraint(fs.getId());
    List<NFSShareACL> nfsAclList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, NFSShareACL.class, containmentConstraint);
    if (nfsAclList != null) {
        Iterator<NFSShareACL> aclIter = nfsAclList.iterator();
        while (aclIter.hasNext()) {
            NFSShareACL dbNFSAcl = aclIter.next();
            String fsPath = dbNFSAcl.getFileSystemPath();
            NfsACE ace = convertNFSShareACLToNfsACE(dbNFSAcl);
            if (map.get(fsPath) == null) {
                List<NfsACE> acl = new ArrayList<NfsACE>();
                acl.add(ace);
                map.put(fsPath, acl);
            } else {
                map.get(fsPath).add(ace);
            }
        }
    }
    return map;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) NfsACE(com.emc.storageos.model.file.NfsACE) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL)

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