mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Initial Subscription Cervice check-in
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28425 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
|
||||
/**
|
||||
* Response object for follower or following paging requests.
|
||||
*
|
||||
* @author Florian Mueller
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface PagingFollowingResults extends PagingResults<String>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
public class PagingFollowingResultsImpl implements PagingFollowingResults
|
||||
{
|
||||
private List<String> page;
|
||||
private boolean hasMore;
|
||||
private Pair<Integer, Integer> totalCount;
|
||||
|
||||
public PagingFollowingResultsImpl(List<String> page, boolean hasMore, Integer total)
|
||||
{
|
||||
this.page = page;
|
||||
this.hasMore = hasMore;
|
||||
|
||||
if (total != null)
|
||||
{
|
||||
totalCount = new Pair<Integer, Integer>(total, total);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPage()
|
||||
{
|
||||
return Collections.unmodifiableList(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionsApplied()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Response object for subscription paging requests.
|
||||
*
|
||||
* @author Florian Mueller
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface PagingSubscriptionResults extends PagingResults<NodeRef>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
public class PagingSubscriptionResultsImpl implements PagingSubscriptionResults
|
||||
{
|
||||
private List<NodeRef> page;
|
||||
private boolean hasMore;
|
||||
private Pair<Integer, Integer> totalCount;
|
||||
|
||||
public PagingSubscriptionResultsImpl(List<NodeRef> page, boolean hasMore, Integer total)
|
||||
{
|
||||
this.page = page;
|
||||
this.hasMore = hasMore;
|
||||
|
||||
if (total != null)
|
||||
{
|
||||
totalCount = new Pair<Integer, Integer>(total, total);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NodeRef> getPage()
|
||||
{
|
||||
return Collections.unmodifiableList(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionsApplied()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
/**
|
||||
* This exception is thrown if a subscription list is private and the accessing
|
||||
* user is not allowed to see it.
|
||||
*
|
||||
* @author Florian Mueller
|
||||
* @since 4.0
|
||||
*/
|
||||
public class PrivateSubscriptionListException extends AlfrescoRuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 6971869799749343887L;
|
||||
|
||||
public PrivateSubscriptionListException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public PrivateSubscriptionListException(String msg, Throwable cause)
|
||||
{
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
/**
|
||||
* Subscription types enum.
|
||||
*
|
||||
* @author Florian Mueller
|
||||
* @since 4.0
|
||||
*/
|
||||
public enum SubscriptionItemTypeEnum
|
||||
{
|
||||
USER("user");
|
||||
|
||||
private String value;
|
||||
|
||||
SubscriptionItemTypeEnum(String type)
|
||||
{
|
||||
value = type;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public static SubscriptionItemTypeEnum fromValue(String v)
|
||||
{
|
||||
for (SubscriptionItemTypeEnum ste : SubscriptionItemTypeEnum.values())
|
||||
{
|
||||
if (ste.value.equals(v))
|
||||
{
|
||||
return ste;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(v);
|
||||
}
|
||||
}
|
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.subscriptions;
|
||||
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.service.Auditable;
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.PublicService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Subscription Service.
|
||||
*
|
||||
* @author Florian Mueller
|
||||
* @since 4.0
|
||||
*/
|
||||
@PublicService
|
||||
public interface SubscriptionService
|
||||
{
|
||||
// --- subscription ---
|
||||
|
||||
/**
|
||||
* Returns the nodes a user has subscribed to.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param type
|
||||
* the type of the nodes
|
||||
* @param pagingRequest
|
||||
* paging details
|
||||
*
|
||||
* @throws PrivateSubscriptionListException
|
||||
* if the subscription list is private and the calling user is
|
||||
* not allowed to see it
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingSubscriptionResults getSubscriptions(String userId, SubscriptionItemTypeEnum type, PagingRequest pagingRequest);
|
||||
|
||||
/**
|
||||
* Returns how many nodes the given user has subscribed to.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param type
|
||||
* the type of the nodes
|
||||
*/
|
||||
@NotAuditable
|
||||
int getSubscriptionCount(String userId, SubscriptionItemTypeEnum type);
|
||||
|
||||
/**
|
||||
* Subscribes to a node.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param node
|
||||
* the node
|
||||
*/
|
||||
@Auditable(parameters = { "userId", "node" })
|
||||
void subscribe(String userId, NodeRef node);
|
||||
|
||||
/**
|
||||
* Unsubscribes from a node.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param node
|
||||
* the node
|
||||
*/
|
||||
@Auditable(parameters = { "userId", "node" })
|
||||
void unsubscribe(String userId, NodeRef node);
|
||||
|
||||
/**
|
||||
* Returns if the user has subscribed to the given node.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param node
|
||||
* the node
|
||||
*/
|
||||
@NotAuditable
|
||||
boolean hasSubscribed(String userId, NodeRef node);
|
||||
|
||||
// --- follow ---
|
||||
|
||||
/**
|
||||
* Returns a list of users that the given user follows.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param pagingRequest
|
||||
* paging details
|
||||
* @throws PrivateSubscriptionListException
|
||||
* if the subscription list is private and the calling user is
|
||||
* not allowed to see it
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingFollowingResults getFollowing(String userId, PagingRequest pagingRequest);
|
||||
|
||||
/**
|
||||
* Returns a list of users that follow the given user.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param pagingRequest
|
||||
* paging details
|
||||
*/
|
||||
@NotAuditable
|
||||
PagingFollowingResults getFollowers(String userId, PagingRequest pagingRequest);
|
||||
|
||||
/**
|
||||
* Returns how many users the given user follows.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param type
|
||||
* the type of the nodes
|
||||
*/
|
||||
@NotAuditable
|
||||
int getFollowingCount(String userId);
|
||||
|
||||
/**
|
||||
* Returns how many users follow the given user.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param type
|
||||
* the type of the nodes
|
||||
*/
|
||||
@NotAuditable
|
||||
int getFollowersCount(String userId);
|
||||
|
||||
/**
|
||||
* Follows another
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param userToFollow
|
||||
* the id of the user to follow
|
||||
*/
|
||||
@Auditable(parameters = { "userId", "userToFollow" })
|
||||
void follow(String userId, String userToFollow);
|
||||
|
||||
@Auditable(parameters = { "userId", "userToUnfollow" })
|
||||
void unfollow(String userId, String userToUnfollow);
|
||||
|
||||
/**
|
||||
* Returns if the user follows to the given other user.
|
||||
*
|
||||
* @param userId
|
||||
* id of the user
|
||||
* @param userToFollow
|
||||
* the id of the other user
|
||||
*/
|
||||
@NotAuditable
|
||||
boolean follows(String userId, String userToFollow);
|
||||
|
||||
// --- privacy settings ---
|
||||
|
||||
/**
|
||||
* Sets or unsets the subscription list of the given user to private.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
* @param isPrivate
|
||||
* <code>true</code> - set list private,
|
||||
* <code>false<code> - set list public
|
||||
*
|
||||
*/
|
||||
@Auditable(parameters = { "userId", "isPrivate" })
|
||||
void setSubscriptionListPrivate(String userId, boolean isPrivate);
|
||||
|
||||
/**
|
||||
* Returns if the subscription list of the given user is set to private.
|
||||
*
|
||||
* @param userId
|
||||
* the id of the user
|
||||
*/
|
||||
@NotAuditable
|
||||
boolean isSubscriptionListPrivate(String userId);
|
||||
}
|
Reference in New Issue
Block a user