http://jira.hyperic.com/browse/HHQ-4153
The code below throws an ApplicationNotFoundException for any ObjectNotFoundException that occurs. Problem is, an ObjectNotFoundException might be thrown if the appServiceId passed in isn't valid, in which case re-throwing an ApplicationNotFoundException is not helpful.
public void removeAppService(AuthzSubject caller, Integer appId, Integer appServiceId)
throws ApplicationException, ApplicationNotFoundException, PermissionException {
try {
Application app = applicationDAO.findById(appId);
permissionManager.checkModifyPermission(caller, app.getEntityId());
AppService appSvcLoc = appServiceDAO.findById(appServiceId);
app.removeService(appSvcLoc); // if THIS LINE throws ObjectNotFoundException.....
appServiceDAO.remove(appSvcLoc);
} catch (ObjectNotFoundException e) {
throw new ApplicationNotFoundException(appId); // then this exception isn't the right one to throw
}
}
Anonymous