/** * Allowed end-points /activitystreams/{userId}/@self/{appId}/{activityId}+ * * Examples: /activitystreams/john.doe/@self/1/object1,object2 * * @param request a {@link org.apache.shindig.social.opensocial.service.SocialRequestItem} object. * @return a {@link java.util.concurrent.Future} object. * @throws org.apache.shindig.protocol.ProtocolException if any. */ @Operation(httpMethods="DELETE") public Future<?> delete(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); Set<String> activityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); HandlerPreconditions.requireNotEmpty(activityIds, "At least one activity ID must be specified"); return service.deleteActivityEntries(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), activityIds, request.getToken()); }
/** * Allowed end-points /activitystreams/{userId}/@self/{appId}/{activityId}+ * * Examples: /activitystreams/john.doe/@self/1/object1,object2 * * @param request a {@link org.apache.shindig.social.opensocial.service.SocialRequestItem} object. * @return a {@link java.util.concurrent.Future} object. * @throws org.apache.shindig.protocol.ProtocolException if any. */ @Operation(httpMethods="DELETE") public Future<?> delete(SocialRequestItem request) throws ProtocolException { Set<UserId> userIds = request.getUsers(); Set<String> activityIds = ImmutableSet.copyOf(request.getListParameter("activityId")); HandlerPreconditions.requireNotEmpty(userIds, "No userId specified"); HandlerPreconditions.requireSingular(userIds, "Multiple userIds not supported"); HandlerPreconditions.requireNotEmpty(activityIds, "At least one activity ID must be specified"); return service.deleteActivityEntries(Iterables.getOnlyElement(userIds), request.getGroup(), request.getAppId(), activityIds, request.getToken()); }
@Test public void testHandleDelete() throws Exception { String path = "/activitystreams/john.doe/@self/@app/myObjectId123"; RestHandler operation = registry.getRestHandler(path, "DELETE"); org.easymock.EasyMock.expect(service.deleteActivityEntries(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.of("myObjectId123")), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); assertNull(operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }
@Test public void testHandleDelete() throws Exception { String path = "/activitystreams/john.doe/@self/@app/myObjectId123"; RestHandler operation = registry.getRestHandler(path, "DELETE"); org.easymock.EasyMock.expect(service.deleteActivityEntries(eq(JOHN_DOE.iterator().next()), eq(new GroupId(GroupId.Type.self, null)), eq("appId"), eq(ImmutableSet.of("myObjectId123")), eq(token))).andReturn(Futures.immediateFuture((Void) null)); replay(); assertNull(operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get()); verify(); reset(); }