support for multifile partially implemented

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@122304 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-01-19 09:25:30 +00:00
parent 4dc9754950
commit 12726771ff
11 changed files with 142 additions and 45 deletions

View File

@ -4,15 +4,12 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="session-checker-0.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependent-module archiveName="session-checker-0.5.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="wsmail-widget-1.9.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wsmail-widget/wsmail-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="gcube-widgets-1.9.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>

View File

@ -3,6 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
@ -93,7 +94,7 @@
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
@ -114,11 +115,6 @@
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>wsmail-widget</artifactId>
<version>[1.9.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>

View File

@ -112,7 +112,7 @@ public class NewsFeedPanel extends Composite {
public static final String LIKE_LABEL = "Favorite";
public static final String LIKED_LABEL = "Favorited";
public static final String COMMENT_LABEL = "Reply";
public static final String MESSAGE_LABEL = "Message";
public static final String SHARE_FWD_LABEL = "Share";
private String vreLabel;

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.newsfeed.client.ui;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Modal;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class SharePostDialog extends Composite {
private static SharePostDialogUiBinder uiBinder = GWT
.create(SharePostDialogUiBinder.class);
interface SharePostDialogUiBinder extends UiBinder<Widget, SharePostDialog> {
}
public SharePostDialog(TweetTemplate toShare) {
initWidget(uiBinder.createAndBindUi(this));
input.addItem("devVRE", "devVRE");
input.addItem("devVRE2", "devVRE");
input.addItem("devVRE3", "devVRE");
}
@UiField Button sharePostButton;
@UiField Button cancel;
@UiField Modal modalWindow;
@UiField ListBox input;
@UiHandler("sharePostButton")
void onClick(ClickEvent e) {
Window.alert("Hello!");
}
@UiHandler("cancel")
void onCancelClick(ClickEvent e) {
modalWindow.hide();
}
public void openModal() {
GWT.log("OpenModal");
modalWindow.show();
}
}

View File

@ -0,0 +1,23 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.important {
font-weight: bold;
}
</ui:style>
<g:HTMLPanel>
<b:Modal ui:field="modalWindow" title="Share this post"
backdrop="STATIC" keyboard="true" animation="true">
<b:Form type="VERTICAL">
<b:ListBox alternateSize="XLARGE" ui:field="input"></b:ListBox>
</b:Form>
<b:ModalFooter>
<b:Button ui:field="cancel">Cancel</b:Button>
<b:Button ui:field="sharePostButton" type="PRIMARY">Send Invite</b:Button>
</b:ModalFooter>
</b:Modal>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -9,6 +9,7 @@ import java.util.List;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.UserInfo;
@ -20,7 +21,6 @@ import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
import org.gcube.portlets.user.newsfeed.client.event.UnLikeEvent;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
@ -70,6 +70,8 @@ public class TweetTemplate extends Composite {
private int totalComments = 0;
private HTML showAllComments = new HTML();
private boolean isAppFeed = false;
private TweetTemplate myInstance;
/**
* tell if this tweet is belonging to the current user
@ -87,7 +89,7 @@ public class TweetTemplate extends Composite {
@UiField
HTML commentArea;
@UiField
HTML messageArea;
HTML sharePostArea;
@UiField
Image avatarImage;
@UiField
@ -120,6 +122,7 @@ public class TweetTemplate extends Composite {
*/
public TweetTemplate(boolean displaySingle, boolean showTimelineSource, UserInfo myUserInfo, EnhancedFeed myFeed, HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
myInstance = this;
this.myUserInfo = myUserInfo;
this.vreSource.setVisible(false);
this.myFeed = myFeed;
@ -138,7 +141,13 @@ public class TweetTemplate extends Composite {
} else {
closeImage.removeFromParent();
}
GWT.log("# attachments: "+myFeed.getAttachments().size());
if (myFeed.getAttachments().size() > 0) {
for (Attachment a : myFeed.getAttachments()) {
GWT.log(a.toString());
}
}
openImage.setStyleName("openImage");
openImage.setTitle("Open this feed separately");
//show if the user has already liked this or not
@ -163,7 +172,7 @@ public class TweetTemplate extends Composite {
feedText = feedText.replaceAll("&amp;","&");
if (! isAppFeed) {
messageArea.setHTML("<a>" + NewsFeedPanel.MESSAGE_LABEL + "</a>");
sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
contentArea.setHTML("<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK
+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
@ -204,7 +213,7 @@ public class TweetTemplate extends Composite {
closeImage.removeFromParent();
try{
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
messageArea.setHTML("<a class=\"link\" style=\"white-space: nowrap;\" href=\""+feed.getUri()+"\"> go App [" +vreName + "]</a>");
sharePostArea.setHTML("<a class=\"link\" style=\"white-space: nowrap;\" href=\""+feed.getUri()+"\"> go App [" +vreName + "]</a>");
}
catch (Exception e) {}
}
@ -374,7 +383,7 @@ public class TweetTemplate extends Composite {
GWT.log("Commenting disabled");
}
@UiHandler("messageArea")
@UiHandler("sharePostArea")
void onMessageClick(ClickEvent e) {
if (! isAppFeed) {
final List<String> listToLogin = new ArrayList<String>();
@ -382,7 +391,8 @@ public class TweetTemplate extends Composite {
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
new MailForm(listToLogin);
SharePostDialog dlg = new SharePostDialog(myInstance);
dlg.openModal();
}
public void onFailure(Throwable reason) {
Window.alert("Could not load this component: " + reason.getMessage());

View File

@ -33,7 +33,7 @@
<g:Label ui:field="messageSeparator" styleName="tweet-separator">-</g:Label>
</td>
<td align="left" style="vertical-align: top;">
<g:HTML styleName="message" ui:field="messageArea" />
<g:HTML styleName="message" ui:field="sharePostArea" />
</td>
<td align="left" style="vertical-align: top;">
<g:HTML styleName="time" ui:field="timeArea" />

View File

@ -26,6 +26,7 @@ import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.Like;
@ -703,6 +704,17 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername());
boolean skip = false;
for (Feed feed : toEnhance) {
boolean isMultiFileUpload = feed.isMultiFileUpload();
ArrayList<Attachment> attachments = new ArrayList<Attachment>();
if (isMultiFileUpload) {
try {
attachments = (ArrayList<Attachment>) store.getAttachmentsByFeedId(feed.getKey());
} catch (FeedIDNotFoundException e) {
_log.error("It looks like sth wrong with this feedid having attachments, could not find feedId = " + feed.getKey() + "\n" + e.getMessage());
}
}
skip = false;
if (! feed.isApplicationFeed()) {
String thumb = getUserImagePortraitUrlLocal(feed.getEntityId());
@ -730,6 +742,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
toAdd = new EnhancedFeed(feed, liked, checkisAdminUser());
} else
toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username));
toAdd.setAttachments(attachments);
toReturn.add(toAdd);
} else {
ArrayList<Comment> comments = getAllCommentsByFeed(feed.getKey());
@ -739,7 +752,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
int currCommentsNumber = comments.size();
//if comments are less than $commentsNumberPerFeed they are the more recent, -1 return all the comments
if (currCommentsNumber < commentsNumberPerFeed || commentsNumberPerFeed == -1) {
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments);
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments, attachments);
toReturn.add(toAdd);
} else {
//need to get the last two
@ -747,10 +760,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
for (int i = currCommentsNumber -commentsNumberPerFeed; i < currCommentsNumber; i++) {
comments2Attach.add(comments.get(i));
}
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments2Attach);
EnhancedFeed toAdd = new EnhancedFeed(feed, liked, isUsers(feed, username), comments2Attach, attachments);
toReturn.add(toAdd);
}
}
}
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.newsfeed.shared;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
/**
@ -17,6 +18,9 @@ public class EnhancedFeed implements Serializable{
private boolean liked;
private boolean isUsers;
private ArrayList<Comment> comments;
private ArrayList<Attachment> attachments;
public EnhancedFeed() {
super();
}
@ -34,6 +38,17 @@ public class EnhancedFeed implements Serializable{
this.liked = liked;
this.comments = comments;
}
public EnhancedFeed(Feed feed, boolean liked, boolean isUsers,
ArrayList<Comment> comments, ArrayList<Attachment> attachments) {
super();
this.feed = feed;
this.liked = liked;
this.isUsers = isUsers;
this.comments = comments;
this.attachments = attachments;
}
public ArrayList<Comment> getComments() {
return comments;
}
@ -57,5 +72,18 @@ public class EnhancedFeed implements Serializable{
}
public void setUsers(boolean isUsers) {
this.isUsers = isUsers;
}
public ArrayList<Attachment> getAttachments() {
return attachments;
}
public void setAttachments(ArrayList<Attachment> attachments) {
this.attachments = attachments;
}
@Override
public String toString() {
return "EnhancedFeed [feed=" + feed + ", liked=" + liked + ", isUsers="
+ isUsers + ", comments=" + comments + ", attachments="
+ attachments + "]";
}
}

View File

@ -14,11 +14,9 @@
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- inherits gCube Widgets Library -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.widgets.wsmail.WsMail_Widget' />
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<inherits name='org.gcube.portlets.widgets.pickitem.PickItem' />
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<!-- Specify the app entry point class. -->

View File

@ -25,27 +25,6 @@
<url-pattern>/newsfeed/scopeService</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>mailWisdgetServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.wsmail.server.WsMailServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mailWisdgetServlet</servlet-name>
<url-pattern>/newsfeed/mailWisdgetServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>workspaceExplorer</servlet-name>
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>workspaceExplorer</servlet-name>
<url-pattern>/newsfeed/WorkspaceExplorerService</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>checkServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>