DND and multiupload now work. The news feed portlet needs to be updated to reflect such changes

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122268 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-15 17:24:52 +00:00
parent d29dccac2c
commit 97f39a4ee4
15 changed files with 874 additions and 260 deletions

View File

@ -7,9 +7,6 @@
<dependent-module archiveName="fileupload-progress-bar-1.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar"> <dependent-module archiveName="fileupload-progress-bar-1.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="fileupload-progress-bar-1.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/> <property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/> <property name="context-root" value="share-updates"/>
</wb-module> </wb-module>

View File

@ -6,6 +6,7 @@ import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portlets.user.shareupdates.shared.LinkPreview; import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
import org.gcube.portlets.user.shareupdates.shared.UploadedFile;
import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean; import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
@ -17,8 +18,10 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/ */
@RemoteServiceRelativePath("shareupdateServlet") @RemoteServiceRelativePath("shareupdateServlet")
public interface ShareUpdateService extends RemoteService { public interface ShareUpdateService extends RemoteService {
ClientFeed share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, String fileName, String FilePathOnServer, boolean notifyGroup);
ClientFeed sharePostWithLinkPreview(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, boolean notifyGroup);
ClientFeed sharePostWithAttachments(String feedText, FeedType type, PrivacyLevel pLevel, String vreName,ArrayList<UploadedFile> uploadedFiles, ArrayList<String> mentionedUsers, boolean notifyGroup, boolean saveCopyWokspace);
UserSettings getUserSettings(); UserSettings getUserSettings();

View File

@ -6,6 +6,7 @@ import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.portal.databook.shared.FeedType;
import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.portal.databook.shared.PrivacyLevel;
import org.gcube.portlets.user.shareupdates.shared.LinkPreview; import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
import org.gcube.portlets.user.shareupdates.shared.UploadedFile;
import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean; import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
@ -15,11 +16,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
* The async counterpart of <code>ShareUpdateService</code>. * The async counterpart of <code>ShareUpdateService</code>.
*/ */
public interface ShareUpdateServiceAsync { public interface ShareUpdateServiceAsync {
void share(String feedText, FeedType type, PrivacyLevel pLevel,
String vreName, LinkPreview preview, String urlThumbnail,
ArrayList<String> mentionedUsers, String fileName,
String FilePathOnServer, boolean notifyGroup,
AsyncCallback<ClientFeed> callback);
void checkLink(String linkToCheck, AsyncCallback<LinkPreview> callback); void checkLink(String linkToCheck, AsyncCallback<LinkPreview> callback);
@ -31,4 +27,16 @@ public interface ShareUpdateServiceAsync {
AsyncCallback<LinkPreview> callback); AsyncCallback<LinkPreview> callback);
void getHashtags(AsyncCallback<ArrayList<ItemBean>> callback); void getHashtags(AsyncCallback<ArrayList<ItemBean>> callback);
void sharePostWithLinkPreview(String feedText, FeedType type,
PrivacyLevel pLevel, String vreName, LinkPreview preview,
String urlThumbnail, ArrayList<String> mentionedUsers, boolean notifyGroup,
AsyncCallback<ClientFeed> callback);
void sharePostWithAttachments(String feedText, FeedType type,
PrivacyLevel pLevel, String vreName,
ArrayList<UploadedFile> uploadedFiles,
ArrayList<String> mentionedUsers, boolean notifyGroup,
boolean saveCopyWokspace, AsyncCallback<ClientFeed> callback);
} }

View File

@ -1,50 +1,135 @@
package org.gcube.portlets.user.shareupdates.client.view; package org.gcube.portlets.user.shareupdates.client.view;
/**
* Attached file class.
* @author Costantino Perciante at ISTI-CNR
*/
public class AttachedFile { public class AttachedFile {
// the name of the file
private String fileName; private String fileName;
// where it has been uploaded on the server (tmp directory of tomcat)
private String fileAbsolutePathOnServer; private String fileAbsolutePathOnServer;
// a description of the file (its content for a pdf, size for images)
private String description;
// when showing a file, this is the url that can be used for download
private String downloadUrl;
// thumbnail url related to the type of file (pdf, png, jpg)
private String thumbnailUrl;
// format type (pdf, jpg ecc..)
private String format;
// object used to show on the client the attachment
private AttachmentPreviewer atPrev; private AttachmentPreviewer atPrev;
// has been it correctly uploaded on the server?
private boolean correctlyUploaded; private boolean correctlyUploaded;
/**
*
* @param fileName name of the file
* @param fileAbsolutePathOnServer path on the server
* @param atPrev object that shows such attachment
* @param uploaded has been it correctly uploaded on the server?
*/
public AttachedFile(String fileName, String fileAbsolutePathOnServer, public AttachedFile(String fileName, String fileAbsolutePathOnServer,
AttachmentPreviewer atPrev, boolean uploaded) { String description, String downloadUrl, String thumbnailUrl,
String format, AttachmentPreviewer atPrev, boolean correctlyUploaded) {
super(); super();
this.fileName = fileName; this.fileName = fileName;
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer; this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
this.description = description;
this.downloadUrl = downloadUrl;
this.thumbnailUrl = thumbnailUrl;
this.format = format;
this.atPrev = atPrev; this.atPrev = atPrev;
this.correctlyUploaded = uploaded;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileAbsolutePathOnServer() {
return fileAbsolutePathOnServer;
}
public void setFileAbsolutePathOnServer(String fileAbsolutePathOnServer) {
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
}
public AttachmentPreviewer getAtPrev() {
return atPrev;
}
public void setAtPrev(AttachmentPreviewer atPrev) {
this.atPrev = atPrev;
}
public boolean isCorrectlyUploaded() {
return correctlyUploaded;
}
public void setCorrectlyUploaded(boolean correctlyUploaded) {
this.correctlyUploaded = correctlyUploaded; this.correctlyUploaded = correctlyUploaded;
} }
/**
* Constructor used when the check uploaded file fails
* @param fileName
* @param absolutePathOnServer
* @param atPrev attachment previewer
* @param thumbnail url thumbnail
*/
public AttachedFile(String fileName, String fileAbsolutePathOnServer,
AttachmentPreviewer atPrev, String thumbnailUrl) {
this.fileName = fileName;
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
this.atPrev = atPrev;
this.thumbnailUrl = thumbnailUrl;
this.correctlyUploaded = false;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileAbsolutePathOnServer() {
return fileAbsolutePathOnServer;
}
public void setFileAbsolutePathOnServer(String fileAbsolutePathOnServer) {
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public String getThumbnailUrl() {
return thumbnailUrl;
}
public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public AttachmentPreviewer getAtPrev() {
return atPrev;
}
public void setAtPrev(AttachmentPreviewer atPrev) {
this.atPrev = atPrev;
}
public boolean isCorrectlyUploaded() {
return correctlyUploaded;
}
public void setCorrectlyUploaded(boolean correctlyUploaded) {
this.correctlyUploaded = correctlyUploaded;
}
@Override
public String toString() {
return "AttachedFile [fileName=" + fileName
+ ", fileAbsolutePathOnServer=" + fileAbsolutePathOnServer
+ ", description=" + description + ", downloadUrl="
+ downloadUrl + ", thumbnailUrl=" + thumbnailUrl + ", mime="
+ format + ", atPrev=" + atPrev + ", correctlyUploaded="
+ correctlyUploaded + "]";
}
} }

View File

@ -1,18 +1,25 @@
package org.gcube.portlets.user.shareupdates.client.view; package org.gcube.portlets.user.shareupdates.client.view;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler; 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.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/**
* Class to show an attached file.
* @author Costantino Perciante at ISTI-CNR
*
*/
public class AttachmentPreviewer extends Composite { public class AttachmentPreviewer extends Composite {
private static AttachmentPreviewerUiBinder uiBinder = GWT private static AttachmentPreviewerUiBinder uiBinder = GWT
@ -26,7 +33,8 @@ public class AttachmentPreviewer extends Composite {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
private static final String DELETE_ATTACHMENT = "The attachment won't be saved. Would you like to continue?"; //private static final String DELETE_ATTACHMENT = "Delete this attachment?";
private static final String RETRY_TO_UPLOAD = "Retry to upload this attachment on the server.";
@UiField @UiField
HTML deleteAttachment; HTML deleteAttachment;
@ -43,12 +51,18 @@ public class AttachmentPreviewer extends Composite {
@UiField @UiField
Image resultImage; Image resultImage;
@UiField
HorizontalPanel attachmentResult;
// Parent of this AttachmentPreviewer object // Parent of this AttachmentPreviewer object
private Placeholder parent; private Placeholder parent;
// the ShareUpdateForm // the ShareUpdateForm
private ShareUpdateForm shareUpdateForm; private ShareUpdateForm shareUpdateForm;
// retry upload button reference
private HTML retryButton;
public AttachmentPreviewer(String fileName, String urlImagePreview, Placeholder parent, ShareUpdateForm shareUpdateForm) { public AttachmentPreviewer(String fileName, String urlImagePreview, Placeholder parent, ShareUpdateForm shareUpdateForm) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
@ -71,11 +85,13 @@ public class AttachmentPreviewer extends Composite {
@UiHandler("deleteAttachment") @UiHandler("deleteAttachment")
void onClick(ClickEvent e) { void onClick(ClickEvent e) {
// alert the user // alert the user (In some firefox versions, this may cause the bug
boolean confirm = Window.confirm(DELETE_ATTACHMENT); //uncaught exception: java.lang.AssertionError: Negative entryDepth value at exit -1)
// due to the fact that a window.alert or window.confirm is invoked within an handler
if(!confirm) // boolean confirm = Window.confirm(DELETE_ATTACHMENT);
return; //
// if(!confirm)
// return;
// we have to remove the AttachmentPreview object (that is, this object) and // we have to remove the AttachmentPreview object (that is, this object) and
// remove the file from the List of AttachedFiles // remove the file from the List of AttachedFiles
@ -85,7 +101,7 @@ public class AttachmentPreviewer extends Composite {
} }
/** /**
* set the label and the that shows if the file has been saved or not * set the label and the icon that shows if the file has been saved or not
* @param result * @param result
* @param urlImageResult * @param urlImageResult
*/ */
@ -103,24 +119,32 @@ public class AttachmentPreviewer extends Composite {
} }
/** /**
* Change style of part of this object to allow the user to retry to upload the file *
* @param tooltip * Change style of part of this object to allow the user to retry to upload the file.
* @param retryToAttachImageUrl *
*/ */
public void setImagePreviewToRetry(String tooltip, String retryToAttachImageUrl) { public void retryToUpload(final AttachmentPreviewer thisPreviewer) {
this.imagePreview.setUrl(retryToAttachImageUrl); // add the button to retry to upload such file
this.imagePreview.setTitle(tooltip); retryButton = new HTML("<a>"+ "<span>Try Again</span></a>");
retryButton.getElement().getStyle().setMarginLeft(5, Unit.PX);
retryButton.getElement().getStyle().setCursor(Cursor.POINTER);
retryButton.setTitle(RETRY_TO_UPLOAD);
// add the handler on the icon retryButton.addClickHandler(new ClickHandler() {
this.imagePreview.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
Window.alert("Retry to attach handler to be implemented...");
// we have to remove the AttachmentPreview object (that is, this object) and
// remove the file from the List of AttachedFiles
parent.remove(thisPreviewer);
shareUpdateForm.removeAttachedFile(thisPreviewer);
} }
}); });
attachmentResult.add(retryButton);
} }
} }

View File

@ -16,7 +16,4 @@ public class LinkLoader extends Composite {
public LinkLoader() { public LinkLoader() {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
} }
} }

