当前位置: 首页>>代码示例>>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;未经允许,请勿转载。