use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class PolicyLogic method read.
@PreAuthorize("hasRole('" + StandardEntitlement.POLICY_READ + "')")
@Transactional(readOnly = true)
public <T extends PolicyTO> T read(final PolicyType type, final String key) {
Policy policy = policyDAO.find(key);
if (policy == null) {
throw new NotFoundException("Policy " + key + " not found");
}
PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
if (type != null && policyUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
throw sce;
}
return binder.getPolicyTO(policy);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class RealmLogic method list.
@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true)
public List<RealmTO> list(final String fullPath) {
Realm realm = realmDAO.findByFullPath(fullPath);
if (realm == null) {
LOG.error("Could not find realm '" + fullPath + "'");
throw new NotFoundException(fullPath);
}
final boolean admin = AuthContextUtils.getAuthorizations().keySet().contains(StandardEntitlement.REALM_LIST);
return realmDAO.findDescendants(realm).stream().map(descendant -> binder.getRealmTO(descendant, admin)).collect(Collectors.toList());
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class RelationshipTypeLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_DELETE + "')")
public RelationshipTypeTO delete(final String key) {
RelationshipType relationshipType = relationshipTypeDAO.find(key);
if (relationshipType == null) {
LOG.error("Could not find relationshipType '" + key + "'");
throw new NotFoundException(key);
}
RelationshipTypeTO deleted = binder.getRelationshipTypeTO(relationshipType);
relationshipTypeDAO.delete(key);
return deleted;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class RemediationLogic method remedy.
@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_REMEDY + "')")
public ProvisioningResult<?> remedy(final String key, final AnyTO anyTO, final boolean nullPriorityAsync) {
Remediation remediation = remediationDAO.find(key);
if (remediation == null) {
LOG.error("Could not find remediation '" + key + "'");
throw new NotFoundException(key);
}
ProvisioningResult<?> result;
switch(remediation.getAnyType().getKind()) {
case USER:
default:
result = userLogic.create((UserTO) anyTO, true, nullPriorityAsync);
break;
case GROUP:
result = groupLogic.create((GroupTO) anyTO, nullPriorityAsync);
break;
case ANY_OBJECT:
result = anyObjectLogic.create((AnyObjectTO) anyTO, nullPriorityAsync);
}
remediationDAO.delete(remediation);
return result;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class RemediationLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_DELETE + "')")
public void delete(final String key) {
Remediation remediation = remediationDAO.find(key);
if (remediation == null) {
LOG.error("Could not find remediation '" + key + "'");
throw new NotFoundException(key);
}
remediationDAO.delete(remediation);
}
Aggregations