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-b396298e98cf
This commit is contained in:
parent
f6bc27788d
commit
adcf5d9242
|
@ -1,7 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-2"
|
||||
date="2017-09-13">
|
||||
date="2017-09-27">
|
||||
<Change>Incident #9676: fixed. Removed check on get sub-folder public link when operation is performed by an administrator</Change>
|
||||
<Change>Feature #9760: WS-Thredds synch folder integration</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-1"
|
||||
date="2017-07-10">
|
||||
|
|
14
pom.xml
14
pom.xml
|
@ -99,6 +99,14 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.usecases</groupId>
|
||||
<artifactId>ws-thredds</artifactId>
|
||||
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- FWS -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
|
@ -138,6 +146,12 @@
|
|||
<version>[1.0.0-SNAPSHOT,)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-explorer</artifactId>
|
||||
<version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- HOME LIBRARY -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
<inherits name="org.gcube.portlets.widgets.imagepreviewerwidget.ImagePreviewer" />
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.wsexplorer.WorkspaceExplorer' />
|
||||
|
||||
<!-- Specify the application specific style sheet. -->
|
||||
<stylesheet src='workspacetree.css' />
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.PasteItemEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnThreddsCatalogueEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnThreddsCatalogueEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.RefreshItemEventHandler;
|
||||
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
||||
|
@ -121,6 +123,7 @@ import org.gcube.portlets.user.workspace.client.view.windows.DialogAddUrl;
|
|||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogGetLink.Link_Type;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogPublishOnThredds;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
||||
|
@ -268,6 +271,21 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(PublishOnThreddsCatalogueEvent.TYPE, new PublishOnThreddsCatalogueEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onPublish(PublishOnThreddsCatalogueEvent publishEvent) {
|
||||
|
||||
final FileModel folder = publishEvent.getFolderToPublish();
|
||||
|
||||
if(folder!=null){
|
||||
DialogPublishOnThredds publishOnThredds = new DialogPublishOnThredds(folder);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(VersioningHistoryShowEvent.TYPE, new VersioningHistoryShowEventHandler() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,6 +44,7 @@ public class ConstantsExplorer {
|
|||
public static final String MESSAGE_ADD_FOLDER = "New Folder";
|
||||
public static final String MESSAGE_ADD_SHARED_FOLDER = "New Shared Folder";
|
||||
public static final String MESSAGE_DATA_CATALOGUE_PUBLISH = "Publish on Catalogue";
|
||||
public static final String MESSAGE_THREDDS_PUBLISH = "Publish on Thredds";
|
||||
public static final String MESSAGE_ADD = "Add";
|
||||
public static final String MESSAGE_ADD_FOLDER_IN = "Create a new folder in: ";
|
||||
public static final String MESSAGE_ITEM_NAME = "Item Name";
|
||||
|
|
|
@ -11,6 +11,7 @@ public enum WorkspaceOperation {
|
|||
RENAME("RNM", "RNM"),
|
||||
INSERT_SHARED_FOLDER("ISHF", "ASHF"), // Insert shared Folder
|
||||
PUBLISH_ON_DATA_CATALOGUE("PODC", "PODC"),
|
||||
PUBLISH_ON_THREDDS("POTD", "POTD"),
|
||||
SHARE("SHR", "SHR"), // SHARE
|
||||
UNSHARE("USHR", "USHR"), // UNSHARE
|
||||
UPLOAD_ARCHIVE("UPA", "UPA"), // Upload Archive
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -451,5 +451,11 @@ public interface Icons extends ClientBundle {
|
|||
*/
|
||||
@Source("icons/versioning.png")
|
||||
ImageResource versioning();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Source("icons/thredds.png")
|
||||
ImageResource thredds();
|
||||
}
|
||||
|
||||
|
|
|
@ -1362,6 +1362,18 @@ public class Resources {
|
|||
return AbstractImagePrototype.create(ICONS.versioning());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the icon thredds publish.
|
||||
*
|
||||
* @return the icon thredds publish
|
||||
*/
|
||||
public static AbstractImagePrototype getIconThreddsPublish() {
|
||||
|
||||
return AbstractImagePrototype.create(ICONS.thredds());
|
||||
}
|
||||
|
||||
|
||||
//ImageResources
|
||||
/**
|
||||
* Gets the image path separator.
|
||||
|
@ -1417,6 +1429,7 @@ public class Resources {
|
|||
return ICONS.cancel();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the image delete.
|
||||
*
|
||||
|
@ -1611,4 +1624,6 @@ public class Resources {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 749 B |
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||
|
@ -23,6 +24,7 @@ import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
|||
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||
|
@ -768,7 +770,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
List<FileVersionModel> getVersionHistory(String fileIdentifier) throws Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the images for folder.
|
||||
*
|
||||
|
@ -778,4 +779,27 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
List<GWTWorkspaceItem> getImagesForFolder(String folderId, String currentImageId) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of vr es for logged user.
|
||||
*
|
||||
* @return the list of vr es for logged user
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<GcubeVRE> getListOfVREsForLoggedUser()
|
||||
throws Exception;
|
||||
/**
|
||||
* @param folderToPublishId
|
||||
* @param folderMetadataId
|
||||
* @param vreScope
|
||||
* @param catalogueName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
TransferOnThreddsReport publishOnThreddsCatalogue(
|
||||
String folderToPublishId, String folderMetadataId, String vreScope,
|
||||
String catalogueName)
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.client.rpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,6 +15,7 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||
|
@ -22,6 +26,7 @@ import org.gcube.portlets.user.workspace.shared.ExtendedWorkspaceACL;
|
|||
import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
||||
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||
|
@ -748,12 +753,52 @@ public interface GWTWorkspaceServiceAsync {
|
|||
void getVersionHistory(
|
||||
String fileIdentifier, AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
/**
|
||||
* Perform operation on versioned file.
|
||||
*
|
||||
* @param fileId the file id
|
||||
* @param olderVersionIds the older version ids
|
||||
* @param operation the operation
|
||||
* @param callback the callback
|
||||
*/
|
||||
void performOperationOnVersionedFile(
|
||||
String fileId, List<String> olderVersionIds,
|
||||
WorkspaceVersioningOperation operation,
|
||||
AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
/**
|
||||
* Gets the images for folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param currentImageId the current image id
|
||||
* @param asyncCallback the async callback
|
||||
* @return the images for folder
|
||||
*/
|
||||
void getImagesForFolder(
|
||||
String folderId, String currentImageId, AsyncCallback<List<GWTWorkspaceItem>> asyncCallback);
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of vr es for logged user.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @return the list of vr es for logged user
|
||||
*/
|
||||
void getListOfVREsForLoggedUser(AsyncCallback<List<GcubeVRE>> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Publish on thredds catalogue.
|
||||
*
|
||||
* @param folderToPublishId the folder to publish id
|
||||
* @param folderMetadataId the folder metadata id
|
||||
* @param vreScope the vre scope
|
||||
* @param catalogueName the catalogue name
|
||||
* @param callback the callback
|
||||
*/
|
||||
void publishOnThreddsCatalogue(
|
||||
String folderToPublishId, String folderMetadataId, String vreScope,
|
||||
String catalogueName, AsyncCallback<TransferOnThreddsReport> callback);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.PublishOnThreddsCatalogueEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
||||
|
@ -364,16 +365,32 @@ public class ContextMenuTree {
|
|||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
FileModel sourceFileModel = listSelectedItems.get(0);
|
||||
String folderId = sourceFileModel.getIdentifier();
|
||||
|
||||
if (sourceFileModel != null) {
|
||||
eventBus.fireEvent(new PublishOnDataCatalogueEvent(folderId));
|
||||
eventBus.fireEvent(new PublishOnDataCatalogueEvent(sourceFileModel.getIdentifier()));
|
||||
}
|
||||
}
|
||||
});
|
||||
publishOnDataCatalogue.setVisible(false);
|
||||
contextMenu.add(publishOnDataCatalogue);
|
||||
|
||||
// publish on data catalogue
|
||||
MenuItem publishOnThredds = new MenuItem();
|
||||
publishOnThredds.setId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId());
|
||||
publishOnThredds.setText(ConstantsExplorer.MESSAGE_THREDDS_PUBLISH);
|
||||
publishOnThredds.setIcon(Resources.getIconThreddsPublish()); // TODO change icon
|
||||
|
||||
publishOnThredds.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
FileModel sourceFileModel = listSelectedItems.get(0);
|
||||
if (sourceFileModel != null) {
|
||||
eventBus.fireEvent(new PublishOnThreddsCatalogueEvent(sourceFileModel));
|
||||
}
|
||||
}
|
||||
});
|
||||
publishOnThredds.setVisible(false);
|
||||
contextMenu.add(publishOnThredds);
|
||||
|
||||
|
||||
MenuItem editPermissions = new MenuItem();
|
||||
editPermissions.setId(WorkspaceOperation.EDIT_PERMISSIONS.getId());
|
||||
|
@ -827,6 +844,7 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(false); //publish on data catalogue
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId()).setVisible(false); //publish on thredds
|
||||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(false); //SHARE
|
||||
|
||||
|
@ -875,6 +893,7 @@ public class ContextMenuTree {
|
|||
//CASE DIRECTORY
|
||||
if(selectedItem.isDirectory()){
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId()).setVisible(true);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.GcubeVRE;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||
|
@ -61,6 +62,7 @@ import org.gcube.portlets.user.workspace.client.workspace.GWTWorkspaceItem;
|
|||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.WorkspaceHandledException;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||
import org.gcube.portlets.user.workspace.server.publish.PublishOnThredds;
|
||||
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfile;
|
||||
import org.gcube.portlets.user.workspace.server.reader.ApplicationProfileReader;
|
||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||
|
@ -78,6 +80,7 @@ import org.gcube.portlets.user.workspace.shared.GarbageItem;
|
|||
import org.gcube.portlets.user.workspace.shared.PublicLink;
|
||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||
|
@ -89,10 +92,12 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingEntryTyp
|
|||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
|
@ -4162,4 +4167,71 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
throw new Exception(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#getListOfVREsForLoggedUser()
|
||||
*/
|
||||
@Override
|
||||
public List<GcubeVRE> getListOfVREsForLoggedUser() throws Exception{
|
||||
workspaceLogger.debug("getListOfVREsForLoggedUser...: ");
|
||||
//PortalContextInfo context = WsUtil.getPortalContext(this.getThreadLocalRequest());
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
|
||||
long userId = user.getUserId();
|
||||
|
||||
if (isTestMode())
|
||||
userId = 21150; //USER ID OF FRANCESCo
|
||||
|
||||
// Instanciate the manager
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
List<GcubeVRE> listOfVres = new ArrayList<GcubeVRE>();
|
||||
try {
|
||||
|
||||
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(userId);
|
||||
for (GCubeGroup gCubeGroup : listOfGroups) {
|
||||
if(groupManager.isVRE(gCubeGroup.getGroupId())){
|
||||
GcubeVRE gcubeVRE = new GcubeVRE(gCubeGroup.getGroupName(), groupManager.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
listOfVres.add(gcubeVRE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (UserRetrievalFault | UserManagementSystemException
|
||||
| GroupRetrievalFault e) {
|
||||
workspaceLogger.error("Error occurred server-side getting VRE folders: ", e);
|
||||
throw new Exception("Sorry, an error occurred server-side getting VRE folders, try again later");
|
||||
}
|
||||
|
||||
workspaceLogger.info("Returning list of VREs: "+listOfVres);
|
||||
return listOfVres;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Publish on thredds catalogue.
|
||||
*
|
||||
* @param folderToPublishId the folder to publish id
|
||||
* @param folderMetadataId the folder metadata id
|
||||
* @param vreScope the vre scope
|
||||
* @param catalogueName the catalogue name
|
||||
* @return the transfer on thredds report
|
||||
*/
|
||||
@Override
|
||||
public TransferOnThreddsReport publishOnThreddsCatalogue(String folderToPublishId, String folderMetadataId, String vreScope, String catalogueName) throws Exception{
|
||||
workspaceLogger.info("Publishing on thredds the folderId: "+folderToPublishId+", metafolderId: "+folderMetadataId +", vre scope: "+vreScope);
|
||||
|
||||
try{
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
String userToken = PortalContext.getConfiguration().getCurrentUserToken(vreScope, user.getUsername());
|
||||
|
||||
PublishOnThredds pub = new PublishOnThredds(vreScope, user.getUsername(), this.getThreadLocalRequest().getSession());
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.workspace.server.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
|
@ -27,6 +30,7 @@ import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParame
|
|||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
import org.gcube.portlets.user.workspace.shared.TransferOnThreddsReport;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
@ -40,6 +44,11 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
*/
|
||||
public class WsUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String FOLDER_PUBLISHING_ON_THREDDS = "FolderPublishingOnThredds";
|
||||
|
||||
protected static Logger logger = Logger.getLogger(WsUtil.class);
|
||||
|
||||
public static final String FOLDERIMPORTER_ATTRIBUTE = "FOLDER_IMPORTER";
|
||||
|
@ -407,4 +416,68 @@ public class WsUtil {
|
|||
return psFolderReader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the folder publishing on thredds.
|
||||
*
|
||||
* @param session the session
|
||||
* @param report the report
|
||||
*/
|
||||
public static void setTransferPublishingOnThredds(HttpSession session, TransferOnThreddsReport report){
|
||||
|
||||
Map<String, TransferOnThreddsReport> map = getMapTransferPublishingOnThredds(session);
|
||||
|
||||
if(map!=null)
|
||||
map.put(report.getTransferId(), report);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the folder publishing on thredds.
|
||||
*
|
||||
* @param session the session
|
||||
* @return the folder publishing on thredds
|
||||
*/
|
||||
public static Map<String, TransferOnThreddsReport> getMapTransferPublishingOnThredds(HttpSession session){
|
||||
|
||||
Map<String, TransferOnThreddsReport> map = null;
|
||||
try{
|
||||
|
||||
map = (Map<String,TransferOnThreddsReport>) session.getAttribute(FOLDER_PUBLISHING_ON_THREDDS);
|
||||
|
||||
if(map==null){
|
||||
logger.info("Creating new map to trace publishing on thredds... ");
|
||||
map = new HashMap<String, TransferOnThreddsReport>();
|
||||
session.setAttribute(FOLDER_PUBLISHING_ON_THREDDS, map);
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
logger.error("an error occurred instancing PropertySpecialFolderReader ",e);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ge transfer publishing on thredds for id.
|
||||
*
|
||||
* @param session the session
|
||||
* @param transferId the transfer id
|
||||
* @return the transfer on thredds report
|
||||
*/
|
||||
public static TransferOnThreddsReport geTransferPublishingOnThreddsForId(HttpSession session, String transferId){
|
||||
|
||||
Map<String, TransferOnThreddsReport> map = getMapTransferPublishingOnThredds(session);
|
||||
|
||||
if(map!=null){
|
||||
return map.get(transferId);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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