updated pom version at 6.19.0
starting integration with new ws-thredds engine [Task #11127] removed previous ws-thredss classes/dependecies git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@164628 82a268e6-3cf1-43bd-a215-b396298e98cftask/19600
parent
d79efe03c3
commit
bc1e67e430
@ -1,21 +0,0 @@
|
||||
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,20 @@
|
||||
package org.gcube.portlets.user.workspace.client.event;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface SyncWithThreddsCatalogueEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 1, 2018
|
||||
*/
|
||||
public interface SyncWithThreddsCatalogueEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On sync.
|
||||
*
|
||||
* @param synWithThreddsEvent the syn with thredds event
|
||||
*/
|
||||
void onSync(SyncWithThreddsCatalogueEvent synWithThreddsEvent);
|
||||
}
|
@ -1,428 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.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;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferToThreddsProperty;
|
||||
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.core.XDOM;
|
||||
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.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;
|
||||
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.Timer;
|
||||
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 = 570;
|
||||
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;
|
||||
private Label infoOnLoading = new Label("");
|
||||
|
||||
private DialogPublishOnThredds INSTANCE = this;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog publish on thredds.
|
||||
*
|
||||
* @param theFolderToPublish the the folder to publish
|
||||
*/
|
||||
public DialogPublishOnThredds(FileModel theFolderToPublish) {
|
||||
|
||||
this.theFolderToPublish = theFolderToPublish;
|
||||
infoOnLoading.setType(LabelType.INFO);
|
||||
infoOnLoading.setVisible(true);
|
||||
infoOnLoading.setText("Loading Configurations...");
|
||||
initLayout();
|
||||
INSTANCE.enablePublish(false);
|
||||
AppControllerExplorer.rpcWorkspaceService.getTransferToThreddsProperty(theFolderToPublish.getIdentifier(), new AsyncCallback<TransferToThreddsProperty>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Error on loading TransferToThreddsProperty: "+caught.getMessage());
|
||||
infoOnLoading.setVisible(false);
|
||||
//initiFormFields();
|
||||
INSTANCE.enablePublish(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TransferToThreddsProperty result) {
|
||||
GWT.log("Loaded TransferToThreddsProperty: "+result);
|
||||
//initiFormFields();
|
||||
|
||||
if(result!=null){
|
||||
txtCatalogueName.setValue(result.getCatalogueName());
|
||||
|
||||
for (GcubeVRE gvre : vreStore.getModels()) {
|
||||
if(gvre.getScope().compareTo(result.getVreScope())==0){
|
||||
selectVRE.setValue(gvre);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(result.getMetadataFolderId()!=null && result.getMetadataFolderName()!=null){
|
||||
|
||||
metadataFolder = new FileModel(result.getMetadataFolderId(), result.getMetadataFolderName(), true);
|
||||
triggerFieldMetadataFolderName.setValue(metadataFolder.getName());
|
||||
}
|
||||
}
|
||||
|
||||
infoOnLoading.setVisible(false);
|
||||
INSTANCE.enablePublish(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(140);
|
||||
layout.setDefaultWidth(380);
|
||||
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("Close");
|
||||
// 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);
|
||||
// selectVRE.setAllowBlank(false);
|
||||
// selectVRE.setAutoValidate(true);
|
||||
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();
|
||||
|
||||
GWT.log("metadataFolder: "+metadataFolder);
|
||||
|
||||
String metadataFolderId = metadataFolder!=null?metadataFolder.getIdentifier():null;
|
||||
|
||||
GcubeVRE vre = selectVRE.getSelection().get(0);
|
||||
GWT.log("metadataFolderId: "+metadataFolderId);
|
||||
AppControllerExplorer.rpcWorkspaceService.publishOnThreddsCatalogue(theFolderToPublish.getIdentifier(), metadataFolderId, vre.getName(), vre.getScope(), txtCatalogueName.getValue(), new AsyncCallback<TransferOnThreddsReport>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TransferOnThreddsReport result) {
|
||||
GWT.log("Publishing on Thredds return: "+result);
|
||||
InfoDisplay.display("On going", "Transferring started correclty...");
|
||||
if(result!=null){
|
||||
pollingStart(result);
|
||||
}else
|
||||
new MessageBoxAlert("Error", "An error occurred during the transferring. Refresh the folder and try again", null);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setFocusWidget(txtCatalogueName);
|
||||
add(infoOnLoading);
|
||||
add(txtCatalogueName);
|
||||
add(selectVRE);
|
||||
//add(browse);
|
||||
add(triggerFieldMetadataFolderName);
|
||||
Label mandatory = new Label("* mandatory");
|
||||
mandatory.setType(LabelType.INFO);
|
||||
//mandatory.getElement().getStyle().set("#FF0000");
|
||||
add(mandatory);
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enable publish.
|
||||
*
|
||||
* @param enable the enable
|
||||
*/
|
||||
private void enablePublish(boolean enable){
|
||||
this.getButtonById(Dialog.OK).setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show result.
|
||||
*
|
||||
* @param result the result
|
||||
*/
|
||||
public void showResult(TransferOnThreddsReport result){
|
||||
|
||||
|
||||
if(result.isOnError()){
|
||||
MessageBox.alert("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, false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Polling start.
|
||||
*
|
||||
* @param result the result
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return true, if is valid form
|
||||
*/
|
||||
public boolean isValidForm() {
|
||||
|
||||
if (txtCatalogueName.isValid() && txtCatalogueName.getValue() != null && selectVRE.getSelection().size()>0)
|
||||
return true;
|
||||
|
||||
// if(selectVRE.getSelection().size()==0)
|
||||
// selectVRE.forceInvalid("Required");
|
||||
|
||||
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.setZIndex(XDOM.getTopZIndex()+50);
|
||||
navigator.show();
|
||||
}
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* The Class PublishOnThredds.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 27, 2017
|
||||
*/
|
||||
public class PublishOnThredds {
|
||||
|
||||
private HashSet<FolderConfiguration> configs;
|
||||
private Logger logger = Logger.getLogger(ApplicationProfileReader.class);
|
||||
private String username;
|
||||
private HttpSession httpSession;
|
||||
private String wsScopeUserToken;
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new publish on thredds.
|
||||
*
|
||||
* @param wsScopeUserToken the ws scope user token
|
||||
* @param username the username
|
||||
* @param httpSession the http session
|
||||
*/
|
||||
public PublishOnThredds(String wsScopeUserToken, String username, HttpSession httpSession) {
|
||||
this.wsScopeUserToken = wsScopeUserToken;
|
||||
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 publishingTargetScopeUserToken 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 publishingTargetScopeUserToken, 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() {
|
||||
|
||||
try{
|
||||
|
||||
WsUtil.setTransferPublishingOnThredds(httpSession, tr);
|
||||
//System.out.println("Setting ws user token : "+wsScopeUserToken);
|
||||
|
||||
TokenSetter.setToken(wsScopeUserToken);
|
||||
FolderConfiguration folderConfig=new FolderConfiguration(publishingTargetScopeUserToken,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){
|
||||
logger.error("WORKSPACE EXC ", e);
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during getting workspace for user: "+e.getMessage(), false);
|
||||
}catch(Exception e){
|
||||
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);
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
workspace.createExternalFile("Transferring on Thredds report file "+sdf.format(timestamp), "", "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 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 transferring to folder: "+folderId, e);
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an error has occurred during report creation to transfer resulting: "+e.getMessage(),false);
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("Unexpected error has occurred when performing the tranferring to Thredds, folderID is: "+folderId, e);
|
||||
e.printStackTrace();
|
||||
setStatusOnTransferId(transferId, true, "Sorry, an unexpected error has occurred when performing the tranferring on Thredds. Refresh and try again later",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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server.util;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.commons.io.output.ByteArrayOutputStream;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferToThreddsProperty;
|
||||
|
||||
|
||||
/**
|
||||
* The Class TransferringToThreddsUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 29, 2017
|
||||
*/
|
||||
public class TransferringToThreddsUtil {
|
||||
|
||||
public static Logger logger = Logger.getLogger(TransferringToThreddsUtil.class);
|
||||
|
||||
|
||||
/**
|
||||
* To xml.
|
||||
*
|
||||
* @param property the property
|
||||
* @return the string
|
||||
*/
|
||||
public static String toXML(TransferToThreddsProperty property) {
|
||||
logger.debug("Marshalling: "+property);
|
||||
System.out.println("Marshalling: "+property);
|
||||
try{
|
||||
// Create a JaxBContext
|
||||
JAXBContext jc = JAXBContext.newInstance(TransferToThreddsProperty.class);
|
||||
// Create the Marshaller Object using the JaxB Context
|
||||
Marshaller marshaller = jc.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
marshaller.marshal(property, baos);
|
||||
String marshallingJsonString = baos.toString("UTF-8");
|
||||
//System.out.println("XML: "+marshallingJsonString);
|
||||
return marshallingJsonString;
|
||||
}catch(JAXBException | UnsupportedEncodingException e){
|
||||
logger.warn("Error during marshalling: "+property, e);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshalling To OBJECT.
|
||||
*
|
||||
* @param xml the xml
|
||||
* @return the transfering to thredds property
|
||||
*/
|
||||
public static TransferToThreddsProperty toObject(String xml){
|
||||
// Create a JaxBContext
|
||||
JAXBContext jc;
|
||||
try {
|
||||
|
||||
jc = JAXBContext.newInstance(TransferToThreddsProperty.class);
|
||||
|
||||
// Create the Unmarshaller Object using the JaxB Context
|
||||
Unmarshaller unmarshaller = jc.createUnmarshaller();
|
||||
|
||||
// Create the StreamSource by creating StringReader using the JSON input
|
||||
StreamSource stream = new StreamSource(new StringReader(xml));
|
||||
|
||||
// Getting the TransferingToThreddsProperty pojo again from the json
|
||||
return unmarshaller.unmarshal(stream, TransferToThreddsProperty.class).getValue();
|
||||
|
||||
}
|
||||
catch (JAXBException e) {
|
||||
logger.warn("Error during unmarshalling: "+xml, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,190 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is transferring report available.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public Boolean isTransferringReportAvailable() {
|
||||
|
||||
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 isOnError() {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class TransferToThreddsProperty.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 29, 2017
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement
|
||||
public class TransferToThreddsProperty implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7160662779647989154L;
|
||||
|
||||
|
||||
private String folderId;
|
||||
private String catalogueName;
|
||||
private String vreName;
|
||||
private String vreScope;
|
||||
private String metadataFolderId;
|
||||
private String metadataFolderName;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new transfering to thredds property.
|
||||
*/
|
||||
public TransferToThreddsProperty() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new transfering to thredds property.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param catalogueName the catalogue name
|
||||
* @param vreName the vre name
|
||||
* @param vreScope the vre scope
|
||||
* @param metadataFolderId the metadata folder id
|
||||
*/
|
||||
public TransferToThreddsProperty(
|
||||
String folderId, String catalogueName, String vreName,
|
||||
String vreScope, String metadataFolderId, String metadataFolderName) {
|
||||
|
||||
super();
|
||||
this.folderId = folderId;
|
||||
this.catalogueName = catalogueName;
|
||||
this.vreName = vreName;
|
||||
this.vreScope = vreScope;
|
||||
this.metadataFolderId = metadataFolderId;
|
||||
this.metadataFolderName = metadataFolderName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the folderId
|
||||
*/
|
||||
public String getFolderId() {
|
||||
|
||||
return folderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the catalogueName
|
||||
*/
|
||||
public String getCatalogueName() {
|
||||
|
||||
return catalogueName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the vreName
|
||||
*/
|
||||
public String getVreName() {
|
||||
|
||||
return vreName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the vreScope
|
||||
*/
|
||||
public String getVreScope() {
|
||||
|
||||
return vreScope;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the metadataFolderId
|
||||
*/
|
||||
public String getMetadataFolderId() {
|
||||
|
||||
return metadataFolderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the metadataFolderName
|
||||
*/
|
||||
public String getMetadataFolderName() {
|
||||
|
||||
return metadataFolderName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param folderId the folderId to set
|
||||
*/
|
||||
public void setFolderId(String folderId) {
|
||||
|
||||
this.folderId = folderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param catalogueName the catalogueName to set
|
||||
*/
|
||||
public void setCatalogueName(String catalogueName) {
|
||||
|
||||
this.catalogueName = catalogueName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param metadataFolderId the metadataFolderId to set
|
||||
*/
|
||||
public void setMetadataFolderId(String metadataFolderId) {
|
||||
|
||||
this.metadataFolderId = metadataFolderId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param metadataFolderName the metadataFolderName to set
|
||||
*/
|
||||
public void setMetadataFolderName(String metadataFolderName) {
|
||||
|
||||
this.metadataFolderName = metadataFolderName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TransferToThreddsProperty [folderId=");
|
||||
builder.append(folderId);
|
||||
builder.append(", catalogueName=");
|
||||
builder.append(catalogueName);
|
||||
builder.append(", vreName=");
|
||||
builder.append(vreName);
|
||||
builder.append(", vreScope=");
|
||||
builder.append(vreScope);
|
||||
builder.append(", metadataFolderId=");
|
||||
builder.append(metadataFolderId);
|
||||
builder.append(", metadataFolderName=");
|
||||
builder.append(metadataFolderName);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package org.gcube.portlets.user.workspace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
|
||||
public class ShareFolder {
|
||||
|
||||
private static final String SUB_FOLDER_NAME = "subfoldermycourse";
|
||||
private static final String FOLDER_NAME = "_mycourse";
|
||||
public static String DEFAULT_SCOPE = "/gcube/devsec"; //DEV
|
||||
// public static String DEFAULT_SCOPE = "/d4science.research-infrastructures.eu/gCubeApps";
|
||||
public static String TEST_USER = "francesco.mangiacrapa";
|
||||
// public static String FOLDER_ID = "4f0ff79d-3c1e-4d2a-bc74-6f731edcac98";
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
|
||||
// System.out.println("start");
|
||||
// ScopeBean scope = new ScopeBean(DEFAULT_SCOPE);
|
||||
ScopeProvider.instance.set(DEFAULT_SCOPE);
|
||||
|
||||
Workspace workspace = HomeLibrary
|
||||
.getHomeManagerFactory()
|
||||
.getHomeManager()
|
||||
.getHome(TEST_USER)
|
||||
.getWorkspace();
|
||||
//
|
||||
|
||||
System.out.println("start get root");
|
||||
WorkspaceItem theRoot = workspace.getRoot();
|
||||
|
||||
System.out.println("\n\n CREATING folder: "+FOLDER_NAME + "\n\n");
|
||||
|
||||
WorkspaceFolder myCourseFolder = workspace.createFolder(FOLDER_NAME, "", theRoot.getId());
|
||||
|
||||
System.out.println("\n\n FOLDER id: "+myCourseFolder.getId() +"\n\n");
|
||||
|
||||
System.out.println("\n\n CREATING sub folder: "+SUB_FOLDER_NAME+"\n\n");
|
||||
|
||||
WorkspaceFolder subFolderMyCourse = workspace.createFolder(SUB_FOLDER_NAME, "", myCourseFolder.getId());
|
||||
|
||||
System.out.println("\n\n SUB_FOLDER id: "+subFolderMyCourse.getId() +"\n\n");
|
||||
|
||||
List<String> users = new ArrayList<String>();
|
||||
users.add("costantino.perciante");
|
||||
WorkspaceSharedFolder subShareFolder = workspace.shareFolder(users, subFolderMyCourse.getId());
|
||||
subShareFolder.setACL(users, ACLType.READ_ONLY);
|
||||
System.out.println("\n\n SHARED SUB_FOLDER id: "+subShareFolder.getId() +"\n\n");
|
||||
|
||||
// WorkspaceSharedFolder sharedFolder = subFolderMyCourse.share(users);
|
||||
|
||||
|
||||
// System.out.println("\n\n SHARED subFolderMyCourse id: "+sharedFolder.getId());
|
||||
//
|
||||
//
|
||||
// WorkspaceFolder folder = (WorkspaceFolder) workspace.getItem(sharedFolder.getId());
|
||||
//
|
||||
// System.out.println("\n\n FINAL id: "+folder.getId());
|
||||
|
||||
System.out.println("end");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue