From e9fbcf32bd35d0cdfb73054e0ed63d6504b61615 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 4 Apr 2016 16:57:04 +0000 Subject: [PATCH] added extractOrgFriendlyURL method git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gcube-widgets@126756 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gcubewidgets/client/ClientScopeHelper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/gcube/portlets/user/gcubewidgets/client/ClientScopeHelper.java b/src/main/java/org/gcube/portlets/user/gcubewidgets/client/ClientScopeHelper.java index 0369ef5..248bdcb 100644 --- a/src/main/java/org/gcube/portlets/user/gcubewidgets/client/ClientScopeHelper.java +++ b/src/main/java/org/gcube/portlets/user/gcubewidgets/client/ClientScopeHelper.java @@ -10,4 +10,19 @@ public class ClientScopeHelper { return GWT.create(ScopeService.class); //Window.Location.getHref(); } + + public static String extractOrgFriendlyURL(String portalURL) { + String groupRegEx = "/group/"; + if (portalURL.contains(groupRegEx)) { + String[] splits = portalURL.split(groupRegEx); + String friendlyURL = splits[1]; + if (friendlyURL.contains("/")) { + friendlyURL = friendlyURL.split("/")[0]; + } else { + friendlyURL = friendlyURL.split("\\?")[0].split("\\#")[0]; + } + return "/"+friendlyURL; + } + return null; + } }