Search in sources :

Example 1 with FileSystemShareList

use of com.emc.storageos.model.file.FileSystemShareList in project coprhd-controller by CoprHD.

the class FileService method getFileSystemShareList.

/**
 * Get list of SMB shares for the specified file system.
 *
 * @param id
 *            the URN of a ViPR File system
 * @brief List file system SMB shares
 * @return List of file system shares.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public FileSystemShareList getFileSystemShareList(@PathParam("id") URI id) {
    _log.info(String.format("Get list of SMB file shares for file system: %1$s", id));
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fileShare = queryResource(id);
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    if (fileShare.getInactive()) {
        return fileShareListResponse;
    }
    SMBShareMap smbShareMap = fileShare.getSMBFileShares();
    Collection<SMBFileShare> smbShares = new ArrayList<SMBFileShare>();
    if (smbShareMap != null) {
        smbShares = smbShareMap.values();
    }
    // Process each share from the map and add its data to shares in response list.
    for (SMBFileShare smbShare : smbShares) {
        SmbShareResponse shareParam = new SmbShareResponse();
        shareParam.setShareName(smbShare.getName());
        shareParam.setDescription(smbShare.getDescription());
        shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
        // Check for "unlimited"
        if (shareParam.getMaxUsers().equals("-1")) {
            shareParam.setMaxUsers(UNLIMITED_USERS);
        }
        shareParam.setPermissionType(smbShare.getPermissionType());
        shareParam.setPermission(smbShare.getPermission());
        shareParam.setMountPoint(smbShare.getMountPoint());
        shareParam.setPath(smbShare.getPath());
        fileShareListResponse.getShareList().add(shareParam);
    }
    return fileShareListResponse;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileSystemShareList(com.emc.storageos.model.file.FileSystemShareList) ArrayList(java.util.ArrayList) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with FileSystemShareList

use of com.emc.storageos.model.file.FileSystemShareList in project coprhd-controller by CoprHD.

the class FileService method getFileSystemShare.

/**
 * Get the SMB share for the specified file system.
 *
 * @param id
 *            the URN of a ViPR File system
 * @param shareName
 *            file system share name
 * @brief Show specified share
 * @return List of file system shares.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public SmbShareResponse getFileSystemShare(@PathParam("id") URI id, @PathParam("shareName") String shareName) throws InternalException {
    _log.info(String.format("Get SMB file share %s for file system: %s", shareName, id.toString()));
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    FileShare fileShare = queryResource(id);
    SMBFileShare smbShare = null;
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    SmbShareResponse shareParam = null;
    if (fileShare.getSMBFileShares() != null) {
        _log.info("Number of SMBShares found {} and looking for share to read {} ", fileShare.getSMBFileShares().size(), shareName);
        _log.info(String.format("Get file system share: file system id: %1$s, share name %2$s", id, shareName));
        smbShare = fileShare.getSMBFileShares().get(shareName);
        if (smbShare == null) {
            _log.info("CIFS share does not exist {}", shareName);
        } else {
            shareParam = new SmbShareResponse();
            shareParam.setShareName(smbShare.getName());
            shareParam.setDescription(smbShare.getDescription());
            shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
            // Check for "unlimited"
            if (shareParam.getMaxUsers().equals("-1")) {
                shareParam.setMaxUsers(UNLIMITED_USERS);
            }
            shareParam.setPermissionType(smbShare.getPermissionType());
            shareParam.setPermission(smbShare.getPermission());
            shareParam.setMountPoint(smbShare.getMountPoint());
            shareParam.setPath(smbShare.getPath());
        }
    }
    return shareParam;
}
Also used : FileSystemShareList(com.emc.storageos.model.file.FileSystemShareList) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with FileSystemShareList

use of com.emc.storageos.model.file.FileSystemShareList in project coprhd-controller by CoprHD.

the class FileSnapshotService method getFileSystemShareList.

/**
 * Lists all SMB shares for the specified snapshot.
 *
 * @param id
 *            the URN of a ViPR Snapshot
 * @brief List file snapshot SMB shares
 * @return List of SMB shares
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public FileSystemShareList getFileSystemShareList(@PathParam("id") URI id) {
    _log.info(String.format("Get list of SMB file shares for snapshot: %1$s", id));
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    Snapshot snap = queryResource(id);
    FileSystemShareList fileShareListResponse = new FileSystemShareList();
    if (snap.getInactive()) {
        return fileShareListResponse;
    }
    // Get SMB share map from snapshot
    SMBShareMap smbShareMap = snap.getSMBFileShares();
    Collection<SMBFileShare> smbShares = new ArrayList<SMBFileShare>();
    if (smbShareMap != null) {
        smbShares = smbShareMap.values();
    }
    // Process each share from the map and add its data to shares in response list.
    for (SMBFileShare smbShare : smbShares) {
        SmbShareResponse shareParam = new SmbShareResponse();
        shareParam.setShareName(smbShare.getName());
        shareParam.setDescription(smbShare.getDescription());
        shareParam.setMaxUsers(Integer.toString(smbShare.getMaxUsers()));
        // Check for "unlimited"
        if (shareParam.getMaxUsers().equals("-1")) {
            shareParam.setMaxUsers(FileService.UNLIMITED_USERS);
        }
        shareParam.setPermissionType(smbShare.getPermissionType());
        shareParam.setPermission(smbShare.getPermission());
        shareParam.setMountPoint(smbShare.getMountPoint());
        shareParam.setPath(smbShare.getPath());
        fileShareListResponse.getShareList().add(shareParam);
    }
    return fileShareListResponse;
}
Also used : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileSystemShareList(com.emc.storageos.model.file.FileSystemShareList) ArrayList(java.util.ArrayList) SmbShareResponse(com.emc.storageos.model.file.SmbShareResponse) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 FileSystemShareList (com.emc.storageos.model.file.FileSystemShareList)3 SmbShareResponse (com.emc.storageos.model.file.SmbShareResponse)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)2 ArrayList (java.util.ArrayList)2 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)1 Snapshot (com.emc.storageos.db.client.model.Snapshot)1