View File

@ -12,6 +12,11 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/**
* Class used to show a link preview.
* @author Massimiliano Assante at ISTI-CNR
*
*/
public class LinkPreviewer extends Composite { public class LinkPreviewer extends Composite {
private static final String HTTP_ERROR_301 = "Moved Permanently"; private static final String HTTP_ERROR_301 = "Moved Permanently";

View File

@ -33,6 +33,5 @@
</td> </td>
</tr> </tr>
</table> </table>
<m:Placeholder ui:field="uploadInWS"></m:Placeholder>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.user.shareupdates.client.view;
/**
* Type of posts.
* @author Costantino Perciante at ISTI-CNR
*/
public enum PostContent {
ONLY_TEXT, TEXT_AND_LINK, TEXT_AND_ATTACHMENTS
}

View File

@ -16,15 +16,14 @@ public class SaveInWorkspaceBox extends Composite {
UiBinder<Widget, SaveInWorkspaceBox> { UiBinder<Widget, SaveInWorkspaceBox> {
} }
public SaveInWorkspaceBox() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiField @UiField
CheckBox saveCheckBox; CheckBox saveCheckBox;
public SaveInWorkspaceBox(String firstName) { public SaveInWorkspaceBox() {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
// set as not visibile
this.setVisible(false);
} }
protected boolean getValue() { protected boolean getValue() {

View File

@ -15,6 +15,7 @@ import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.shareupdates.client.ShareUpdateService; import org.gcube.portlets.user.shareupdates.client.ShareUpdateService;
import org.gcube.portlets.user.shareupdates.client.ShareUpdateServiceAsync; import org.gcube.portlets.user.shareupdates.client.ShareUpdateServiceAsync;
import org.gcube.portlets.user.shareupdates.shared.LinkPreview; import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
import org.gcube.portlets.user.shareupdates.shared.UploadedFile;
import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent; import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler; import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
@ -51,7 +52,7 @@ import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment; import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
* * The main share update class.
* @author Massimiliano Assante at ISTI CNR * @author Massimiliano Assante at ISTI CNR
* @author Costantino Perciante at ISTI CNR * @author Costantino Perciante at ISTI CNR
* *
@ -67,6 +68,9 @@ public class ShareUpdateForm extends Composite {
// the label for all Vres/channels // the label for all Vres/channels
private final static String ALL_VRES = "Share with: your Virtual Research Environments"; private final static String ALL_VRES = "Share with: your Virtual Research Environments";
// maximum number of files that can be attached
private static final int MAX_NUMBER_ATTACHMENTS = 10;
// Labels // Labels
protected final static String SHARE_UPDATE_TEXT = "Share an update or a link, use “@” to mention and “#” to add a topic"; protected final static String SHARE_UPDATE_TEXT = "Share an update or a link, use “@” to mention and “#” to add a topic";
protected final static String ERROR_UPDATE_TEXT = "Looks like empty to me!"; protected final static String ERROR_UPDATE_TEXT = "Looks like empty to me!";
@ -75,21 +79,17 @@ public class ShareUpdateForm extends Composite {
public static final String DROP_FILE_HERE_TEXT = "Drop your file(s) here!"; public static final String DROP_FILE_HERE_TEXT = "Drop your file(s) here!";
public static final String ATTACHMENT_LOADED = "Attachment loaded!"; public static final String ATTACHMENT_LOADED = "Attachment loaded!";
public static final String ATTACHMENT_NOT_LOADED = "Attachment not loaded!"; public static final String ATTACHMENT_NOT_LOADED = "Attachment not loaded!";
private static final String RETRY_TO_ATTACH_MESSAGE = "Retry to attach this file";
private static final String DELETE_LINK_PREVIEW = "The link preview will be removed. Would you like to continue?"; private static final String DELETE_LINK_PREVIEW = "The link preview will be removed. Would you like to continue?";
private static final String DELETE_ATTACHMENTS = "The attachment(s) will be removed. Would you like to continue?"; private static final String DELETE_ATTACHMENTS = "The attachment(s) will be removed. Would you like to continue?";
private static final String TOO_MUCH_ATTACHMENT_ALERT = "Sorry, but you cannot upload more than " + MAX_NUMBER_ATTACHMENTS + " attachments!";
// image urls // image urls
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif"; public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png"; public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
public static final String attach = GWT.getModuleBaseURL() + "../images/attach.png"; public static final String attachImageUrl = GWT.getModuleBaseURL() + "../images/attach.png";
public static final String attachedDefault = GWT.getModuleBaseURL() + "../images/attachment_default.png"; public static final String attachedDefaultImageUrl = GWT.getModuleBaseURL() + "../images/attachment_default.png";
public static final String loadedAttachment = GWT.getModuleBaseURL() + "../images/load.png"; public static final String loadedAttachmentImageUrl = GWT.getModuleBaseURL() + "../images/load.png";
public static final String notLoadedAttachment = GWT.getModuleBaseURL() + "../images/not_load.png"; public static final String notLoadedAttachmentImageUrl = GWT.getModuleBaseURL() + "../images/not_load.png";
public static final String retryToAttach = GWT.getModuleBaseURL() + "../images/reload.png";
// maximum number of files that can be attached!
private static final int MAX_NUMBER_ATTACHMENTS = 10;
// remember the previous text in the textarea (while handling drag and drop) // remember the previous text in the textarea (while handling drag and drop)
private static String previousText; private static String previousText;
@ -103,7 +103,7 @@ public class ShareUpdateForm extends Composite {
.create(ShareUpdateFormUiBinder.class); .create(ShareUpdateFormUiBinder.class);
// The link previewer // The link previewer
private LinkPreviewer myLinkPreviewer; private LinkPreviewer linkPreviewer;
// panel that show the in progress upload of an attachment // panel that show the in progress upload of an attachment
private UploadProgressPanel uploadProgress; private UploadProgressPanel uploadProgress;
@ -114,6 +114,10 @@ public class ShareUpdateForm extends Composite {
// this instance // this instance
private static ShareUpdateForm singleton; private static ShareUpdateForm singleton;
/**
* Get this ShareUpdateForm object
* @return
*/
public static ShareUpdateForm get() { public static ShareUpdateForm get() {
return singleton; return singleton;
} }
@ -142,6 +146,9 @@ public class ShareUpdateForm extends Composite {
@UiField @UiField
ListBox notifyListbox = new ListBox(); ListBox notifyListbox = new ListBox();
@UiField
SaveInWorkspaceBox saveInWorkspaceCheckbox;
// requested user's information // requested user's information
private UserInfo myUserInfo; private UserInfo myUserInfo;
@ -211,33 +218,8 @@ public class ShareUpdateForm extends Composite {
GWT.log("Drag over handler"); GWT.log("Drag over handler");
// save current text (note that the DragOverEvent event can be fired several times) // add style change
boolean conditionToSave = !shareTextArea.getText().equals(DROP_FILE_HERE_TEXT) && !shareTextArea.getText().equals(SHARE_UPDATE_TEXT); addDNDStyleEffects();
previousText = conditionToSave ? shareTextArea.getText() : previousText;
// change border properties
shareTextArea.getElement().getStyle().setBorderStyle(BorderStyle.DASHED);
shareTextArea.getElement().getStyle().setBorderColor("rgba(82, 168, 236, 0.6)");
shareTextArea.getElement().getStyle().setBorderWidth(2.5, Unit.PX);
// change background color
shareTextArea.getElement().getStyle().setBackgroundColor("rgba(82, 168, 236, 0.2)");
// enlarge the window
Document.get().getElementById("highlighterContainer").getStyle().setHeight(52, Unit.PX);
Document.get().getElementById("highlighter").getStyle().setHeight(52, Unit.PX);
Document.get().getElementById("postTextArea").getStyle().setHeight(52, Unit.PX);
// add "Drop file here" text
shareTextArea.setText(DROP_FILE_HERE_TEXT);
shareTextArea.setAlignment(TextAlignment.CENTER);
shareTextArea.getElement().getStyle().setFontWeight(FontWeight.BOLD);
shareTextArea.getElement().getStyle().setPaddingTop(
(Double.parseDouble(shareTextArea.getElement().getStyle().getHeight().replace("px", "")) + 20)/2.0, Unit.PX);
// set the color of the text if needed to gray
if(!previousText.equals(SHARE_UPDATE_TEXT))
shareTextArea.getElement().getStyle().setColor("#999");
} }
}); });
@ -260,6 +242,10 @@ public class ShareUpdateForm extends Composite {
// enable shareTextArea as drop target (using native javascript) // enable shareTextArea as drop target (using native javascript)
addNativeDropHandler(singleton, FileSubmit.URL); addNativeDropHandler(singleton, FileSubmit.URL);
}else{
GWT.log("Drag and drop not supported.");
} }
} }
}); });
@ -272,6 +258,7 @@ public class ShareUpdateForm extends Composite {
//get the uploaded file result //get the uploaded file result
eventBus.addHandler(FileUploadCompleteEvent.TYPE, new FileUploadCompleteEventHandler() { eventBus.addHandler(FileUploadCompleteEvent.TYPE, new FileUploadCompleteEventHandler() {
@Override @Override
public void onUploadComplete(FileUploadCompleteEvent event) { public void onUploadComplete(FileUploadCompleteEvent event) {
String absolutePathOnServer = event.getUploadedFileInfo().getAbsolutePath(); String absolutePathOnServer = event.getUploadedFileInfo().getAbsolutePath();
@ -303,7 +290,7 @@ public class ShareUpdateForm extends Composite {
void onAttachClick(ClickEvent e) { void onAttachClick(ClickEvent e) {
// check if there is a linkpreview // check if there is a linkpreview
if(myLinkPreviewer != null){ if(linkPreviewer != null){
// in this case let the user choose what to do // in this case let the user choose what to do
boolean confirm = Window.confirm(DELETE_LINK_PREVIEW); boolean confirm = Window.confirm(DELETE_LINK_PREVIEW);
@ -315,6 +302,14 @@ public class ShareUpdateForm extends Composite {
cancelLinkPreview(); cancelLinkPreview();
} }
// check the number of already attached files
if(numberOfAttachments() >= MAX_NUMBER_ATTACHMENTS){
Window.alert(TOO_MUCH_ATTACHMENT_ALERT);
return;
}
// proceed with the upload // proceed with the upload
FileUpload up = uploadProgress.initialize(); FileUpload up = uploadProgress.initialize();
up.setVisible(false); up.setVisible(false);
@ -328,7 +323,9 @@ public class ShareUpdateForm extends Composite {
* @param el * @param el
*/ */
public static native void fileBrowse(Element el) /*-{ public static native void fileBrowse(Element el) /*-{
el.click(); el.click();
}-*/; }-*/;
@ -340,9 +337,12 @@ public class ShareUpdateForm extends Composite {
shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() { shareupdateService.getUserSettings(new AsyncCallback<UserSettings>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Window.alert("Ops! we encountered some problems delivering your message, server is not responding, please try again in a short while."); Window.alert("Ops! we encountered some problems delivering your message, server is not responding, please try again in a short while.");
} }
public void onSuccess(UserSettings result) { public void onSuccess(UserSettings result) {
if (result.getUserInfo().getUsername().equals("test.user")) { if (result.getUserInfo().getUsername().equals("test.user")) {
Window.alert("Your session has expired, please log out and login again"); Window.alert("Your session has expired, please log out and login again");
return; return;
@ -350,75 +350,108 @@ public class ShareUpdateForm extends Composite {
myUserInfo = result.getUserInfo(); myUserInfo = result.getUserInfo();
String toShare = shareTextArea.getText().trim(); String toShare = shareTextArea.getText().trim();
//We allow to post a file without writing nothing in the sharing textarea // Establish the content of this post
if (myLinkPreviewer != null && (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) ) { PostContent postContent = PostContent.ONLY_TEXT;
// check if we are going to send a link preview (The shared text cannot be empty nor it can be an error message)
if(linkPreviewer != null && (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals(""))){
shareTextArea.addStyleName("error");
shareTextArea.setText(ERROR_UPDATE_TEXT);
return;
}else{
if(linkPreviewer != null)
postContent = PostContent.TEXT_AND_LINK;
if(numberOfAttachmentsUploaded() > 0){
postContent = PostContent.TEXT_AND_ATTACHMENTS;
toShare = NO_TEXT_FILE_SHARE; toShare = NO_TEXT_FILE_SHARE;
} }
}
// check the text (attachment can be sent without shared text)
if (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) { if (toShare.equals(SHARE_UPDATE_TEXT) || toShare.equals(ERROR_UPDATE_TEXT) || toShare.equals("")) {
shareTextArea.addStyleName("error"); shareTextArea.addStyleName("error");
shareTextArea.setText(ERROR_UPDATE_TEXT); shareTextArea.setText(ERROR_UPDATE_TEXT);
return; return;
} }
//then you can post but you have to pass html checks now //then you can post but you have to pass html checks now
String toPost = toShare; String toPost = toShare;
postTweet(toPost, shareTextArea.getMentionedUsers()); postTweet(toPost, shareTextArea.getMentionedUsers(), postContent);
} }
}); });
} }
/** /**
* * Publish a post.
* @param textToPost * @param textToPost the text of this port
* @param mentionedUsers list of users mentioned in the text (if any)
* @param postContent the type of post
*/ */
private void postTweet(String textToPost, ArrayList<String> mentionedUsers) { private void postTweet(String textToPost, ArrayList<String> mentionedUsers, PostContent postContent) {
String toShare = escapeHtml(textToPost);
if (! checkTextLength(toShare)) { // escape html text
String toShareText = escapeHtml(textToPost);
if (! checkTextLength(toShareText)) {
Window.alert("We found a single word containing more than 50 chars and it's not a link, is it meaningful?"); Window.alert("We found a single word containing more than 50 chars and it's not a link, is it meaningful?");
return; return;
} }
// disable text edit and submission button
submitButton.setEnabled(false); submitButton.setEnabled(false);
shareTextArea.setEnabled(false); shareTextArea.setEnabled(false);
// retrieve the vre id
String vreId = ""; String vreId = "";
if (getPrivacyLevel() == PrivacyLevel.SINGLE_VRE) { if (getPrivacyLevel() == PrivacyLevel.SINGLE_VRE) {
vreId = privacyLevel.getValue(privacyLevel.getSelectedIndex()); vreId = privacyLevel.getValue(privacyLevel.getSelectedIndex());
} }
//preparing to send stuff
String linkTitle = "", linkDescription = "" , linkUrl = "", linkUrlThumbnail = "", linkHost = "", fileName = null, filePath = null; // notify group information
if (myLinkPreviewer != null) {
linkTitle = myLinkPreviewer.getLinkTitle();
linkDescription = myLinkPreviewer.getLinkDescription();
linkUrl = myLinkPreviewer.getUrl();
linkUrlThumbnail = myLinkPreviewer.getUrlThumbnail();
linkHost = myLinkPreviewer.getHost();
// TODO handle attachments
// if (myLinkPreviewer.isSaveCopySelected()) {
// fileName = uploadedFileNameOnServer;
// filePath = uploadedFilePathOnServer;
// }
}
LinkPreview preview2Share = new LinkPreview(linkTitle, linkDescription, linkUrl, linkHost, null);
boolean notifyGroup = notifyListbox.getSelectedIndex() > 0; boolean notifyGroup = notifyListbox.getSelectedIndex() > 0;
shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, fileName, filePath, notifyGroup, new AsyncCallback<ClientFeed>() { // case in which there are no attachments but there could be a link preview
if(postContent == PostContent.ONLY_TEXT || postContent == PostContent.TEXT_AND_LINK){
//preparing to send stuff
String linkTitle = "", linkDescription = "" , linkUrl = "", linkUrlThumbnail = "", linkHost = "";
if (linkPreviewer != null) {
linkTitle = linkPreviewer.getLinkTitle();
linkDescription = linkPreviewer.getLinkDescription();
linkUrl = linkPreviewer.getUrl();
linkUrlThumbnail = linkPreviewer.getUrlThumbnail();
linkHost = linkPreviewer.getHost();
}
LinkPreview preview2Share = new LinkPreview(linkTitle, linkDescription, linkUrl, linkHost, null);
// share post (it could contain a link preview)
shareupdateService.sharePostWithLinkPreview(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, notifyGroup, new AsyncCallback<ClientFeed>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
submitButton.setEnabled(true); submitButton.setEnabled(true);
shareTextArea.setEnabled(true); shareTextArea.setEnabled(true);
shareTextArea.setText(SHARE_UPDATE_TEXT); shareTextArea.setText(SHARE_UPDATE_TEXT);
shareTextArea.cleanHighlighterDiv(); shareTextArea.cleanHighlighterDiv();
preview.clear(); preview.clear();
myLinkPreviewer = null; linkPreviewer = null;
} }
public void onSuccess(ClientFeed feed) { public void onSuccess(ClientFeed feed) {
submitButton.setEnabled(true); submitButton.setEnabled(true);
shareTextArea.setEnabled(true); shareTextArea.setEnabled(true);
shareTextArea.setText(SHARE_UPDATE_TEXT); shareTextArea.setText(SHARE_UPDATE_TEXT);
shareTextArea.cleanHighlighterDiv(); shareTextArea.cleanHighlighterDiv();
preview.clear(); preview.clear();
myLinkPreviewer = null; linkPreviewer = null;
if (feed == null) if (feed == null)
Window.alert("Ops! we encountered some problems delivering your message, please try again in a short while."); Window.alert("Ops! we encountered some problems delivering your message, please try again in a short while.");
else { else {
@ -429,11 +462,88 @@ public class ShareUpdateForm extends Composite {
GWT.log(ex.getMessage()); GWT.log(ex.getMessage());
} }
} }
//needed when posting long texts otherwise it stays with the current height //needed when posting long texts otherwise it stays with the current height
shareTextArea.getElement().getStyle().setHeight(54, Unit.PX); shareTextArea.getElement().getStyle().setHeight(54, Unit.PX);
} }
}); });
} }
else{
// case with at least one attachment available
ArrayList<UploadedFile> uploadedFiles = new ArrayList<UploadedFile>();
// consider only correctly uploaded file(s)
for(AttachedFile file: listOfAttachedFiles){
if(file.isCorrectlyUploaded())
uploadedFiles.add(
new UploadedFile(
file.getFileName(),
file.getFileAbsolutePathOnServer(),
file.getDescription(),
file.getDownloadUrl(),
file.getThumbnailUrl(),
file.getFormat()));
}
// share the post
shareupdateService.sharePostWithAttachments(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, uploadedFiles, mentionedUsers, notifyGroup, saveInWorkspaceCheckbox.getValue(), new AsyncCallback<ClientFeed>() {
@Override
public void onSuccess(ClientFeed result) {
GWT.log("OK");
submitButton.setEnabled(true);
shareTextArea.setEnabled(true);
shareTextArea.setText(SHARE_UPDATE_TEXT);
shareTextArea.cleanHighlighterDiv();
saveInWorkspaceCheckbox.setVisible(false);
preview.clear();
listOfAttachedFiles.clear();
if (result == null)
Window.alert("Ops! we encountered some problems delivering your message, please try again in a short while.");
else {
// publish a message with the refresh notification
try {
pageBusAdapter.PageBusPublish("org.gcube.portal.databook.shared", result, (Jsonizer)GWT.create(ClientFeedJsonizer.class));
} catch (PageBusAdapterException ex) {
GWT.log(ex.getMessage());
}
}
//needed when posting long texts otherwise it stays with the current height
shareTextArea.getElement().getStyle().setHeight(54, Unit.PX);
}
@Override
public void onFailure(Throwable caught) {
GWT.log(caught.toString());
submitButton.setEnabled(true);
shareTextArea.setEnabled(true);
shareTextArea.setText(SHARE_UPDATE_TEXT);
shareTextArea.cleanHighlighterDiv();
saveInWorkspaceCheckbox.setVisible(false);
preview.clear();
listOfAttachedFiles.clear();
}
});
}
}
/**
* Determines the privacy level of the post to be shared.
* @return
*/
private PrivacyLevel getPrivacyLevel() { private PrivacyLevel getPrivacyLevel() {
String selected = privacyLevel.getValue(privacyLevel.getSelectedIndex()); String selected = privacyLevel.getValue(privacyLevel.getSelectedIndex());
if (selected.compareTo(PrivacyLevel.CONNECTION.toString()) == 0) if (selected.compareTo(PrivacyLevel.CONNECTION.toString()) == 0)
@ -467,7 +577,7 @@ public class ShareUpdateForm extends Composite {
* @param linkToCheck * @param linkToCheck
*/ */
protected void checkLink(String textToCheck) { protected void checkLink(String textToCheck) {
if (myLinkPreviewer == null) { if (linkPreviewer == null) {
String [] parts = textToCheck.split("\\s"); String [] parts = textToCheck.split("\\s");
// Attempt to convert each item into an URL. // Attempt to convert each item into an URL.
for( String item : parts ) { for( String item : parts ) {
@ -485,11 +595,13 @@ public class ShareUpdateForm extends Composite {
// else... remove attachments and continue // else... remove attachments and continue
listOfAttachedFiles.clear(); listOfAttachedFiles.clear();
preview.clear(); preview.clear();
saveInWorkspaceCheckbox.setVisible(false);
} }
preview.add(new LinkLoader()); preview.add(new LinkLoader());
submitButton.setEnabled(false); submitButton.setEnabled(false);
//GWT.log("It's http link:" + linkToCheck); //GWT.log("It's http link:" + linkToCheck);
shareupdateService.checkLink(textToCheck, new AsyncCallback<LinkPreview>() { shareupdateService.checkLink(textToCheck, new AsyncCallback<LinkPreview>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -498,6 +610,11 @@ public class ShareUpdateForm extends Composite {
} }
public void onSuccess(LinkPreview result) { public void onSuccess(LinkPreview result) {
// For a link, the LinkPreview object is like this
// LinkPreview [title=ANSA.it - Homepage, description=ANSA.it: Il sito Internet dell'Agenzia ANSA. Ultime notizie, foto, video e approfondimenti su: cronaca, politica, economia, regioni, mondo, sport, calcio, cultura e tecnologia,
// url=http://www.ansa.it/, host=ansa.it, imageUrls=[http://www.ansa.it/sito/img/ico/ansa-57-precomposed.png]]
// GWT.log(result.toString());
preview.clear(); preview.clear();
if (result != null) if (result != null)
addPreviewLink(result); addPreviewLink(result);
@ -521,7 +638,7 @@ public class ShareUpdateForm extends Composite {
protected void checkFile(final String fileName, final String absolutePathOnServer) { protected void checkFile(final String fileName, final String absolutePathOnServer) {
// create temp view of the attached file and add to the previewer // create temp view of the attached file and add to the previewer
final AttachmentPreviewer atPrev = new AttachmentPreviewer(fileName, attachedDefault, preview, this); final AttachmentPreviewer atPrev = new AttachmentPreviewer(fileName, attachedDefaultImageUrl, preview, this);
preview.add(atPrev); preview.add(atPrev);
// disable the submit button till we know the result of the upload process // disable the submit button till we know the result of the upload process
@ -529,45 +646,48 @@ public class ShareUpdateForm extends Composite {
shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback<LinkPreview>() { shareupdateService.checkUploadedFile(fileName, absolutePathOnServer, new AsyncCallback<LinkPreview>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
GWT.log("Upload of the file failed!");
uploadProgress.showRegisteringResult(false); GWT.log("Unable to check uploaded file!");
// hide progress bar
uploadProgress.setVisible(false); uploadProgress.setVisible(false);
// attach the file with error..
listOfAttachedFiles.add(
new AttachedFile(
fileName,
absolutePathOnServer,
atPrev,
null)
);
// there is no a linkPreview...
addPreviewAttachment(null, atPrev); addPreviewAttachment(null, atPrev);
listOfAttachedFiles.add(new AttachedFile(fileName, absolutePathOnServer, atPrev, false));
// enable anyway the button
submitButton.setEnabled(true); submitButton.setEnabled(true);
/*preview.clear();
final HorizontalPanel hp = new HorizontalPanel();
final Button close = new Button("Try Again");
final HTML reportIssue = new HTML("<a href=\"https://support.d4science.research-infrastructures.eu\" target=\"_blank\">"
+ "<span>Report the issue</span></a>");
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
uploadProgress.setVisible(false);
preview.remove(hp);
}
});
hp.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE);
hp.add(close);
hp.add(reportIssue);
preview.add(hp);*/
} }
// it returns a LinkPreview (for compatibility with old code)
public void onSuccess(LinkPreview result) { public void onSuccess(LinkPreview result) {
if(result == null) if(result == null)
return; return;
uploadProgress.setVisible(false); listOfAttachedFiles.add(
addPreviewAttachment(result, atPrev); new AttachedFile(
listOfAttachedFiles.add(new AttachedFile(fileName, absolutePathOnServer, atPrev, true)); result.getTitle(),
submitButton.setEnabled(true); absolutePathOnServer,
result.getDescription(),
result.getUrl(),
result.getImageUrls().get(0),
result.getHost(),
atPrev,
true)
);
addPreviewAttachment(result, atPrev);
submitButton.setEnabled(true);
} }
}); });
} }
@ -594,10 +714,11 @@ public class ShareUpdateForm extends Composite {
* @param result * @param result
*/ */
private void addPreviewLink(LinkPreview result) { private void addPreviewLink(LinkPreview result) {
//GWT.log(result.toString());
preview.clear(); preview.clear();
uploadProgress.setVisible(false); uploadProgress.setVisible(false);
myLinkPreviewer = new LinkPreviewer(this, result); linkPreviewer = new LinkPreviewer(this, result);
preview.add(myLinkPreviewer); preview.add(linkPreviewer);
} }
/** /**
@ -605,30 +726,41 @@ public class ShareUpdateForm extends Composite {
*/ */
private void addPreviewAttachment(LinkPreview result, AttachmentPreviewer atPrev){ private void addPreviewAttachment(LinkPreview result, AttachmentPreviewer atPrev){
// GWT.log(result.toString());
// disable progress bar
uploadProgress.setVisible(false); uploadProgress.setVisible(false);
// check the result // check the result
if(result == null){ if(result == null){
// failed upload
atPrev.setResultAttachment(ATTACHMENT_NOT_LOADED, notLoadedAttachment);
// change the preview image to reload icon to let the user retry // failed upload
atPrev.setImagePreviewToRetry(RETRY_TO_ATTACH_MESSAGE, retryToAttach); atPrev.setResultAttachment(ATTACHMENT_NOT_LOADED, notLoadedAttachmentImageUrl);
// change the atPrev object and let the user retry the upload
atPrev.retryToUpload(atPrev);
} }
else{ else{
// set the preview information (the first image is the one related to attachments)
atPrev.setResultAttachment(ATTACHMENT_LOADED, loadedAttachment); // set the preview information (the first image is the one related to the type of file)
atPrev.setResultAttachment(ATTACHMENT_LOADED, loadedAttachmentImageUrl);
atPrev.setImagePreview(result.getImageUrls().get(0)); atPrev.setImagePreview(result.getImageUrls().get(0));
} }
preview.add(atPrev); preview.add(atPrev);
// enable checkbox to save in workspace if it's the case
if(numberOfAttachments() > 0 && !saveInWorkspaceCheckbox.isVisible())
saveInWorkspaceCheckbox.setVisible(true);
} }
/** /**
* * Delete the only link previewer allowed.
*/ */
protected void cancelLinkPreview() { protected void cancelLinkPreview() {
preview.clear(); preview.clear();
myLinkPreviewer = null; linkPreviewer = null;
attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting attachButton.getElement().getStyle().setVisibility(Visibility.VISIBLE); //beacuse otherwise it looses the other properties setting
} }
@ -639,11 +771,8 @@ public class ShareUpdateForm extends Composite {
private static native void addNativeDropHandler(ShareUpdateForm instance, private static native void addNativeDropHandler(ShareUpdateForm instance,
String servletUrl)/*-{ String servletUrl)/*-{
console.log("Adding drop handler to text area");
// retrieve textArea by id // retrieve textArea by id
var drop = $wnd.$('#postTextArea')[0]; var drop = $wnd.$('#postTextArea')[0];
console.log("drop is " + drop);
// check if this file is a folder // check if this file is a folder
function isFolder(file) { function isFolder(file) {
@ -749,7 +878,7 @@ public class ShareUpdateForm extends Composite {
// check its size // check its size
var fileSize = file.size / 1024 / 1024; var fileSize = file.size / 1024 / 1024;
console.log("File size is " + fileSize); console.log("File size is " + fileSize + "MB");
if(fileSize > maximumSize){ if(fileSize > maximumSize){
numberIgnoredFiles ++; numberIgnoredFiles ++;
@ -809,7 +938,7 @@ public class ShareUpdateForm extends Composite {
if(numberIgnoredFiles == files.length){ if(numberIgnoredFiles == files.length){
msg = file.name + " can't be uploaded since it is too large!"; msg = file.name + " can't be uploaded because it is too large!";
instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::showAlert(Ljava/lang/String;)(msg); instance.@org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm::showAlert(Ljava/lang/String;)(msg);
// reset text area // reset text area
@ -829,6 +958,7 @@ public class ShareUpdateForm extends Composite {
}-*/; }-*/;
/** /**
* Check if DND could be enabled (i.e, it's supported by the browser) * Check if DND could be enabled (i.e, it's supported by the browser)
* @return * @return
@ -839,6 +969,40 @@ public class ShareUpdateForm extends Composite {
}-*/; }-*/;
/**
* Add DND style effect on drag over.
*/
private void addDNDStyleEffects() {
// save current text (note that the DragOverEvent event can be fired several times)
boolean conditionToSave = !shareTextArea.getText().equals(DROP_FILE_HERE_TEXT) && !shareTextArea.getText().equals(SHARE_UPDATE_TEXT);
previousText = conditionToSave ? shareTextArea.getText() : previousText;
// change border properties
shareTextArea.getElement().getStyle().setBorderStyle(BorderStyle.DASHED);
shareTextArea.getElement().getStyle().setBorderColor("rgba(82, 168, 236, 0.6)");
shareTextArea.getElement().getStyle().setBorderWidth(2.5, Unit.PX);
// change background color
shareTextArea.getElement().getStyle().setBackgroundColor("rgba(82, 168, 236, 0.2)");
// enlarge the window
Document.get().getElementById("highlighterContainer").getStyle().setHeight(52, Unit.PX);
Document.get().getElementById("highlighter").getStyle().setHeight(52, Unit.PX);
Document.get().getElementById("postTextArea").getStyle().setHeight(52, Unit.PX);
// add "Drop file here" text
shareTextArea.setText(DROP_FILE_HERE_TEXT);
shareTextArea.setAlignment(TextAlignment.CENTER);
shareTextArea.getElement().getStyle().setFontWeight(FontWeight.BOLD);
shareTextArea.getElement().getStyle().setPaddingTop(
(Double.parseDouble(shareTextArea.getElement().getStyle().getHeight().replace("px", "")) + 20)/2.0, Unit.PX);
// set the color of the text if needed to gray
if(!previousText.equals(SHARE_UPDATE_TEXT))
shareTextArea.getElement().getStyle().setColor("#999");
}
/** /**
* On dragLeave reset changes on the text area * On dragLeave reset changes on the text area
*/ */
@ -897,17 +1061,21 @@ public class ShareUpdateForm extends Composite {
while (iterator.hasNext()) { while (iterator.hasNext()) {
AttachedFile attachedFile = (AttachedFile) iterator.next(); AttachedFile attachedFile = (AttachedFile) iterator.next();
if(attachedFile.getAtPrev().equals(attachedFile)){ if(attachedFile.getAtPrev().equals(attachmentPreviewer)){
iterator.remove(); iterator.remove();
return; break;
}
} }
} // check the final number of attachments and if it's less than one, set to false
// the save in workspace checkbox visibility
if(numberOfAttachments() == 0)
saveInWorkspaceCheckbox.setVisible(false);
} }
/** /**
* Get the number of attached files * Get the number of attached files (both uploaded and not).
* @return number of attached files * @return number of attached files
*/ */
public int numberOfAttachments(){ public int numberOfAttachments(){
@ -915,4 +1083,20 @@ public class ShareUpdateForm extends Composite {
return listOfAttachedFiles.size(); return listOfAttachedFiles.size();
} }
/**
* Retrieve the number of correctly uploaded attached files.
* @return number of attached files correctly uploaded.
*/
private int numberOfAttachmentsUploaded(){
int counter = 0;
for (AttachedFile attachedFile : listOfAttachedFiles) {
if(attachedFile.isCorrectlyUploaded())
counter ++;
}
return counter;
}
} }

View File

@ -25,6 +25,7 @@
</table> </table>
<j:UploadProgressPanel ui:field="uploadProgress"></j:UploadProgressPanel> <j:UploadProgressPanel ui:field="uploadProgress"></j:UploadProgressPanel>
<m:Placeholder ui:field="preview"></m:Placeholder> <m:Placeholder ui:field="preview"></m:Placeholder>
<m:SaveInWorkspaceBox ui:field="saveInWorkspaceCheckbox"></m:SaveInWorkspaceBox>
<table class="share-updates-table"> <table class="share-updates-table">
<tr> <tr>
<td class="share-updates-photo-cell"> <td class="share-updates-photo-cell">

View File

@ -14,6 +14,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.validator.routines.UrlValidator; import org.apache.commons.validator.routines.UrlValidator;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
@ -33,6 +35,7 @@ import org.gcube.portal.custom.communitymanager.impl.OrganizationManagerImpl;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.ClientFeed; import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.FeedType; import org.gcube.portal.databook.shared.FeedType;
@ -47,6 +50,7 @@ import org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm;
import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph; import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph;
import org.gcube.portlets.user.shareupdates.shared.HashTagAndOccurrence; import org.gcube.portlets.user.shareupdates.shared.HashTagAndOccurrence;
import org.gcube.portlets.user.shareupdates.shared.LinkPreview; import org.gcube.portlets.user.shareupdates.shared.LinkPreview;
import org.gcube.portlets.user.shareupdates.shared.UploadedFile;
import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean; import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
@ -67,8 +71,6 @@ import com.liferay.portal.model.Role;
import com.liferay.portal.service.OrganizationLocalServiceUtil; import com.liferay.portal.service.OrganizationLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.theme.ThemeDisplay;
import com.sun.net.ssl.HttpsURLConnection;
/** /**
* The server side implementation of the RPC service. * The server side implementation of the RPC service.
*/ */
@ -85,6 +87,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
public static final String UPLOAD_DIR = "/social-framework-uploads"; public static final String UPLOAD_DIR = "/social-framework-uploads";
private static final String NEWS_FEED_PORTLET_CLASSNAME = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl"; private static final String NEWS_FEED_PORTLET_CLASSNAME = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
private final static String ATTR_TO_CHECK = "Postnotificationviaemail"; private final static String ATTR_TO_CHECK = "Postnotificationviaemail";
/** /**
* *
*/ */
@ -121,7 +124,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = TEST_USER; String user = TEST_USER;
// user = "massimiliano.assante"; user = "costantino.perciante";
return user; return user;
} }
/** /**
@ -140,29 +143,35 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
/** /**
* * Share post that could contain a link preview.
*/ */
public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel, @Override
String vreId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames,String fileName, String filePathOnServer, boolean notifyGroup) { public ClientFeed sharePostWithLinkPreview(String postText, FeedType feedType, PrivacyLevel pLevel,
String vreId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames, boolean notifyGroup) {
_log.debug("Writing a new post with text " + postText);
// escape text
String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(postText); String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(postText);
// get hashtags
List<String> hashtags = TextTransfromUtils.getHashTags(postText); List<String> hashtags = TextTransfromUtils.getHashTags(postText);
if (hashtags != null && !hashtags.isEmpty()) if (hashtags != null && !hashtags.isEmpty())
escapedFeedText = TextTransfromUtils.convertHashtagsAnchorHTML(escapedFeedText, hashtags); escapedFeedText = TextTransfromUtils.convertHashtagsAnchorHTML(escapedFeedText, hashtags);
// retrieve mentioned users
ArrayList<ItemBean> mentionedUsers = null; ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNames); mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers); escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers);
} }
// get session
ASLSession session = getASLSession(); ASLSession session = getASLSession();
String username = session.getUsername(); String username = session.getUsername();
String email = username+"@isti.cnr.it"; String email = username+"@isti.cnr.it";
String fullName = username+" FULL"; String fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png"; String thumbnailAvatarURL = "images/Avatar_default.png";
boolean withinPortal = isWithinPortal(); boolean withinPortal = isWithinPortal();
@ -171,12 +180,13 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
UserInfo user = getUserSettings().getUserInfo(); UserInfo user = getUserSettings().getUserInfo();
email = user.getEmailaddress(); email = user.getEmailaddress();
fullName = user.getFullName(); fullName = user.getFullName();
thumbnailURL = user.getAvatarId(); thumbnailAvatarURL = user.getAvatarId();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
// get data from the preview of the link
String linkTitle = preview.getTitle(); String linkTitle = preview.getTitle();
String linkDesc = preview.getDescription(); String linkDesc = preview.getDescription();
String host = preview.getHost(); String host = preview.getHost();
@ -185,10 +195,171 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
urlThumbnail = "null"; urlThumbnail = "null";
Date feedDate = new Date(); Date feedDate = new Date();
//get the VRE scope if single channel post
String vreScope2Set = "";
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope();
}
// build the feed to share (and save on cassandra)
Feed toShare = new Feed(UUID.randomUUID().toString(), feedType, username, feedDate,
vreScope2Set, url, urlThumbnail, escapedFeedText, pLevel, fullName, email, thumbnailAvatarURL, linkTitle, linkDesc, host);
_log.info("Attempting to save Feed with text: " + escapedFeedText + " Level: " + pLevel + " Timeline="+vreScope2Set);
boolean result = store.saveUserFeed(toShare);
//need to put the feed into VRES Timeline too
if (pLevel == PrivacyLevel.VRES) {
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
for (GroupModel vre : getUserVREs(username)) {
String vreScope = getScopeByOrganizationId(vre.getGroupId());
_log.trace("Attempting to write onto " + vreScope);
try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
} catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope);
} //save the feed
_log.trace("Success writing onto " + vreScope);
}
}
//share on a single VRE Timeline
//receives a VreId(groupId) get the scope from the groupId
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
_log.trace("Attempting to write onto " + vreScope2Set);
try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
if (hashtags != null && !hashtags.isEmpty())
store.saveHashTags(toShare.getKey(), vreScope2Set, hashtags);
} catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope2Set);
} //save the feed
_log.trace("Success writing onto " + vreScope2Set);
}
if (!result) return null;
//everything went fine
ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(),
TextTransfromUtils.replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailAvatarURL, toShare.getLinkTitle(), toShare.getLinkDescription(),
toShare.getUriThumbnail(), toShare.getLinkHost());
//send the notification about this posts to everyone in the group if notifyGroup is true
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0 && notifyGroup) {
NotificationsManager nm = new ApplicationNotificationsManager(session, NEWS_FEED_PORTLET_CLASSNAME);
Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), escapedFeedText, ""+session.getGroupId(), nm, hashtags));
thread.start();
}
//send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0) {
NotificationsManager nm = new ApplicationNotificationsManager(session);
ArrayList<GenericItemBean> toPass = new ArrayList<GenericItemBean>();
for (ItemBean u : mentionedUsers) {
toPass.add(new GenericItemBean(u.getId(), u.getName(), u.getAlternativeName(), u.getThumbnailURL()));
}
Thread thread = new Thread(new MentionNotificationsThread(toShare.getKey(), escapedFeedText, nm, toPass));
thread.start();
}
return cf;
}
/**
* Share a post with at least one attachment.
*/
@Override
public ClientFeed sharePostWithAttachments(String feedText, FeedType feedType,
PrivacyLevel pLevel, String vreId, ArrayList<UploadedFile> uploadedFiles,
ArrayList<String> mentionedUserFullNames, boolean notifyGroup, boolean saveCopyWokspace) {
// escape text
String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(feedText);
// get the list of hashtags
List<String> hashtags = TextTransfromUtils.getHashTags(feedText);
if (hashtags != null && !hashtags.isEmpty())
escapedFeedText = TextTransfromUtils.convertHashtagsAnchorHTML(escapedFeedText, hashtags);
// get the list of mentioned users
ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers);
}
ASLSession session = getASLSession();
String username = session.getUsername();
String email = username+"@isti.cnr.it";
String fullName = username+" FULL";
String thumbnailAvatarURL = "images/Avatar_default.png";
boolean withinPortal = isWithinPortal();
if (withinPortal && username.compareTo(TEST_USER) != 0) {
try {
UserInfo user = getUserSettings().getUserInfo();
email = user.getEmailaddress();
fullName = user.getFullName();
thumbnailAvatarURL = user.getAvatarId();
} catch (Exception e) {
e.printStackTrace();
}
}
// Managing attachments: the first one (if any) will use the same fields of a link preview.
// If more than one attachments are present, they will be saved as Attachment objects.
// In this way we can handle retro-compatibility.
List<Attachment> attachments = null;
String firstAttachmentName = "",
firstAttachmentDescription = "",
firstAttachmentFormat = "",
firstAttachmentDownloadUrl = "",
firstAttachmenturlThumbnail = "";
if(uploadedFiles.size() > 0){
// retrieve the first element
UploadedFile firstAttachment = uploadedFiles.get(0);
firstAttachmentName = firstAttachment.getFileName();
firstAttachmentDescription = firstAttachment.getDescription();
firstAttachmentFormat = firstAttachment.getFormat();
firstAttachmentDownloadUrl = firstAttachment.getDownloadUrl();
firstAttachmenturlThumbnail = firstAttachment.getThumbnailUrl();
if(uploadedFiles.size() > 1){
attachments = new ArrayList<>();
// check if there are more files
for (UploadedFile file : uploadedFiles) {
attachments.add(new Attachment(
UUID.randomUUID().toString(),
file.getDownloadUrl(),
file.getFileName(),
file.getDescription(),
file.getThumbnailUrl(),
file.getFormat())
);
}
}
}
// evaluate the date (this will be the date of the post)
Date feedDate = new Date();
//this means the user has shared a file without text in it. //this means the user has shared a file without text in it.
String textToPost = ""; String textToPost = "";
if (escapedFeedText.trim().compareTo(ShareUpdateForm.NO_TEXT_FILE_SHARE) == 0) { if (escapedFeedText.trim().compareTo(ShareUpdateForm.NO_TEXT_FILE_SHARE) == 0) {
textToPost = TextTransfromUtils.convertFileNameAnchorHTML(url); textToPost = TextTransfromUtils.convertFileNameAnchorHTML(textToPost);
} else { } else {
textToPost = escapedFeedText; textToPost = escapedFeedText;
//System.out.println("textToPost=" + textToPost); //System.out.println("textToPost=" + textToPost);
@ -200,13 +371,36 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope(); vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope();
} }
Feed toShare = new Feed(UUID.randomUUID().toString(), feedType, username, feedDate, Feed toShare = null;
vreScope2Set, url, urlThumbnail, textToPost, pLevel, fullName, email, thumbnailURL, linkTitle, linkDesc, host); boolean result;
if(uploadedFiles.size() <= 1){
toShare = new Feed(
UUID.randomUUID().toString(), feedType, username, feedDate,
vreScope2Set, firstAttachmentDownloadUrl, firstAttachmenturlThumbnail,
textToPost, pLevel, fullName, email, thumbnailAvatarURL,
firstAttachmentName, firstAttachmentDescription, firstAttachmentFormat);
// save the feed itself
result = store.saveUserFeed(toShare);
}
else{
toShare = new Feed(
UUID.randomUUID().toString(), feedType, username, feedDate,
vreScope2Set, firstAttachmentDownloadUrl, firstAttachmenturlThumbnail,
textToPost, pLevel, fullName, email, thumbnailAvatarURL,
firstAttachmentName, firstAttachmentDescription, firstAttachmentFormat);
// set the field multiFileUpload to true
toShare.setMultiFileUpload(true);
// save the feed itself plus the attachments
result = store.saveUserFeed(toShare, attachments);
}
_log.info("Attempting to save Feed with text: " + textToPost + " Level: " + pLevel + " Timeline="+vreScope2Set); _log.info("Attempting to save Feed with text: " + textToPost + " Level: " + pLevel + " Timeline="+vreScope2Set);
boolean result = store.saveUserFeed(toShare);
//need to put the feed into VRES Timeline too //need to put the feed into VRES Timeline too
if (pLevel == PrivacyLevel.VRES) { if (pLevel == PrivacyLevel.VRES) {
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines"); _log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
@ -238,7 +432,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
//everything went fine //everything went fine
ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(), ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(),
TextTransfromUtils.replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailURL, toShare.getLinkTitle(), toShare.getLinkDescription(), TextTransfromUtils.replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailAvatarURL, toShare.getLinkTitle(), toShare.getLinkDescription(),
toShare.getUriThumbnail(), toShare.getLinkHost()); toShare.getUriThumbnail(), toShare.getLinkHost());
@ -260,17 +454,25 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
thread.start(); thread.start();
} }
//it means I also should upload a copy on the user's Workspace root folder //it means I also should upload a copy of the files on the user's Workspace root folder
if (fileName != null && filePathOnServer != null) { if (saveCopyWokspace) {
//The workspace uploader Thread starts here asyncronously
Thread thread = new Thread(new UploadToWorkspaceThread(fullName, username, fileName, filePathOnServer));
thread.start();
for(UploadedFile file: uploadedFiles){
new Thread(
new UploadToWorkspaceThread(
fullName,
username,
file.getFileName(),
file.getFileAbsolutePathOnServer()))
.start();
}
} }
return cf; return cf;
} }
@Override @Override
public UserSettings getUserSettings() { public UserSettings getUserSettings() {
try { try {
@ -335,14 +537,14 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
String httpURL = ""; String httpURL = "";
String smpURI = ""; String smpURI = "";
if (isWithinPortal()) { //if (isWithinPortal()) {
//get the url to show, before actually uploading it //get the url to show, before actually uploading it
smpURI = storageClient.getUrl(true).RFile(remoteFilePath); smpURI = "http://ciccio.com";//storageClient.getUrl(true).RFile(remoteFilePath);
//The storage uploader Thread starts here asyncronously //The storage uploader Thread starts here asyncronously
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath)); //Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath));
thread.start(); //thread.start();
} //}
try { try {
String mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName); String mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);
@ -571,10 +773,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
} }
/** /**
* Indicates whether the scope is the whole infrastructure. * Indicates whether the scope is the whole infrastructure.
* @return <code>true</code> if it is, <code>false</code> otherwise. * @return <code>true</code> if it is, <code>false</code> otherwise.
@ -688,8 +886,4 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
return portalUsers; return portalUsers;
} }
} }

View File

@ -5,17 +5,17 @@ import java.util.ArrayList;
@SuppressWarnings("serial") @SuppressWarnings("serial")
/** /**
* This class is used for link preview (both actual links and attachments) * This class is used for link preview (and when a file is attached)
* @author Costantino Perciante at ISTI-CNR * @author Costantino Perciante at ISTI-CNR
* *
*/ */
public class LinkPreview implements Serializable { public class LinkPreview implements Serializable {
private String title; private String title; //in case of a file, it is the name of the file itself
private String description; private String description;
private String url; private String url;
private String host; private String host;
private ArrayList<String> imageUrls; private ArrayList<String> imageUrls; // in case of a file, the first element is the image related to the format (pdf, jpg..)
public LinkPreview() { public LinkPreview() {

View File

@ -0,0 +1,107 @@
package org.gcube.portlets.user.shareupdates.shared;
import java.io.Serializable;
/**
* Information of an already uploaded file.
* @author Costantino Perciante at ISTI-CNR
*/
public class UploadedFile implements Serializable{
/**
* Generated UUID
*/
private static final long serialVersionUID = 1690771870370846188L;
// name of the file
private String fileName;
// path on the server of this file (tomcat tmp)
private String fileAbsolutePathOnServer;
// a description of the file (its content for a pdf, size for images)
private String description;
// when showing a file, this is the url that can be used for download
private String downloadUrl;
// thumbnail url related to the type of file (pdf, png, jpg)
private String thumbnailUrl;
// mime type (pdf, jpg ecc..)
private String format;
public UploadedFile() {
super();
}
public UploadedFile(String fileName, String fileAbsolutePathOnServer,
String description, String downloadUrl, String thumbnailUrl,
String mime) {
super();
this.fileName = fileName;
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
this.description = description;
this.downloadUrl = downloadUrl;
this.thumbnailUrl = thumbnailUrl;
this.format = mime;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileAbsolutePathOnServer() {
return fileAbsolutePathOnServer;
}
public void setFileAbsolutePathOnServer(String fileAbsolutePathOnServer) {
this.fileAbsolutePathOnServer = fileAbsolutePathOnServer;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public String getThumbnailUrl() {
return thumbnailUrl;
}
public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
}
public String getFormat() {
return format;
}
public void setMime(String format) {
this.format = format;
}
@Override
public String toString() {
return "UploadedFile [fileName=" + fileName
+ ", fileAbsolutePathOnServer=" + fileAbsolutePathOnServer
+ ", description=" + description + ", downloadUrl="
+ downloadUrl + ", thumbnailUrl=" + thumbnailUrl + ", format="
+ format + "]";
}
}