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@154668 82a268e6-3cf1-43bd-a215-b396298e98cftask/19600
parent
f6bc27788d
commit
adcf5d9242
@ -0,0 +1,55 @@
|
||||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
/**
|
||||
* The Class PublishOnThreddsCatalogueEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class PublishOnThreddsCatalogueEvent extends GwtEvent<PublishOnThreddsCatalogueEventHandler> {
|
||||
public static Type<PublishOnThreddsCatalogueEventHandler> TYPE = new Type<PublishOnThreddsCatalogueEventHandler>();
|
||||
|
||||
private FileModel folderToPublish;
|
||||
|
||||
/**
|
||||
* Instantiates a new publish on thredds catalogue event.
|
||||
*
|
||||
* @param folderToPublish the folder to publish
|
||||
*/
|
||||
public PublishOnThreddsCatalogueEvent(FileModel folderToPublish) {
|
||||
this.folderToPublish = folderToPublish;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the folderToPublish
|
||||
*/
|
||||
public FileModel getFolderToPublish() {
|
||||
|
||||
return folderToPublish;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<PublishOnThreddsCatalogueEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(PublishOnThreddsCatalogueEventHandler handler) {
|
||||
handler.onPublish(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface PublishOnThreddsCatalogueEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public interface PublishOnThreddsCatalogueEventHandler extends EventHandler {
|
||||
|
||||
|
||||
/**
|
||||
* On publish.
|
||||
*
|
||||
* @param loadSelecteReleaseEvent the load selecte release event
|
||||
*/
|
||||
void onPublish(PublishOnThreddsCatalogueEvent loadSelecteReleaseEvent);
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.client.model;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class GcubeVRE extends BaseModelData implements IsSerializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4852709833439398009L;
|
||||
private String vreName;
|
||||
private String vreScope;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected GcubeVRE() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vreName
|
||||
* @param vreScope
|
||||
*/
|
||||
public GcubeVRE(String vreName, String vreScope) {
|
||||
|
||||
super();
|
||||
this.vreName = vreName;
|
||||
setName(vreName);
|
||||
this.vreScope = vreScope;
|
||||
setScope(vreScope);
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return get("scope");
|
||||
}
|
||||
|
||||
public void setScope(String id) {
|
||||
set("scope", id);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return get("name");
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
set("name", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vreName
|
||||
*/
|
||||
public String getVreName() {
|
||||
|
||||
return vreName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the vreScope
|
||||
*/
|
||||
public String getVreScope() {
|
||||
|
||||
return vreScope;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param vreName the vreName to set
|
||||
*/
|
||||
public void setVreName(String vreName) {
|
||||
|
||||
this.vreName = vreName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param vreScope the vreScope to set
|
||||
*/
|
||||
public void setVreScope(String vreScope) {
|
||||
|
||||
this.vreScope = vreScope;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GcubeVRE [vreName=");
|
||||
builder.append(vreName);
|
||||
builder.append(", vreScope=");
|
||||
builder.append(vreScope);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 749 B |
@ -0,0 +1,294 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
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.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||
import com.extjs.gxt.ui.client.event.BaseEvent;
|
||||
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
||||
import com.extjs.gxt.ui.client.event.Events;
|
||||
import com.extjs.gxt.ui.client.event.KeyListener;
|
||||
import com.extjs.gxt.ui.client.event.KeyboardEvents;
|
||||
import com.extjs.gxt.ui.client.event.Listener;
|
||||
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.form.ComboBox;
|
||||
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.form.TriggerField;
|
||||
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.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
* The Class DialogPublishOnThredds.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class DialogPublishOnThredds extends Dialog {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int widthDialog = 500;
|
||||
private TextField<String> txtCatalogueName;
|
||||
private TriggerField<String> triggerFieldMetadataFolderName;
|
||||
private ComboBox<GcubeVRE> selectVRE;
|
||||
//private Button browse = new Button("Browse...");
|
||||
private FileModel metadataFolder = null;
|
||||
private FileModel theFolderToPublish;
|
||||
private ListStore<GcubeVRE> vreStore = new ListStore<GcubeVRE>();
|
||||
|
||||
public static List<GcubeVRE> listOfVres = null;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog publish on thredds.
|
||||
*
|
||||
* @param theFolderToPublish the the folder to publish
|
||||
*/
|
||||
public DialogPublishOnThredds(FileModel theFolderToPublish) {
|
||||
|
||||
this.theFolderToPublish = theFolderToPublish;
|
||||
initLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load vres for logged user.
|
||||
*/
|
||||
private void loadVresForLoggedUser() {
|
||||
|
||||
selectVRE.mask();
|
||||
selectVRE.setLoadingText("Loading VREs...");
|
||||
getButtonById(Dialog.OK).setEnabled(false);
|
||||
AppControllerExplorer.rpcWorkspaceService.getListOfVREsForLoggedUser(new AsyncCallback<List<GcubeVRE>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GcubeVRE> result) {
|
||||
|
||||
listOfVres = result;
|
||||
setStoreToSelectVre();
|
||||
getButtonById(Dialog.OK).setEnabled(true);
|
||||
selectVRE.unmask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
GWT.log("Error on getting VREs");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the store to select vre.
|
||||
*/
|
||||
private void setStoreToSelectVre() {
|
||||
vreStore.removeAll();
|
||||
vreStore.add(listOfVres);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog add folder and smart.
|
||||
*/
|
||||
private void initLayout() {
|
||||
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(120);
|
||||
layout.setDefaultWidth(350);
|
||||
setLayout(layout);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
// setHideOnButtonClick(true);
|
||||
// setIcon(IconHelper.createStyle("user"));
|
||||
setHeading("Publish "+Format.ellipse(theFolderToPublish.getName(), 20)+" on Thredds...");
|
||||
setModal(true);
|
||||
// setBodyBorder(true);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
|
||||
this.getButtonById(Dialog.OK).setText("Publish");
|
||||
// this.getButtonById(Dialog.CANCEL).setText("Reset");
|
||||
txtCatalogueName = new TextField<String>();
|
||||
txtCatalogueName.setEmptyText("Type a Name...");
|
||||
txtCatalogueName.setAllowBlank(false);
|
||||
txtCatalogueName.setAutoValidate(true);
|
||||
txtCatalogueName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
|
||||
txtCatalogueName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
|
||||
txtCatalogueName.setFieldLabel("Catalogue Name *");
|
||||
|
||||
|
||||
triggerFieldMetadataFolderName = new TriggerField<String>();
|
||||
triggerFieldMetadataFolderName.setAllowBlank(true);
|
||||
triggerFieldMetadataFolderName.setReadOnly(true);
|
||||
triggerFieldMetadataFolderName.setAutoValidate(true);
|
||||
triggerFieldMetadataFolderName.setFieldLabel("Metadata Folder");
|
||||
triggerFieldMetadataFolderName.setEmptyText("Browse a Metadata Folder...");
|
||||
triggerFieldMetadataFolderName.addListener(Events.OnClick, new Listener<BaseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(BaseEvent be) {
|
||||
|
||||
showWsExplorer();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
selectVRE = new ComboBox<GcubeVRE>();
|
||||
selectVRE.setEmptyText("Select a VRE...");
|
||||
selectVRE.setFieldLabel("Publish in the VRE *");
|
||||
selectVRE.setDisplayField("name");
|
||||
selectVRE.setStore(vreStore);
|
||||
if(listOfVres==null || listOfVres.isEmpty())
|
||||
loadVresForLoggedUser();
|
||||
else
|
||||
setStoreToSelectVre();
|
||||
//selectVRE.setStore(scopeNameModels);
|
||||
selectVRE.setTypeAhead(true);
|
||||
selectVRE.setEditable(false);
|
||||
selectVRE.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
txtCatalogueName.addKeyListener(new KeyListener() { // KEY ENTER
|
||||
|
||||
public void componentKeyPress(ComponentEvent event) {
|
||||
|
||||
if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
|
||||
getButtonById(Dialog.OK).fireEvent(Events.Select);
|
||||
}
|
||||
});
|
||||
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if (isValidForm()){
|
||||
hide();
|
||||
|
||||
String metadataFolderId = metadataFolder!=null?metadataFolder.getIdentifier():null;
|
||||
|
||||
GcubeVRE vre = selectVRE.getSelection().get(0);
|
||||
|
||||
AppControllerExplorer.rpcWorkspaceService.publishOnThreddsCatalogue(theFolderToPublish.getIdentifier(), metadataFolderId, vre.getScope(), txtCatalogueName.getValue(), new AsyncCallback<TransferOnThreddsReport>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TransferOnThreddsReport result) {
|
||||
|
||||
if(result!=null){
|
||||
//START TIMER...
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setFocusWidget(txtCatalogueName);
|
||||
add(txtCatalogueName);
|
||||
add(selectVRE);
|
||||
//add(browse);
|
||||
add(triggerFieldMetadataFolderName);
|
||||
Label mandatory = new Label("* mandatory");
|
||||
mandatory.setType(LabelType.INFO);
|
||||
//mandatory.getElement().getStyle().set("#FF0000");
|
||||
add(mandatory);
|
||||
//add(hp);
|
||||
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is valid form.
|
||||
*
|
||||
* @return true, if is valid form
|
||||
*/
|
||||
public boolean isValidForm() {
|
||||
|
||||
if (txtCatalogueName.isValid() && txtCatalogueName.getValue() != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show ws explorer.
|
||||
*/
|
||||
public void showWsExplorer(){
|
||||
|
||||
final WorkspaceExplorerSelectDialog navigator = new WorkspaceExplorerSelectDialog("Select a folder...", true);
|
||||
|
||||
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
|
||||
|
||||
@Override
|
||||
public void onSelectedItem(Item item) {
|
||||
GWT.log("onSelectedItem: "+item);
|
||||
navigator.hide();
|
||||
triggerFieldMetadataFolderName.setValue(item.getName());
|
||||
metadataFolder = new FileModel(item.getId(), item.getName(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(Throwable throwable) {
|
||||
GWT.log("onFailed..");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAborted() {
|
||||
GWT.log("onAborted..");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotValidSelection() {
|
||||
GWT.log("onNotValidSelection..");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
navigator.addWorkspaceExplorerSelectNotificationListener(listener);
|
||||
navigator.show();
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.publish;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.UserNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
|
||||
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.usecases.ws.thredds.FolderConfiguration;
|
||||
import org.gcube.usecases.ws.thredds.PublishFolders;
|
||||
import org.gcube.usecases.ws.thredds.TokenSetter;
|
||||
import org.gcube.usecases.ws.thredds.engine.TransferRequestServer;
|
||||
import org.gcube.usecases.ws.thredds.engine.TransferRequestServer.Report;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class PublishOnThredds.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class PublishOnThredds {
|
||||
|
||||
private HashSet<FolderConfiguration> configs;
|
||||
private Logger logger = LoggerFactory.getLogger(ApplicationProfileReader.class);
|
||||
private String username;
|
||||
private HttpSession httpSession;
|
||||
|
||||
/**
|
||||
* Instantiates a new publish on thredds.
|
||||
*
|
||||
* @param publishingScope the publishing scope
|
||||
* @param username the username
|
||||
* @param httpSession the http session
|
||||
*/
|
||||
public PublishOnThredds(String publishingScope, String username, HttpSession httpSession) {
|
||||
TokenSetter.set(publishingScope);
|
||||
this.configs = new HashSet<FolderConfiguration>();
|
||||
this.username = username;
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Publish folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param metadataFolderID the metadata folder id
|
||||
* @param publishingUserToken the publishing user token
|
||||
* @param catalogueName the catalogue name
|
||||
* @return the transfer on thredds report
|
||||
*/
|
||||
public TransferOnThreddsReport publishFolder(final String folderId, final String metadataFolderID, final String publishingUserToken, final String catalogueName){
|
||||
|
||||
final String transferId = UUID.randomUUID().toString();
|
||||
final TransferOnThreddsReport tr = new TransferOnThreddsReport(transferId, folderId, false, null);
|
||||
|
||||
new Thread(){
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Thread#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
WsUtil.setTransferPublishingOnThredds(httpSession, tr);
|
||||
|
||||
FolderConfiguration folderConfig=new FolderConfiguration(publishingUserToken,folderId,catalogueName);
|
||||
folderConfig.setProvidedMetadata(false);
|
||||
|
||||
if(metadataFolderID!=null){
|
||||
folderConfig.setProvidedMetadata(true);
|
||||
folderConfig.setMetadataFolderId(metadataFolderID);
|
||||
}
|
||||
configs.add(folderConfig);
|
||||
TransferRequestServer server=new TransferRequestServer();
|
||||
for(FolderConfiguration entry:configs){
|
||||
|
||||
try{
|
||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(username).getWorkspace();
|
||||
// FolderReport report=new FolderReport(entry);
|
||||
logger.debug("Managing {} ",entry);
|
||||
WorkspaceFolder folder = (WorkspaceFolder) ws.getItem(entry.getFolderId());
|
||||
PublishFolders.handleFolder(ws,entry,server,folder);
|
||||
|
||||
|
||||
}catch(WorkspaceException | HomeNotFoundException | InternalErrorException | UserNotFoundException e){
|
||||
System.err.println("WORKSPACE EXC ");
|
||||
logger.error("WORKSPACE EXC ", e);
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during getting workspace for user: "+e.getMessage(), false);
|
||||
}catch(Exception e){
|
||||
System.err.println("UNEXPECTED EXC");
|
||||
logger.error("UNEXPECTED EXC ", e);
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an unexpected error has occurred during getting workspace for user", false);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Waiting for service.. ");
|
||||
server.waitCompletion();
|
||||
|
||||
Report report = server.getReport();
|
||||
File reportFile = report.toFile(folderConfig);
|
||||
if(reportFile!=null){
|
||||
Workspace workspace;
|
||||
try {
|
||||
workspace = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome(username).getWorkspace();
|
||||
InputStream fileData = new FileInputStream(reportFile);
|
||||
workspace.createExternalFile("Publishing on thredds report file", "", "text/plain", fileData, folderId);
|
||||
setStatusOnTransferId(transferId, false, "Sorry, an unexpected error has occurred during getting workspace for user",true);
|
||||
|
||||
}
|
||||
catch (WorkspaceFolderNotFoundException
|
||||
| InternalErrorException
|
||||
| HomeNotFoundException
|
||||
| UserNotFoundException e) {
|
||||
logger.error("Error on getting workspace for thredds transfering 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);
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during report creation to transfer resulting: "+e.getMessage(),false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
return tr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the status of transfer id.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @param transferId the transfer id
|
||||
* @return the status of transfer id
|
||||
*/
|
||||
public static TransferOnThreddsReport getStatusOfTransferId(HttpSession httpSession, String transferId){
|
||||
return WsUtil.geTransferPublishingOnThreddsForId(httpSession, transferId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the error on transfer id.
|
||||
*
|
||||
* @param transferId the new error on transfer id
|
||||
* @param error the error
|
||||
* @param reportMessage the report message
|
||||
* @param reportCreated the report created
|
||||
*/
|
||||
public void setStatusOnTransferId(String transferId, Boolean error, String reportMessage, Boolean reportCreated){
|
||||
TransferOnThreddsReport tr = WsUtil.geTransferPublishingOnThreddsForId(httpSession, transferId);
|
||||
|
||||
if(tr!=null){
|
||||
tr.setOnError(error);
|
||||
tr.setReportMessage(reportMessage);
|
||||
tr.setReportCreatedOnWorkspace(reportCreated);
|
||||
WsUtil.setTransferPublishingOnThredds(httpSession, tr);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class TransferOnThreddsReport.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class TransferOnThreddsReport implements Serializable, IsSerializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8593731354178551332L;
|
||||
private String transferId;
|
||||
private String folderId;
|
||||
private Boolean onError = false;
|
||||
private String reportMessage = null;
|
||||
private Boolean reportCreatedOnWorkspace = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new transfer on thredds report.
|
||||
*/
|
||||
public TransferOnThreddsReport() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new transfer on thredds report.
|
||||
*
|
||||
* @param transferId the transfer id
|
||||
* @param folderId the folder id
|
||||
* @param onError the on error
|
||||
* @param reportMessage the report message
|
||||
*/
|
||||
public TransferOnThreddsReport(String transferId, String folderId, Boolean onError, String reportMessage) {
|
||||
|
||||
this.transferId = transferId;
|
||||
this.folderId = folderId;
|
||||
this.onError = onError;
|
||||
this.reportMessage = reportMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the report created on workspace.
|
||||
*
|
||||
* @param reportCreatedOnWorkspace the reportCreated to set
|
||||
*/
|
||||
public void setReportCreatedOnWorkspace(Boolean reportCreatedOnWorkspace) {
|
||||
|
||||
this.reportCreatedOnWorkspace = reportCreatedOnWorkspace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the report created on workspace.
|
||||
*
|
||||
* @return the reportCreatedOnWorkspace
|
||||
*/
|
||||
public Boolean getReportCreatedOnWorkspace() {
|
||||
|
||||
return reportCreatedOnWorkspace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the transfer id.
|
||||
*
|
||||
* @return the transferId
|
||||
*/
|
||||
public String getTransferId() {
|
||||
|
||||
return transferId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the folder id.
|
||||
*
|
||||
* @return the folderId
|
||||
*/
|
||||
public String getFolderId() {
|
||||
|
||||
return folderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the on error.
|
||||
*
|
||||
* @return the onError
|
||||
*/
|
||||
public Boolean getOnError() {
|
||||
|
||||
return onError;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the transfer id.
|
||||
*
|
||||
* @param transferId the transferId to set
|
||||
*/
|
||||
public void setTransferId(String transferId) {
|
||||
|
||||
this.transferId = transferId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the folder id.
|
||||
*
|
||||
* @param folderId the folderId to set
|
||||
*/
|
||||
public void setFolderId(String folderId) {
|
||||
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the on error.
|
||||
*
|
||||
* @param onError the onError to set
|
||||
*/
|
||||
public void setOnError(Boolean onError) {
|
||||
|
||||
this.onError = onError;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the report message.
|
||||
*
|
||||
* @return the reportMessage
|
||||
*/
|
||||
public String getReportMessage() {
|
||||
|
||||
return reportMessage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the report message.
|
||||
*
|
||||
* @param reportMessage the reportMessage to set
|
||||
*/
|
||||
public void setReportMessage(String reportMessage) {
|
||||
|
||||
this.reportMessage = reportMessage;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TransferOnThreddsReport [transferId=");
|
||||
builder.append(transferId);
|
||||
builder.append(", folderId=");
|
||||
builder.append(folderId);
|
||||
builder.append(", onError=");
|
||||
builder.append(onError);
|
||||
builder.append(", reportMessage=");
|
||||
builder.append(reportMessage);
|
||||
builder.append(", reportCreated=");
|
||||
builder.append(reportCreatedOnWorkspace);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue