Updated GUI to manage Catalogue Bean and Configurations
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-thredds-sync-widget@164837 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8957fbad4b
commit
f1f1b11294
|
@ -3,6 +3,7 @@ package org.gcube.portlets.widgets.wsthreddssync.client.rpc;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeVRE;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderConfiguration;
|
||||
|
@ -11,17 +12,60 @@ import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderDescr
|
|||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
* The Interface ThreddsWorkspaceSyncService.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 8, 2018
|
||||
*/
|
||||
@RemoteServiceRelativePath("wsthreddssync")
|
||||
public interface ThreddsWorkspaceSyncService extends RemoteService {
|
||||
|
||||
/**
|
||||
* Checks if is item synched.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @return the ws thredds synch folder descriptor
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
WsThreddsSynchFolderDescriptor isItemSynched(String folderId) throws ItemNotSynched, Exception;
|
||||
|
||||
/**
|
||||
* Do sync folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param clientConfig the client config
|
||||
* @return the th sync status
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ThSyncStatus doSyncFolder(final String folderId, WsThreddsSynchFolderConfiguration clientConfig) throws Exception;
|
||||
|
||||
/**
|
||||
* Monitor sync status.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @return the th sync status
|
||||
* @throws ItemNotSynched the item not synched
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ThSyncStatus monitorSyncStatus(String folderId) throws ItemNotSynched, 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;
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the available catalogues for scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<ThCatalogueBean> getAvailableCataloguesForScope(String scope) throws Exception;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.wsthreddssync.client.rpc;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeVRE;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderConfiguration;
|
||||
|
@ -10,16 +11,31 @@ import org.gcube.portlets.widgets.wsthreddssync.shared.WsThreddsSynchFolderDescr
|
|||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ThreddsWorkspaceSyncServiceAsync.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 8, 2018
|
||||
*/
|
||||
public interface ThreddsWorkspaceSyncServiceAsync
|
||||
{
|
||||
|
||||
/**
|
||||
* Utility class to get the RPC Async interface from client-side code
|
||||
* Utility class to get the RPC Async interface from client-side code.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 8, 2018
|
||||
*/
|
||||
public static final class Util
|
||||
{
|
||||
private static ThreddsWorkspaceSyncServiceAsync instance;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Util.
|
||||
*
|
||||
* @return single instance of Util
|
||||
*/
|
||||
public static final ThreddsWorkspaceSyncServiceAsync getInstance()
|
||||
{
|
||||
if ( instance == null )
|
||||
|
@ -29,6 +45,9 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new util.
|
||||
*/
|
||||
private Util()
|
||||
{
|
||||
// Utility class should not be instantiated
|
||||
|
@ -36,14 +55,48 @@ public interface ThreddsWorkspaceSyncServiceAsync
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is item synched.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param callback the callback
|
||||
*/
|
||||
void isItemSynched(String folderId, AsyncCallback<WsThreddsSynchFolderDescriptor> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Do sync folder.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param clientConfig the client config
|
||||
* @param callback the callback
|
||||
*/
|
||||
void doSyncFolder(String folderId, WsThreddsSynchFolderConfiguration clientConfig, AsyncCallback<ThSyncStatus> callback);
|
||||
|
||||
|
||||
/**
|
||||
* Monitor sync status.
|
||||
*
|
||||
* @param folderId the folder id
|
||||
* @param callback the callback
|
||||
*/
|
||||
void monitorSyncStatus(String folderId, AsyncCallback<ThSyncStatus> callback);
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param callback the callback
|
||||
* @return the available catalogues for scope
|
||||
*/
|
||||
void getAvailableCataloguesForScope(String scope, AsyncCallback<List<ThCatalogueBean>> callback);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.WsThreddsWidget;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.event.PerformDoSyncEvent;
|
||||
|
@ -242,8 +243,10 @@ public class WsThreddsWidgetViewManager {
|
|||
panelView.closeHandler();
|
||||
WsThreddsSynchFolderConfiguration conf = new WsThreddsSynchFolderConfiguration();
|
||||
conf.setFilter(null);
|
||||
conf.setRemotePath(getRemotePath());
|
||||
conf.setCatalogName(getCatalogueName());
|
||||
|
||||
ThCatalogueBean catalogueSelected = getSelectedCatalogue();
|
||||
conf.setRemotePath(catalogueSelected.getPath());
|
||||
conf.setCatalogName(catalogueSelected.getName());
|
||||
conf.setTheVRE(getSelectedVRE());
|
||||
WsThreddsWidget.eventBus.fireEvent(new PerformDoSyncEvent(folder, conf));
|
||||
}
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package org.gcube.portlets.widgets.wsthreddssync.client.view.binder;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.client.WsThreddsWidget;
|
||||
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeVRE;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.Pager;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Document;
|
||||
import com.google.gwt.dom.client.Style.Float;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.DomEvent;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -52,10 +62,19 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
Pager pager;
|
||||
|
||||
|
||||
/** The field course desciption. */
|
||||
@UiField
|
||||
ListBox field_select_vre;
|
||||
|
||||
@UiField
|
||||
Button butt_create_new_catalogue;
|
||||
|
||||
@UiField
|
||||
Button butt_add_catalogue;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox field_select_catalogue_name;
|
||||
|
||||
|
||||
/** The field catalogue name. */
|
||||
@UiField
|
||||
|
@ -63,16 +82,25 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
|
||||
/** The field folder name. */
|
||||
@UiField
|
||||
TextBox field_remote_path;
|
||||
TextBox field_folder_name;
|
||||
|
||||
|
||||
/** The cg catalogue name. */
|
||||
@UiField
|
||||
ControlGroup cg_catalogue_name;
|
||||
|
||||
/** The cg folder name. */
|
||||
@UiField
|
||||
ControlGroup cg_remote_path;
|
||||
ControlGroup cg_folder_name;
|
||||
|
||||
/** The cg folder name. */
|
||||
//@UiField
|
||||
//ControlGroup cg_remote_path;
|
||||
|
||||
@UiField
|
||||
ControlGroup cg_select_catalogue_name;
|
||||
|
||||
@UiField
|
||||
Fieldset fieldset_add_catalogue_bean;
|
||||
|
||||
|
||||
/** The folder id. */
|
||||
|
@ -82,6 +110,12 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
private Map<String, GcubeVRE> mapVREs = new HashMap<String, GcubeVRE>();
|
||||
|
||||
|
||||
private Map<String, List<ThCatalogueBean>> mapCatalogueNames = new HashMap<String, List<ThCatalogueBean>>();
|
||||
|
||||
|
||||
private String currentScope;
|
||||
|
||||
|
||||
/**
|
||||
* Submit handler.
|
||||
*/
|
||||
|
@ -128,6 +162,19 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
}
|
||||
});
|
||||
|
||||
cg_catalogue_name.getElement().getStyle().setMarginTop(20, Unit.PX);
|
||||
|
||||
field_select_vre.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
String scope = field_select_vre.getSelectedItemText();
|
||||
GWT.log("Selected VRE: "+scope);
|
||||
loadCatalogueNamesForScope(scope);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
WsThreddsWidget.wsThreddsSyncService.getListOfVREsForLoggedUser(new AsyncCallback<List<GcubeVRE>>() {
|
||||
|
||||
@Override
|
||||
|
@ -139,6 +186,13 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
field_select_vre.addItem(gcubeVRE.getVreScope(), gcubeVRE.getVreName());
|
||||
|
||||
}
|
||||
|
||||
if(result.size()>0){
|
||||
field_select_vre.setSelectedValue(result.get(0).getVreName());
|
||||
//field_select_vre.setSelectedIndex(0);
|
||||
//field_select_vre.fireEvent(DomEvent.fireNativeEvent(nativeEvent, handlerSource););
|
||||
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), field_select_vre);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,8 +202,140 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
butt_create_new_catalogue.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
fieldset_add_catalogue_bean.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
butt_add_catalogue.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
if (field_catalogue_name.getValue() == null || field_catalogue_name.getValue().isEmpty()) {
|
||||
cg_catalogue_name.setType(ControlGroupType.ERROR);
|
||||
setError(true, "Catalogue Name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(field_folder_name.getValue() == null || field_folder_name.getValue().isEmpty()){
|
||||
cg_folder_name.setType(ControlGroupType.ERROR);
|
||||
setError(true, "The Folder Name is required");
|
||||
return;
|
||||
}else if(field_folder_name.getValue().startsWith("/")){
|
||||
cg_folder_name.setType(ControlGroupType.ERROR);
|
||||
setError(true, "Folder Name must be a relative URL. It does not start with '/'");
|
||||
return;
|
||||
}
|
||||
|
||||
addCatalogueNameForCurrentScope(field_catalogue_name.getValue(), field_folder_name.getValue());
|
||||
fieldset_add_catalogue_bean.setVisible(false);
|
||||
initFieldCatalogueName();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
butt_add_catalogue.getElement().getStyle().setFloat(Float.RIGHT);
|
||||
butt_add_catalogue.getElement().getStyle().setMarginRight(90, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill selectable catalogue names.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param result the result
|
||||
*/
|
||||
private void fillSelectableCatalogueNames(String scope, List<ThCatalogueBean> result){
|
||||
|
||||
field_select_catalogue_name.clear();
|
||||
field_select_catalogue_name.setEnabled(true);
|
||||
|
||||
if(result!=null && result.size()>0){
|
||||
|
||||
mapCatalogueNames.put(scope, result);
|
||||
for (ThCatalogueBean thCatalogueBean : result) {
|
||||
field_select_catalogue_name.addItem(thCatalogueBean.getName(), thCatalogueBean.getName());
|
||||
|
||||
if(thCatalogueBean.isDefault()){
|
||||
field_select_catalogue_name.setSelectedValue(thCatalogueBean.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the catalogue name for current scope.
|
||||
*
|
||||
* @param catalogueName the catalogue name
|
||||
* @param folderName the folder name. Can be a relative Path
|
||||
*/
|
||||
private void addCatalogueNameForCurrentScope(String catalogueName, String folderName) {
|
||||
|
||||
List<ThCatalogueBean> listCtlgs = mapCatalogueNames.get(currentScope);
|
||||
|
||||
if(listCtlgs==null){
|
||||
listCtlgs = new ArrayList<ThCatalogueBean>();
|
||||
}
|
||||
|
||||
listCtlgs.add(new ThCatalogueBean(catalogueName, folderName, true));
|
||||
fillSelectableCatalogueNames(currentScope, listCtlgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load catalogue names for scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
*/
|
||||
private void loadCatalogueNamesForScope(String scope){
|
||||
this.currentScope = scope;
|
||||
field_select_catalogue_name.setEnabled(false);
|
||||
initFieldCatalogueName();
|
||||
|
||||
List<ThCatalogueBean> listCtlgs = mapCatalogueNames.get(scope);
|
||||
|
||||
if(listCtlgs==null){
|
||||
|
||||
WsThreddsWidget.wsThreddsSyncService.getAvailableCataloguesForScope(scope, new AsyncCallback<List<ThCatalogueBean>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Error: "+caught.getMessage());
|
||||
field_select_catalogue_name.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<ThCatalogueBean> result) {
|
||||
GWT.log("Fill Catalogue Names: "+result);
|
||||
fillSelectableCatalogueNames(currentScope, result);
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
|
||||
fillSelectableCatalogueNames(scope, listCtlgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inits the field catalogue name.
|
||||
*/
|
||||
private void initFieldCatalogueName() {
|
||||
|
||||
field_catalogue_name.setText("");
|
||||
field_folder_name.setText("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate submit.
|
||||
|
@ -158,44 +344,60 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|||
*/
|
||||
protected boolean validateSubmit() {
|
||||
cg_catalogue_name.setType(ControlGroupType.NONE);
|
||||
cg_remote_path.setType(ControlGroupType.NONE);
|
||||
//cg_remote_path.setType(ControlGroupType.NONE);
|
||||
|
||||
if(field_catalogue_name.getValue()==null || field_catalogue_name.getValue().isEmpty()){
|
||||
// if(field_catalogue_name.getValue()==null || field_catalogue_name.getValue().isEmpty()){
|
||||
// cg_catalogue_name.setType(ControlGroupType.ERROR);
|
||||
// setError(true, "Catalogue Name is required");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if(field_select_catalogue_name.getSelectedItemText()==null){
|
||||
cg_catalogue_name.setType(ControlGroupType.ERROR);
|
||||
setError(true, "Catalogue Name is required");
|
||||
setError(true, "Select a Catalogue Name!!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(field_remote_path.getValue()==null || field_remote_path.getValue().isEmpty()){
|
||||
cg_remote_path.setType(ControlGroupType.ERROR);
|
||||
setError(true, "Remote Path field is required");
|
||||
return false;
|
||||
}else if(field_remote_path.getValue().startsWith("/")){
|
||||
cg_remote_path.setType(ControlGroupType.ERROR);
|
||||
setError(true, "Remote Path must be a relative URL. It does not start with '/'");
|
||||
return false;
|
||||
}
|
||||
// if(field_remote_path.getValue()==null || field_remote_path.getValue().isEmpty()){
|
||||
// cg_remote_path.setType(ControlGroupType.ERROR);
|
||||
// setError(true, "Remote Path field is required");
|
||||
// return false;
|
||||
// }else if(field_remote_path.getValue().startsWith("/")){
|
||||
// cg_remote_path.setType(ControlGroupType.ERROR);
|
||||
// setError(true, "Remote Path must be a relative URL. It does not start with '/'");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the remote path.
|
||||
* Gets the selected catalogue.
|
||||
*
|
||||
* @return the remote path
|
||||
* @return the selected catalogue
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
return field_remote_path.getValue();
|
||||
public ThCatalogueBean getSelectedCatalogue(){
|
||||
|
||||
List<ThCatalogueBean> listCatalogues = mapCatalogueNames.get(currentScope);
|
||||
|
||||
String selectedCatalogueName = getCatalogueName();
|
||||
for (ThCatalogueBean thCatalogueBean : listCatalogues) {
|
||||
if(thCatalogueBean.getName().compareTo(selectedCatalogueName)==0)
|
||||
return thCatalogueBean;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the catalogue name.
|
||||
*
|
||||
* @return the catalogue name
|
||||
*/
|
||||
public String getCatalogueName(){
|
||||
return field_catalogue_name.getValue();
|
||||
return field_select_catalogue_name.getSelectedItemText();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,28 @@
|
|||
<g:HTMLPanel ui:field="form_unit_fields">
|
||||
<b:Form type="HORIZONTAL">
|
||||
<b:Fieldset styleName="{style.noBorder}">
|
||||
|
||||
<b:ControlGroup ui:field="cg_select_vre">
|
||||
<b:ControlLabel for="cl_select_vre">Publish in the VRE</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:ListBox name="Select a VRE..." b:id="field_select_vre"
|
||||
ui:field="field_select_vre">
|
||||
</b:ListBox>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:ControlGroup ui:field="cg_select_catalogue_name">
|
||||
<b:ControlLabel for="cl_select_catalogue_name">Select Catalogue Name</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:ListBox name="Select a Catalogue Name..." b:id="field_select_catalogue_name"
|
||||
ui:field="field_select_catalogue_name">
|
||||
</b:ListBox>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:Button ui:field="butt_create_new_catalogue" text="Create New Catalogue"
|
||||
type="LINK"></b:Button>
|
||||
<b:Fieldset ui:field="fieldset_add_catalogue_bean" visible="false">
|
||||
<b:ControlGroup ui:field="cg_catalogue_name">
|
||||
<b:ControlLabel for="cl_catalogue_name">Catalogue Name</b:ControlLabel>
|
||||
<b:Controls>
|
||||
|
@ -18,27 +40,22 @@
|
|||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:ControlGroup ui:field="cg_unit_description">
|
||||
<b:ControlLabel for="cl_course_description">Publish in the VRE</b:ControlLabel>
|
||||
<b:ControlGroup ui:field="cg_folder_name">
|
||||
<b:ControlLabel for="cl_folder_name">Folder Name</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:ListBox name="Select a VRE..."
|
||||
b:id="field_select_vre" ui:field="field_select_vre">
|
||||
</b:ListBox>
|
||||
<b:TextBox placeholder="Type the Folder Name..."
|
||||
title="This is the Folder Name" b:id="field_folder_name"
|
||||
ui:field="field_folder_name"></b:TextBox>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
|
||||
<b:ControlGroup ui:field="cg_remote_path">
|
||||
<b:ControlLabel for="cl_remote_path">Remote Path</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:TextBox placeholder="Type the Remote Path..."
|
||||
title="This is the Remote Path" b:id="field_remote_path"
|
||||
ui:field="field_remote_path"></b:TextBox>
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:Button ui:field="butt_add_catalogue">Add Catalogue</b:Button>
|
||||
|
||||
</b:Fieldset>
|
||||
</b:Fieldset>
|
||||
</b:Form>
|
||||
</g:HTMLPanel>
|
||||
<b:Pager left="Older" right="Create Configuration and Do Sync" aligned="true"
|
||||
ui:field="pager" />
|
||||
<b:Pager left="Older" right="Create Configuration and Do Sync"
|
||||
aligned="true" ui:field="pager" />
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -3,10 +3,13 @@
|
|||
*/
|
||||
package org.gcube.portlets.widgets.wsthreddssync.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration;
|
||||
|
@ -14,9 +17,6 @@ import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SyncronizeWithThredds.
|
||||
*
|
||||
|
@ -197,11 +197,28 @@ public class SyncronizeWithThredds {
|
|||
* @param folderId the folder id
|
||||
* @param scope the scope
|
||||
* @param userToken the user token
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void registerCallbackForId(String folderId, String scope, String userToken) throws Exception {
|
||||
setContextParameters(scope, userToken);
|
||||
workspaceThreddsSynchronize.registerCallbackForId(folderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the available catalogues by token.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param userToken the user token
|
||||
* @param targetToken the target token
|
||||
* @return
|
||||
* @return the available catalogues by token
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<ThCatalogueBean> getAvailableCataloguesByToken(String scope, String userToken, String targetToken) throws Exception {
|
||||
setContextParameters(scope, userToken);
|
||||
return workspaceThreddsSynchronize.getAvailableCataloguesByToken(targetToken);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portal.wssynclibrary.shared.ItemNotSynched;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncFolderDescriptor;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSyncStatus;
|
||||
import org.gcube.portal.wssynclibrary.shared.thredds.ThSynchFolderConfiguration;
|
||||
|
@ -108,8 +109,10 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
logger.info("Calling doSyncFolder on folderId: "+folderId +", config: "+config);
|
||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||
|
||||
ThSyncStatus status = getSyncService().doSyncFolder(folderId, config, wsScope, wsUserToken);
|
||||
logger.debug("Returning for folderId "+folderId+" the syncStatus: "+status);
|
||||
|
||||
return status;
|
||||
}catch (Exception e) {
|
||||
logger.error("Do sync Folder error: ",e);
|
||||
|
@ -118,6 +121,36 @@ public class ThreddsWorkspaceSyncServiceImpl extends RemoteServiceServlet implem
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the available catalogues for scope.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @return the available catalogues for scope
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<ThCatalogueBean> getAvailableCataloguesForScope(String scope) throws Exception {
|
||||
|
||||
if(scope==null)
|
||||
throw new Exception("Invalid scope null");
|
||||
|
||||
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(this.getThreadLocalRequest());
|
||||
String wsScope = PortalContext.getConfiguration().getCurrentScope(this.getThreadLocalRequest());
|
||||
String wsUserToken = PortalContext.getConfiguration().getCurrentUserToken(wsScope, user.getUsername());
|
||||
String targetScopeUserToken = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
|
||||
List<ThCatalogueBean> listCtlgs = getSyncService().getAvailableCataloguesByToken(scope, wsUserToken, targetScopeUserToken);
|
||||
|
||||
logger.debug("Retuning "+listCtlgs.size()+" Catalogues for scope: "+scope);
|
||||
if(logger.isDebugEnabled()){
|
||||
for (ThCatalogueBean thCatalogueBean : listCtlgs) {
|
||||
logger.debug(thCatalogueBean.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return listCtlgs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of VR es for logged user.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue