use of javax.ws.rs.DELETE in project nifi by apache.
the class ProvenanceResource method deleteLineage.
/**
* Deletes the lineage with the specified id.
*
* @param httpServletRequest request
* @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @param id The id of the lineage
* @return A lineageEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("lineage/{id}")
@ApiOperation(value = "Deletes a lineage query", response = LineageEntity.class, authorizations = { @Authorization(value = "Read - /provenance") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response deleteLineage(@Context final HttpServletRequest httpServletRequest, @ApiParam(value = "The id of the node where this query exists if clustered.", required = false) @QueryParam("clusterNodeId") final String clusterNodeId, @ApiParam(value = "The id of the lineage query.", required = true) @PathParam("id") final String id) {
// replicate if cluster manager
if (isReplicateRequest()) {
return replicate(HttpMethod.DELETE, clusterNodeId);
}
final ComponentEntity requestEntity = new ComponentEntity();
requestEntity.setId(id);
return withWriteLock(serviceFacade, requestEntity, lookup -> authorizeProvenanceRequest(), null, (entity) -> {
// delete the lineage
serviceFacade.deleteLineage(entity.getId());
// generate the response
return generateOkResponse(new LineageEntity()).build();
});
}
use of javax.ws.rs.DELETE in project coprhd-controller by CoprHD.
the class SchedulePolicyService method deleteSchedulePolicy.
/**
* Delete schedule policy from CoprHD DB.
*
* @param policyId the URN of a schedule policy
* @brief Delete schedule policy from CoprHD DB
* @return No data returned in response body
* @throws BadRequestException
*/
@DELETE
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN })
public Response deleteSchedulePolicy(@PathParam("id") URI policyId) {
ArgValidator.checkFieldUriType(policyId, SchedulePolicy.class, "policyId");
SchedulePolicy schedulePolicy = getPolicyById(policyId, true);
ArgValidator.checkReference(SchedulePolicy.class, policyId, checkForDelete(schedulePolicy));
// Check policy is associated with FS before delete
StringSet resources = schedulePolicy.getAssignedResources();
if (resources != null && !resources.isEmpty()) {
_log.error("Unable to delete schedule policy {} as it is already associated with resources", schedulePolicy.getPolicyName());
throw APIException.badRequests.unableToDeleteSchedulePolicy(schedulePolicy.getPolicyName());
}
_dbClient.markForDeletion(schedulePolicy);
_log.info("Schedule policy {} deleted successfully", schedulePolicy.getPolicyName());
return Response.ok().build();
}
use of javax.ws.rs.DELETE in project coprhd-controller by CoprHD.
the class FileService method deleteFileSystemACL.
/**
* Delete all the existing ACLs of a fileSystem or subDirectory
*
* @param id
* the URN of a ViPR fileSystem
* @param subDir
* sub-directory within a fileSystem
* @brief Delete an ACL for a file system
* @return Task resource representation
*/
@DELETE
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep deleteFileSystemACL(@PathParam("id") URI id, @QueryParam("subDir") String subDir) {
// log input received.
_log.info("Delete ACL of fileSystem: Request received for filesystem: {} with subDir {} ", id, subDir);
// Validate the FS id.
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fs = queryResource(id);
String task = UUID.randomUUID().toString();
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
// Check for VirtualPool whether it has NFS v4 enabled
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
if (!vpool.getProtocols().contains(StorageProtocol.File.NFSv4.name())) {
// Throw an error
throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool does not support " + StorageProtocol.File.NFSv4.name() + " protocol");
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileController controller = getController(FileController.class, device.getSystemType());
Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.DELETE_FILE_SYSTEM_NFS_ACL);
op.setDescription("Delete ACL of file system ");
try {
controller.deleteNFSAcls(device.getId(), fs.getId(), subDir, task);
auditOp(OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE_ACL, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), subDir);
} catch (BadRequestException e) {
op = _dbClient.error(FileShare.class, fs.getId(), task, e);
_log.error("Error Processing File System ACL Delete {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
_log.error("Error Processing File System ACL Delete {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(fs, task, op);
}
use of javax.ws.rs.DELETE in project coprhd-controller by CoprHD.
the class FileService method unexport.
/**
* @Deprecated use @Path("/{id}/export") instead
*
* <p>
* NOTE: This is an asynchronous operation.
* @param id
* the URN of a ViPR Project
* @param protocol
* Protocol valid values - NFS,NFSv4,CIFS
* @param securityType
* Security type valid values - sys,krb5,krb5i,krb5p
* @param permissions
* Permissions valid values - ro,rw,root
* @param rootUserMapping
* Root user mapping
* @brief Delete file system export.
* <p>
* Use /file/filesystems/{id}/export instead
* @return Task resource representation
* @throws InternalException
*/
@Deprecated
@DELETE
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/exports/{protocol},{secType},{perm},{root_mapping}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep unexport(@PathParam("id") URI id, @PathParam("protocol") String protocol, @PathParam("secType") String securityType, @PathParam("perm") String permissions, @PathParam("root_mapping") String rootUserMapping, @QueryParam("subDirectory") String subDirectory) throws InternalException {
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fs = queryResource(id);
ArgValidator.checkFieldNotNull(protocol, "protocol");
ArgValidator.checkFieldNotNull(securityType, "secType");
ArgValidator.checkFieldNotNull(permissions, "perm");
ArgValidator.checkFieldNotNull(rootUserMapping, "root_mapping");
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
String task = UUID.randomUUID().toString();
if (fs.getFsExports() == null) {
// No exports present. Return success.
return getSuccessResponse(fs, task, ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM, "Export does not exist");
}
if (fs.getStoragePort() == null) {
// port associated with export, fail the operation
return getFailureResponse(fs, task, ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM, "No storage port associated with " + fs.getLabel());
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileController controller = getController(FileController.class, device.getSystemType());
String path = fs.getPath();
String mountPath = fs.getMountPath();
if (subDirectory != null && subDirectory.length() > 0) {
// Add subdirectory to the path as this is a subdirectory export
path += "/" + subDirectory;
mountPath += "/" + subDirectory;
}
FileExport fExport = null;
_log.info("unexport subdirectory passed value is {}", subDirectory);
if (subDirectory != null) {
_log.info("unexport subdirectory {} with path {} ", subDirectory, path);
_log.info(String.format("securityType %1$s, permissions %2$s, rootMapping %3$s, protocol %4$s subDirectory %5$s", securityType, permissions, rootUserMapping, protocol, path));
fExport = fs.getFsExports().get(FileExport.exportLookupKey(protocol, securityType, permissions, rootUserMapping, path));
} else {
_log.info("unexport FS {} with path {} ", fs.getName(), path);
_log.info(String.format("securityType %1$s, permissions %2$s, rootMapping %3$s, protocol %4$s FileSystem %5$s", securityType, permissions, rootUserMapping, protocol, path));
fExport = fs.getFsExports().get(FileExport.exportLookupKey(protocol, securityType, permissions, rootUserMapping, path));
}
if (fExport == null) {
// No export to unexport, return success.
return getSuccessResponse(fs, task, ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM, "Export does not exist");
}
fExport.setStoragePort(fs.getStoragePort().toString());
Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM);
op.setDescription("Filesystem unexport");
// empty list for unexport
List<String> endpoints = new ArrayList<String>();
FileShareExport export = new FileShareExport(endpoints, securityType, permissions, rootUserMapping, protocol, fExport.getStoragePortName(), fExport.getStoragePort(), fExport.getPath());
export.setIsilonId(fExport.getIsilonId());
controller.unexport(device.getId(), fs.getId(), Arrays.asList(export), task);
auditOp(OperationTypeEnum.UNEXPORT_FILE_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), securityType, permissions, rootUserMapping, protocol);
return toTask(fs, task, op);
}
use of javax.ws.rs.DELETE in project coprhd-controller by CoprHD.
the class FileSnapshotService method deleteSnapshotShareACL.
/**
* Delete Snapshot Share ACL
*
* @param id
* the file system URI
* @param shareName
* name of the share
* @brief Delete a snapshot ACL
* @return TaskResponse
*/
@DELETE
@Path("/{id}/shares/{shareName}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep deleteSnapshotShareACL(@PathParam("id") URI id, @PathParam("shareName") String shareName) {
// log input received.
_log.info("Delete ACL of share: Request received for {}, of file snapshot {}", shareName, id);
String taskId = UUID.randomUUID().toString();
// Validate the snapshot 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);
}
FileShare fs = _permissionsHelper.getObjectById(snapshot.getParent(), FileShare.class);
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
CifsShareUtility.checkForUpdateShareACLOperationOnStorage(device.getSystemType(), OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL.name());
Operation op = _dbClient.createTaskOpStatus(Snapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL);
op.setDescription("Delete ACL of Snapshot Cifs share");
FileServiceApi fileServiceApi = FileService.getFileShareServiceImpl(fs, _dbClient);
fileServiceApi.deleteShareACLs(device.getId(), snapshot.getId(), shareName, taskId);
auditOp(OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL, true, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), device.getId().toString(), shareName);
return toTask(snapshot, taskId, op);
}
Aggregations