Example usage for javax.persistence NoResultException NoResultException

List of usage examples for javax.persistence NoResultException NoResultException

Introduction

In this page you can find the example usage for javax.persistence NoResultException NoResultException.

Prototype

public NoResultException() 

Source Link

Document

Constructs a new NoResultException exception with null as its detail message.

Usage

From source file:cz.fi.muni.pa165.service.layer.facade.GenreFacadeImplementation.java

@Override
public GenreDTO findGenreByID(Long genreID) {
    if (genreService.findGenreByID(genreID) != null) {
        return mappingService.mapToEnforceID(genreService.findGenreByID(genreID), GenreDTO.class);
    } else {//w  w  w.  j  a  v a  2 s.c  om
        throw new NoResultException();
    }
}

From source file:org.opens.tanaguru.rules.test.PreProcessResultDataServiceMock.java

@Override
public String getPreProcessResultByKeyAndWebResource(String key, WebResource webresource) {
    String path = StringUtils.replace(webresource.getURL(), "html", "json");
    path = StringUtils.replace(path, "file:", "");
    try {/* w  w w .  j  av a 2  s .  c o  m*/
        String json = FileUtils.readFileToString(new File(path));
        System.out.println(json);
        return json;
    } catch (IOException ex) {
        System.out.println(ex);
        throw new NoResultException();
    }
}

From source file:org.asqatasun.rules.test.PreProcessResultDataServiceMock.java

@Override
public String getPreProcessResultByKeyAndWebResource(String key, WebResource webresource) {
    String path = StringUtils.replace(webresource.getURL(), "html", "json");
    path = StringUtils.replace(path, "file:", "");
    try {/*from ww w. ja  va2 s.  c  o  m*/
        String json = FileUtils.readFileToString(new File(path));
        LOGGER.debug(json);
        return json;
    } catch (IOException ex) {
        LOGGER.warn(ex);
        throw new NoResultException();
    }
}

From source file:cz.fi.muni.pa165.service.layer.facade.GenreFacadeImplementation.java

@Override
public GenreDTO findGenreByTitle(String genreTitle) {
    if (genreService.findGenreByTitle(genreTitle) != null) {
        return mappingService.mapToEnforceID(genreService.findGenreByTitle(genreTitle), GenreDTO.class);
    } else {/*  w ww. j a  va  2s.  c  om*/
        throw new NoResultException();
    }
}

From source file:com.moderndrummer.data.MemberDaoImpl.java

@Override
public Member findByEmailOrUsername(String userName, String email) {
    try {//from   ww w.  j  ava  2 s.  c  o m
        Member found = executeNamedQueryByTwoParams(userName.toLowerCase(), email.toLowerCase(),
                "findMemberByUserNameOrEmail");
        if (found == null) {
            throw new NoResultException();
        }
        return found;
    } catch (NoResultException e) {
        return new Member();
    }
}

From source file:cz.fi.muni.pa165.service.layer.facade.AlbumFacadeImplementation.java

@Override
public AlbumDTO findById(Long id) {
    if (albumService.findById(id) != null) {
        return mappingService.mapToEnforceID(albumService.findById(id), AlbumDTO.class);
    } else {// ww  w .  j  a  va2s  .  co m
        throw new NoResultException();
    }
}

From source file:cz.fi.muni.pa165.service.layer.facade.AlbumFacadeImplementation.java

@Override
public AlbumDTO findByTitle(String title) {
    if (albumService.findByTitle(title) != null) {
        return mappingService.mapToEnforceID(albumService.findByTitle(title), AlbumDTO.class);
    } else {// ww  w.ja  v  a 2 s .  c  om
        throw new NoResultException();
    }
}

From source file:net.dontdrinkandroot.persistence.dao.GenericJpaDao.java

@Override
@Transactional(propagation = Propagation.MANDATORY, readOnly = true)
public <E extends Entity<K>, K> E load(final K id, final Class<E> clazz) {
    final E entity = this.getEntityManager().find(clazz, id);
    if (entity == null) {
        throw new NoResultException();
    }/*from  w w w  .  java  2 s.  c o  m*/

    return entity;
}

