Package com.google.api.server.spi.response

Examples of com.google.api.server.spi.response.NotFoundException


  }

  public BlogPost getBlogPost(@Named("id") Long id) throws NotFoundException {
    BlogPost bp = ofy().load().type(BlogPost.class).id(id).get();
    if (bp == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    BlogPostContent bpc = ofy().load().type(BlogPostContent.class).id(id).get();
    if (bpc == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    bp.setContent(bpc.getContent());
    return bp;
  }
View Full Code Here


  }

  public BlogPost updateBlogPost(@Named("id") Long id, BlogPost bp) throws NotFoundException {
    BlogPost updatedBp = ofy().load().type(BlogPost.class).id(id).get();
    if (updatedBp == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    BlogPostContent updatedBpc = ofy().load().type(BlogPostContent.class).id(id).get();
    if (updatedBpc == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    if (bp.getTitle() != null) {
      updatedBp.setTitle(bp.getTitle());
    }
    if (bp.getMeta() != null) {
View Full Code Here

  public void removeBlogPost(@Named("id") Long id, User user) throws OAuthRequestException, NotFoundException {
    if (user != null) {
      BlogPost deletedBp = ofy().load().type(BlogPost.class).id(id).get();
      if (deletedBp == null) {
        throw new NotFoundException("No entity with the id " + id + " exists.");
      }
      BlogPostContent deletedBpc = ofy().load().type(BlogPostContent.class).id(id).get();
      if (deletedBpc == null) {
        throw new NotFoundException("No entity with the id " + id + " exists.");
      }
      ofy().delete().entity(deletedBp);
      ofy().delete().entity(deletedBpc);
    } else {
      throw new OAuthRequestException("Invalid user.");
View Full Code Here

            @Named("websafeConferenceKey") final String websafeConferenceKey)
            throws NotFoundException {
        Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
        Conference conference = ofy().load().key(conferenceKey).now();
        if (conference == null) {
            throw new NotFoundException("No Conference found with key: " + websafeConferenceKey);
        }
        return conference;
    }
View Full Code Here

            }
        });
        // if result is false
        if (!result.getResult()) {
            if (result.getReason().contains("No Conference found with key")) {
                throw new NotFoundException (result.getReason());
            }
            else if (result.getReason() == "Already registered") {
                throw new ConflictException("You have already registered");
            }
            else if (result.getReason() == "No seats available") {
View Full Code Here

            }
        });
        // if result is false
        if (!result.getResult()) {
            if (result.getReason().contains("No Conference found with key")) {
                throw new NotFoundException (result.getReason());
            }
            else {
                throw new ForbiddenException(result.getReason());
            }
        }
View Full Code Here

        if (user == null) {
            throw new UnauthorizedException("Authorization required");
        }
        Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
        if (profile == null) {
            throw new NotFoundException("Profile doesn't exist.");
        }
        List<String> keyStringsToAttend = profile.getConferenceKeysToAttend();
        List<Key<Conference>> keysToAttend = new ArrayList<>();
        for (String keyString : keyStringsToAttend) {
            keysToAttend.add(Key.<Conference>create(keyString));
View Full Code Here

            @Named("websafeConferenceKey") final String websafeConferenceKey)
            throws NotFoundException {
        Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
        Conference conference = ofy().load().key(conferenceKey).now();
        if (conference == null) {
            throw new NotFoundException("No Conference found with key: " + websafeConferenceKey);
        }
        return conference;
    }
View Full Code Here

            }
        });
        // if result is false
        if (!result.getResult()) {
            if (result.getReason().contains("No Conference found with key")) {
                throw new NotFoundException (result.getReason());
            }
            else if (result.getReason() == "Already registered") {
                throw new ConflictException("You have already registered");
            }
            else if (result.getReason() == "No seats available") {
View Full Code Here

            }
        });
        // if result is false
        if (!result.getResult()) {
            if (result.getReason().contains("No Conference found with key")) {
                throw new NotFoundException (result.getReason());
            }
            else {
                throw new ForbiddenException(result.getReason());
            }
        }
View Full Code Here

TOP

Related Classes of com.google.api.server.spi.response.NotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.