本文整理汇总了Java中org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn类的典型用法代码示例。如果您正苦于以下问题:Java ActionReturn类的具体用法?Java ActionReturn怎么用?Java ActionReturn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActionReturn类属于org.sakaiproject.entitybroker.entityprovider.extension包,在下文中一共展示了ActionReturn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPost
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action = "post", viewKey = EntityView.VIEW_LIST)
public ActionReturn getPost(EntityView view, Map<String, Object> params) {
String userId = getCheckedUser();
String postId = (String) params.get("postId");
if (StringUtils.isBlank(postId)) {
throw new EntityException("You must supply a postId" , "", HttpServletResponse.SC_BAD_REQUEST);
}
Post post = commonsManager.getPost(postId, true);
if (post != null) {
return new ActionReturn(post);
} else {
throw new EntityException("No post with id '" + postId + "'" , "", HttpServletResponse.SC_NOT_FOUND);
}
}
示例2: handleDeletePost
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action = "deletePost", viewKey = EntityView.VIEW_LIST)
public ActionReturn handleDeletePost(Map<String, Object> params) {
log.debug("handleDeletePost");
getCheckedUser();
String postId = (String) params.get("postId");
String commonsId = (String) params.get("commonsId");
String siteId = (String) params.get("siteId");
if (StringUtils.isBlank(postId) || StringUtils.isBlank(commonsId) || StringUtils.isBlank(siteId)) {
throw new EntityException("You must supply a postId, a commonsId and a siteId."
, "", HttpServletResponse.SC_BAD_REQUEST);
}
if (commonsManager.deletePost(postId)) {
String reference = PostReferenceFactory.getReference(commonsId, postId);
sakaiProxy.postEvent(CommonsEvents.POST_DELETED,
reference,
siteId);
return new ActionReturn("SUCCESS");
} else {
return new ActionReturn("FAIL");
}
}
示例3: getConnections
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="connections",viewKey=EntityView.VIEW_SHOW)
public Object getConnections(EntityView view, EntityReference ref) {
if(!sakaiProxy.isLoggedIn()) {
throw new SecurityException("You must be logged in to get a connection list.");
}
//convert input to uuid
String uuid = sakaiProxy.ensureUuid(ref.getId());
if(StringUtils.isBlank(uuid)) {
throw new EntityNotFoundException("Invalid user.", ref.getId());
}
//get list of connections
List<BasicConnection> connections = connectionsLogic.getBasicConnectionsForUser(uuid);
if(connections == null) {
throw new EntityException("Error retrieving connections for " + ref.getId(), ref.getReference());
}
return new ActionReturn(connections);
}
示例4: getUnreadMessagesCount
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="unreadMessagesCount",viewKey=EntityView.VIEW_SHOW)
public Object getUnreadMessagesCount(EntityReference ref) {
if (!sakaiProxy.isLoggedIn()) {
throw new SecurityException("You must be logged in to get the unread messages count.");
}
//convert input to uuid
String uuid = sakaiProxy.ensureUuid(ref.getId());
if (StringUtils.isBlank(uuid)) {
throw new EntityNotFoundException("Invalid user.", ref.getId());
}
if (sakaiProxy.isAdminUser() || sakaiProxy.getCurrentUserId().equals(uuid)) {
return new ActionReturn(messagingLogic.getAllUnreadMessagesCount(uuid));
} else {
throw new SecurityException("You can only view your own message count.");
}
}
示例5: getFormattedProfile
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="formatted",viewKey=EntityView.VIEW_SHOW)
public Object getFormattedProfile(EntityReference ref, EntityView view) {
//this allows a normal full profile to be returned formatted in HTML
final boolean wantsOfficial = StringUtils.equals("official", view.getPathSegment(3)) ? true : false;
//get the full profile
UserProfile userProfile = (UserProfile) getEntity(ref);
//Check for siteId in the request
String siteId = requestGetter.getRequest().getParameter("siteId");
//convert UserProfile to HTML object
String formattedProfile = getUserProfileAsHTML(userProfile, siteId, wantsOfficial);
//ActionReturn actionReturn = new ActionReturn("UTF-8", "text/html", entity);
ActionReturn actionReturn = new ActionReturn(Formats.UTF_8, Formats.HTML_MIME_TYPE, formattedProfile);
return actionReturn;
}
示例6: getExport
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
/**
* Gets the output data.
*
* Does not require a HTTP request/response
*
* @param out
* @param reference
* @param parameters
* @throws IOException
*/
@EntityCustomAction(action = "get-export", viewKey = EntityView.VIEW_SHOW)
public ActionReturn getExport(final OutputStream out, final EntityReference reference,
final Map<String, Object> parameters) {
final String userId = getUserId(reference);
final String siteId = getSiteId(reference);
try {
if (this.sakaiProxy.hasUserSitePermission(userId, RosterFunctions.ROSTER_FUNCTION_EXPORT, siteId)) {
final RosterSite site = getSite(reference, siteId);
final Workbook workbook = getExportData(userId, site, parameters);
workbook.write(out);
out.close();
final ActionReturn actionReturn = new ActionReturn("base64",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", out);
return actionReturn;
} else {
throw new EntityException(MSG_NO_EXPORT_PERMISSION, reference.getReference());
}
} catch (final IOException e) {
log.error(MSG_NO_FILE_CREATED, e);
throw new EntityException(MSG_NO_FILE_CREATED, reference.getReference());
}
}
示例7: addOrUpdateMembership
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="membership", viewKey=EntityView.VIEW_EDIT)
public ActionReturn addOrUpdateMembership(EntityView view, Map<String, Object> params) {
validateRequest(params, null);
String eid = view.getPathSegment(1);
String userEid = (String)params.get("userId");
if (userEid == null) throw new IllegalArgumentException("Missing required parameter: userEid");
String role = (String)params.get("role");
if (role == null) throw new IllegalArgumentException("Missing required parameter: role");
String status = (String)params.get("status");
if (status == null) throw new IllegalArgumentException("Missing required parameter: status");
MembershipData data = new MembershipData();
data.userId = userEid;
data.role = role;
data.status = status;
data.memberContainer = eid;
addOrUpdateMembership(data);
return null;
}
示例8: handleSiteMembershipPreservesDotsInSiteIdPathParams_GET
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@Test
public void handleSiteMembershipPreservesDotsInSiteIdPathParams_GET() throws IdUnusedException {
EntityView entityView = new EntityView("/membership/site/site.with.dots.json");
entityView.setMethod(EntityView.Method.GET);
Site site = mock(Site.class);
when(site.getId()).thenReturn("site.with.dots");
EntityUser user = new EntityUser();
user.setId("user-foo");
user.setEid("user-foo");
Member member = mock(Member.class);
when(member.getUserId()).thenReturn("user-foo");
when(member.getUserEid()).thenReturn("user-foo");
Set<Member> members = new HashSet<Member>();
members.add(member);
when(site.getMembers()).thenReturn(members);
when(siteService.getSite("site.with.dots")).thenReturn(site);
when(developerHelperService.getCurrentUserReference()).thenReturn("/user/me");
when(siteService.allowViewRoster("site.with.dots")).thenReturn(true);
when(userEntityProvider.getUserById("user-foo")).thenReturn(user);
ActionReturn result =
provider.handleSiteMemberships(entityView, new HashMap<String, Object>());
assertEquals(1, result.getEntitiesList().size());
assertEquals("user-foo::site:site.with.dots", result.getEntitiesList().get(0).getEntityId());
}
示例9: statistics
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
/**
* GET /direct/lap-sakai-extractor/statistics
*
* @param view
* @return
*/
@EntityCustomAction(action="statistics", viewKey=EntityView.VIEW_LIST)
public ActionReturn statistics(EntityView view) {
if (!extractorService.isAdminSession()){
throw new SecurityException("User not allowed to access statistics data.", null);
}
Map<String, Map<String, String>> lastExtractionDate = data.getLatestExtractionDate();
String nextExtractionDate = data.getNextScheduledExtractionDate();
Map<String, Map<String, String>> allExtractionDates = data.getExtractionDates();
Map<String, String> availableFiles = data.getAvailableFiles();
Map<String, Object> responseData = new HashMap<String, Object>(4);
responseData.put(Constants.REST_MAP_KEY_LATEST_EXTRACTION_DATE, lastExtractionDate);
responseData.put(Constants.REST_MAP_KEY_NEXT_EXTRACTION_DATE, nextExtractionDate);
responseData.put(Constants.REST_MAP_KEY_ALL_EXTRACTION_DATES, allExtractionDates);
responseData.put(Constants.REST_MAP_KEY_AVAILABLE_FILES, availableFiles);
responseData.put(Constants.REST_MAP_KEY_VALID_FILE_SYSTEM, fileService.isValidFileSystem());
Gson gson = new Gson();
String json = gson.toJson(responseData, HashMap.class);
return new ActionReturn(Constants.ENCODING_UTF8, Formats.JSON, json);
}
开发者ID:Apereo-Learning-Analytics-Initiative,项目名称:LAP-Sakai-Extractor,代码行数:30,代码来源:ExtractorProvider.java
示例10: getLibrary
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="library", viewKey=EntityView.VIEW_LIST)
public Object getLibrary(EntityView view, Search search) {
// GET /kaltura/library/site/{siteId}
// GET /kaltura/library/tool/{toolId}
int start = 0;
int limit = 0;
String locationId = null;
Filter filter = null;
String searchFilter = null;
String locType = view.getPathSegment(2);
String locId = view.getPathSegment(3);
if (locType == null || locId == null) {
throw new IllegalArgumentException("expects a URL like: GET /kaltura/library/site/{siteId} OR GET /kaltura/library/tool/{toolId}");
}
if ("tool".equals(locType)) {
locationId = getLocationIdFromToolId(locId);
} else {
locationId = "/"+locType+"/"+locId;
}
if (search != null) {
Restriction sharedR = search.getRestrictionByProperties(new String[] {"shared"});
if (sharedR != null && sharedR.getBooleanValue()) {
filter = Filter.SHARED;
}
Restriction filterR = search.getRestrictionByProperty("search");
if (filterR != null) {
searchFilter = filterR.getStringValue();
}
start = (int) search.getStart();
limit = (int) search.getLimit();
}
if (locationId == null) {
locationId = developerHelperService.getCurrentLocationReference();
}
List<MediaItem> mediaItems = "isMyMedia".equals(locId) ? service.getMyMedia(null, null, start, limit) :
service.getLibrary(locationId, filter, searchFilter, null, start, limit);
return new ActionReturn(mediaItems);
}
示例11: replaceCollectionItems
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="replace", viewKey=EntityView.VIEW_EDIT)
public ActionReturn replaceCollectionItems(EntityView view, Map<String, Object> data) {
// POST /kaltura/{cid}/replace (list of item ids in params are required)
// added for https://jira.sakaiproject.org/browse/SKE-174
String cid = view.getEntityReference().getId();
if (cid == null) {
throw new IllegalArgumentException("expects a URL like: PUT /kaltura/{cid}/replace WITH an 'ids[]' param containing ordered list of item ids for the collection");
}
Object ids;
if (!data.containsKey("ids[]") || data.get("ids[]") == null) {
if (data.containsKey("ids")) {
ids = data.get("ids"); // should be a single string
} else {
throw new IllegalArgumentException("replace action requires 'ids[]' param containing an ordered list of item ids for the collection");
}
} else {
ids = data.get("ids[]");
}
String[] kalturaIds;
if (ids instanceof String[]) {
kalturaIds = (String[]) ids;
} else if (StringUtils.isNotBlank((String)ids)) {
// single item needs to convert back into an array
kalturaIds = new String[] { (String)ids };
} else {
kalturaIds = new String[0]; // empty means remove all the items
}
List<MediaItem> items = service.updateCollectionMediaItems(cid, kalturaIds);
return new ActionReturn(items);
}
示例12: getTargetCollectionsForMyMedia
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
/**
* @return The list of MyMediaCollectionItem (represented collection including the Site Library)
* which the user has access to in the given Sakai site
*/
@EntityCustomAction(action="mymediatargets", viewKey="")
public ActionReturn getTargetCollectionsForMyMedia(EntityView view, Map<String, Object> data) {
// GET /kaltura/mymediatargets/{kalturaId}/site/{siteId}
// GET /kaltura/mymediatargets/{kalturaId}/tool/{toolId}
if (view.getPathSegments().length < 5) {
throw new IllegalArgumentException("not enough path segments ("+view.getOriginalEntityUrl()+"), expects a URL like: GET /kaltura/mymediatargets/{kalturaId}/site/{siteId} OR /kaltura/mymediatargets/{kalturaId}tool/{toolId}");
}
// NOTE: by using show - we know the first key will always be set
String kalturaId = view.getPathSegment(2); // will equal the {kalturaId} value
if (StringUtils.isEmpty(kalturaId)) {
throw new IllegalArgumentException("kalturaId is blank ("+view.getOriginalEntityUrl()+"), expects a URL like: GET /kaltura/mymediatargets/{kalturaId}/site/{siteId} OR /kaltura/mymediatargets/{kalturaId}tool/{toolId}");
}
String locationId = developerHelperService.getCurrentLocationReference();
String locType = view.getPathSegment(3);
String locId = view.getPathSegment(4);
if (locType != null && locId != null) {
// get the location from the URL
if ("tool".equals(locType)) {
locationId = getLocationIdFromToolId(locId);
} else {
locationId = "/"+locType+"/"+locId;
}
}
if (StringUtils.isEmpty(locationId)) {
throw new IllegalArgumentException("locationId is blank ("+view.getOriginalEntityUrl()+"), expects a URL like: GET /kaltura/mymediatargets/{kalturaId}/site/{siteId} OR /kaltura/mymediatargets/{kalturaId}tool/{toolId}");
}
List<MyMediaCollectionItem> result = service.getCollectionsForMyMedia(kalturaId, locationId);
return new ActionReturn(result); // needed to avoid this trying to encode inappropriate data
}
示例13: handleDeleteComment
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action = "deleteComment", viewKey = EntityView.VIEW_LIST)
public ActionReturn handleDeleteComment(Map<String, Object> params) {
log.debug("handleDeleteComment");
getCheckedUser();
String siteId = (String) params.get("siteId");
String commonsId = (String) params.get("commonsId");
String postId = (String) params.get("postId");
String embedder = (String) params.get("embedder");
String commentId = (String) params.get("commentId");
String commentCreatorId = (String) params.get("commentCreatorId");
String postCreatorId = (String) params.get("postCreatorId");
if (StringUtils.isBlank(siteId) || StringUtils.isBlank(commonsId) || StringUtils.isBlank(postId)
|| StringUtils.isBlank(embedder) || StringUtils.isBlank(commentId)
|| StringUtils.isBlank(commentCreatorId) || StringUtils.isBlank(postCreatorId)) {
throw new EntityException("You must supply siteId, commonsId, postId, embedder, commentId, commentCreatorId and postCreatorId"
, "", HttpServletResponse.SC_BAD_REQUEST);
}
if (commonsManager.deleteComment(siteId, commonsId, embedder, commentId, commentCreatorId, postCreatorId)) {
String reference = CommonsManager.REFERENCE_ROOT + "/" + commonsId + "/posts/" + postId + "/comments/" + commentId;
sakaiProxy.postEvent(CommonsEvents.COMMENT_DELETED, reference, siteId);
return new ActionReturn("SUCCESS");
} else {
return new ActionReturn("FAIL");
}
}
示例14: getIncomingConnectionRequests
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="incomingConnectionRequests", viewKey=EntityView.VIEW_SHOW)
public Object getIncomingConnectionRequests(EntityView view, EntityReference ref) {
if(!sakaiProxy.isLoggedIn()) {
throw new SecurityException("You must be logged in to get the incoming connection list.");
}
//convert input to uuid
String uuid = sakaiProxy.ensureUuid(ref.getId());
if (StringUtils.isBlank(uuid)) {
throw new EntityNotFoundException("Invalid user.", ref.getId());
}
final List<BasicConnection> requests
= connectionsLogic.getConnectionRequestsForUser(uuid).stream().map(p -> {
BasicConnection bc = new BasicConnection();
bc.setUuid(p.getUuid());
bc.setDisplayName(p.getDisplayName());
bc.setEmail(p.getProfile().getEmail());
bc.setProfileUrl(linkLogic.getInternalDirectUrlToUserProfile(p.getUuid()));
bc.setType(p.getType());
bc.setSocialNetworkingInfo(p.getProfile().getSocialInfo());
return bc;
}).collect(Collectors.toList());
if (requests == null) {
throw new EntityException("Error retrieving connection requests for " + ref.getId(), ref.getReference());
}
return new ActionReturn(requests);
}
示例15: getOutgoingConnectionRequests
import org.sakaiproject.entitybroker.entityprovider.extension.ActionReturn; //导入依赖的package包/类
@EntityCustomAction(action="outgoingConnectionRequests", viewKey=EntityView.VIEW_SHOW)
public Object getOutgoingConnectionRequests(EntityView view, EntityReference ref) {
if (!sakaiProxy.isLoggedIn()) {
throw new SecurityException("You must be logged in to get the outgoing connection list.");
}
//convert input to uuid
String uuid = sakaiProxy.ensureUuid(ref.getId());
if (StringUtils.isBlank(uuid)) {
throw new EntityNotFoundException("Invalid user.", ref.getId());
}
final List<BasicConnection> requests
= connectionsLogic.getOutgoingConnectionRequestsForUser(uuid).stream().map(p -> {
BasicConnection bc = new BasicConnection();
bc.setUuid(p.getUuid());
bc.setDisplayName(p.getDisplayName());
bc.setEmail(p.getProfile().getEmail());
bc.setProfileUrl(linkLogic.getInternalDirectUrlToUserProfile(p.getUuid()));
bc.setType(p.getType());
bc.setSocialNetworkingInfo(p.getProfile().getSocialInfo());
return bc;
}).collect(Collectors.toList());
if (requests == null) {
throw new EntityException("Error retrieving outgoing connection requests for " + uuid, ref.getReference());
}
return new ActionReturn(requests);
}