當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityNotFoundException類代碼示例

本文整理匯總了Java中javax.persistence.EntityNotFoundException的典型用法代碼示例。如果您正苦於以下問題:Java EntityNotFoundException類的具體用法?Java EntityNotFoundException怎麽用?Java EntityNotFoundException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityNotFoundException類屬於javax.persistence包,在下文中一共展示了EntityNotFoundException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteCategories

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
/**
 * @param toBeDeleted
 * @throws OperationNotPermittedException
 * @throws ObjectNotFoundException
 */
private void deleteCategories(List<VOCategory> toBeDeleted)
        throws OperationNotPermittedException, ObjectNotFoundException {
    final Organization currentOrg = dm.getCurrentUser().getOrganization();
    final Query marketplaceQuery = dm
            .createNamedQuery("Marketplace.findByBusinessKey");
    for (VOCategory voCategory : toBeDeleted) {
        final Category category = dm.getReference(Category.class,
                voCategory.getKey());
        try {
            marketplaceQuery.setParameter("marketplaceId", category
                    .getMarketplace().getMarketplaceId());
        } catch (EntityNotFoundException e) {
            throw new ObjectNotFoundException(ClassEnum.MARKETPLACE,
                    voCategory.getMarketplaceId());
        }
        final Marketplace marketplace = (Marketplace) marketplaceQuery
                .getSingleResult();
        PermissionCheck.owns(marketplace, currentOrg, logger, null);
        List<PlatformUser> usersToBeNotified = collectUsersToBeNotified(category);
        prefetchRequiredObject(category);
        dm.remove(category);
        sendNotification(category, usersToBeNotified);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:30,代碼來源:CategorizationServiceBean.java

示例2: update

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
public <T extends WithId<T>> void update(T entity) {
    Optional<String> id = entity.getId();
    if (!id.isPresent()) {
        throw new EntityNotFoundException("Setting the id on the entity is required for updates");
    }

    String idVal = id.get();

    Kind kind = entity.getKind();
    T previous = this.<T, T>doWithDataAccessObject(kind.getModelClass(), d -> d.update(entity));

    Map<String, T> cache = caches.getCache(kind.getModelName());
    if (!cache.containsKey(idVal) && previous==null) {
        throw new EntityNotFoundException("Can not find " + kind + " with id " + idVal);
    }

    cache.put(idVal, entity);
    broadcast("updated", kind.getModelName(), idVal);

    //TODO 1. properly merge the data ? + add data validation in the REST Resource
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:22,代碼來源:DataManager.java

示例3: delete

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
public <T extends WithId<T>> boolean delete(Class<T> model, String id) {
    if (id == null || id.equals("")) {
        throw new EntityNotFoundException("Setting the id on the entity is required for updates");
    }

    Kind kind = Kind.from(model);
    Map<String, WithId<T>> cache = caches.getCache(kind.getModelName());

    // Remove it out of the cache
    WithId<T> entity = cache.remove(id);
    boolean deletedInCache = entity != null;

    // And out of the DAO
    boolean deletedFromDAO = Boolean.TRUE.equals(doWithDataAccessObject(model, d -> d.delete(id)));

    // Return true if the entity was found in any of the two.
    if ( deletedInCache || deletedFromDAO ) {
        broadcast("deleted", kind.getModelName(), id);
        return true;
    }

    return false;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:24,代碼來源:DataManager.java

示例4: get

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@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()));
    }

    //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;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:24,代碼來源:IntegrationHandler.java

示例5: withGeneratorAndTemplate

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
final <T> T withGeneratorAndTemplate(final String templateId,
    final BiFunction<ConnectorGenerator, ConnectorTemplate, T> callback) {
    final ConnectorTemplate connectorTemplate = getDataManager().fetch(ConnectorTemplate.class, templateId);

    if (connectorTemplate == null) {
        throw new EntityNotFoundException("Connector template: " + templateId);
    }

    final ConnectorGenerator connectorGenerator = context.getBean(templateId, ConnectorGenerator.class);
    if (connectorGenerator == null) {
        throw new EntityNotFoundException(
            "Unable to find connector generator for connector template with id: " + templateId);
    }

    return callback.apply(connectorGenerator, connectorTemplate);
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:17,代碼來源:BaseConnectorGeneratorHandler.java

示例6: load

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@Override
public final Object load() {
	final Serializable entityId = resolveNaturalId( this.naturalIdParameters );
	if ( entityId == null ) {
		return null;
	}
	try {
		return this.getIdentifierLoadAccess().load( entityId );
	}
	catch (EntityNotFoundException enf) {
		// OK
	}
	catch (ObjectNotFoundException nf) {
		// OK
	}
	return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:SessionImpl.java

示例7: RequestDetailPage

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
public RequestDetailPage(PageParameters params) {
	super(params);
	
	if (getProject().getDefaultBranch() == null) 
		throw new RestartResponseException(NoBranchesPage.class, paramsOf(getProject()));

	requestModel = new LoadableDetachableModel<PullRequest>() {

		@Override
		protected PullRequest load() {
			Long requestNumber = params.get(PARAM_REQUEST).toLong();
			PullRequest request = GitPlex.getInstance(PullRequestManager.class).find(getProject(), requestNumber);
			if (request == null)
				throw new EntityNotFoundException("Unable to find request #" + requestNumber + " in project " + getProject());
			return request;
		}

	};

	reviewUpdateId = requestModel.getObject().getLatestUpdate().getId();
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:22,代碼來源:RequestDetailPage.java

示例8: changePassword

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
/**
 * Handles the actual act of changing the user's password.
 *
 * @param newPassword The password, which should be already validated.
 */
private void changePassword(String newPassword) {
    // Ensure that we have an employee to change the password for
    if(this.employeeId == null) {
        throw new IllegalStateException("Must initialize employeeId");
    }

    EmployeeService employeeService = new EmployeeService();
    Employee employee = employeeService.getEmployeeById(this.employeeId);
    try {
        employee.setPassword(newPassword);
        employeeService.updateEmployee(employee);
    } catch (EntityNotFoundException e) {
        // TODO
    }
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:21,代碼來源:ResetEmployeePasswordDialogController.java

示例9: authenticate

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
/**
 * Performs authentication on the provided employee.
 *
 * @param employeeId The id number of the employee to authenticate.
 *
 * @param plaintextPassword The plaintext password of the employee.
 *
 * @return The appropriate authenticationResult enum type.
 */
public AuthenticationResult authenticate(Long employeeId, String plaintextPassword) {
    Employee employee = getEmployeeById(employeeId);
    String hashed; // The encrypted (hashed) password of the employee.
    try {
        hashed = employee.getHashedPassword();
    } catch (EntityNotFoundException e) {
        return AuthenticationResult.FAILURE;
    }

    boolean passwordCorrect = BCrypt.checkpw(plaintextPassword, hashed);
    if(passwordCorrect) {
        return AuthenticationResult.SUCCESS;
    } else {
        return AuthenticationResult.FAILURE;
    }
}
 
開發者ID:maillouxc,項目名稱:git-rekt,代碼行數:26,代碼來源:EmployeeService.java

示例10: update

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
/**
 * Update a named token with a new generated one.
 * 
 * @param name
 *            Token to update.
 * @return the new generated token.
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Path("{name:[\\w\\-\\.]+}")
public String update(@PathParam("name") final String name) throws GeneralSecurityException {
	final SystemApiToken entity = repository.findByUserAndName(securityHelper.getLogin(), name);
	if (entity == null) {
		// No token with given name
		throw new EntityNotFoundException();
	}

	// Token has been found, update it
	final String token = newToken(entity);
	repository.saveAndFlush(entity);
	return token;
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:23,代碼來源:ApiTokenResource.java

示例11: getAllEventItems

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@Override
public List<RvepEventItem> getAllEventItems(String eventProfileId, String email) {
    // get user id
    RvepUser user = this.rvepUserProfileDAO.findByEmail(email).getRvepUser();

    // get event
    RvepEvent event = rvepEventProfileDAO
            .findById(Integer.valueOf(eventProfileId).intValue())
            .getRvepEvent();

    // get user event roles
    List<RvepUserEventRole> rvepUserEventRoles = this.rvepUserEventRoleDAO
            .findByRvepUserIdAndRvepEventId(user.getId(), event.getId());

    // check if user has roles for the event
    if (rvepUserEventRoles.size() > 0) {
        return this.rvepEventItemDAO.findByRvepEventId(event.getId());
    }

    // no access found, throw exception
    throw new EntityNotFoundException();
}
 
開發者ID:rvep,項目名稱:dev_backend,代碼行數:23,代碼來源:RvepEventItemService.java

示例12: getHomeMunicipalityName

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@Nonnull
public LocalisedString getHomeMunicipalityName() {
    if (this.homeMunicipality != null) {
        if (!Hibernate.isInitialized(this.homeMunicipality)) {
            try {
                // Referenced row might not exist
                return this.homeMunicipality.getNameLocalisation();
            } catch (UnresolvableObjectException | EntityNotFoundException o) {
                this.homeMunicipality = null;
            }
        } else {
            return this.homeMunicipality.getNameLocalisation();
        }
    }
    return LocalisedString.EMPTY;
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:17,代碼來源:Person.java

示例13: putComicBook

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@RequestMapping(value = {"/{id}"},
        consumes = {"application/json"},
        produces = {"application/json; charset=UTF-8"},
        method = RequestMethod.PUT)
@ResponseBody
public Object putComicBook(@PathVariable("id") Long id, @RequestBody ComicBookWebDTO dto, HttpServletResponse httpResponse) throws ExecutionException, InterruptedException {
    ComicBookEntity entity = service.findById(id);
    if (entity != null) {
        converter.updateEntity(entity, dto);
        try {
            ComicBookEntity result = service.update(entity);
            httpResponse.setDateHeader(HttpHeaders.LAST_MODIFIED, result.getUpdated().getTime());
            return converter.convertEntity(result);
        } catch (EntityNotFoundException e) {
            LOGGER.warn("Can't modify the resource: " + entity, e);
            httpResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
            return null;
        }
    } else {
        httpResponse.setStatus(HttpStatus.NOT_FOUND.value());
        return null;
    }
}
 
開發者ID:demis27,項目名稱:comics-blog,代碼行數:24,代碼來源:ComicBookController.java

示例14: deleteComicBook

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@RequestMapping(value = {"/{id}"}, method = RequestMethod.DELETE)
@ResponseBody
public Object deleteComicBook(@PathVariable(value = "id") Long id, HttpServletResponse httpResponse) {
    ComicBookEntity entity = service.findById(id);
    if (entity != null) {
        try {
            service.delete(id);
        } catch (EntityNotFoundException e) {
            LOGGER.warn("Can't delete the resource: " + entity, e);
            httpResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        }
        httpResponse.setStatus(HttpStatus.NO_CONTENT.value());
    } else {
        httpResponse.setStatus(HttpStatus.NOT_FOUND.value());
    }
    return null;
}
 
開發者ID:demis27,項目名稱:comics-blog,代碼行數:18,代碼來源:ComicBookController.java

示例15: create

import javax.persistence.EntityNotFoundException; //導入依賴的package包/類
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes("application/json")
@Path("/{connector-template-id}")
public Connector create(@NotNull @PathParam("connector-template-id") final String connectorTemplateId, final Connector template) {
    final ConnectorTemplate connectorTemplate = getDataManager().fetch(ConnectorTemplate.class, connectorTemplateId);

    if (connectorTemplate == null) {
        throw new EntityNotFoundException("Connector template: " + connectorTemplateId);
    }

    final ConnectorGenerator connectorGenerator = applicationContext.getBean(connectorTemplateId, ConnectorGenerator.class);

    final Connector connector = connectorGenerator.generate(connectorTemplate, template);

    return getDataManager().create(connector);
}
 
開發者ID:syndesisio,項目名稱:syndesis-rest,代碼行數:18,代碼來源:ConnectorHandler.java


注:本文中的javax.persistence.EntityNotFoundException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。