From a3dc89b6d797c0e079c36bd8f44ad1c447f4e34c Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 6 Apr 2022 16:03:52 +0200 Subject: [PATCH] fixed pom --- .project | 2 +- pom.xml | 50 ++++++++++--------- .../MessageClient.java | 9 ++-- .../filter/AuthorizationFilter.java | 8 ++- .../TestClientServices.java | 38 +++++++------- 5 files changed, 59 insertions(+), 48 deletions(-) diff --git a/.project b/.project index 57e640d..3b362f9 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - social-networking-client-library + social-service-client diff --git a/pom.xml b/pom.xml index ed667fa..c467eb7 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,4 @@ - + 4.0.0 @@ -11,9 +9,9 @@ org.gcube.social-networking - social-networking-client-library + social-service-client 1.0.0-SNAPSHOT - social-networking-client-library + social-networking-service-client jar The social networking web service client library @@ -22,14 +20,14 @@ org.gcube.distribution gcube-bom - 2.0.2 + 2.0.2-SNAPSHOT pom import org.gcube.distribution - maven-portal-bom - 3.6.3 + gcube-smartgears-bom + 2.1.1-SNAPSHOT pom import @@ -47,16 +45,16 @@ - scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git - scm:git:https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws.git - https://code-repo.d4science.org/gCubeSystem/social-networking-library-ws + scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git + scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git + https://code-repo.d4science.org/gCubeSystem/${project.artifactId} - org.gcube.portal social-networking-library + [1.16.0, 2.0.0) compile @@ -67,11 +65,12 @@ org.gcube.social-networking social-service-model - [1.0.0-SNAPSHOT,) + [1.0.0-SNAPSHOT, 2.0.0) commons-lang commons-lang + 2.6 compile @@ -89,17 +88,19 @@ slf4j-api provided - - org.slf4j - slf4j-log4j12 - provided - + junit junit - 4.10 + 4.11 test + + ch.qos.logback + logback-classic + test + + @@ -107,17 +108,20 @@ org.apache.maven.plugins - maven-war-plugin + maven-jar-plugin - compile - exploded + test-jar + + + org.apache.maven.plugins + maven-surefire-plugin - ${webappDirectory} + true diff --git a/src/main/java/org/gcube/social_networking/social_networking_client_library/MessageClient.java b/src/main/java/org/gcube/social_networking/social_networking_client_library/MessageClient.java index 4cdceef..558afec 100644 --- a/src/main/java/org/gcube/social_networking/social_networking_client_library/MessageClient.java +++ b/src/main/java/org/gcube/social_networking/social_networking_client_library/MessageClient.java @@ -8,6 +8,7 @@ import javax.ws.rs.core.GenericType; import org.apache.commons.lang.Validate; import org.gcube.social_networking.social_networking_client_library.utils.HttpClient; import org.gcube.social_networking.socialnetworking.model.beans.Message; +import org.gcube.social_networking.socialnetworking.model.beans.MessageInbox; import org.gcube.social_networking.socialnetworking.model.output.ResponseBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,12 +31,12 @@ public class MessageClient extends BaseClient{ * Get sent messages * @return */ - public List getSentMessages(){ + public List getSentMessages(){ logger.debug("Request for sent messages"); String thisMethodSignature = "get-sent-messages"; String request = getServiceEndpoint() + thisMethodSignature + "?"; - return HttpClient.get(new GenericType>>(){}, request); + return HttpClient.get(new GenericType>>(){}, request); } @@ -43,12 +44,12 @@ public class MessageClient extends BaseClient{ * Get received messages * @return */ - public List getReceivedMessages(){ + public List getReceivedMessages(){ logger.debug("Request for received messages"); String thisMethodSignature = "get-received-messages"; String request = getServiceEndpoint() + thisMethodSignature + "?"; - return HttpClient.get(new GenericType>>(){}, request); + return HttpClient.get(new GenericType>>(){}, request); } diff --git a/src/main/java/org/gcube/social_networking/social_networking_client_library/filter/AuthorizationFilter.java b/src/main/java/org/gcube/social_networking/social_networking_client_library/filter/AuthorizationFilter.java index 1704afc..c9f65a0 100644 --- a/src/main/java/org/gcube/social_networking/social_networking_client_library/filter/AuthorizationFilter.java +++ b/src/main/java/org/gcube/social_networking/social_networking_client_library/filter/AuthorizationFilter.java @@ -12,17 +12,21 @@ import org.slf4j.LoggerFactory; /** * Authorization filter for the jersey client. - * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) */ public class AuthorizationFilter implements ClientRequestFilter{ private final static String AUTH_TOKEN_PARAMETER = "Authorization"; + private final static String LEGACY_AUTH_TOKEN_PARAMETER = "gcube-token"; private static Logger logger = LoggerFactory.getLogger(AuthorizationFilter.class); @Override public void filter(ClientRequestContext original) throws IOException { logger.debug("Adding token to the request " + original.getUri()); String token = AccessTokenProvider.instance.get(); - original.getHeaders().add(AUTH_TOKEN_PARAMETER, " Bearer " + token); + String legacyToken = SecurityTokenProvider.instance.get(); + if (token != null) + original.getHeaders().add(AUTH_TOKEN_PARAMETER, " Bearer " + token); + if (legacyToken != null) + original.getHeaders().add(LEGACY_AUTH_TOKEN_PARAMETER, legacyToken); } } diff --git a/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java index 5db5554..40ab942 100644 --- a/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java +++ b/src/test/java/org/gcube/portal/social_networking_client_library/TestClientServices.java @@ -25,6 +25,7 @@ import org.gcube.social_networking.social_networking_client_library.VREClient; import org.gcube.social_networking.socialnetworking.model.beans.ApplicationId; import org.gcube.social_networking.socialnetworking.model.beans.JobNotificationBean; import org.gcube.social_networking.socialnetworking.model.beans.Message; +import org.gcube.social_networking.socialnetworking.model.beans.MessageInbox; import org.gcube.social_networking.socialnetworking.model.beans.MyVRE; import org.gcube.social_networking.socialnetworking.model.beans.PostInputBean; import org.gcube.social_networking.socialnetworking.model.beans.Recipient; @@ -42,18 +43,18 @@ public class TestClientServices { @Before public void setContextAndToken(){ - ScopeProvider.instance.set("/gcube"); - AccessTokenProvider.instance.set("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDkxNjgwNDEsImlhdCI6MTY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YWdlciIsIlZSRS1NYW5hZ2VyIiwiTWVtYmVyIl19fSwiYXV0aG9yaXphdGlvbiI6eyJwZXJtaXNzaW9ucyI6W3sicnNpZCI6IjU3Mjg1NTEwLTM5MzktNGRlNy04ZmMxLWUzYTlkM2NjZTI4MSIsInJzbmFtZSI6IkRlZmF1bHQgUmVzb3VyY2UifV19LCJzY29wZSI6ImVtYWlsIHByb2ZpbGUiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwibmFtZSI6Ik1hc3NpbWlsaWFuIEFzc2FudGUiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJtYXNzaW1pbGlhbm8uYXNzYW50ZSIsImdpdmVuX25hbWUiOiJNYXNzaW1pbGlhbiIsImxvY2FsZSI6ImVuIiwiZmFtaWx5X25hbWUiOiJBc3NhbnRlIiwiZW1haWwiOiJtYXNzaW1pbGlhbm8uYXNzYW50ZUBpc3RpLmNuci5pdCJ9.MFee4w8XAgchOHGiqMYnmYCpclNOmC8xiZMkoqeg3UnaN9iEslwJJtAjeZiEdCBlnypw9Y1a8Fisc5p6f2IBBMaDtbE_omYTStBSDT84ZJMrspHIjstAinax0sY0h2tG-DBhdK6AI0D-MFiOL07FW4iQgizXh4qnpzVNL0vxIUQMYo99R4DYsZzcsrxnUL0qzhNHfN4PqdMRWpt-eRyKO15FvA7_HExAemOzYEFbRrw8JSpsXj6BNcRg9ZwRV7815WhbqhV-Cq3_PDjyiSw3mVGjeh1QmNTOSbBKniGYJo2nWBng3tP_HS0yoS1xRCS9d0PrjBEVdbRn-HlM4M43DA"); + //SecurityTokenProvider.instance.set(""); } - //@Test + @Test public void testSearch() throws Exception { FullTextSearchClient search = new FullTextSearchClient(); ArrayList result = search.search("looking for test", 0, 10); - for (EnhancedFeed enhancedFeed : result) { - logger.debug("Returned feed " + enhancedFeed); + for (EnhancedFeed enhancedPost : result) { + logger.debug("Returned post " + enhancedPost); } } @@ -67,27 +68,28 @@ public class TestClientServices { } } - //@Test + @Test public void testHashTags() throws Exception { HashTagClient hashtags = new HashTagClient(); Map hashtagsCount = hashtags.getHashtagsCount(); logger.debug("Returned tags " + hashtagsCount); } - //@Test + @Test public void testMessagesReceived() throws Exception { MessageClient messagesClient = new MessageClient(); - List receivedMessages = messagesClient.getReceivedMessages(); - for (Message workspaceMessage : receivedMessages) { + List receivedMessages = messagesClient.getReceivedMessages(); + System.out.println("Messages found # " + receivedMessages.size()); + for (MessageInbox workspaceMessage : receivedMessages) { logger.debug("Received message " + workspaceMessage.toString()); } } - //@Test + @Test public void testMessagesSent() throws Exception { MessageClient messagesClient = new MessageClient(); - List sentMessages = messagesClient.getSentMessages(); - for (Message workspaceMessage : sentMessages) { + List sentMessages = messagesClient.getSentMessages(); + for (MessageInbox workspaceMessage : sentMessages) { logger.debug("Sent message was " + workspaceMessage); } } @@ -96,7 +98,7 @@ public class TestClientServices { public void sendMessage() throws Exception{ logger.debug("Sending message "); MessageClient messagesClient = new MessageClient(); - List rec = Arrays.asList(new Recipient("andrea.rossi"), new Recipient("luca.frosini")); + List rec = Arrays.asList(new Recipient("andrea.rossi")); Message message = new Message( "Test message", "Sending message via client " + System.currentTimeMillis(), @@ -114,21 +116,21 @@ public class TestClientServices { } } - //@Test + @Test public void sendJobNotification() throws Exception { NotificationClient notificationsClient = new NotificationClient(); JobNotificationBean notification = new JobNotificationBean( - "costantino.perciante", + "massimiliano.assante", UUID.randomUUID().toString(), "SmartExecutor Social Indexer", - "SmartExecutor", + "Workspace Application", JobStatusType.SUCCEEDED, "all ok"); notificationsClient.sendJobNotification(notification); logger.debug("Sent job notification "); } - //@Test + @Test public void getProfile() throws Exception { PeopleClient getProfile = new PeopleClient(); UserProfile profile = getProfile.getProfile();