Search in sources :

Example 6 with ResourceNotFoundException

use of org.craftercms.profile.management.exceptions.ResourceNotFoundException in project profile by craftercms.

the class ProfileController method deleteProfile.

@RequestMapping(value = URL_DELETE_PROFILE, method = RequestMethod.POST)
@ResponseBody
public Map<String, String> deleteProfile(@PathVariable(PATH_VAR_ID) String id) throws ProfileException {
    Profile profile = profileService.getProfile(id);
    if (profile != null) {
        checkIfAllowed(profile, Action.DELETE_PROFILE);
        profileService.deleteProfile(id);
        return Collections.singletonMap(MODEL_MESSAGE, String.format(MSG_PROFILE_DELETED_FORMAT, id));
    } else {
        throw new ResourceNotFoundException("No profile found for ID '" + id + "'");
    }
}
Also used : ResourceNotFoundException(org.craftercms.profile.management.exceptions.ResourceNotFoundException) Profile(org.craftercms.profile.api.Profile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ResourceNotFoundException (org.craftercms.profile.management.exceptions.ResourceNotFoundException)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 Tenant (org.craftercms.profile.api.Tenant)3 Profile (org.craftercms.profile.api.Profile)2 ActionDeniedException (org.craftercms.commons.security.exception.ActionDeniedException)1 AccessToken (org.craftercms.profile.api.AccessToken)1