public async Task Delete(Guid id) { if (_securityServices.AuthorizeActivity(PermissionType.DeleteObject, id, nameof(PlanNodeDO))) { await _target.Delete(id); } else { throw new HttpException(403, "You are not authorized to perform this activity!"); } }
public async Task <IHttpActionResult> Delete(Guid id) { await _plan.Delete(id); return(Ok(id)); }
/// <summary> /// Checks if there is already monitoring plan and activates it (if necessary). Otherwise creates a new plan and activates it /// </summary> public async Task <ManifestRegistryMonitorResult> StartMonitoringManifestRegistrySubmissions() { //If start attempt is already in progress we just reuse it and wait for the result if (Interlocked.CompareExchange(ref _isRunning, 1, 0) != 0) { Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Plan creation is in progress, skipping the new attempt"); return(await _currentRun.Task); } //Otherwise we run a new attempt try { _currentRun = new TaskCompletionSource <ManifestRegistryMonitorResult>(); Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Retrieving system user"); var systemUser = _fr8Account.GetSystemUser(); if (systemUser == null) { Logger.GetLogger().Error($"{ManifestMonitoringPrefix}System user doesn't exists"); throw new ApplicationException("System user doesn't exist"); } var isNewPlanCreated = false; Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Trying to find existing plan"); var plan = GetExistingPlan(systemUser); if (plan == null) { Logger.GetLogger().Info($"{ManifestMonitoringPrefix}No existing plan found. Creating new plan"); isNewPlanCreated = true; plan = await CreateAndConfigureNewPlan(systemUser); Logger.GetLogger().Info($"{ManifestMonitoringPrefix}New plan was created (Id - {plan.Id})"); } else { Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Existing plan was found (Id - {plan.Id})"); } try { Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Trying to launch the plan"); await RunPlan(plan); Logger.GetLogger().Info($"{ManifestMonitoringPrefix}Plan was successfully launched"); } catch (Exception ex) { Logger.GetLogger().Error($"{ManifestMonitoringPrefix}Failed to launch a plan. {ex}"); if (isNewPlanCreated) { await _plan.Delete(plan.Id); } throw; } _currentRun.SetResult(new ManifestRegistryMonitorResult(plan.Id, isNewPlanCreated)); } catch (Exception ex) { _currentRun.SetException(ex); } finally { Interlocked.Exchange(ref _isRunning, 0); } return(await _currentRun.Task); }