Storage upload calls changed

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122384 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-20 16:54:20 +00:00
parent 636c42d7aa
commit e4f5ed7702
4 changed files with 32 additions and 13 deletions

View File

@ -40,5 +40,4 @@ public class Placeholder extends FlowPanel {
add((Widget)atPrev);
}
}
}

View File

@ -315,6 +315,7 @@ public class ShareUpdateForm extends Composite {
up.setVisible(false);
fileBrowse(up.getElement());
uploadProgress.setVisible(true);
attachButton.setEnabled(false);
}
@ -497,6 +498,8 @@ public class ShareUpdateForm extends Composite {
@Override
public void onSuccess(ClientFeed feed) {
//GWT.log("Saved feed looks like " + feed.toString());
submitButton.setEnabled(true);
shareTextArea.setEnabled(true);
@ -668,6 +671,9 @@ public class ShareUpdateForm extends Composite {
// enable anyway the button
submitButton.setEnabled(true);
// enable attach button
attachButton.setEnabled(true);
}
// it returns a LinkPreview (for compatibility with old code)
@ -690,6 +696,9 @@ public class ShareUpdateForm extends Composite {
addPreviewAttachment(result, atPrev);
submitButton.setEnabled(true);
// enable attach button
attachButton.setEnabled(true);
}
});
}

View File

@ -323,7 +323,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
firstAttachmentDescription = "",
firstAttachmentFormat = "",
firstAttachmentDownloadUrl = "",
firstAttachmenturlThumbnail = "null";
firstAttachmenturlThumbnail = "";
if(uploadedFiles.size() > 0){
@ -343,17 +343,18 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
attachments = new ArrayList<>();
// starting from 1
for (int i = 1; i < uploadedFiles.size(); i++){
UploadedFile file = uploadedFiles.get(i);
attachments.add(new Attachment(
UUID.randomUUID().toString(),
file.getDownloadUrl(),
file.getFileName(),
file.getDescription(),
file.getThumbnailUrl() == null ? "null" : file.getThumbnailUrl(),
file.getThumbnailUrl(),
file.getFormat())
);
);
}
}
@ -542,20 +543,25 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
String httpURL = "";
String smpURI = "";
String mimeType = null;
if (isWithinPortal()) {
//get the url to show, before actually uploading it
smpURI = storageClient.getUrl(true).RFile(remoteFilePath); //"http://ciccio.com";
//smpURI = storageClient.getUrl(true).RFile(remoteFilePath); //"http://ciccio.com";
smpURI = storageClient.getHttpUrl(true).RFile(remoteFilePath);
//The storage uploader Thread starts here asyncronously
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath));
//The storage uploader Thread starts here asyncronouslyù
try {
mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);
} catch (IOException e) {
e.printStackTrace();
}
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath, mimeType));
thread.start();
}
try {
String mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);
UriResolverReaderParameter resolver = new UriResolverReaderParameter();
//get the url to show (though it could not be ready for download at this stage)
httpURL = resolver.resolveAsUriRequest(smpURI, fileName, mimeType, true);
httpURL = smpURI;
switch (mimeType) {
case "application/pdf":

View File

@ -26,22 +26,27 @@ public class UploadToStorageThread implements Runnable {
private String fileabsolutePathOnServer;
private IClient sClient;
// type of file
private String mimeType;
/**
*
* @param sClient the instance of the storage client
* @param mimeType
* @param fileToUpload the absolute path of the file
*/
public UploadToStorageThread(IClient sClient, String fileName, String fileabsolutePathOnServer, String remoteFilePath) {
public UploadToStorageThread(IClient sClient, String fileName, String fileabsolutePathOnServer, String remoteFilePath, String mimeType) {
super();
this.sClient = sClient;
this.remoteFilePath = remoteFilePath;
this.fileName = fileName;
this.fileabsolutePathOnServer = fileabsolutePathOnServer;
this.mimeType = mimeType;
}
@Override
public void run() {
String theID = sClient.put(true).LFile(fileabsolutePathOnServer).RFile(remoteFilePath);
String theID = sClient.put(true, mimeType).LFile(fileabsolutePathOnServer).RFile(remoteFilePath);
_log.debug("Uploaded " + fileName + " - Returned Storage id=" + theID);
}