Search in sources :

Example 1 with AssignedPolicyRemovingException

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));
}
Also used : PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) AssignedPolicyDocument(io.imunity.furms.domain.policy_documents.AssignedPolicyDocument) AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) PolicyDocumentRemovedEvent(io.imunity.furms.domain.policy_documents.PolicyDocumentRemovedEvent) FurmsAuthorize(io.imunity.furms.core.config.security.method.FurmsAuthorize)

Example 2 with AssignedPolicyRemovingException

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;
}
Also used : AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog)

Example 3 with AssignedPolicyRemovingException

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;
}
Also used : AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog)

Aggregations

AssignedPolicyRemovingException (io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException)3 FurmsDialog (io.imunity.furms.ui.components.FurmsDialog)2 FurmsAuthorize (io.imunity.furms.core.config.security.method.FurmsAuthorize)1 AssignedPolicyDocument (io.imunity.furms.domain.policy_documents.AssignedPolicyDocument)1 PolicyDocument (io.imunity.furms.domain.policy_documents.PolicyDocument)1 PolicyDocumentRemovedEvent (io.imunity.furms.domain.policy_documents.PolicyDocumentRemovedEvent)1