Search in sources :

Example 1 with VerificationGeneralView

use of net.cryptonomica.returns.VerificationGeneralView in project cryptonomica by Cryptonomica.

the class VerificationAPI method getVerificationByID.

/* --- Get verification info by verification ID: */
@ApiMethod(name = "getVerificationByID", path = "getVerificationByID", httpMethod = ApiMethod.HttpMethod.GET)
@SuppressWarnings("unused")
public VerificationGeneralView getVerificationByID(final HttpServletRequest httpServletRequest, final User googleUser, @Named("verificationID") final String verificationID) throws // see: https://cloud.google.com/appengine/docs/java/endpoints/exceptions
UnauthorizedException, BadRequestException, NotFoundException {
    /* --- Check authorization: */
    CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaRegisteredUser(googleUser);
    /* --- Check input: */
    if (verificationID == null || verificationID.equals("")) {
        throw new BadRequestException("Verification ID missing");
    }
    /* --- Load verification entity from DS: */
    Verification verification = ofy().load().key(Key.create(Verification.class, verificationID)).now();
    if (verification == null) {
        throw new NotFoundException("Verification info not found");
    }
    /* --- Create new verification info representation: */
    VerificationGeneralView verificationGeneralView = new VerificationGeneralView(verification);
    LOG.warning(new Gson().toJson(verificationGeneralView));
    return verificationGeneralView;
}
Also used : BadRequestException(com.google.api.server.spi.response.BadRequestException) NotFoundException(com.google.api.server.spi.response.NotFoundException) Gson(com.google.gson.Gson) Verification(net.cryptonomica.entities.Verification) VerificationGeneralView(net.cryptonomica.returns.VerificationGeneralView) CryptonomicaUser(net.cryptonomica.entities.CryptonomicaUser) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Example 2 with VerificationGeneralView

use of net.cryptonomica.returns.VerificationGeneralView in project cryptonomica by Cryptonomica.

the class VerificationAPI method getVerificationByWebSafeString.

// end: getVerificationByID
/* --- Get verification info by web-safe key string: */
@ApiMethod(name = "getVerificationByWebSafeString", path = "getVerificationByWebSafeString", httpMethod = ApiMethod.HttpMethod.GET)
@SuppressWarnings("unused")
public VerificationGeneralView getVerificationByWebSafeString(final HttpServletRequest httpServletRequest, final User googleUser, @Named("verificationWebSafeString") final String verificationWebSafeString) throws // see: https://cloud.google.com/appengine/docs/java/endpoints/exceptions
UnauthorizedException, BadRequestException, NotFoundException {
    /* --- Check authorization: */
    CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaRegisteredUser(googleUser);
    /* --- Check input: */
    if (verificationWebSafeString == null || verificationWebSafeString.equals("")) {
        throw new BadRequestException("Verification ID missing");
    }
    /* --- Load verification entity from DS: */
    Key<Verification> verificationKey = Key.create(verificationWebSafeString);
    Verification verification = ofy().load().key(verificationKey).now();
    if (verification == null) {
        throw new NotFoundException("Verification info not found");
    }
    /* --- Create new verification info representation: */
    VerificationGeneralView verificationGeneralView = new VerificationGeneralView(verification);
    LOG.warning(new Gson().toJson(verificationGeneralView));
    return verificationGeneralView;
}
Also used : BadRequestException(com.google.api.server.spi.response.BadRequestException) NotFoundException(com.google.api.server.spi.response.NotFoundException) Gson(com.google.gson.Gson) Verification(net.cryptonomica.entities.Verification) VerificationGeneralView(net.cryptonomica.returns.VerificationGeneralView) CryptonomicaUser(net.cryptonomica.entities.CryptonomicaUser) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Aggregations

ApiMethod (com.google.api.server.spi.config.ApiMethod)2 BadRequestException (com.google.api.server.spi.response.BadRequestException)2 NotFoundException (com.google.api.server.spi.response.NotFoundException)2 Gson (com.google.gson.Gson)2 CryptonomicaUser (net.cryptonomica.entities.CryptonomicaUser)2 Verification (net.cryptonomica.entities.Verification)2 VerificationGeneralView (net.cryptonomica.returns.VerificationGeneralView)2