From source file:org.energyos.espi.thirdparty.web.ScopeSelectionController.java

@RequestMapping(value = Routes.THIRD_PARTY_SCOPE_SELECTION_SCREEN, method = RequestMethod.POST)
public String scopeAuthorization(@RequestParam("scope") String scope,
        @RequestParam("DataCustodianID") String dataCustodianId, Principal principal) throws JAXBException {

    System.out.printf("ScopeSelectionController: HttpRequest Method: POST, scope: %s dataCustodianID: %s\n",
            scope, dataCustodianId);//www  .  jav  a  2s .  c om

    ApplicationInformation applicationInformation = applicationInformationService
            .findByDataCustodianClientId(dataCustodianId);

    try {
        // Does an ACTIVE authorization record exist for the requested Scope
        Authorization currentAuthorization = authorizationService.findByScope(scope,
                currentCustomer(principal).getId());

        // Is this a valid authorization record?
        if (currentAuthorization.getStatus() == null) {

            // Delete the invalid record and continue request
            authorizationService.delete(currentAuthorization);
            throw new NoResultException();
        }

        else {

            // Is the existing authorization record Active
            if (!currentAuthorization.getStatus().equals("1")) {

                // No, create a new authorization record entry
                throw new NoResultException();
            }
        }

    } catch (NoResultException | EmptyResultDataAccessException e) {

        // No authorization record exist for the requested Scope
        Authorization authorization = new Authorization();

        // Initialize authorization record content
        authorization.setApplicationInformation(applicationInformation);
        authorization.setThirdParty(applicationInformation.getClientId());
        authorization.setRetailCustomer(currentCustomer(principal));
        authorization.setState(stateService.newState());
        authorization.setUUID(UUID.randomUUID());
        authorization.setResponseType("code");
        authorization.setScope(scope);
        authorizationService.persist(authorization);

        return "redirect:" + applicationInformation.getAuthorizationServerAuthorizationEndpoint()
                + "?client_id=" + applicationInformation.getClientId() + "&redirect_uri="
                + applicationInformation.getRedirectUri() + "&response_type=code&scope=" + scope + "&state="
                + authorization.getState();
    }

    // TODO: If an Oauth access token already exists, do we want to display
    // the "UsagePoint" screen?
    // Display the Authorization List screen if an OAuth access token
    // already exist
    return "redirect:/RetailCustomer/" + currentCustomer(principal).getId() + "/AuthorizationList";

}

From source file:de.uni_koblenz.aggrimm.icp.interfaceAgents.AbstractResultParser.java

/**
 *
 * <p>This method checks whether {@code resultURL} needs to be filtered or
 * not. It returns {@code null} if no filtering is necessary and a
 * {@code FilteredImageResult} or {@code FilteredWebResult} else (depending on
 * the value of {@code isImage})./* ww  w . j  a v  a2 s . c  om*/
 *
 * @param resultURL result that should be displayed or regulated.
 * @param isImage   {@code true} if {@code FilteredImageResult} should be
 *                   returned, {@code FilteredWebResult} else.
 *
 * @return {@code null} if result must not be filtered;
 *          {@code AbstractFilteredResult} with values set else.
 */
protected AbstractFilteredResult createFilteredResultIfNeeded(String resultURL, boolean isImage) {
    AbstractFilteredResult result = null;
    try {
        AbstractRuleEntity regulatingRule = databaseQueryHelper.getRegulatingRule(resultURL);
        if (regulatingRule == null) {
            throw new NoResultException();
        }

        if (!regulatingRule.isInformationFlowAllowed()) {
            result = createFilteredResultFromRule(regulatingRule, isImage);
        }
    } catch (NoResultException e) {
        if (!areInformationFlowsAllowed) {
            result = createFilterResultForDefaultRule(isImage);
        }
    }
    return result;
}