Java API:Relay

Java API:Relay

From LongJump Support Wiki

Java API:Relay
Jump to: navigation, search

The Java APIs for Relay let you do social networking programmatically.

Contents


Group Methods

getSocialGroup

Get group details.

Syntax
SocialGroupBean sgb = Functions.getSocialGroup(String id);
Parameters
id
The ID of the group
Returns
A SocialGroupBean object containing group information.
Throws
Exception

addSocialGroup

Add a group.

Syntax
String group_id = Functions.addSocialGroup(SocialGroupBean sgb);
Parameters
sgb
A SocialGroupBean object containing group information.
Returns
A string containing the ID of the new group.
Throws
Exception

updateSocialGroup

Update a group.

Syntax
void Functions.updateSocialGroup(SocialGroupBean sgb, String groupId);
Parameters
sgb
A SocialGroupBean object that contains group information.
groupId
The group ID
Throws
Exception

deleteSocialGroup

Delete a group.

Syntax
void Functions.deleteSocialGroup(String groupId);
Parameters
id
The ID of the group
Throws
Exception

searchSocialGroups

Search groups.

Syntax
List groups = Functions.searchSocialGroups(SearchContext sc);
Parameters
sc
A SearchContext object that defines the search.
Returns
A list of strings containing IDs of groups.
Throws
Exception
Example
SearchContext searchContext = new SearchContext();

searchContext.setFieldList("*");
searchContext.setFilter("privateGroup equals '1'"); //criteria
searchContext.setPage(0);
searchContext.setPageSize(5000);
searchContext.setSortBy("date_created");
searchContext.setSortBy2("");
searchContext.setSortOrder("DESC");
searchContext.setSortOrder2("");

List<SocialBean<SocialGroupBean>> results = searchSocialGroups(searchContext);

Messaging Methods

addSocialFeed

Post a message.

Syntax
String feed_id = Functions.addSocialFeed(SocialFeedBean sfb);
Parameters
sfb
A SocialFeedBean containing the message to post.
Returns
A string containing the ID of the posted message.
Throws
Exception

getSocialFeed

Get a posted message.

Syntax
SocialFeedBean posting = Functions.getSocialFeed(String id);
Parameters
Returns
A SocialFeedBean instance that contains the details of the posting.
Throws
Exception

deleteSocialFeed

Delete a posted message.

Syntax
void Functions.deleteSocialFeed(String feedId);
Parameters
feedId
The ID of the post.
Throws
Exception

searchSocialFeeds

Search postings.

Syntax
List feeds = Functions.searchSocialFeeds(SearchContext sc);
Parameters
sc
A SearchContext object that defines the search.
Returns
A list of strings containing IDs of posted messages.
Throws
Exception
Example
<syntaxhiglight lang="java" enclose="div">

SearchContext searchContext = new SearchContext();

searchContext.setFieldList("feedMessage,feedToType"); searchContext.setFilter("feedToType equals 'record'"); //criteria searchContext.setPage(0); searchContext.setPageSize(5000); searchContext.setSortBy("date_created"); searchContext.setSortBy2(""); searchContext.setSortOrder("DESC"); searchContext.setSortOrder2("");

List<SocialBean<SocialFeedBean>> results = searchSocialFeeds(searchContext ); for (SocialBean<SocialFeedBean> sb: results) {

   SocialFeedBean sfb = sb.getObject();
   Functions.debug(sfb.getFeedMessage());

} </syntaxhighlight>

Message Voting

getSocialVotes

Get a count of votes on a post.

Syntax
CollectionBean votes;
votes = Functions.getSocialVotes(String id, String action, String criteria);
Parameters
id
The ID of a posted message.
action
A string containing the voting action:
  • "like"
criteria
A filter expression that specifies the kinds of votes to select.
Returns
A CollectionBean containing IDBean objects that point to User records.
Throws
Exception

socialVote

Vote on a post ("like").

Syntax
void Functions.socialVote(String id, String action);
Parameters
id
The ID of the posted message you're voting on.
action
A string containing the voting action:
  • "like"
Throws
Exception

Follow Methods

socialFollow

Follow a resource.

Syntax
void Functions.socialFollow(SocialBean sb);
Parameters
SocialBean
An instance of a SocialBean subclass:
Throws
Exception
Example
SocialRecordBean srb = new SocialRecordBean();
srb.setObjectId("__object name__");
srb.setRecordId("__record Id__");
srb.setFollower("__user id__", "__user name__");
Functions.socialFollow(new SocialBean(srb));

socialUnFollow

Unfollow a resource.

Syntax
void Functions.socialUnfollow(SocialBean sb);
Parameters
SocialBean
An instance of a SocialBean subclass:
Throws
Exception

getSocialFollowers

Get a list of users who are following a resource.

Syntax
CollectionsBean followers;
followers = Functions.getSocialFollowers(String type, String id, String objectId, String criteria);
Parameters
type
A string containing one of the Relay Feed Types. (required)
id
The ID of the feed. (required)
objectId
Required if the feed type is "record". Otherwise, it can be an empty string.
criteria
An optional filter expression that specifies records to select. Otherwise, it can be an empty string.
Returns
A CollectionBean containing the SocialUserBean objects for users who are following the resource.
Throws
Exception

getSocialFollowing

List the things a user is following.

Syntax
CollectionBean feeds
feeds = Functions.getSocialFollowing(String userId, String criteria);
Parameters
userId
The userID. If an empty string is supplied, the method returns values for the currently logged in user.
criteria
An optional filter expression that specifies records to select. If an empty string is supplied, the function returns everything the user is following.
Returns
A CollectionBean containing instances of things the user is following:
Throws
Exception

Notification Methods

getSocialNotificationsCount

Get a count of current user's unread notifications.

Syntax
int count = Functions.getSocialNotificationsCount();
Returns
An integer containing the number of new notification messages.
Throws
Exception

getSocialNotificationsList

Get current user's notifications (new only or all, depending on the argument).

Syntax
CollectionsBean notifications;
notifications= Functions.getSocialNotificationsList(boolean show_new);
Parameters
show_new
  • If true, only new (unread) notifications are returned.
  • If false, all notifications are returned.
Returns
A CollectionBean containing SocialNotificationBean objects.
Throws
Exception

setAllSocialNotificationsRead

Mark all notifications as read.

Syntax
void = Functions.setAllSocialNotificationsRead();
Throws
Exception
Personal tools