Working on Feature #9760: WS-Thredds synch folder integration

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@154676 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-09-28 09:59:49 +00:00
parent adcf5d9242
commit 992ae01887
6 changed files with 101 additions and 11 deletions

View File

@ -801,5 +801,12 @@ public interface GWTWorkspaceService extends RemoteService{
String folderToPublishId, String folderMetadataId, String vreScope,
String catalogueName)
throws Exception;
/**
* @param transferId
* @return
* @throws Exception
*/
TransferOnThreddsReport getStatusOfPublishingOnThreddsCatalogue(String transferId)
throws Exception;
}

View File

@ -800,5 +800,8 @@ public interface GWTWorkspaceServiceAsync {
String folderToPublishId, String folderMetadataId, String vreScope,
String catalogueName, AsyncCallback<TransferOnThreddsReport> callback);
void getStatusOfPublishingOnThreddsCatalogue(
String transferId, AsyncCallback<TransferOnThreddsReport> callback);
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
@ -26,6 +27,7 @@ import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.TextField;
@ -34,6 +36,7 @@ import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -130,6 +133,7 @@ public class DialogPublishOnThredds extends Dialog {
setButtons(Dialog.OKCANCEL);
this.getButtonById(Dialog.OK).setText("Publish");
this.getButtonById(Dialog.CANCEL).setText("Close");
// this.getButtonById(Dialog.CANCEL).setText("Reset");
txtCatalogueName = new TextField<String>();
txtCatalogueName.setEmptyText("Type a Name...");
@ -208,15 +212,15 @@ public class DialogPublishOnThredds extends Dialog {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
new MessageBoxAlert("Error", caught.getMessage(), null);
}
@Override
public void onSuccess(TransferOnThreddsReport result) {
GWT.log("Publishing on Thredds return: "+result);
if(result!=null){
//START TIMER...
pollingStart(result);
}
}
@ -239,6 +243,59 @@ public class DialogPublishOnThredds extends Dialog {
this.show();
}
public void showResult(TransferOnThreddsReport result){
if(result.isOnError()){
MessageBox.info("Error", result.getReportMessage(), null);
}
if(result.isTransferringReportAvailable()){
InfoDisplay.display("Transferring completed", "Refreshing folder content...");
FileModel folderTarget = new FileModel(result.getFolderId(), "", true);
AppControllerExplorer.getEventBus().fireEvent(new RefreshFolderEvent(folderTarget, false, false, true));
}
}
public void pollingStart(final TransferOnThreddsReport result){
showResult(result);
final Timer t = new Timer(){
public void run() {
AppControllerExplorer.rpcWorkspaceService.getStatusOfPublishingOnThreddsCatalogue(result.getTransferId(), new AsyncCallback<TransferOnThreddsReport>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert("Error", caught.getMessage(), null);
}
@Override
public void onSuccess(TransferOnThreddsReport result) {
GWT.log("Get status of Publishing on Thredds return: "+result);
showResult(result);
if(result.isOnError() || result.isTransferringReportAvailable()){
GWT.log("Cancelling timer for Transferring: "+result);
cancelTimer();
}
}
});
};
public void cancelTimer(){
this.cancel();
}
};
t.scheduleRepeating(2000);
}
/**
* Checks if is valid form.

View File

@ -4207,7 +4207,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
/**
* Publish on thredds catalogue.
*
@ -4216,6 +4215,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* @param vreScope the vre scope
* @param catalogueName the catalogue name
* @return the transfer on thredds report
* @throws Exception the exception
*/
@Override
public TransferOnThreddsReport publishOnThreddsCatalogue(String folderToPublishId, String folderMetadataId, String vreScope, String catalogueName) throws Exception{
@ -4230,7 +4230,30 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
return pub.publishFolder(folderToPublishId, folderMetadataId, userToken, catalogueName);
}catch(Exception e){
workspaceLogger.error("Error occurred server-side when transfer to Thredds: ", e);
throw new Exception("Sorry, an error occurred erver-side performing transfer to Thredds, try again later");
throw new Exception("Sorry, an error occurred server-side performing transfer to Thredds, try again later");
}
}
/**
* Gets the publishing on thredds catalogue.
*
* @param transferId the transfer id
* @return the publishing on thredds catalogue
* @throws Exception the exception
*/
@Override
public TransferOnThreddsReport getStatusOfPublishingOnThreddsCatalogue(String transferId) throws Exception{
workspaceLogger.debug("Getting publishing on thredds for transfer id: "+transferId);
TransferOnThreddsReport tr = null;
try{
tr = PublishOnThredds.getStatusOfTransferId(this.getThreadLocalRequest().getSession(), transferId);
return tr;
}catch(Exception e){
workspaceLogger.error("Error occurred server-side when getting the status of transferring on Thredds: ", e);
tr.setOnError(true);
WsUtil.setTransferPublishingOnThredds(this.getThreadLocalRequest().getSession(), tr);
throw new Exception("Sorry, an error occurred server-side getting the status of transferring on Thredds, try again later");
}
}

View File

@ -134,12 +134,12 @@ public class PublishOnThredds {
| InternalErrorException
| HomeNotFoundException
| UserNotFoundException e) {
logger.error("Error on getting workspace for thredds transfering to folder: "+folderId, e);
logger.error("Error on getting workspace for thredds transferring to folder: "+folderId, e);
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during getting workspace for user: "+e.getMessage(),false);
}
catch (FileNotFoundException | InsufficientPrivilegesException | ItemAlreadyExistException | WrongDestinationException e) {
// TODO Auto-generated catch block
logger.error("Error on writing report for thredds transfering to folder: "+folderId, e);
logger.error("Error on writing report for thredds transferring to folder: "+folderId, e);
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during report creation to transfer resulting: "+e.getMessage(),false);
}
}

View File

@ -61,11 +61,11 @@ public class TransferOnThreddsReport implements Serializable, IsSerializable{
/**
* Gets the report created on workspace.
* Checks if is transferring report available.
*
* @return the reportCreatedOnWorkspace
* @return the boolean
*/
public Boolean getReportCreatedOnWorkspace() {
public Boolean isTransferringReportAvailable() {
return reportCreatedOnWorkspace;
}
@ -98,7 +98,7 @@ public class TransferOnThreddsReport implements Serializable, IsSerializable{
*
* @return the onError
*/
public Boolean getOnError() {
public Boolean isOnError() {
return onError;
}