use of io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException in project furms by unity-idm.
the class PolicyDocumentServiceImpl method delete.
@Override
@FurmsAuthorize(capability = SITE_WRITE, resourceType = SITE, id = "siteId")
public void delete(String siteId, PolicyId policyId) {
LOG.debug("Deleting Policy Document {} for site id={}", policyId.id, siteId);
boolean isAssigned = policyDocumentRepository.findAllAssignPoliciesBySiteId(siteId).stream().anyMatch(policy -> policy.id.equals(policyId));
if (isAssigned)
throw new AssignedPolicyRemovingException(String.format("Policy %s removing error. Only not assigned policy can be removed", policyId.id));
PolicyDocument policyDocument = policyDocumentRepository.findById(policyId).get();
policyDocumentRepository.deleteById(policyId);
publisher.publishEvent(new PolicyDocumentRemovedEvent(policyDocument));
}
use of io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException in project furms by unity-idm.
the class AlarmsView method createConfirmDialog.
private Dialog createConfirmDialog(String projectId, AlarmId alarmId, String alarmName) {
FurmsDialog furmsDialog = new FurmsDialog(getTranslation("view.project-admin.alarms.page.dialog.text", alarmName));
furmsDialog.addConfirmButtonClickListener(event -> {
try {
alarmService.remove(projectId, alarmId);
loadGridContent();
} catch (AssignedPolicyRemovingException e) {
showErrorNotification(getTranslation("policy.document.assigned.removing"));
} catch (Exception e) {
showErrorNotification(getTranslation("base.error.message"));
}
});
return furmsDialog;
}
use of io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException in project furms by unity-idm.
the class PolicyDocumentsView method createConfirmDialog.
private Dialog createConfirmDialog(PolicyId policyDocumentId, String policyDocumentName, String siteId) {
FurmsDialog furmsDialog = new FurmsDialog(getTranslation("view.site-admin.policy-documents.dialog.text", policyDocumentName));
furmsDialog.addConfirmButtonClickListener(event -> {
try {
policyDocumentService.delete(siteId, policyDocumentId);
loadGridContent();
} catch (AssignedPolicyRemovingException e) {
showErrorNotification(getTranslation("policy.document.assigned.removing"));
} catch (Exception e) {
showErrorNotification(getTranslation("base.error.message"));
}
});
return furmsDialog;
}
Aggregations