private Feed getUserFeed() throws UriBuilderException, IllegalArgumentException { Feed userFeed = getFeed(userName, new Date()); userFeed.setTitle(userName); // add a self link userFeed.addLink(getSelfLink()); // add a edit link Link editLink = getAbderaFactory().newLink(); editLink.setHref(getUriInfo().getRequestUri().toString()); editLink.setRel(Link.REL_EDIT); editLink.setMimeType(MediaType.APPLICATION_JSON); userFeed.addLink(editLink); // add a alternate link Link altLink = getAbderaFactory().newLink(); altLink.setHref( getRelativeURIBuilder() .path(OrganizationUserResource.class) .path(USER_CONTENT_METHOD) .build(organizationUniqueShortName, userName) .toString()); altLink.setRel(Link.REL_ALTERNATE); altLink.setMimeType(MediaType.APPLICATION_JSON); userFeed.addLink(altLink); Link privilegesLink = getAbderaFactory().newLink(); privilegesLink.setHref( getRelativeURIBuilder() .path(UserPrivilegesResource.class) .build(organizationUniqueShortName, userName) .toString()); privilegesLink.setRel(REL_USER_PRIVILEGES); privilegesLink.setMimeType(MediaType.APPLICATION_JSON); userFeed.addLink(privilegesLink); Link rolesLink = getAbderaFactory().newLink(); rolesLink.setHref( getRelativeURIBuilder() .path(UserRolesResource.class) .build(organizationUniqueShortName, userName) .toString()); rolesLink.setRel(REL_USER_ROLES); rolesLink.setMimeType(MediaType.APPLICATION_JSON); userFeed.addLink(rolesLink); Link organizationLink = getAbderaFactory().newLink(); organizationLink.setHref( getRelativeURIBuilder() .path(OrganizationResource.class) .build(organizationUniqueShortName) .toString()); organizationLink.setRel("organization"); organizationLink.setMimeType(MediaType.APPLICATION_JSON); userFeed.addLink(organizationLink); return userFeed; }
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(); }