ref 11711: SAI - Add a simple text viewer so that log files created by Data Miner algorithms can be directly viewed in the browser

https://support.d4science.org/issues/11711

Added service info[ticket #12594]
Added support to show log information [ticket #11711]
Added support to show files html, json, pdf, txt [ticket #17106]
Updated information show to the user when a computation is submitted [ticket #17030]

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@181868 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-09-27 17:46:36 +00:00
parent c68182c4a3
commit ad17f51709
28 changed files with 929 additions and 123 deletions

View File

@ -1,5 +1,13 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-11-0" date="2019-06-14">
<Change>Added service info [ticket #12594]</Change>
<Change>Added support to show log information [ticket #11711]</Change>
<Change>Added support to show files html, json, pdf, txt [ticket
#17106]
</Change>
<Change>Updated information show to the user when a computation is
submitted [ticket #17030]
</Change>
<Change>Added Item Id support [ticket #16503]</Change>
</Changeset>
<Changeset component="${groupId}.${artifactId}.1-10-0" date="2019-04-01">

View File

@ -130,7 +130,7 @@
</dependency>
<!-- Portal-Api -->
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
@ -252,7 +252,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -7,6 +7,7 @@ import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.Compu
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
import org.gcube.data.analysis.dataminermanagercl.shared.perspective.PerspectiveType;
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
@ -17,6 +18,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.ComputationDataReq
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DeleteItemRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ServiceInfoRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationEvent;
@ -27,6 +29,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWo
import org.gcube.portlets.user.dataminermanager.client.events.RemoveSelectedOperatorEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ServiceInfoEvent;
import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent;
import org.gcube.portlets.user.dataminermanager.client.events.StartComputationExecutionEvent;
import org.gcube.portlets.user.dataminermanager.client.events.StartComputationExecutionRequestEvent;
@ -232,6 +235,18 @@ public class DataMinerManagerController {
});
EventBusProvider.INSTANCE.addHandler(ServiceInfoRequestEvent.TYPE,
new ServiceInfoRequestEvent.ServiceInfoRequestEventHandler() {
@Override
public void onRequest(ServiceInfoRequestEvent event) {
Log.debug("Catch EnvironmentRequestEvent: " + event);
retrieveEnvironment(event);
}
});
}
private void restoreUISession() {
@ -532,6 +547,34 @@ public class DataMinerManagerController {
});
}
private void retrieveEnvironment(final ServiceInfoRequestEvent event) {
DataMinerPortletServiceAsync.INSTANCE.getServiceInfo(new AsyncCallback<ServiceInfo>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
UtilsGXT3.alert("Error", "Expired Session");
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
} else {
UtilsGXT3.alert("Error",
"Error retrieving DataMiner service info: " + caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(ServiceInfo serviceInfo) {
Log.debug("DataMiner Service Info: " + serviceInfo);
ServiceInfoEvent serviceInfoEvent = new ServiceInfoEvent(serviceInfo);
EventBusProvider.INSTANCE.fireEvent(serviceInfoEvent);
}
});
}
private void fireDataMinerWorkAreaEventRetrieved(DataMinerWorkAreaRequestEvent event, DataMinerWorkArea result) {
dataMinerWorkArea = result;

View File

@ -1,7 +1,8 @@
package org.gcube.portlets.user.dataminermanager.client.computations;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.widgets.ShowFileDialog;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
@ -11,6 +12,9 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.dom.XDOM;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@ -31,8 +35,8 @@ public class ComputationValueFilePanel extends SimpleContainer {
init();
create();
}
private void init(){
private void init() {
setBorders(false);
}
@ -42,19 +46,26 @@ public class ComputationValueFilePanel extends SimpleContainer {
final String fileUrl = computationValueFile.getValue();
HtmlLayoutContainer fileNameHtml;
if (fileName != null) {
fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName)
.toSafeHtml().asString() + "</p></div>");
fileNameHtml = new HtmlLayoutContainer("<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName).toSafeHtml().asString() + "</p></div>");
} else {
fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped("NoName")
.toSafeHtml().asString() + "</p></div>");
fileNameHtml = new HtmlLayoutContainer("<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped("NoName").toSafeHtml().asString() + "</p></div>");
}
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton downloadBtn = new TextButton("Download File");
TextButton showFileButton = new TextButton("Show");
showFileButton.setIcon(DataMinerManager.resources.pageWhite());
showFileButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
showFileCreate();
}
});
TextButton downloadBtn = new TextButton("Download");
downloadBtn.setIcon(DataMinerManager.resources.download());
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
@ -63,7 +74,7 @@ public class ComputationValueFilePanel extends SimpleContainer {
}
});
TextButton netcdfButton = new TextButton("");
netcdfButton.setIcon(DataMinerManager.resources.netcdf());
netcdfButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -74,21 +85,45 @@ public class ComputationValueFilePanel extends SimpleContainer {
}
});
HBoxLayoutContainer buttonsContainer = new HBoxLayoutContainer();
buttonsContainer.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
BoxLayoutData buttonBoxLayoutData = new BoxLayoutData(new Margins(2, 2, 2, 2));
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
if (computationValueFile.isNetcdf()) {
lc.add(netcdfButton, new VerticalLayoutData(-1, -1, new Margins(0)));
if (fileName != null && !fileName.isEmpty()) {
String fileNameLowerCase = fileName.toLowerCase();
if (fileNameLowerCase.endsWith(".html") || fileNameLowerCase.endsWith(".htm")
|| fileNameLowerCase.endsWith(".log") || fileNameLowerCase.endsWith(".json")
|| fileNameLowerCase.endsWith(".txt")) {
buttonsContainer.add(showFileButton, buttonBoxLayoutData);
}
}
// c.add(previewButton, new VerticalLayoutData(-1, -1, new Margins(0)));
buttonsContainer.add(downloadBtn, buttonBoxLayoutData);
if (computationValueFile.isNetcdf()) {
buttonsContainer.add(netcdfButton, buttonBoxLayoutData);
}
lc.add(buttonsContainer);
add(lc);
}
private void showFileCreate() {
if (computationValueFile != null && computationValueFile.getValue() != null
&& !computationValueFile.getValue().isEmpty()) {
GWT.log("ShowFileCreate");
ShowFileDialog showFileDialog = new ShowFileDialog(computationValueFile.getValue());
showFileDialog.setZIndex(XDOM.getTopZIndex());
showFileDialog.show();
}
}
private void showNetCDFFile() {
if (computationValueFile != null && computationValueFile.getValue() != null && !computationValueFile.getValue().isEmpty()
&& computationValueFile.isNetcdf()) {
if (computationValueFile != null && computationValueFile.getValue() != null
&& !computationValueFile.getValue().isEmpty() && computationValueFile.isNetcdf()) {
GWT.log("NetcdfBasicWidgetsManager");
SelectVariableEventHandler handler = new SelectVariableEventHandler() {
@Override
@ -105,5 +140,4 @@ public class ComputationValueFilePanel extends SimpleContainer {
}
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Service Info Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceInfoEvent extends GwtEvent<ServiceInfoEvent.ServiceInfoEventHandler> {
public static Type<ServiceInfoEventHandler> TYPE = new Type<ServiceInfoEventHandler>();
private ServiceInfo serviceInfo;
public interface ServiceInfoEventHandler extends EventHandler {
void onRequest(ServiceInfoEvent event);
}
public interface HasServiceInfoEventHandler extends HasHandlers {
public HandlerRegistration addServiceInfoEventHandler(ServiceInfoEventHandler handler);
}
public ServiceInfoEvent(ServiceInfo serviceInfo) {
this.serviceInfo = serviceInfo;
}
@Override
protected void dispatch(ServiceInfoEventHandler handler) {
handler.onRequest(this);
}
@Override
public Type<ServiceInfoEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<ServiceInfoEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, ServiceInfoEvent event) {
source.fireEvent(event);
}
public ServiceInfo getServiceInfo() {
return serviceInfo;
}
@Override
public String toString() {
return "ServiceInfoEvent [serviceInfo=" + serviceInfo + "]";
}
}

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Service Info Request Event
*
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceInfoRequestEvent extends GwtEvent<ServiceInfoRequestEvent.ServiceInfoRequestEventHandler> {
public static Type<ServiceInfoRequestEventHandler> TYPE = new Type<ServiceInfoRequestEventHandler>();
public interface ServiceInfoRequestEventHandler extends EventHandler {
void onRequest(ServiceInfoRequestEvent event);
}
public interface HasServiceInfoRequestEventHandler extends HasHandlers {
public HandlerRegistration addServiceInfoRequestEventHandler(ServiceInfoRequestEventHandler handler);
}
public ServiceInfoRequestEvent() {
}
@Override
protected void dispatch(ServiceInfoRequestEventHandler handler) {
handler.onRequest(this);
}
@Override
public Type<ServiceInfoRequestEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<ServiceInfoRequestEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, ServiceInfoRequestEvent event) {
source.fireEvent(event);
}
@Override
public String toString() {
return "ServiceInfoRequestEvent []";
}
}

View File

@ -86,9 +86,8 @@ public class ComputationStatusPanel extends SimpleContainer {
*/
// vert.add(date, new VerticalLayoutData(-1, -1, new Margins(0)));
vert.add(new HtmlLayoutContainer("<p>Created, the id is "
+ computationId.getId() + " [<a href='"
+ computationId.getUrlId() + "' >link</a>]</p>"));
vert.add(new HtmlLayoutContainer("<p><span style='margin-right:165px;'>Id:</span> "
+ computationId.getId() + "</p>"));
TextButton equivalentRequestBtn = new TextButton();
equivalentRequestBtn.setText("Show");
@ -99,15 +98,32 @@ public class ComputationStatusPanel extends SimpleContainer {
showEquivalentRequestDialog();
}
});
FieldLabel equivalentRequestLabel = new FieldLabel(
equivalentRequestBtn, "Equivalent Get Request");
equivalentRequestLabel.setLabelWidth(140);
equivalentRequestBtn, "WPS Request");
equivalentRequestLabel.setLabelWidth(180);
vert.add(equivalentRequestLabel, new VerticalLayoutData(-1, -1,
new Margins(0)));
TextButton monitorComputationBtn = new TextButton();
monitorComputationBtn.setText("Show");
monitorComputationBtn.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
showLinkToMonitorComputationDialog();;
}
});
FieldLabel monitorComputationLabel = new FieldLabel(
monitorComputationBtn, "Link to monitor the computation");
monitorComputationLabel.setLabelWidth(180);
vert.add(monitorComputationLabel, new VerticalLayoutData(-1, -1,
new Margins(0)));
progressBar = new ProgressBar();
progressBar.updateProgress(0, "Starting...");
vert.add(progressBar, new VerticalLayoutData(1, -1, new Margins(20)));
@ -138,6 +154,12 @@ public class ComputationStatusPanel extends SimpleContainer {
computationId);
equivalentRequestDialog.show();
}
private void showLinkToMonitorComputationDialog() {
LinkToMonitorComputationDialog linkToMonitorComputDialogDialog = new LinkToMonitorComputationDialog(
computationId);
linkToMonitorComputDialogDialog.show();
}
private void cancelComputation() {
CancelComputationExecutionRequestEvent event = new CancelComputationExecutionRequestEvent(

View File

@ -35,12 +35,12 @@ public class EquivalentRequestDialog extends Dialog {
}
private void create() {
TextArea equivalentRequestArea = new TextArea();
equivalentRequestArea.setHeight(200);
equivalentRequestArea.setWidth(640);
equivalentRequestArea.setValue(computationId.getEquivalentRequest());
equivalentRequestArea.setReadOnly(true);
add(equivalentRequestArea);
TextArea infoArea = new TextArea();
infoArea.setHeight(200);
infoArea.setWidth(640);
infoArea.setValue(computationId.getEquivalentRequest());
infoArea.setReadOnly(true);
add(infoArea);
}
}

View File

@ -0,0 +1,48 @@
package org.gcube.portlets.user.dataminermanager.client.experiments;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.Dialog;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.form.TextArea;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class LinkToMonitorComputationDialog extends Dialog {
private ComputationId computationId;
public LinkToMonitorComputationDialog(ComputationId computationId) {
super();
Log.debug("LinkToMonitorComputationDialog: " + computationId);
this.computationId = computationId;
init();
create();
}
private void init() {
setModal(true);
setClosable(true);
setHeadingText("Link To Monitor The Computation");
setBodyBorder(true);
setHideOnButtonClick(true);
setPredefinedButtons(PredefinedButton.CLOSE);
getButtonBar().setPack(BoxLayoutPack.CENTER);
}
private void create() {
TextArea infoArea = new TextArea();
infoArea.setHeight(200);
infoArea.setWidth(640);
infoArea.setValue(computationId.getUrlId());
infoArea.setReadOnly(true);
add(infoArea);
}
}

View File

@ -7,6 +7,7 @@ import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.ComputationReadyEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionEvent;
import org.gcube.portlets.user.dataminermanager.client.info.ServiceInfoPanel;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import com.allen_sauer.gwt.log.client.Log;
@ -25,6 +26,7 @@ public class WorkflowPanel extends TabPanel {
private ComputationExecutionPanel computationExecutionPanel;
private ComputationPanel computationPanel;
private ServiceInfoPanel environmentPanel;
/**
*
@ -66,6 +68,13 @@ public class WorkflowPanel extends TabPanel {
.folderExplore());
computationExecutionPanel = new ComputationExecutionPanel();
add(computationExecutionPanel, tabComputationPanelItemConf);
TabItemConfig tabEnvironmentPanelItemConf = new TabItemConfig(
"Service Info", false);
tabEnvironmentPanelItemConf.setIcon(DataMinerManager.resources
.folderExplore());
environmentPanel = new ServiceInfoPanel();
add(environmentPanel, tabEnvironmentPanelItemConf);
setActiveWidget(computationPanel);
}

View File

@ -0,0 +1,48 @@
package org.gcube.portlets.user.dataminermanager.client.info;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceInfoData implements Serializable {
private static final long serialVersionUID = 4732143678328978038L;
private String key;
private String value;
public ServiceInfoData() {
super();
}
public ServiceInfoData(String key, String value) {
super();
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "ServiceInfoData [key=" + key + ", value=" + value + "]";
}
}

View File

@ -0,0 +1,22 @@
package org.gcube.portlets.user.dataminermanager.client.info;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author Giancarlo Panichi
*
*
*/
public interface ServiceInfoDataProperties extends PropertyAccess<ServiceInfoData> {
@Path("key")
ModelKeyProvider<ServiceInfoData> id();
ValueProvider<ServiceInfoData, String> key();
ValueProvider<ServiceInfoData, String> value();
}

View File

@ -0,0 +1,183 @@
package org.gcube.portlets.user.dataminermanager.client.info;
import java.util.ArrayList;
import java.util.List;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.ServiceInfoEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ServiceInfoRequestEvent;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ServiceInfoPanel extends FramedPanel {
private static final ServiceInfoDataProperties props = GWT.create(ServiceInfoDataProperties.class);
private VerticalLayoutContainer v;
private VerticalLayoutContainer environmentVBox;
public ServiceInfoPanel() {
super();
Log.debug("ServiceInfoPanel");
init();
create();
bind();
EventBusProvider.INSTANCE.fireEvent(new ServiceInfoRequestEvent());
}
private void init() {
setItemId("ServiceInfoPanel");
forceLayoutOnResize = true;
setBodyBorder(false);
setBorders(false);
setBodyStyle("backgroundColor:white;");
setHeaderVisible(false);
setResize(true);
setHeadingText("Service Info");
setBodyStyle("backgroundColor:white;");
}
private void create() {
try {
v = new VerticalLayoutContainer();
v.setScrollMode(ScrollMode.AUTO);
add(v);
createView();
forceLayout();
} catch (Throwable e) {
Log.error("Error creating ServiceInfoPanel: " + e.getLocalizedMessage(), e);
}
}
private void bind() {
EventBusProvider.INSTANCE.addHandler(ServiceInfoEvent.TYPE, new ServiceInfoEvent.ServiceInfoEventHandler() {
@Override
public void onRequest(ServiceInfoEvent event) {
Log.debug("Catch ServiceInfoEvent");
showServiceInfo(event.getServiceInfo());
}
});
}
private void createView() {
SimpleContainer sectionTitle = new SimpleContainer();
// title
HtmlLayoutContainer title = new HtmlLayoutContainer(
"<center style='font-size:16px;font-weight:bold;'>Service Info</center>");
sectionTitle.add(title, new MarginData());
sectionTitle.getElement().getStyle().setMarginRight(20, Unit.PX);
// v.add(sectionTitle, new VerticalLayoutData(1, -1, new
// Margins(0)));
v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(10)));
FieldSet environmentFieldSet = environmentView();
v.add(environmentFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
}
private FieldSet environmentView() {
try {
environmentVBox = new VerticalLayoutContainer();
FieldSet configurationFieldSet = new FieldSet();
configurationFieldSet.setHeadingText("Environment");
configurationFieldSet.setCollapsible(true);
configurationFieldSet.add(environmentVBox);
configurationFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
return configurationFieldSet;
} catch (Throwable e) {
Log.error("Error in ServiceInfoPanel in environment: " + e.getLocalizedMessage(), e);
throw e;
}
}
private void showServiceInfo(ServiceInfo serviceInfo) {
if (serviceInfo != null && serviceInfo.getServiceProperties() != null
&& !serviceInfo.getServiceProperties().isEmpty()) {
ArrayList<ServiceInfoData> serviceInfoDataList = new ArrayList<>();
for (String key : serviceInfo.getServiceProperties().keySet()) {
ServiceInfoData serviceInfoData = new ServiceInfoData(key, serviceInfo.getServiceProperties().get(key));
serviceInfoDataList.add(serviceInfoData);
}
Grid<ServiceInfoData> grid = createInfoGrid(serviceInfoDataList);
environmentVBox.add(grid, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4)));
} else {
HtmlLayoutContainer emptyInfoContainer = new HtmlLayoutContainer(
"<div class='service-property'><p>No Info Available.</p></div>");
environmentVBox.add(emptyInfoContainer, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4)));
}
forceLayout();
}
private Grid<ServiceInfoData> createInfoGrid(ArrayList<ServiceInfoData> serviceInfoDataList) {
ColumnConfig<ServiceInfoData, String> keyCol = new ColumnConfig<ServiceInfoData, String>(props.key(), 100,
"Key");
ColumnConfig<ServiceInfoData, String> valueCol = new ColumnConfig<ServiceInfoData, String>(props.value(), 100,
"Value");
List<ColumnConfig<ServiceInfoData, ?>> columns = new ArrayList<ColumnConfig<ServiceInfoData, ?>>();
columns.add(keyCol);
columns.add(valueCol);
ColumnModel<ServiceInfoData> cm = new ColumnModel<ServiceInfoData>(columns);
ListStore<ServiceInfoData> store = new ListStore<ServiceInfoData>(props.id());
store.addAll(serviceInfoDataList);
Grid<ServiceInfoData> grid = new Grid<ServiceInfoData>(store, cm);
grid.setAllowTextSelection(false);
grid.getView().setAutoFill(true);
grid.getView().setAutoExpandColumn(valueCol);
grid.getView().setEmptyText("No info retrieved");
grid.setAllowTextSelection(true);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.setBorders(false);
grid.setColumnReordering(false);
// Stage manager, turn on state management
grid.setStateful(true);
grid.setStateId("gridServiceInfoData");
return grid;
}
}

