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:
parent
636c42d7aa
commit
e4f5ed7702
|
@ -40,5 +40,4 @@ public class Placeholder extends FlowPanel {
|
||||||
add((Widget)atPrev);
|
add((Widget)atPrev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,7 @@ public class ShareUpdateForm extends Composite {
|
||||||
up.setVisible(false);
|
up.setVisible(false);
|
||||||
fileBrowse(up.getElement());
|
fileBrowse(up.getElement());
|
||||||
uploadProgress.setVisible(true);
|
uploadProgress.setVisible(true);
|
||||||
|
attachButton.setEnabled(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,6 +499,8 @@ public class ShareUpdateForm extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ClientFeed feed) {
|
public void onSuccess(ClientFeed feed) {
|
||||||
|
|
||||||
|
//GWT.log("Saved feed looks like " + feed.toString());
|
||||||
|
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
shareTextArea.setEnabled(true);
|
shareTextArea.setEnabled(true);
|
||||||
shareTextArea.setText(SHARE_UPDATE_TEXT);
|
shareTextArea.setText(SHARE_UPDATE_TEXT);
|
||||||
|
@ -668,6 +671,9 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
// enable anyway the button
|
// enable anyway the button
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
|
|
||||||
|
// enable attach button
|
||||||
|
attachButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// it returns a LinkPreview (for compatibility with old code)
|
// it returns a LinkPreview (for compatibility with old code)
|
||||||
|
@ -690,6 +696,9 @@ public class ShareUpdateForm extends Composite {
|
||||||
|
|
||||||
addPreviewAttachment(result, atPrev);
|
addPreviewAttachment(result, atPrev);
|
||||||
submitButton.setEnabled(true);
|
submitButton.setEnabled(true);
|
||||||
|
|
||||||
|
// enable attach button
|
||||||
|
attachButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,7 +323,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
firstAttachmentDescription = "",
|
firstAttachmentDescription = "",
|
||||||
firstAttachmentFormat = "",
|
firstAttachmentFormat = "",
|
||||||
firstAttachmentDownloadUrl = "",
|
firstAttachmentDownloadUrl = "",
|
||||||
firstAttachmenturlThumbnail = "null";
|
firstAttachmenturlThumbnail = "";
|
||||||
|
|
||||||
if(uploadedFiles.size() > 0){
|
if(uploadedFiles.size() > 0){
|
||||||
|
|
||||||
|
@ -343,6 +343,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
|
|
||||||
attachments = new ArrayList<>();
|
attachments = new ArrayList<>();
|
||||||
|
|
||||||
|
// starting from 1
|
||||||
for (int i = 1; i < uploadedFiles.size(); i++){
|
for (int i = 1; i < uploadedFiles.size(); i++){
|
||||||
UploadedFile file = uploadedFiles.get(i);
|
UploadedFile file = uploadedFiles.get(i);
|
||||||
|
|
||||||
|
@ -351,7 +352,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
file.getDownloadUrl(),
|
file.getDownloadUrl(),
|
||||||
file.getFileName(),
|
file.getFileName(),
|
||||||
file.getDescription(),
|
file.getDescription(),
|
||||||
file.getThumbnailUrl() == null ? "null" : file.getThumbnailUrl(),
|
file.getThumbnailUrl(),
|
||||||
file.getFormat())
|
file.getFormat())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -542,20 +543,25 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
||||||
|
|
||||||
String httpURL = "";
|
String httpURL = "";
|
||||||
String smpURI = "";
|
String smpURI = "";
|
||||||
|
String mimeType = null;
|
||||||
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); //"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
|
//The storage uploader Thread starts here asyncronouslyù
|
||||||
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath));
|
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();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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)
|
//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) {
|
switch (mimeType) {
|
||||||
case "application/pdf":
|
case "application/pdf":
|
||||||
|
|
|
@ -26,22 +26,27 @@ public class UploadToStorageThread implements Runnable {
|
||||||
private String fileabsolutePathOnServer;
|
private String fileabsolutePathOnServer;
|
||||||
|
|
||||||
private IClient sClient;
|
private IClient sClient;
|
||||||
|
|
||||||
|
// type of file
|
||||||
|
private String mimeType;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param sClient the instance of the storage client
|
* @param sClient the instance of the storage client
|
||||||
|
* @param mimeType
|
||||||
* @param fileToUpload the absolute path of the file
|
* @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();
|
super();
|
||||||
this.sClient = sClient;
|
this.sClient = sClient;
|
||||||
this.remoteFilePath = remoteFilePath;
|
this.remoteFilePath = remoteFilePath;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.fileabsolutePathOnServer = fileabsolutePathOnServer;
|
this.fileabsolutePathOnServer = fileabsolutePathOnServer;
|
||||||
|
this.mimeType = mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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);
|
_log.debug("Uploaded " + fileName + " - Returned Storage id=" + theID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue