Intragrated with the Workspace (Select file from Workspace)

This commit is contained in:
Francesco Mangiacrapa 2024-02-16 15:35:09 +01:00
parent 9dca67e00f
commit dde28ced0c
12 changed files with 429 additions and 104 deletions

View File

@ -104,6 +104,11 @@
<artifactId>gcubedatacatalogue-metadata-discovery</artifactId>
<version>[3.0.0, 4.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>uri-resolver-manager</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -162,4 +162,14 @@ public interface CKanPublisherService extends RemoteService {
* @throws Exception the exception
*/
DatasetBean updateCKANDataset(DatasetBean toUpdate) throws Exception;
/**
* Gets the public link for file item id.
*
* @param itemId the item id
* @param shortenUrl the shorten url
* @return the public link for file item id
* @throws Exception the exception
*/
String getPublicLinkForFileItemId(String itemId, boolean shortenUrl) throws Exception;
}

View File

@ -48,10 +48,10 @@ public interface CKanPublisherServiceAsync {
/**
* Add this resource to the dataset whose id is datasetId.
*
* @param resource the resource
* @param resource the resource
* @param organizationName the organization name
* @param datasetId the dataset id
* @param callback the callback
* @param datasetId the dataset id
* @param callback the callback
*/
void addResourceToDataset(ResourceElementBean resource, String organizationName, String datasetId,
AsyncCallback<ResourceElementBean> callback);
@ -167,4 +167,15 @@ public interface CKanPublisherServiceAsync {
* @throws Exception the exception
*/
void updateCKANDataset(DatasetBean toUpdate, AsyncCallback<DatasetBean> callaback);
/**
* Gets the public link for file item id.
*
* @param itemId the item id
* @param shortenUrl the shorten url
* @param callaback the callaback
* @return the public link for file item id
* @throws Exception the exception
*/
void getPublicLinkForFileItemId(String itemId, boolean shortenUrl, AsyncCallback<String> callaback);
}

View File

@ -0,0 +1,51 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class WorkspaceItemSelectedEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 16, 2024
*/
public class WorkspaceItemSelectedEvent extends GwtEvent<WorkspaceItemSelectedEventHandler> {
public static Type<WorkspaceItemSelectedEventHandler> TYPE = new Type<WorkspaceItemSelectedEventHandler>();
private Item item;
/**
* Instantiates a new workspace item selected event.
*
* @param resource the resource
*/
public WorkspaceItemSelectedEvent(Item item) {
this.item = item;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<WorkspaceItemSelectedEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(WorkspaceItemSelectedEventHandler handler) {
handler.onSelectedItem(this);
}
public Item getItem() {
return item;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface WorkspaceItemSelectedEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Feb 16, 2024
*/
public interface WorkspaceItemSelectedEventHandler extends EventHandler {
/**
* On selected item.
*
* @param workspaceItemSelectedEvent the workspace item selected event
*/
void onSelectedItem(WorkspaceItemSelectedEvent workspaceItemSelectedEvent);
}

View File

@ -20,7 +20,6 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCu
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEventHandler;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
@ -46,7 +45,6 @@ import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;

View File

@ -1014,26 +1014,6 @@ public class UpdateDatasetForm extends Composite {
actionsAfterOnContinue();
else {
actionsAfterOnContinue();
// alertOnContinue("Checking if a item with such title already exists, please wait...", AlertType.INFO);
// final String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText());
// ckanServices.datasetIdAlreadyExists(titleTextBox.getText(), orgName, new AsyncCallback<Boolean>() {
//
// @Override
// public void onSuccess(Boolean result) {
// if (result) {
// alertOnContinue("Sorry but an item with such title already exists, try to change it",
// AlertType.WARNING);
// } else {
// actionsAfterOnContinue();
// }
// }
//
// @Override
// public void onFailure(Throwable caught) {
// alertOnContinue("Sorry but there was a problem while checking if the inserted data are correct",
// AlertType.ERROR);
// }
// });
}
}
}
@ -1399,10 +1379,6 @@ public class UpdateDatasetForm extends Composite {
ManageResources manageResources = new ManageResources(eventBusPublisherWidget, theDatasetBean, datasetUrl);
// form container
// AddResourceContainer container = new AddResourceContainer(datasetUrl);
// container.add(tabPanel);
// add the new content of the main panel
createDatasetMainPanel.add(manageResources);
@ -1414,8 +1390,6 @@ public class UpdateDatasetForm extends Composite {
manageResources.getEventBus().fireEvent(new AddResourceEvent(reb));
}
}
// ((NavLink) tabPanel.getWidget(1)).setActive(true);
}
/**

View File

@ -4,9 +4,12 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherSe
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.AddResourceEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.ReloadDatasetPageEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.WorkspaceItemSelectedEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.WorkspaceItemSelectedEventHandler;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
@ -15,6 +18,7 @@ import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
@ -25,20 +29,21 @@ import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
/**
* Form used to add resource(s) to a dataset
*
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class AddResourceToDataset extends Composite{
public class AddResourceToDataset extends Composite {
private static AddResourceToDatasetUiBinder uiBinder = GWT
.create(AddResourceToDatasetUiBinder.class);
private static AddResourceToDatasetUiBinder uiBinder = GWT.create(AddResourceToDatasetUiBinder.class);
interface AddResourceToDatasetUiBinder extends
UiBinder<Widget, AddResourceToDataset> {
interface AddResourceToDatasetUiBinder extends UiBinder<Widget, AddResourceToDataset> {
}
// bus to alert the dataset form about this new resource
@ -52,30 +57,46 @@ public class AddResourceToDataset extends Composite{
private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
@UiField TextBox resourceUrlTextBox;
@UiField TextBox resourceNameTextBox;
@UiField TextArea resourceDescriptionTextArea;
@UiField Button addResourceButton;
@UiField AlertBlock infoBlock;
@UiField Button goToDatasetButton;
@UiField ControlGroup urlControlGroup;
@UiField ControlGroup nameControlGroup;
@UiField FlowPanel infoPanel;
@UiField
TextBox resourceUrlTextBox;
@UiField
TextBox resourceNameTextBox;
@UiField
TextArea resourceDescriptionTextArea;
@UiField
Button addResourceButton;
@UiField
AlertBlock infoBlock;
@UiField
Button goToDatasetButton;
@UiField
ControlGroup urlControlGroup;
@UiField
ControlGroup nameControlGroup;
@UiField
FlowPanel infoPanel;
@UiField
Button buttoSelectFromWorkspace;
@UiField
Alert alertInfoURL;
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle, final String datasetOrg, final String datasetUrl) {
FlowPanel alertPanel = new FlowPanel();
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle,
final String datasetOrg, final String datasetUrl) {
initWidget(uiBinder.createAndBindUi(this));
// save bus
this.eventBus = eventBus;
// save dataset id (it is needed when we will add resources)
this.datasetId = datasetId;
this.datasetOrg = datasetOrg;
String title = datasetTitle;
String link = "";
link += title.length() > 90 ? title.substring(0, 90) + "..." : title;
goToDatasetButton.setTitle("Go to the item: "+title);
goToDatasetButton.setTitle("Go to the item: " + title);
goToDatasetButton.setText(link);
// goToDatasetButton.setHref(datasetUrl);
// goToDatasetButton.setHref(datasetUrl);
goToDatasetButton.addClickHandler(new ClickHandler() {
@Override
@ -83,11 +104,69 @@ public class AddResourceToDataset extends Composite{
Window.open(datasetUrl, "_blank", "");
}
});
alertInfoURL.setType(AlertType.WARNING);
infoBlock.add(alertPanel);
bind();
addResourceButton.setEnabled(true);
}
private void bind() {
eventBus.addHandler(WorkspaceItemSelectedEvent.TYPE, new WorkspaceItemSelectedEventHandler() {
@Override
public void onSelectedItem(final WorkspaceItemSelectedEvent workspaceItemSelectedEvent) {
if (workspaceItemSelectedEvent.getItem() != null) {
LoaderIcon loader = new LoaderIcon("Getting public link...");
showAlert(null, loader, AlertType.INFO, false, true);
ckanServices.getPublicLinkForFileItemId(workspaceItemSelectedEvent.getItem().getId(), true,
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
showAlert(caught.getMessage(), null, AlertType.ERROR, false, true);
}
@Override
public void onSuccess(String result) {
showAlert("", null, null, false, false);
resourceUrlTextBox.setText(result);
resourceNameTextBox.setText(workspaceItemSelectedEvent.getItem().getName());
}
});
}
}
});
}
@UiHandler("buttoSelectFromWorkspace")
void onSelectFromWorkspaceClick(ClickEvent e) {
final DialogBox dialog = new DialogBox(false);
dialog.setText("Select file from Workspace...");
dialog.getElement().getStyle().setWidth(700, Unit.PX);
dialog.getElement().getStyle().setZIndex(10000);
dialog.setHeight("400px");
DialogWorkspaceExplorer dbw = new DialogWorkspaceExplorer(dialog, eventBus);
dialog.add(dbw);
dialog.center();
}
@UiHandler("addResourceButton")
void onAddButtonClick(ClickEvent e){
void onAddButtonClick(ClickEvent e) {
infoBlock.setVisible(false);
urlControlGroup.setType(ControlGroupType.NONE);
nameControlGroup.setType(ControlGroupType.NONE);
@ -95,7 +174,7 @@ public class AddResourceToDataset extends Composite{
// validation
if (resourceUrlTextBox.getText().isEmpty()) {
showAlert("'URL' field cannot be empty", AlertType.ERROR);
showAlert("'URL' field cannot be empty", null, AlertType.ERROR, true, true);
urlControlGroup.setType(ControlGroupType.ERROR);
return;
}
@ -103,40 +182,31 @@ public class AddResourceToDataset extends Composite{
// validation
if (resourceNameTextBox.getText().isEmpty() || resourceNameTextBox.getText().isEmpty()) {
showAlert("'Name' field cannot be empty", AlertType.ERROR);
showAlert("'Name' field cannot be empty", null, AlertType.ERROR, true, true);
nameControlGroup.setType(ControlGroupType.ERROR);
return;
}
//THE URL must be HTTPS, see #21068
if(!(resourceUrlTextBox.getText().toLowerCase().startsWith("https://"))){
showAlert("The URL must be HTTPS, so start with \"https://\" (e.g. https://your-resource.com)", AlertType.ERROR);
// THE URL must be HTTPS, see #21068
if (!(resourceUrlTextBox.getText().toLowerCase().startsWith("https://"))) {
showAlert("The URL must be HTTPS, so start with \"https://\" (e.g. https://your-resource.com)", null,
AlertType.ERROR, true, true);
urlControlGroup.setType(ControlGroupType.ERROR);
return;
}
// collect data and build up the bean
final ResourceElementBean resource =
new ResourceElementBean(
resourceNameTextBox.getText(),
true,
false,
null,
null,
null,
null,
null,
resourceUrlTextBox.getText(),
resourceDescriptionTextArea.getText(),
datasetOrg);
final ResourceElementBean resource = new ResourceElementBean(resourceNameTextBox.getText(), true, false, null,
null, null, null, null, resourceUrlTextBox.getText(), resourceDescriptionTextArea.getText(),
datasetOrg);
// disable add button
addResourceButton.setEnabled(false);
LoaderIcon loader = new LoaderIcon("Adding resource, please wait...");
infoPanel.add(loader);
// try to create
ckanServices.addResourceToDataset(resource, datasetOrg, datasetId, new AsyncCallback<ResourceElementBean>() {
@ -144,8 +214,8 @@ public class AddResourceToDataset extends Composite{
public void onSuccess(ResourceElementBean result) {
infoPanel.clear();
if(result != null){
showAlert("Resource created correctly", AlertType.SUCCESS);
if (result != null) {
showAlert("Resource created correctly", null, AlertType.SUCCESS, true, true);
eventBus.fireEvent(new AddResourceEvent(result));
eventBus.fireEvent(new ReloadDatasetPageEvent(datasetId));
@ -154,16 +224,17 @@ public class AddResourceToDataset extends Composite{
resourceNameTextBox.setText("");
resourceDescriptionTextArea.setText("");
}
else
showAlert("Unable to add this resource. Check that the url is correct", AlertType.ERROR);
} else
showAlert("Unable to add this resource. Check that the url is correct", null, AlertType.ERROR, true,
true);
}
@Override
public void onFailure(Throwable caught) {
infoPanel.clear();
showAlert("Unable to add this resource, sorry. Error is: " + caught.getMessage(), AlertType.ERROR);
showAlert("Unable to add this resource, sorry. Error is: " + caught.getMessage(), null, AlertType.ERROR,
true, true);
}
});
@ -172,27 +243,39 @@ public class AddResourceToDataset extends Composite{
/**
* Show error/success after resource creation attempt.
*
* @param text
* @param type
*/
protected void showAlert(String text, AlertType type) {
protected void showAlert(String text, LoaderIcon loader, AlertType type, boolean scheduleHide, boolean setVisible) {
alertPanel.clear();
infoBlock.setText(text);
infoBlock.setType(type);
infoBlock.setVisible(true);
addResourceButton.setEnabled(true);
infoBlock.setVisible(setVisible);
// hide after some seconds
Timer t = new Timer() {
if (scheduleHide) {
// hide after some seconds
Timer t = new Timer() {
@Override
public void run() {
@Override
public void run() {
infoBlock.setVisible(false);
infoBlock.setVisible(false);
}
};
}
};
t.schedule(8000);
}
if (text != null) {
alertPanel.add(new HTML(text));
}
if (loader != null) {
alertPanel.add(loader);
}
t.schedule(8000);
}
}

View File

@ -44,6 +44,11 @@
vertical-align: middle;
font-weight: bold;
}
.background_gray {
background-color: #fcfcfc !important;
background-color: gray !important;
}
</ui:style>
<g:HTMLPanel>
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
@ -58,8 +63,13 @@
</small>
</b:Legend>
<b:Alert type="INFO" close="false">The URL of the resource you are
publishing (only HTTPS URLs are allowed). If your resource is a
<!-- Add resource button -->
<b:Button title="Select from Workspace..."
ui:field="buttoSelectFromWorkspace" type="LINK">Select from Workspace</b:Button>
<b:Alert close="false" ui:field="alertInfoURL">The URL of the resource you are
publishing (only HTTPS
URLs are allowed). If your resource is a
file that you own on your
desktop, please upload that file to your
workspace and generate a

View File

@ -0,0 +1,113 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.WorkspaceItemSelectedEvent;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectPanel;
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
import com.github.gwtbootstrap.client.ui.Button;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
public class DialogWorkspaceExplorer extends Composite {
private static DialogBoxWorkspaceUiBinder uiBinder = GWT.create(DialogBoxWorkspaceUiBinder.class);
interface DialogBoxWorkspaceUiBinder extends UiBinder<Widget, DialogWorkspaceExplorer> {
}
@UiField
Button okButton;
@UiField
Button cancelButton;
@UiField
FlowPanel panelContainer;
private DialogBox dialogBox;
private Item selectedItem;
private HandlerManager eventBus;
public DialogWorkspaceExplorer(DialogBox dialog, HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
this.dialogBox = dialog;
this.eventBus = eventBus;
FilterCriteria filterCriteria = null;
List<ItemType> selectableTypes = Arrays.asList(ItemType.DOCUMENT, ItemType.EXTERNAL_IMAGE,
ItemType.EXTERNAL_FILE, ItemType.EXTERNAL_PDF_FILE, ItemType.EXTERNAL_URL, ItemType.REPORT_TEMPLATE,
ItemType.REPORT, ItemType.CSV, ItemType.MOVIE, ItemType.ZIP, ItemType.RAR, ItemType.HTML, ItemType.XML,
ItemType.TEXT_PLAIN, ItemType.DOCUMENT, ItemType.PRESENTATION, ItemType.SPREADSHEET, ItemType.METADATA,
ItemType.PDF_DOCUMENT, ItemType.IMAGE_DOCUMENT, ItemType.URL_DOCUMENT, ItemType.GCUBE_ITEM,
ItemType.TIME_SERIES
);
WorkspaceExplorerSelectPanel selectDialog = new WorkspaceExplorerSelectPanel("Select the file...",
filterCriteria, selectableTypes);
selectDialog.setWidth("700px");
selectDialog.setHeight("370px");
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
@Override
public void onSelectedItem(Item item) {
GWT.log("onSelectedItem: " + item);
selectedItem = item;
}
@Override
public void onFailed(Throwable throwable) {
GWT.log("onFailed..");
}
@Override
public void onAborted() {
GWT.log("onAborted..");
}
@Override
public void onNotValidSelection() {
GWT.log("onNotValidSelection..");
}
};
selectDialog.addWorkspaceExplorerSelectNotificationListener(listener);
panelContainer.add(selectDialog);
}
@UiHandler("okButton")
void onOKClick(ClickEvent e) {
if(selectedItem!=null) {
eventBus.fireEvent(new WorkspaceItemSelectedEvent(selectedItem));
dialogBox.hide();
}
}
@UiHandler("cancelButton")
void onCancelClick(ClickEvent e) {
dialogBox.hide();
}
}

View File

@ -0,0 +1,24 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.select_button {
margin: 5px;
float: right;
}
.cancel_button {
margin: 5px;
margin-left: 10px;
float: right;
}
</ui:style>
<g:FlowPanel>
<g:FlowPanel ui:field="panelContainer"></g:FlowPanel>
<b:Button ui:field='cancelButton'
addStyleNames="{style.cancel_button}">Cancel</b:Button>
<b:Button ui:field='okButton' type='PRIMARY'
addStyleNames="{style.select_button}">Select</b:Button>
</g:FlowPanel>
</ui:UiBinder>

View File

@ -31,6 +31,8 @@ import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanLicense;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanOrganization;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResource;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanTag;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.CatalogueRoleManager;
import org.gcube.portlets.widgets.ckandatapublisherwidget.server.utils.DiscoverTagsList;
@ -387,8 +389,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
CkanOrganization ckanOrganization = dataset.getOrganization();
// UPDATED By Francesco
// String vreName = scope.substring(scope.lastIndexOf("/") + 1, scope.length());
// logger.debug("In dev mode using the scope: " + scope + " and VRE name: " + vreName);
final OrganizationBean ckanOrganizationBean = new OrganizationBean(ckanOrganization.getTitle(),
ckanOrganization.getName(), true);
bean.setOrganizationList(Arrays.asList(ckanOrganizationBean));
@ -413,15 +413,6 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
// Vocabulary Tags from Generi Resources
bean.setTagsVocabulary(discoverTagsVocabulary(scopePerCurrentUrl));
// By default setting the root folder ID for updating the Resources on the
// client-side
// TODO LOAD THE WORKSPACE ROOT
/*
* Workspace workspace = getWorkspaceFromStorageHub();
* WorkspaceUtils.toWorkspaceResource(workspace.getRoot().getId(), userName,
* bean, workspace);
*/
// Settings the CKAN resources
List<CkanResource> resources = dataset.getResources();
if (resources != null) {
@ -1091,7 +1082,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.warn("Dev mode detected");
toReturn = Arrays.asList();
}
logger.info("Returning user's groups: " + toReturn);
return toReturn;
}
@ -1274,6 +1265,41 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
}
/**
* Gets the public link for file item id.
*
* @param itemId the item id
* @param shortenUrl the shorten url
* @return the public link for file item id
* @throws Exception the exception
*/
@Override
public String getPublicLinkForFileItemId(String itemId, boolean shortenUrl) throws Exception {
logger.debug("get Public Link For ItemId: " + itemId);
//String scopePerCurrentUrl = GenericUtils.getScopeFromClientUrl(getThreadLocalRequest());
String theLink = null;
try {
GenericUtils.getCurrentContext(getThreadLocalRequest(), true);
UriResolverManager resolver = new UriResolverManager("SHUB");
Map<String, String> params = new HashMap<String, String>();
params.put("id", itemId);
theLink = resolver.getLink(params, true);
logger.info("Returning public link: "+theLink);
} catch (UriResolverMapException e) {
logger.error("UriResolverMapException", e);
throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
} catch (IllegalArgumentException e) {
logger.error("Failed to check the user's role", e);
throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
} catch (Exception e) {
logger.error("Failed to check the user's role", e);
throw new Exception("Sorry an error occurred on getting the link " + e.getMessage());
}
return theLink;
}
/**
* Gets the reserverd system fields.
*