View File

@ -87,6 +87,9 @@ public interface Resources extends ClientBundle {
@Source("download.png")
ImageResource download();
@Source("page-white.png")
ImageResource pageWhite();
@Source("show.png")
ImageResource netcdf();

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

View File

@ -10,6 +10,7 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
@ -54,4 +55,6 @@ public interface DataMinerPortletService extends RemoteService {
public ItemDescription getItemDescription(String itemId) throws ServiceException;
public ServiceInfo getServiceInfo() throws ServiceException;
}

View File

@ -10,6 +10,7 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;
@ -57,5 +58,7 @@ public interface DataMinerPortletServiceAsync {
void cancelComputation(ItemDescription itemDescription, AsyncCallback<String> asyncCallback);
void getItemDescription(String itemId, AsyncCallback<ItemDescription> asyncCallback);
void getServiceInfo(AsyncCallback<ServiceInfo> asyncCallback);
}

View File

@ -13,6 +13,9 @@ import com.google.gwt.user.client.Window;
import com.sencha.gxt.core.client.dom.XDOM;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@ -38,7 +41,7 @@ public class FileViewer extends SimpleContainer {
*/
public FileViewer(ComputationId computationId, FileResource fileResource) {
super();
GWT.log("FileViewer: [computationId="+computationId+", fileResource="+fileResource+"]");
GWT.log("FileViewer: [computationId=" + computationId + ", fileResource=" + fileResource + "]");
this.fileResource = fileResource;
// this.computationId = computationId;
init();
@ -56,17 +59,28 @@ public class FileViewer extends SimpleContainer {
HtmlLayoutContainer fileNameHtml = new HtmlLayoutContainer("<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName).toSafeHtml().asString() + "</p></div>");
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton downloadBtn = new TextButton("Download File");
downloadBtn.setIcon(DataMinerManager.resources.download());
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
TextButton showFileButton = new TextButton("Show");
showFileButton.setIcon(DataMinerManager.resources.pageWhite());
showFileButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
GWT.log("Download File url: "+fileUrl);
showFileCreate();
}
});
TextButton downloadButton = new TextButton("Download");
downloadButton.setIcon(DataMinerManager.resources.download());
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
GWT.log("Download File url: " + fileUrl);
Window.open(fileUrl, fileName, "");
}
});
TextButton netcdfButton = new TextButton("");
netcdfButton.setIcon(DataMinerManager.resources.netcdf());
netcdfButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -77,13 +91,41 @@ public class FileViewer extends SimpleContainer {
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
if (fileResource.isNetcdf()) {
lc.add(netcdfButton, new VerticalLayoutData(-1, -1, new Margins(0)));
HBoxLayoutContainer buttonsContainer = new HBoxLayoutContainer();
buttonsContainer.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
BoxLayoutData buttonBoxLayoutData = new BoxLayoutData(new Margins(2, 2, 2, 2));
// HorizontalLayoutData buttonBoxLayoutData = new
// HorizontalLayoutData(-1, -1, new Margins(2));
if (fileName != null && !fileName.isEmpty()) {
String fileNameLowerCase = fileName.toLowerCase();
if (fileNameLowerCase.endsWith(".html") || fileNameLowerCase.endsWith(".htm")
|| fileNameLowerCase.endsWith(".log") || fileNameLowerCase.endsWith(".json")
|| fileNameLowerCase.endsWith(".txt")) {
buttonsContainer.add(showFileButton, buttonBoxLayoutData);
}
}
buttonsContainer.add(downloadButton, buttonBoxLayoutData);
if (fileResource.isNetcdf()) {
buttonsContainer.add(netcdfButton, buttonBoxLayoutData);
}
lc.add(buttonsContainer);
add(lc);
}
private void showFileCreate() {
if (fileResource != null && fileResource.getUrl() != null && !fileResource.getUrl().isEmpty()) {
GWT.log("ShowFileCreate");
ShowFileDialog showFileDialog = new ShowFileDialog(fileResource.getUrl());
showFileDialog.setZIndex(XDOM.getTopZIndex());
showFileDialog.show();
}
}
private void showNetCDFFile() {
if (fileResource != null && fileResource.getUrl() != null && !fileResource.getUrl().isEmpty()
&& fileResource.isNetcdf()) {

View File

@ -0,0 +1,82 @@
package org.gcube.portlets.user.dataminermanager.client.widgets;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.ui.Frame;
import com.sencha.gxt.widget.core.client.Dialog;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/**
*
* Simple file show dialog
*
* @author Giancarlo Panichi
*
*
*/
public class ShowFileDialog extends Dialog {
private String url;
private Frame frame;
public ShowFileDialog(String url) {
super();
this.url = url;
init();
create();
}
private void init() {
setWidth("640px");
setHeight("480px");
setResizable(true);
setHeadingText("View");
setModal(true);
setMaximizable(true);
setPredefinedButtons(PredefinedButton.CLOSE);
setButtonAlign(BoxLayoutPack.CENTER);
getButtonBar();
}
private void create() {
/*
* VerticalLayoutContainer vc = new VerticalLayoutContainer();
*
* HtmlLayoutContainer propertyHtmlContainer = new HtmlLayoutContainer(
* "<div><p><object type='text/html' width='640' height='480' data='" +
* url + "'></object></p></div>");
*
* vc.add(propertyHtmlContainer, new VerticalLayoutData(-1, -1, new
* Margins(0)));
*
* add(vc);
*/
VerticalLayoutContainer vc = new VerticalLayoutContainer();
vc.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
manageResize(event);
}
});
frame = new Frame(url+"?content-disposition=inline");
frame.getElement().setAttribute("style", "margin:auto;");
frame.getElement().getStyle().setBorderWidth(0, Unit.PX);
frame.getElement().getStyle().setBackgroundColor("white");
vc.add(frame, new VerticalLayoutData(-1,-1));
add(vc);
}
private void manageResize(ResizeEvent event){
frame.setHeight(String.valueOf(event.getHeight())+"px");
frame.setWidth(String.valueOf(event.getWidth())+"px");
forceLayout();
}
}

