private Feed createAtomObject(String spid, String contentLocation) throws Exception {
    PID pid = PID.getInstance(spid);
    Date date = new Date(1);
    String title = "title";
    String author = "org.fcrepo.test.api.TestManagedDatastreams";

    Feed feed = abdera.newFeed();
    feed.setId(pid.toURI());
    feed.setTitle(title);
    feed.setUpdated(date);
    feed.addAuthor(author);

    if (contentLocation != null && contentLocation.length() > 0) {
      addAtomManagedDatastream(feed, contentLocation);
    }

    return feed;
  }
  private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {

    Target target = context.getTarget();
    String collection = target.getParameter("collection");
    LOG.debug("Feed for collection:" + collection);

    // String priority = target.getParameter("priority");
    // String deadline = target.getParameter("deadline");
    // Locale preferredLocale = context.getPreferredLocale();

    String user = target.getParameter("user");
    String password = target.getParameter("password");
    String token = target.getParameter("token");

    Feed feed = createFeedBase(context);

    TokenClient tokenClient = Configuration.getInstance().getTokenClient();
    try {
      if (token != null) {
        Property[] props = tokenClient.getTokenProperties(token);
        user =
            (String)
                PropertyUtils.getProperty(props, AuthenticationConstants.PROPERTY_USER).getValue();
      } else if (user != null && password != null) {
        token = tokenClient.authenticateUser(user, password);
      } else throw new Exception("No credentials");

      feed.setSubtitle("This is a feed for the following user:"******"Credential exception", e1);
      throw new ResponseContextException(500, e1);
    }

    feed.setId("IntalioFEEDID");

    feed.setMustPreserveWhitespace(true);
    feed.setUpdated(new Date());
    try {
      ITaskManagementService client =
          new RemoteTMSFactory(Configuration.getInstance().getTmsService(), token).getService();
      if (collection.equalsIgnoreCase(IntalioFeeds.PROCESSES.name())) {
        feed.setTitle("Intalio Processes");
        addTasksToFeed(
            context,
            feed,
            client.getAvailableTasks(PIPATask.class.getSimpleName(), null),
            token,
            user);
      } else if (collection.equalsIgnoreCase(IntalioFeeds.TASKS.name())) {
        feed.setTitle("Intalio Tasks");
        addTasksToFeed(
            context,
            feed,
            client.getAvailableTasks(
                PATask.class.getSimpleName(), "T._state <> TaskState.COMPLETED"),
            token,
            user);
        addTasksToFeed(
            context,
            feed,
            client.getAvailableTasks(
                Notification.class.getSimpleName(), "T._state <> TaskState.COMPLETED"),
            token,
            user);
      } else if (collection.equalsIgnoreCase(IntalioFeeds.ALL.name())) {
        feed.setTitle("Full Intalio Feeds");
        addTasksToFeed(context, feed, client.getTaskList(), token, user);
      } else throw new Exception("Invalid collection requestsed");

      feed.addCategory(collection);

    } catch (Exception e) {
      LOG.error("Feed exception", e);
      throw new ResponseContextException(500, e);
    }

    if (LOG.isDebugEnabled())
      try {
        feed.writeTo(System.out);
      } catch (IOException e) {
      }
    return feed.getDocument();
  }