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;
}
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;
}
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);
}
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);
}
Aggregations