View File

@ -3,16 +3,28 @@
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name="com.google.gwt.resources.Resources" />
<!-- <inherits name="com.google.gwt.i18n.I18N" /> -->
<!-- <inherits name='com.extjs.gxt.ui.GXT' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- GXT Theme -->
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue' /> -->
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
<!-- Be sure to include Neptunes gxt-theme-neptune.jar in the classpath -->
<!-- <inherits name='com.sencha.gxt.theme.neptune.Theme' /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!-- Debug CSS style <set-configuration-property name="CssResource.style"
value="pretty" /> -->
<!-- Debug CSS style -->
<set-configuration-property name="CssResource.style"
value="pretty" />
<inherits name='org.gcube.portal.clientcontext.GCubeClientContext' />

View File

@ -21,6 +21,7 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
@ -363,4 +364,24 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public ServiceInfo getServiceInfo() throws ServiceException {
try {
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
logger.debug("GetServiceInfo()");
ServiceInfo serviceInfo = smClient.getServiceInfo();
return serviceInfo;
} catch (ServiceException e) {
logger.error(e.getLocalizedMessage(),e);
throw e;
} catch (Throwable e) {
logger.error("Error retrieving Service Info: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

View File

@ -17,8 +17,8 @@ public class Constants {
public static final String DATA_MINER_OPERATOR_ID = "OperatorId";
public static final String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public final static String DEFAULT_TOKEN = "";
public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public static final String DEFAULT_TOKEN = "";
public static final String DEFAULT_ROLE = "OrganizationMember";

View File

@ -3,16 +3,28 @@
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name="com.google.gwt.resources.Resources" />
<!-- <inherits name="com.google.gwt.i18n.I18N" /> -->
<!-- <inherits name='com.extjs.gxt.ui.GXT' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- GXT Theme -->
<!-- <inherits name='com.sencha.gxt.theme.blue.Blue' /> -->
<!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
<!-- Be sure to include Neptunes gxt-theme-neptune.jar in the classpath -->
<!-- <inherits name='com.sencha.gxt.theme.neptune.Theme' /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!-- Debug CSS style <set-configuration-property name="CssResource.style"
value="pretty" /> -->
<!-- Debug CSS style -->
<set-configuration-property name="CssResource.style"
value="pretty" />
<inherits name='org.gcube.portal.clientcontext.GCubeClientContext' />
@ -52,7 +64,6 @@
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<source path='client' />
<source path='shared' />

View File

@ -481,3 +481,7 @@
width: 616px !important;
resize: none;
}
.grid-service-info-style {
font-size:13px;
}

View File

@ -6,7 +6,7 @@
<link type="text/css" rel="stylesheet" href="dataminermanager/reset.css">
<link type="text/css" rel="stylesheet" href="DataMinerManager.css">
<link type="text/css" rel="stylesheet" href="gxt/css/gxt-all.css">
<link type="text/css" rel="stylesheet" href="gxt/css/gxt-all.css">
<link type="text/css" rel="stylesheet" href="dataminermanager/css/ol.css">
<title>Data Miner Manager</title>

View File

@ -12,7 +12,7 @@
type="text/css">
<link rel="stylesheet"
href="<%=request.getContextPath()%>/gxt/css/gxt-all.css"
type="text/css">
type="text/css">
<link rel="stylesheet"
href="<%=request.getContextPath()%>/dataminermanager/css/ol.css"
type="text/css">

View File

@ -16,8 +16,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import junit.framework.TestCase;
import org.apache.commons.codec.binary.Base64;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.data.analysis.dataminermanagercl.server.is.InformationSystemUtils;
@ -26,6 +24,8 @@ import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
/**
*
* @author Giancarlo Panichi
@ -34,8 +34,7 @@ import org.slf4j.LoggerFactory;
*/
public class TestDataMinerService extends TestCase {
private static Logger logger = LoggerFactory
.getLogger(TestDataMinerService.class);
private static Logger logger = LoggerFactory.getLogger(TestDataMinerService.class);
private String wpsToken;
private String wpsUser;
@ -43,70 +42,64 @@ public class TestDataMinerService extends TestCase {
private String scope;
private void retrieveServicesInfo() throws Exception {
logger.info("Use test user");
// Remove comment for Test
wpsUser = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
ServiceCredentials serviceCredentials=new ServiceCredentials();
serviceCredentials.setUserName(wpsUser);
serviceCredentials.setScope(scope);
List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE);
/*
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
* userRoles.add("VRE-Manager");
*/
try {
wpsToken = authorizationService().generateUserToken(
new UserInfo(serviceCredentials.getUserName(), userRoles),
serviceCredentials.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new Exception("Error generating the token for test: "
+ e.getLocalizedMessage());
}
serviceCredentials.setToken(wpsToken);
logger.info("Use test user");
List<String> serviceAddress = InformationSystemUtils
.retrieveServiceAddress(
Constants.DATAMINER_SERVICE_CATEGORY,
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
logger.debug("Service Address retrieved:" + serviceAddress);
if (serviceAddress == null || serviceAddress.size() < 1) {
logger.error("No DataMiner service address available!");
throw new Exception("No DataMiner service address available!");
} else {
logger.info("DataMiner service address found: "
+ serviceAddress.get(0));
wpsProcessingServlet = serviceAddress.get(0);
// Remove comment for Test
wpsUser = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
ServiceCredentials serviceCredentials = new ServiceCredentials();
serviceCredentials.setUserName(wpsUser);
serviceCredentials.setScope(scope);
List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE);
/*
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
* userRoles.add("VRE-Manager");
*/
try {
wpsToken = authorizationService().generateUserToken(
new UserInfo(serviceCredentials.getUserName(), userRoles), serviceCredentials.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: " + e.getLocalizedMessage(), e);
throw new Exception("Error generating the token for test: " + e.getLocalizedMessage(), e);
}
serviceCredentials.setToken(wpsToken);
String serviceAddress = InformationSystemUtils.retrieveServiceAddress(Constants.DATAMINER_SERVICE_CATEGORY,
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
logger.debug("Service Address retrieved:" + serviceAddress);
if (serviceAddress == null || serviceAddress.isEmpty()) {
logger.error("No DataMiner service address available!");
throw new Exception("No DataMiner service address available!");
} else {
logger.info("DataMiner service address found: " + serviceAddress);
wpsProcessingServlet = serviceAddress;
}
}
}
public void testExecuteProcess() {
if(Constants.TEST_ENABLE){
if (Constants.TEST_ENABLE) {
executeProcess();
} else {
assertTrue(true);
}
}
private void executeProcess(){
private void executeProcess() {
try {
retrieveServicesInfo();
String urlString=wpsProcessingServlet;
String urlString = wpsProcessingServlet;
logger.debug("RetrieveDataViaPost(): " + urlString);
String authString = wpsUser + ":" + wpsToken;
@ -123,9 +116,9 @@ public class TestDataMinerService extends TestCase {
conn.setRequestProperty("Content-Type", "text/xml");
conn.setDoOutput(true);
OutputStream output = conn.getOutputStream();
Path currentPath=Paths.get(".");
logger.info("CurrentPath:"+currentPath.toAbsolutePath().toString());
Path currentPath = Paths.get(".");
logger.info("CurrentPath:" + currentPath.toAbsolutePath().toString());
Files.copy(Paths.get("TestDataMinerServiceDBSCAN.xml"), output);
InputStream input = null;
@ -136,24 +129,23 @@ public class TestDataMinerService extends TestCase {
input = conn.getInputStream();
}
BufferedReader r = new BufferedReader(new InputStreamReader(input,
StandardCharsets.UTF_8));
BufferedReader r = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
logger.info("Response:");
String str = null;
while ((str = r.readLine()) != null) {
logger.info(str);
}
logger.info("End Response!");
assertTrue(true);
} catch (Exception e) {
logger.debug(e.getLocalizedMessage());
e.printStackTrace();
fail(e.getLocalizedMessage());
}
}

View File

@ -0,0 +1,98 @@
package org.gcube.portlets.user.dataminermanager;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.data.analysis.dataminermanagercl.server.is.InformationSystemUtils;
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class TestInformationSystemRequests extends TestCase {
private static Logger logger = LoggerFactory.getLogger(TestInformationSystemRequests.class);
private String wpsToken;
private String wpsUser;
private String scope;
private void retrieveServicesInfo() throws Exception {
logger.info("Use test user");
wpsUser = Constants.DEFAULT_USER;
scope = Constants.DEFAULT_SCOPE;
ServiceCredentials serviceCredentials = new ServiceCredentials();
serviceCredentials.setUserName(wpsUser);
serviceCredentials.setScope(scope);
List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE);
try {
wpsToken = authorizationService().generateUserToken(
new UserInfo(serviceCredentials.getUserName(), userRoles), serviceCredentials.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: " + e.getLocalizedMessage(), e);
throw new Exception("Error generating the token for test: " + e.getLocalizedMessage(), e);
}
serviceCredentials.setToken(wpsToken);
String serviceAddress = InformationSystemUtils.retrieveServiceAddress(Constants.DATAMINER_SERVICE_CATEGORY,
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
logger.debug("Service Address retrieved:" + serviceAddress);
if (serviceAddress == null || serviceAddress.isEmpty()) {
logger.error("No DataMiner service address available!");
throw new Exception("No DataMiner service address available!");
} else {
logger.info("DataMiner service address found: " + serviceAddress);
}
Map<String, String> serviceProperties = InformationSystemUtils.retrieveServiceProperties(
Constants.DATAMINER_SERVICE_CATEGORY, Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
logger.debug("Service Properties retrieved:" + serviceProperties);
if (serviceProperties == null || serviceProperties.isEmpty()) {
logger.error("No DataMiner service properties available!");
throw new Exception("No DataMiner service properties available!");
} else {
logger.info("DataMiner service properties found: ");
for (String key : serviceProperties.keySet()) {
logger.debug("Property: " + key + "=" + serviceProperties.get(key));
}
}
}
public void testExecuteProcess() {
if (Constants.TEST_ENABLE) {
try {
retrieveServicesInfo();
assertTrue(true);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage(), e);
assertTrue(false);
}
} else {
assertTrue(true);
}
}
}