List of usage examples for javax.persistence EntityNotFoundException EntityNotFoundException
public EntityNotFoundException(String message)
EntityNotFoundException
exception with the specified detail message. From source file:com.mothsoft.alexis.service.impl.DataSetServiceImpl.java
@Override public DataSet get(Long id) { final DataSet dataSet = this.dataSetDao.get(id); if (dataSet == null) { throw new EntityNotFoundException("DataSet:" + id + " not found."); }/*from w w w. ja va 2s . c om*/ if (dataSet.getUserId() != null) { CurrentUserUtil.assertAuthenticatedUserOrAdminOrSystem(dataSet.getUserId()); } return dataSet; }
From source file:io.syndesis.rest.v1.handler.integration.IntegrationHandler.java
@Override public Integration get(String id) { Integration integration = Getter.super.get(id); if (Status.Deleted.equals(integration.getCurrentStatus().get()) || Status.Deleted.equals(integration.getDesiredStatus().get())) { //Not sure if we need to do that for both current and desired status, //but If we don't do include the desired state, IntegrationITCase is not going to pass anytime soon. Why? //Cause that test, is using NoopHandlerProvider, so that means no controllers. throw new EntityNotFoundException( String.format("Integration %s has been deleted", integration.getId())); }/*from www. j a v a 2 s. c om*/ //fudging the timesUsed for now Optional<Status> currentStatus = integration.getCurrentStatus(); if (currentStatus.isPresent() && currentStatus.get() == Integration.Status.Activated) { return new Integration.Builder().createFrom(integration) .timesUsed(BigInteger.valueOf(new Date().getTime() / 1000000)).build(); } return integration; }
From source file:au.id.wolfe.stormcloud.core.dao.jpa.GenericDaoJpa.java
/** * {@inheritDoc}/*from ww w . j a va 2s. c o m*/ */ public T getById(PK id) { T entity = this.entityManager.find(this.persistentClass, id); if (entity == null) { String msg = "Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."; log.warn(msg); throw new EntityNotFoundException(msg); } return entity; }
From source file:it.smartcommunitylab.aac.apikey.APIKeyManager.java
/** * Update key validity. Validity period is restarted * @param key/*w ww . j a v a2 s . c o m*/ * @param validity * @return * @throws #{@link EntityNotFoundException} if the key does not exists */ public APIKey updateKeyValidity(String key, Long validity) throws EntityNotFoundException { APIKeyEntity entity = keyRepo.findOne(key); if (entity != null) { entity.setIssuedTime(System.currentTimeMillis()); entity.setValidity(validity); keyRepo.save(entity); APIKey result = new APIKey(entity); log.debug("Update API Key validity " + key); keyCache.put(key, result); return result; } throw new EntityNotFoundException(key); }
From source file:edu.cmu.cs.lti.discoursedb.annotation.lightside.io.LightSideService.java
/** * Exports annotations on contributions associated with any DiscoursePart of * the given type that are part of the discourse with the provided name into * the provided output file.//from w w w . j a va 2 s.c om * * @param discourseName name of the discourse to extract contributions from * @param dptype type of the discourse parts to extract contributions from * @param outputFile file to write the annotations to */ @Transactional(readOnly = true) public void exportAnnotations(String discourseName, DiscoursePartTypes dptype, File outputFile) { Discourse discourse = discourseService.findOne(discourseName).orElseThrow( () -> new EntityNotFoundException("Discourse with name " + discourseName + " does not exist.")); exportAnnotations(discourse, dptype, outputFile); }
From source file:it.smartcommunitylab.aac.apikey.APIKeyManager.java
/** * Update key additional data. //from www . j a v a 2 s . c o m * @param key * @param data * @return * @throws #{@link EntityNotFoundException} if the key does not exists */ public APIKey updateKeyData(String key, Map<String, Object> data) throws EntityNotFoundException { APIKeyEntity entity = keyRepo.findOne(key); if (entity != null) { entity.setAdditionalInformation(APIKey.toDataString(data)); keyRepo.save(entity); APIKey result = new APIKey(entity); log.debug("Update API Key data " + key); keyCache.put(key, result); return result; } throw new EntityNotFoundException(key); }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.RoleDAOJPAImpl.java
@Override public void removeEntitlementFromRole(Role role, Entitlement entitlement) { RoleEntity roleEntity = null;//from ww w. ja v a 2s . c o m if (role.getId() != 0) { roleEntity = em.find(RoleEntity.class, role.getId()); } else { roleEntity = getRoleEntity(role.getName(), em); } EntitlementEntity entitlementEntity = null; if (entitlement.getId() != 0) { entitlementEntity = em.find(EntitlementEntity.class, entitlement.getId()); } else { entitlementEntity = EntitlementDAOJPAImpl.getEntitlementEntity(entitlement.getName(), em); } if (entitlementEntity == null) { throw new EntityNotFoundException("EntitlementEntity not found"); } if (!roleEntity.getEntitlements().remove(entitlementEntity)) { throw new EntityNotFoundException("EntitlementEntity not assigned to RoleEntity"); } LOG.debug("Entitlement '{}' removed from Role '{}'", entitlement.getName(), role.getName()); }
From source file:org.openwms.core.uaa.UserServiceImpl.java
@Override public void remove(String username) { repository.delete(repository.findByUsername(username).orElseThrow( () -> new EntityNotFoundException(translator.translate(ExceptionCodes.USER_NOT_EXIST, username)))); }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.IdpDAOJPAImpl.java
@Override public void removeApplicationFromIdp(Idp idp, Application application) { IdpEntity idpEntity = null;/*from www . j a va 2 s.c o m*/ if (idp.getId() != 0) { idpEntity = em.find(IdpEntity.class, idp.getId()); } else { idpEntity = getIdpEntity(idp.getRealm(), em); } ApplicationEntity applicationEntity = null; if (application.getId() != 0) { applicationEntity = em.find(ApplicationEntity.class, application.getId()); } else { applicationEntity = ApplicationDAOJPAImpl.getApplicationEntity(application.getRealm(), em); } if (applicationEntity == null) { throw new EntityNotFoundException("ApplicationEntity not found"); } if (!idpEntity.getApplications().remove(applicationEntity)) { throw new EntityNotFoundException("ApplicationEntity not assigned to IdpEntity"); } LOG.debug("Application '{}' removed from IDP '{}'", application.getRealm(), idp.getRealm()); }
From source file:com.impetus.ankush.common.dao.impl.GenericDaoJpa.java
/** * {@inheritDoc}//from w ww .ja va 2 s.co m */ public T get(P id) { T entity = this.entityManager.find(this.persistentClass, id); if (entity == null) { String msg = "Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."; log.warn(msg); throw new EntityNotFoundException(msg); } return entity; }