コード例 #1
0
  /**
   * Delete a bookmark from current user's collection.
   *
   * @param inActionContext action context.
   * @return true upon successful completion.
   */
  @Override
  public Serializable execute(final PrincipalActionContext inActionContext) {
    Person person =
        personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId()));
    Long ssIdToRemove = (Long) inActionContext.getParams();
    List<StreamScope> bookmarks = person.getBookmarks();

    log.debug("Attempting to delete bookmark with id: " + ssIdToRemove);

    for (StreamScope ss : bookmarks) {
      log.debug("Examinging SS with id: " + ss.getId());
      if (ss.getId() == ssIdToRemove) {
        log.debug("Match found!");
        bookmarks.remove(ss);
        personMapper.flush();
        break;
      }
    }

    return Boolean.TRUE;
  }
コード例 #2
0
  /**
   * Get the activities.
   *
   * @param id the id of the composite stream.
   * @param openSocialId the open social id of the user.
   * @param maxCount the number of activities to return
   * @return the activity DTOs.
   * @throws Exception exception.
   */
  @SuppressWarnings("unchecked")
  public PagedSet<ActivityDTO> getActivities(
      final Long id, final String openSocialId, final int maxCount) throws Exception {
    // checks to see if composite stream is still valid
    FindByIdRequest findByIdRequest = new FindByIdRequest("StreamView", id);
    StreamView stream = findByIdMapper.execute(findByIdRequest);

    if (stream == null) {
      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND);
    }

    // create the request
    GetActivitiesByCompositeStreamRequest request =
        new GetActivitiesByCompositeStreamRequest(id, maxCount);
    request.setMaxActivityId(Long.MAX_VALUE);

    // Create the actionContext
    PrincipalActionContext ac =
        new ServiceActionContext(request, principalPopulator.getPrincipal(openSocialId));

    // execute action and return results.
    return (PagedSet<ActivityDTO>)
        serviceActionController.execute((ServiceActionContext) ac, action);
  }