From 86cf7f6d70607b5981edbdeb6a0bd4204794ae41 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Tue, 21 Nov 2023 18:36:28 +0100 Subject: [PATCH] API corresponding to each social networking library function. --- .../PostClient.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/social_networking/social_networking_client_library/PostClient.java b/src/main/java/org/gcube/social_networking/social_networking_client_library/PostClient.java index 4e9ac80..f01da59 100644 --- a/src/main/java/org/gcube/social_networking/social_networking_client_library/PostClient.java +++ b/src/main/java/org/gcube/social_networking/social_networking_client_library/PostClient.java @@ -3,7 +3,9 @@ package org.gcube.social_networking.social_networking_client_library; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.ws.rs.core.GenericType; @@ -197,13 +199,27 @@ public class PostClient extends BaseClient{ return HttpClient.post(new GenericType>(){}, request, post); } //bool - public boolean saveAttachmentEntryLib(String key, Attachment attachment){ - Validate.isTrue(attachment != null, "attachment to write cannot be null"); + public boolean saveUserPostLib(Post post, List attachments) { + Validate.isTrue(post != null, "Post to write cannot be null"); + + logger.debug("Request for saving application post"); + String thisMethodSignature = "save-user-post-attachments-lib"; + String request = getServiceEndpoint() + thisMethodSignature; + Map> obj = new HashMap<>(); + obj.put(post, attachments); + return HttpClient.post(new GenericType>(){}, request, obj); + } + + public boolean saveAppPostLib(Post post, List attachments) { + Validate.isTrue(post != null, "Post to write cannot be null"); + + logger.debug("Request for saving application post"); + String thisMethodSignature = "save-app-post-attachments-lib"; + String request = getServiceEndpoint() + thisMethodSignature; + Map> obj = new HashMap<>(); + obj.put(post, attachments); + return HttpClient.post(new GenericType>(){}, request, obj); - logger.debug("Request for save attachment"); - String thisMethodSignature = "save-attachment-entry-lib"; - String request = getServiceEndpoint() + thisMethodSignature + "?postid=" + key; - return HttpClient.post(new GenericType>(){}, request, attachment); } public boolean saveAppPostLib(Post post){