removed client scope helper dependency

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@144460 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2017-03-01 11:09:16 +00:00
parent 9cf2f11361
commit e99edf659a
3 changed files with 22 additions and 9 deletions

View File

@ -17,7 +17,6 @@ import org.gcube.portal.databook.shared.Like;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portal.databook.shared.ShowUserStatisticAction; import org.gcube.portal.databook.shared.ShowUserStatisticAction;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.newsfeed.client.FilterType; import org.gcube.portlets.user.newsfeed.client.FilterType;
import org.gcube.portlets.user.newsfeed.client.NewsFeed; import org.gcube.portlets.user.newsfeed.client.NewsFeed;
import org.gcube.portlets.user.newsfeed.client.NewsService; import org.gcube.portlets.user.newsfeed.client.NewsService;
@ -211,7 +210,7 @@ public class NewsFeedPanel extends Composite {
eventBus.addHandler(SelectedUserEvent.TYPE, new SelectedUserEventHandler() { eventBus.addHandler(SelectedUserEvent.TYPE, new SelectedUserEventHandler() {
@Override @Override
public void onSelectedUser(SelectedUserEvent event) { public void onSelectedUser(SelectedUserEvent event) {
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
Location.assign(profilePageURL+"?"+ Location.assign(profilePageURL+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(event.getSelectedUser().getId())); Encoder.encode(event.getSelectedUser().getId()));
@ -443,7 +442,7 @@ public class NewsFeedPanel extends Composite {
@Override @Override
public void onSuccess(EnhancedFeed result) { public void onSuccess(EnhancedFeed result) {
if (result.getFeed().getType() == FeedType.DISABLED) { if (result.getFeed().getType() == FeedType.DISABLED) {
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
String usrLink = "<a class=\"link\" href=\""+profilePageURL+"?"+ String usrLink = "<a class=\"link\" href=\""+profilePageURL+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(result.getFeed().getEntityId())+"\">"+result.getFeed().getFullName()+ Encoder.encode(result.getFeed().getEntityId())+"\">"+result.getFeed().getFullName()+
@ -1475,4 +1474,19 @@ public class NewsFeedPanel extends Composite {
public static String getCurrentScope() { public static String getCurrentScope() {
return currentScope; return currentScope;
} }
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;
}
} }

View File

@ -6,8 +6,8 @@ import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.Comment;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.newsfeed.client.event.DeleteCommentEvent; import org.gcube.portlets.user.newsfeed.client.event.DeleteCommentEvent;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
@ -90,7 +90,7 @@ public class SingleComment extends Composite {
commentToShow = commentToShow.substring(0, TEXT_TO_SHOW_LENGHT) + "..."; commentToShow = commentToShow.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
seeMore.setHTML("<a class=\"seemore\"> See More </a>"); seeMore.setHTML("<a class=\"seemore\"> See More </a>");
} }
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+ commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
@ -135,7 +135,7 @@ public class SingleComment extends Composite {
commentToShow = commentToShow.replaceAll("&lt;","<").replaceAll("&gt;",">"); commentToShow = commentToShow.replaceAll("&lt;","<").replaceAll("&gt;",">");
commentToShow = commentToShow.replaceAll("&amp;","&"); commentToShow = commentToShow.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+ commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+

View File

@ -16,7 +16,6 @@ import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.portal.databook.shared.EnhancedFeed;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent; import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent;
import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent; import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent;
import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent; import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent;
@ -312,7 +311,7 @@ public class TweetTemplate extends Composite {
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">"); feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&"); feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
if (! isAppFeed) { if (! isAppFeed) {
// sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>"); // sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
@ -460,7 +459,7 @@ public class TweetTemplate extends Composite {
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">"); feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&"); feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+ contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+