List of usage examples for javax.persistence EntityNotFoundException EntityNotFoundException
public EntityNotFoundException()
EntityNotFoundException
exception with null
as its detail message. From source file:com.br.helpdesk.controller.AttachmentsController.java
public List<Attachments> findByName(String name) { List<Attachments> attachments = attachmentsService.findByNameContaining(name); if (attachments == null || attachments.isEmpty()) { throw new EntityNotFoundException(); }/*from ww w.j av a 2 s. c om*/ return attachments; }
From source file:com.br.helpdesk.controller.AttachmentsController.java
public Attachments findById(long id) throws EntityNotFoundException { Attachments attachment = attachmentsService.findById(id); if (attachment == null) { throw new EntityNotFoundException(); }/*w w w . ja va 2 s . c o m*/ return attachment; }
From source file:it.smartcommunitylab.aac.apikey.APIKeyController.java
/** * Delete a specified API key// ww w . jav a2 s. co m * @param apiKey * @return */ @ApiOperation(value = "Update key") @PutMapping(value = "/apikey/{apiKey:.*}") public @ResponseBody APIKey updateKey(HttpServletRequest request, @RequestBody APIKey body, @PathVariable String apiKey) throws SecurityException, EntityNotFoundException { APIKey key = keyManager.findKey(apiKey); if (key != null) { String clientId = getClientId(request); if (!clientId.equals(key.getClientId())) { throw new SecurityException(); } if (body.getValidity() != null && body.getValidity() > 0) { keyManager.updateKeyValidity(apiKey, body.getValidity()); } if (body.getAdditionalInformation() != null) { keyManager.updateKeyData(apiKey, body.getAdditionalInformation()); } return keyManager.findKey(apiKey); } throw new EntityNotFoundException(); }
From source file:com.br.helpdesk.controller.AttachmentsController.java
public void delete(Long id) throws EntityNotFoundException, DataIntegrityViolationException { Attachments attachment = attachmentsService.findById(id); if (attachment == null) { throw new EntityNotFoundException(); }//w w w . j av a2 s. c o m try { attachmentsService.remove(attachment); } catch (Exception e) { throw new DataIntegrityViolationException("Entidade possui dependencias e no pode ser deletada");//DEPENDENCIAS } }
From source file:com.impetus.ankush.admin.service.impl.GenericManagerImplTest.java
@Test(expected = EntityNotFoundException.class) public void testRemove() { genericDao.remove(1L);/* w w w .jav a 2s . c o m*/ EasyMock.expectLastCall(); EasyMock.expect(genericDao.get(1L)).andThrow(new EntityNotFoundException()); EasyMock.replay(genericDao); genericManager.remove(1L); genericManager.get(1L); }
From source file:org.zanata.action.ProjectHome.java
public void validateSuppliedId() { HProject ip = getInstance(); // this will raise an EntityNotFound // exception//from w w w . j a v a 2s . co m // when id is invalid and conversation will not // start if (ip.getStatus().equals(EntityStatus.OBSOLETE)) { throw new EntityNotFoundException(); } }
From source file:org.zanata.service.impl.RequestServiceImpl.java
@Override public void updateLanguageRequest(Long requestId, HAccount actor, RequestState state, String comment) throws EntityNotFoundException { LanguageRequest languageRequest = languageRequestDAO.findById(requestId); if (languageRequest != null) { Request oldRequest = languageRequest.getRequest(); Request newRequest = oldRequest.update(actor, state, comment, new Date()); requestDAO.makePersistent(oldRequest); languageRequest.setRequest(newRequest); requestDAO.makePersistent(oldRequest); requestDAO.makePersistent(newRequest); languageRequestDAO.makePersistent(languageRequest); requestUpdatedEvent.fire(/*from w ww. j ava 2 s. co m*/ new RequestUpdatedEvent(newRequest.getId(), languageRequest.getId(), actor.getId(), state)); } else { throw new EntityNotFoundException(); } }