Search in sources :

Example 1 with CifsShareUtility

use of com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility in project coprhd-controller by CoprHD.

the class FileSnapshotService method getSnapshotShareACLs.

/**
 * Get Snapshot Share ACLs
 *
 * @param id
 *            the file system URI
 * @param shareName
 *            name of the share
 * @brief List snapshot share ACLs
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ShareACLs getSnapshotShareACLs(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
    _log.info("Request recieved to get ACLs with Id: {}  shareName: {}", id, shareName);
    // Validate the FS id
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    Snapshot snapshot = queryResource(id);
    ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
    if (!CifsShareUtility.doesShareExist(snapshot, shareName)) {
        _log.error("CIFS share does not exist {}", shareName);
        throw APIException.notFound.invalidParameterObjectHasNoSuchShare(snapshot.getId(), shareName);
    }
    ShareACLs acls = new ShareACLs();
    CifsShareUtility util = new CifsShareUtility(_dbClient, null, snapshot, shareName);
    List<ShareACL> shareAclList = util.queryExistingShareACLs();
    _log.info("Number of existing ACLs found : {} ", shareAclList.size());
    if (!shareAclList.isEmpty()) {
        acls.setShareACLs(shareAclList);
    }
    return acls;
}
Also used : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) ShareACLs(com.emc.storageos.model.file.ShareACLs) CifsShareUtility(com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility) ShareACL(com.emc.storageos.model.file.ShareACL) 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 CifsShareUtility

use of com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility in project coprhd-controller by CoprHD.

the class FileService method getShareACLs.

/**
 * Get File Share ACLs
 *
 * @param id
 *            the file system URI
 * @param shareName
 *            name of the share
 * @brief Show the ACLs for a file share
 * @return ShareACLs
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ShareACLs getShareACLs(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
    _log.info("Request recieved to get ACLs with Id: {}  shareName: {}", id, shareName);
    // Validate the FS id
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    FileShare fs = queryResource(id);
    if (!CifsShareUtility.doesShareExist(fs, shareName)) {
        _log.error("CIFS share does not exist {}", shareName);
        throw APIException.notFound.invalidParameterObjectHasNoSuchShare(fs.getId(), shareName);
    }
    ShareACLs acls = new ShareACLs();
    CifsShareUtility util = new CifsShareUtility(_dbClient, fs, null, shareName);
    List<ShareACL> shareAclList = util.queryExistingShareACLs();
    _log.info("Number of existing ACLs found : {} ", shareAclList.size());
    if (!shareAclList.isEmpty()) {
        acls.setShareACLs(shareAclList);
    }
    return acls;
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs) CifsShareUtility(com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) ShareACL(com.emc.storageos.model.file.ShareACL) 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 CifsShareUtility

use of com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility in project coprhd-controller by CoprHD.

the class FileService method updateShareACL.

/**
 * Update Share ACL
 *
 * API to update ACLs of an existing share
 *
 * @param id
 *            the file system URI
 * @param shareName
 *            name of the share
 * @param param
 *            request payload object of type <code>com.emc.storageos.model.file.CifsShareACLUpdateParams</code>
 * @brief Change the ACLs for a specified file share
 * @return TaskResponse
 * @throws InternalException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateShareACL(@PathParam("id") URI id, @PathParam("shareName") String shareName, FileCifsShareACLUpdateParams param) throws InternalException {
    _log.info("Update file share acl request received. Filesystem: {}, Share: {}", id.toString(), shareName);
    _log.info("Request body: {}", param.toString());
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = queryResource(id);
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    CifsShareUtility.checkForUpdateShareACLOperationOnStorage(device.getSystemType(), OperationTypeEnum.UPDATE_FILE_SYSTEM_SHARE_ACL.name());
    if (!CifsShareUtility.doesShareExist(fs, shareName)) {
        _log.error("CIFS share does not exist {}", shareName);
        throw APIException.notFound.invalidParameterObjectHasNoSuchShare(fs.getId(), shareName);
    }
    String task = UUID.randomUUID().toString();
    // Check for VirtualPool whether it has CIFS enabled
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
    if (!vpool.getProtocols().contains(StorageProtocol.File.CIFS.name())) {
        throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool doesn't support " + StorageProtocol.File.CIFS.name() + " protocol");
    }
    // Validate the input
    CifsShareUtility util = new CifsShareUtility(_dbClient, fs, null, shareName);
    util.verifyShareACLs(param);
    _log.info("Request payload verified. No errors found.");
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.UPDATE_FILE_SYSTEM_SHARE_ACL);
    op.setDescription("Update file system share ACLs");
    FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
    fileServiceApi.updateShareACLs(device.getId(), fs.getId(), shareName, param, task);
    auditOp(OperationTypeEnum.UPDATE_FILE_SYSTEM_SHARE_ACL, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), param);
    return toTask(fs, task, op);
}
Also used : CifsShareUtility(com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with CifsShareUtility

use of com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility in project coprhd-controller by CoprHD.

the class FileSnapshotService method updateSnapshotShareACL.

/**
 * API to update ACLs of an existing share
 *
 * @param id
 *            the file system URI
 * @param shareName
 *            name of the share
 * @param param
 *            request payload object of type <code>com.emc.storageos.model.file.CifsShareACLUpdateParams</code>
 * @brief Change a snapshot share ACL
 * @return TaskResponse
 * @throws InternalException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateSnapshotShareACL(@PathParam("id") URI id, @PathParam("shareName") String shareName, SnapshotCifsShareACLUpdateParams param) throws InternalException {
    _log.info("Update snapshot share acl request received. Snapshot: {}, Share: {}", id.toString(), shareName);
    _log.info("Request body: {}", param.toString());
    ArgValidator.checkFieldNotNull(shareName, "shareName");
    ArgValidator.checkFieldUriType(id, Snapshot.class, "id");
    Snapshot snapshot = queryResource(id);
    ArgValidator.checkEntity(snapshot, id, isIdEmbeddedInURL(id));
    if (!CifsShareUtility.doesShareExist(snapshot, shareName)) {
        _log.error("CIFS share does not exist {}", shareName);
        throw APIException.notFound.invalidParameterObjectHasNoSuchShare(snapshot.getId(), shareName);
    }
    FileShare fs = _permissionsHelper.getObjectById(snapshot.getParent(), FileShare.class);
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    CifsShareUtility.checkForUpdateShareACLOperationOnStorage(device.getSystemType(), OperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL.name());
    String task = UUID.randomUUID().toString();
    // Check for VirtualPool whether it has CIFS enabled
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
    if (!vpool.getProtocols().contains(StorageProtocol.File.CIFS.name())) {
        throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool doesn't support " + StorageProtocol.File.CIFS.name() + " protocol");
    }
    // Validate the input
    CifsShareUtility util = new CifsShareUtility(_dbClient, null, snapshot, shareName);
    util.verifyShareACLs(param);
    _log.info("Request payload verified. No errors found.");
    Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snapshot.getId(), task, ResourceOperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL);
    FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fs, _dbClient);
    fileServiceApi.updateShareACLs(device.getId(), snapshot.getId(), shareName, param, task);
    auditOp(OperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL, true, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), device.getId().toString(), param);
    return toTask(snapshot, task, op);
}
Also used : MapFileSnapshot(com.emc.storageos.api.mapper.functions.MapFileSnapshot) Snapshot(com.emc.storageos.db.client.model.Snapshot) CifsShareUtility(com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CifsShareUtility (com.emc.storageos.api.service.impl.resource.utils.CifsShareUtility)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 FileShare (com.emc.storageos.db.client.model.FileShare)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)2 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)2 Operation (com.emc.storageos.db.client.model.Operation)2 Snapshot (com.emc.storageos.db.client.model.Snapshot)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 ShareACL (com.emc.storageos.model.file.ShareACL)2 ShareACLs (com.emc.storageos.model.file.ShareACLs)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 PUT (javax.ws.rs.PUT)2