示例#1
0
  /**
   * @param params
   * @param request
   * @param response
   * @return
   * @throws RepositoryException
   * @throws JCRNodeFactoryServiceException
   * @throws IOException
   */
  private Map<String, Object> doIgnoreConnect(
      FriendsParams params, HttpServletRequest request, HttpServletResponse response)
      throws JCRNodeFactoryServiceException, RepositoryException, IOException {
    FriendsBean myFriends = friendsResolverService.resolve(params.uuid);
    FriendsBean friendFriends = friendsResolverService.resolve(params.friendUuid);
    if (!myFriends.hasFriend(params.friendUuid) || !friendFriends.hasFriend(params.uuid)) {
      throw new RestServiceFaultException(
          HttpServletResponse.SC_NOT_FOUND, " The friend connection is missing ");
    }
    FriendBean myFriendBean = myFriends.getFriend(params.friendUuid);
    FriendBean friendFriendBean = friendFriends.getFriend(params.uuid);
    if (!myFriendBean.isInState(FriendStatus.INVITED)
        || !friendFriendBean.isInState(FriendStatus.PENDING)) {
      throw new RestServiceFaultException(
          HttpServletResponse.SC_CONFLICT, "The invitation to connect is not current");
    }

    myFriends.removeFriend(params.friendUuid);
    friendFriends.removeFriend(params.uuid);
    authzResolverService.setRequestGrant("Saving Ignore Connect");
    try {
      myFriends.save();
      friendFriends.save();
      jcrService.getSession().save();
    } finally {
      authzResolverService.clearRequestGrant();
    }
    return OK;
  }
示例#2
0
  /**
   * @param params
   * @param request
   * @param response
   * @return
   * @throws RepositoryException
   * @throws JCRNodeFactoryServiceException
   * @throws IOException
   */
  private Map<String, Object> doRemoveConnect(
      FriendsParams params, HttpServletRequest request, HttpServletResponse response)
      throws JCRNodeFactoryServiceException, RepositoryException, IOException {
    FriendsBean myFriends = friendsResolverService.resolve(params.uuid);
    FriendsBean friendFriends = friendsResolverService.resolve(params.friendUuid);
    if (!myFriends.hasFriend(params.friendUuid) || !friendFriends.hasFriend(params.uuid)) {
      throw new RestServiceFaultException(
          HttpServletResponse.SC_NOT_FOUND, " The friend connection is missing ");
    }
    myFriends.removeFriend(params.friendUuid);
    friendFriends.removeFriend(params.uuid);

    authzResolverService.setRequestGrant("Saving Remove Connect");
    try {
      myFriends.save();
      friendFriends.save();
      jcrService.getSession().save();
    } finally {
      authzResolverService.clearRequestGrant();
    }
    return OK;
  }