当前位置: 首页>>代码示例>>Java>>正文


Java NotFoundException类代码示例

本文整理汇总了Java中com.google.api.server.spi.response.NotFoundException的典型用法代码示例。如果您正苦于以下问题:Java NotFoundException类的具体用法?Java NotFoundException怎么用?Java NotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NotFoundException类属于com.google.api.server.spi.response包,在下文中一共展示了NotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDiscoveryDoc

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
private <T> T getDiscoveryDoc(Cache<ApiKey, T> cache, String root, String name, String version,
    Callable<T> loader) throws NotFoundException, InternalServerErrorException {
  ApiKey key = new ApiKey(name, version, root);
  try {
    return cache.get(key, loader);
  } catch (ExecutionException | UncheckedExecutionException e) {
    // Cast here so we can maintain specific errors for documentation in throws clauses.
    if (e.getCause() instanceof NotFoundException) {
      throw (NotFoundException) e.getCause();
    } else if (e.getCause() instanceof InternalServerErrorException) {
      throw (InternalServerErrorException) e.getCause();
    } else {
      logger.log(Level.SEVERE, "Could not generate or cache discovery doc", e.getCause());
      throw new InternalServerErrorException("Internal Server Error", e.getCause());
    }
  }
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:18,代码来源:CachingDiscoveryProvider.java

示例2: get

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
/**
 * Responds with the {@link WaxDataItem} resource requested.
 *
 * @throws NotFoundException if the session doesn't exist or has no {@link WaxDataItem} with the
 *         requested id
 */
@ApiMethod(
    name = "items.get",
    path = "sessions/{sessionId}/items/{itemId}")
public WaxDataItem get(@Named("sessionId") String sessionId, @Named("itemId") String itemId)
    throws NotFoundException {
  try {
    WaxDataItem item = store.get(sessionId, itemId);
    if (item != null) {
      return item;
    }
    throw new NotFoundException("Invalid itemId: " + itemId);
  } catch (InvalidSessionException e) {
    throw new NotFoundException(e.getMessage());
  }
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:22,代码来源:WaxEndpoint.java

示例3: sendTestSms

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@ApiMethod(
        name = "sendTestSms",
        path = "sendTestSms",
        httpMethod = ApiMethod.HttpMethod.POST
)
@SuppressWarnings("unused")
public StringWrapperObject sendTestSms(
        // final HttpServletRequest httpServletRequest,
        final User googleUser,
        final @Named("phoneNumber") String phoneNumber,
        final @Named("smsMessage") String smsMessage
        // see: https://cloud.google.com/appengine/docs/java/endpoints/exceptions
) throws UnauthorizedException, BadRequestException, NotFoundException, NumberParseException,
        IllegalArgumentException, TwilioRestException {

    /* --- Check authorization: */
    CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaOfficer(googleUser);

    /* --- Send SMS */
    Message message = TwilioUtils.sendSms(phoneNumber, smsMessage);

    return new StringWrapperObject(message.toJSON());

}
 
开发者ID:Cryptonomica,项目名称:cryptonomica,代码行数:25,代码来源:OnlineVerificationAPI.java

示例4: removeFriend

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
/**
 * Remove user's friend
 *
 * @param friendId The user id of the friend to remove
 * @param user The Google Authenticated User
 */
@ApiMethod(
        name = "friends.remove",
        path = "friends/{friendId}",
        httpMethod = ApiMethod.HttpMethod.DELETE
)
public void removeFriend(@Named("friendId") long friendId, User user)
        throws OAuthRequestException, BadRequestException, NotFoundException, IOException {

    UserRecord currentUser = userDAO.getUserRecord(user);
    if (currentUser == null) {
        throw new OAuthRequestException(Messages.ERROR_AUTH);
    }

    if (friendId == 0) {
        throw new BadRequestException(Messages.ERROR_INVALID_PARAMETERS);
    }

    FriendRecord friendRecord = friendDAO.getFriendRecord(currentUser);
    if (friendRecord != null && friendRecord.removeFriend(friendId)) {
        // if friend was found and removed then update friend record
        friendDAO.save(friendRecord);
    } else {
        throw new NotFoundException(Messages.ERROR_FRIEND_NOT_FOUND);
    }
}
 
开发者ID:AndrewJack,项目名称:moment-for-android-wear,代码行数:32,代码来源:FriendEndpoint.java

示例5: getUserSyncedWithProvider

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
/**
 * Checks if user exists on provider, syncs with tech gallery's datastore. If
 * user exists, adds to TG's datastore (if not there). Returns the user.
 *
 * @param userLogin
 *          userLogin
 * @return the user saved on the datastore
 * @throws InternalServerErrorException
 *           in case something goes wrong
 * @throws NotFoundException
 *           in case the information are not founded
 * @throws BadRequestException
 *           in case a request with problem were made.
 * @return user sinchronized in provider.
 */
@Override
public TechGalleryUser getUserSyncedWithProvider(final String userLogin)
    throws NotFoundException, InternalServerErrorException, BadRequestException {
  TechGalleryUser tgUser = null;
  TechGalleryUser userResp = getUserFromProvider(userLogin);
  tgUser = userDao.findByEmail(getUserFromProvider(userLogin).getEmail());
  if (tgUser == null) {
    tgUser = new TechGalleryUser();
    tgUser.setEmail(userResp.getEmail());
    tgUser.setName(userResp.getName());
    tgUser = addUser(tgUser);
    // Key<TechGalleryUser> key = userDao.add(tgUser);
    // tgUser.setId(key.getId());
  }
  return tgUser;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:32,代码来源:UserServiceTGImpl.java

示例6: get

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
/**
 * Returns the {@link Article} with the corresponding ID.
 *
 * @param id the ID of the entity to be retrieved
 * @return the entity with the corresponding ID
 * @throws NotFoundException if there is no {@code Article} with the provided ID.
 */
@ApiMethod(
        name = "get",
        path = "article/{id}",
        httpMethod = ApiMethod.HttpMethod.GET)
public Article get(@Named("id") Long id,
                   @Nullable @Named("timehash") Long timehash, @Nullable @Named("cert") String cert)
        throws NotFoundException, UnauthorizedException, ForbiddenException {
    validateRequest(timehash, cert);

    Article article = ObjectifyService.ofy().load().type(Article.class).id(id).now();
    if (article == null) {
        throw new NotFoundException("Could not find Article with ID: " + id);
    }
    return article;
}
 
开发者ID:kimkha,项目名称:triethocduongpho,代码行数:23,代码来源:Article2Endpoint.java

示例7: getRecommendations

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public List<Response> getRecommendations(String technologyId, User user)
    throws BadRequestException, InternalServerErrorException {
  Technology technology;
  try {
    technology = technologyService.getTechnologyById(technologyId, user);
  } catch (final NotFoundException e) {
    return null;
  }
  final List<TechnologyRecommendation> recommendations =
      technologyRecommendationDAO.findAllActivesByTechnology(technology);
  final List<Response> recommendationTOs = new ArrayList<Response>();
  for (final TechnologyRecommendation recommendation : recommendations) {
    recommendationTOs.add(techRecTransformer.transformTo(recommendation));
  }
  return recommendationTOs;

}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:19,代码来源:TechnologyRecommendationServiceImpl.java

示例8: deleteRecommendById

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public Response deleteRecommendById(Long recommendId, User user)
    throws BadRequestException, NotFoundException, InternalServerErrorException {
  final TechnologyRecommendation recommendation =
      technologyRecommendationDAO.findById(recommendId);
  final TechGalleryUser techUser = userService.getUserByEmail(user.getEmail());

  validateDeletion(recommendId, recommendation, user, techUser);

  recommendation.setActive(false);
  technologyRecommendationDAO.update(recommendation);
  technologyService.removeRecomendationCounter(recommendation.getTechnology().get(),
      recommendation.getScore());

  UserProfileServiceImpl.getInstance().handleRecommendationChanges(recommendation);
  return techRecTransformer.transformTo(recommendation);
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:18,代码来源:TechnologyRecommendationServiceImpl.java

示例9: addComment

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public TechnologyComment addComment(TechnologyComment comment, User user)
    throws InternalServerErrorException, BadRequestException, NotFoundException {
  log.info("Starting creating Technology Comment.");

  final Technology technology = comment.getTechnology().get();

  validateUser(user);
  validateComment(comment);
  validateTechnology(technology);

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  final TechnologyComment newComment = addNewComment(comment, techUser, technology);
  techService.addCommentariesCounter(technology);
  techService.audit(technology.getId(), user);

  followTechnology(technology, techUser);

  UserProfileServiceImpl.getInstance().handleCommentChanges(newComment);
  return newComment;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:22,代码来源:TechnologyCommentServiceImpl.java

示例10: addRecommendationComment

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public TechnologyRecommendation addRecommendationComment(TechnologyRecommendation recommendation,
    TechnologyComment comment, Technology technology, User user)
        throws BadRequestException, InternalServerErrorException, NotFoundException {

  if (!isValidComment(comment)) {
    throw new BadRequestException(ValidationMessageEnums.COMMENT_CANNOT_BLANK.message());
  }
  Key<Technology> techKey = Key.create(Technology.class, technology.getId());
  comment.setTechnology(Ref.create(techKey));
  comment = comService.addComment(comment, user);
  recommendation.setComment(Ref.create(comment));
  recommendation.setTimestamp(new Date());
  recommendation.setTechnology(Ref.create(techKey));
  recommendation = recService.addRecommendation(recommendation, user);
  technologyService.audit(technology.getId(), user);

  return recommendation;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:20,代码来源:TechnologyRecommendationCommentServiceImpl.java

示例11: transformGroupedUserMapIntoList

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
private List<EndorsementsGroupedByEndorsedTransient> transformGroupedUserMapIntoList(
    Map<TechGalleryUser, List<TechGalleryUser>> mapUsersGrouped, String techId)
        throws BadRequestException, NotFoundException, InternalServerErrorException,
        OAuthRequestException {
  final List<EndorsementsGroupedByEndorsedTransient> groupedList =
      new ArrayList<EndorsementsGroupedByEndorsedTransient>();

  for (final Map.Entry<TechGalleryUser, List<TechGalleryUser>> entry : mapUsersGrouped
      .entrySet()) {
    final EndorsementsGroupedByEndorsedTransient grouped =
        new EndorsementsGroupedByEndorsedTransient();
    grouped.setEndorsed(entry.getKey());
    final Skill response = skillService.getUserSkill(techId, entry.getKey());
    if (response != null) {
      grouped.setEndorsedSkill(response.getValue());
    } else {
      grouped.setEndorsedSkill(0);
    }
    grouped.setEndorsers(entry.getValue());
    groupedList.add(grouped);
  }
  return groupedList;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:24,代码来源:EndorsementServiceImpl.java

示例12: addLink

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public TechnologyLink addLink(TechnologyLink link, User user)
    throws InternalServerErrorException, BadRequestException, NotFoundException {
  log.info("Starting creating Technology Link.");

  final Technology technology = link.getTechnology().get();

  validateUser(user);
  validateLink(link);
  validateTechnology(technology);

  final TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  final TechnologyLink newLink = addNewLink(link, techUser, technology);

  // TODO: Adicionar contador de links na tecnologia
  // techService.addLinksCounter(technology);
  techService.audit(technology.getId(), user);

  followTechnology(technology, techUser);

  return newLink;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:23,代码来源:TechnologyLinkServiceImpl.java

示例13: getLinksByTech

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public Response getLinksByTech(String techId, User user) throws InternalServerErrorException,
    BadRequestException, NotFoundException, OAuthRequestException {

  final Technology technology = techService.getTechnologyById(techId, user);

  validateUser(user);
  validateTechnology(technology);

  final List<TechnologyLink> linksByTech =
      technologyLinkDao.findAllByTechnology(technology);
  final TechnologyLinksTO response = new TechnologyLinksTO();
  response.setLinks(linksByTech);

  return response;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:17,代码来源:TechnologyLinkServiceImpl.java

示例14: addOrUpdateSkill

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
@Override
public Skill addOrUpdateSkill(Skill skill, User user)
    throws InternalServerErrorException, BadRequestException, NotFoundException {

  log.info("Starting creating or updating skill");

  validateInputs(skill, user);

  Technology technology = skill.getTechnology().get();
  TechGalleryUser techUser = userService.getUserByGoogleId(user.getUserId());
  Skill skillEntity = skillDao.findByUserAndTechnology(techUser, technology);

  // if there is a skillEntity, it is needed to inactivate it and create a new
  // one
  inactivateSkill(skillEntity);

  final Skill newSkill = addNewSkill(skill, techUser, technology);

  UserProfileServiceImpl.getInstance().handleSkillChanges(newSkill);
  return newSkill;
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:22,代码来源:SkillServiceImpl.java

示例15: getTechnologies

import com.google.api.server.spi.response.NotFoundException; //导入依赖的package包/类
/**
 * GET for getting all technologies.
 *
 * @throws NotFoundException
 *           .
 */
@Override
public Response getTechnologies(User user)
    throws InternalServerErrorException, NotFoundException, BadRequestException {
  List<Technology> techEntities = technologyDAO.findAllActives();
  // if list is null, return a not found exception
  if (techEntities == null || techEntities.isEmpty()) {
    return new TechnologiesResponse();
  } else {
    verifyTechnologyFollowedByUser(user, techEntities);
    TechnologiesResponse response = new TechnologiesResponse();
    Technology.sortTechnologiesDefault(techEntities);
    response.setTechnologies(techEntities);
    return response;
  }
}
 
开发者ID:ciandt-dev,项目名称:tech-gallery,代码行数:22,代码来源:TechnologyServiceImpl.java


注:本文中的com.google.api.server.spi.response.NotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。