added getHeaders iterator
This commit is contained in:
parent
19ae7f2f66
commit
284f2e5dca
|
@ -43,21 +43,17 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
private String idFolder;
|
||||
private UPLOAD_TYPE type;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new multiple dilaog upload stream.
|
||||
*
|
||||
* @param headerTitle
|
||||
* the header title
|
||||
* @param parentId
|
||||
* the parent id
|
||||
* @param uploadType
|
||||
* the upload type
|
||||
* @param headerTitle the header title
|
||||
* @param parentId the parent id
|
||||
* @param uploadType the upload type
|
||||
*/
|
||||
public MultipleDilaogUpload(String headerTitle, String parentId, UPLOAD_TYPE uploadType) {
|
||||
super(headerTitle, parentId, uploadType);
|
||||
|
||||
this.type =uploadType;
|
||||
this.type = uploadType;
|
||||
this.idFolder = parentId;
|
||||
|
||||
fileUploadID = GenerateUUID.get(10, 16); // is tagID
|
||||
|
@ -65,7 +61,9 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
this.addHandlers();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.user.client.ui.DialogBox#show()
|
||||
*/
|
||||
@Override
|
||||
|
@ -73,7 +71,9 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
super.show();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.user.client.ui.PopupPanel#center()
|
||||
*/
|
||||
@Override
|
||||
|
@ -84,13 +84,13 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
/**
|
||||
* Generate new upload client keys.
|
||||
*
|
||||
* @param files the files
|
||||
* @param parentId the parent id
|
||||
* @param files the files
|
||||
* @param parentId the parent id
|
||||
* @return the list
|
||||
*/
|
||||
public void generateFakeUploaders(String filesSelected, String parentId) {
|
||||
|
||||
if(filesSelected==null || filesSelected.isEmpty())
|
||||
if (filesSelected == null || filesSelected.isEmpty())
|
||||
return;
|
||||
|
||||
String[] files = filesSelected.split(FILE_DELEMITER);
|
||||
|
@ -99,11 +99,12 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
for (int i = 0; i < files.length; i++) {
|
||||
String normalizedFileName = files[i];
|
||||
if (normalizedFileName.contains("\\")) {
|
||||
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath if exists
|
||||
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath
|
||||
// if exists
|
||||
}
|
||||
}
|
||||
|
||||
GWT.log("generating fake uploaders on: "+Arrays.asList(files.toString()));
|
||||
GWT.log("generating fake uploaders on: " + Arrays.asList(files.toString()));
|
||||
fakeUploaders = new ArrayList<WorkspaceUploaderItem>(files.length);
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
WorkspaceUploaderItem fakeItem = new WorkspaceUploaderItem();
|
||||
|
@ -116,7 +117,7 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
fakeUploaders.add(fakeItem);
|
||||
}
|
||||
|
||||
GWT.log("fakeUploaders generated: "+fakeUploaders.toString());
|
||||
GWT.log("fakeUploaders generated: " + fakeUploaders.toString());
|
||||
// return fakeUploaders;
|
||||
}
|
||||
|
||||
|
@ -141,13 +142,11 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
|
||||
if (result == null) {
|
||||
removeLoading();
|
||||
new DialogResult(null, "Error during upload",
|
||||
"An error occurred during file upload.").center();
|
||||
new DialogResult(null, "Error during upload", "An error occurred during file upload.").center();
|
||||
return;
|
||||
}
|
||||
String strippedResult = new HTML(result).getText();
|
||||
final HandlerResultMessage resultMessage = HandlerResultMessage
|
||||
.parseResult(strippedResult);
|
||||
final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult);
|
||||
|
||||
switch (resultMessage.getStatus()) {
|
||||
case ERROR:
|
||||
|
@ -159,12 +158,12 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
GWT.log("Error during upload " + resultMessage.getMessage());
|
||||
break;
|
||||
case WARN: {
|
||||
GWT.log("Upload completed with warnings "+ resultMessage.getMessage());
|
||||
GWT.log("Upload completed with warnings " + resultMessage.getMessage());
|
||||
removeLoading();
|
||||
break;
|
||||
}
|
||||
case SESSION_EXPIRED:{
|
||||
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
||||
case SESSION_EXPIRED: {
|
||||
GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage());
|
||||
Window.alert("Session expired, please reload the page");
|
||||
removeLoading();
|
||||
break;
|
||||
|
@ -193,20 +192,19 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
GWT.log("browse return...");
|
||||
if (fileUpload.getFilename() == null
|
||||
|| fileUpload.getFilename().isEmpty()) {
|
||||
if (fileUpload.getFilename() == null || fileUpload.getFilename().isEmpty()) {
|
||||
GWT.log("No file specified ");
|
||||
MultipleDilaogUpload.this.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
String[] files = null;
|
||||
GWT.log("Current Uploader has id: "+fileUploadID);
|
||||
GWT.log("Current Uploader has id: " + fileUploadID);
|
||||
String filesSelected = getFilesSelected(fileUploadID, FILE_DELEMITER);
|
||||
GWT.log("getFilesSelected: " + filesSelected);
|
||||
files = filesSelected.split(FILE_DELEMITER);
|
||||
|
||||
if(isLimitExceeded(files.length))
|
||||
if (isLimitExceeded(files.length))
|
||||
return;
|
||||
|
||||
// GENERATE NEW UPLOADERS
|
||||
|
@ -223,67 +221,23 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
// ADD TO FORM PANEL
|
||||
// initJsonClientKeys();
|
||||
jsonClientKeys.setValue(jsonKeys);
|
||||
|
||||
// // CASE 1 FILE
|
||||
// if (files.length == 1) {
|
||||
//
|
||||
// // recall: Some browser would write in
|
||||
// // fileUploadField.getValue() C:\fakepath\$fileName
|
||||
// final String label = files[0];
|
||||
// WorkspaceUploaderServiceAsync.Util.getInstance()
|
||||
// .itemExistsInWorkpaceFolder(parentIdentifier,
|
||||
// label, new AsyncCallback<String>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(
|
||||
// final String itemId) {
|
||||
// GWT.log("itemExistsInWorkpaceFolder: "
|
||||
// + itemId);
|
||||
// if (itemId != null) {
|
||||
// removeItemAndSubmitForm(itemId);
|
||||
// updateItemSubmitForm(itemId);
|
||||
//// if (Window.confirm(label+ " exists in folder. If you continue, a new version will be created")) {
|
||||
//// removeItemAndSubmitForm(itemId);
|
||||
//// updateItemSubmitForm(itemId);
|
||||
//// }
|
||||
// } else
|
||||
// submitForm(); // ITEM does NOT
|
||||
// // EXIST SO
|
||||
// // SUBMIT FORM;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// GWT.log("Sorry an error occurred on the server "
|
||||
// + caught.getLocalizedMessage()
|
||||
// + ". Please try again later");
|
||||
// Window.alert(caught.getMessage());
|
||||
// }
|
||||
//
|
||||
// });
|
||||
// } else
|
||||
submitForm();
|
||||
submitForm();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is limit exceeded.
|
||||
*
|
||||
* @param numbOfFiles the numb of files
|
||||
* @return true, if is limit exceeded
|
||||
*/
|
||||
public boolean isLimitExceeded(int numbOfFiles){
|
||||
public boolean isLimitExceeded(int numbOfFiles) {
|
||||
|
||||
if (numbOfFiles > ConstantsWorkspaceUploader.LIMIT_UPLOADS) {
|
||||
Window.alert("Multiple upload limit is "
|
||||
+ ConstantsWorkspaceUploader.LIMIT_UPLOADS
|
||||
+ " files");
|
||||
Window.alert("Multiple upload limit is " + ConstantsWorkspaceUploader.LIMIT_UPLOADS + " files");
|
||||
MultipleDilaogUpload.this.hide();
|
||||
return true;
|
||||
}
|
||||
|
@ -294,11 +248,12 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
/**
|
||||
* Adds the new submit to monitor.
|
||||
*/
|
||||
public void addNewSubmitToMonitor(){
|
||||
public void addNewSubmitToMonitor() {
|
||||
GWT.log("addNewSubmitToMonitor...");
|
||||
int queueIndex = UploaderMonitor.getInstance().newQueue();
|
||||
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
|
||||
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName());
|
||||
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem,
|
||||
workspaceUploaderItem.getFile().getFileName());
|
||||
setVisible(false);
|
||||
removeLoading();
|
||||
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
|
||||
|
@ -308,7 +263,6 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the json key for files.
|
||||
*
|
||||
|
@ -330,7 +284,7 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
}
|
||||
|
||||
jsonKeys = productObj.toString();
|
||||
GWT.log("updated jsonKeys: "+jsonKeys);
|
||||
GWT.log("updated jsonKeys: " + jsonKeys);
|
||||
} catch (Exception e) {
|
||||
GWT.log("error " + e.getMessage());
|
||||
jsonKeys = null;
|
||||
|
@ -394,10 +348,8 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
/**
|
||||
* Gets the files selected.
|
||||
*
|
||||
* @param tagId
|
||||
* the tag id
|
||||
* @param fileDelimiter
|
||||
* the file delimiter
|
||||
* @param tagId the tag id
|
||||
* @param fileDelimiter the file delimiter
|
||||
* @return the files selected
|
||||
*/
|
||||
public static native String getFilesSelected(final String tagId, final String fileDelimiter) /*-{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue