package org.gcube.social_networking.social_networking_client_library; import java.util.ArrayList; import java.util.List; import javax.ws.rs.core.GenericType; import org.apache.commons.lang.Validate; import org.gcube.portal.databook.shared.Like; import org.gcube.social_networking.social_networking_client_library.utils.HttpClient; import org.gcube.social_networking.socialnetworking.model.output.ResponseBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Posts client. * @author Ahmed Ibrahim at ISTI-CNR (ahmed.ibrahim@isti.cnr.it) */ public class LikeClient extends BaseClient{ private static final String SUB_SERVICE_PATH = "2/likes/"; private static Logger logger = LoggerFactory.getLogger(LikeClient.class); public LikeClient() throws Exception { super(SUB_SERVICE_PATH); } public boolean likeLib(Like like){ Validate.isTrue(like != null, "like to write cannot be null"); logger.debug("Request for liking post"); String thisMethodSignature = "like-lib"; String request = getServiceEndpoint() + thisMethodSignature; return HttpClient.post(new GenericType>(){}, request, like); } public boolean unlikeLib(String userid, String likeid, String feedid){ Validate.isTrue(likeid != null, "likeid to unlike cannot be null"); logger.debug("Request for unliking post"); String thisMethodSignature = "unlike-lib"; String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid + "&likeid=" + likeid + "&feedid=" + feedid ; return HttpClient.post(new GenericType>(){}, request, likeid); } public ListgetAllLikedPostIdsByUserLib(String userid){ Validate.isTrue(userid != null, "userid to read likes cannot be null"); logger.debug("Request for reading likes of user"); String thisMethodSignature = "get-all-liked-posts-by-user-lib"; String request = getServiceEndpoint() + thisMethodSignature + "?userid=" + userid; return HttpClient.get(new GenericType>>(){}, request); } public ListgetAllLikesByPostLib(String postid){ Validate.isTrue(postid != null, "postid to read likes cannot be null"); logger.debug("Request for reading likes of post"); String thisMethodSignature = "get-all-likes-by-post-lib"; String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + postid; return HttpClient.get(new GenericType>>(){}, request); } }