ref 8541: StatisticalAlgorithmImporter - Support Java 8 compatibility

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

Updated to support Java 8 compatibility

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@148631 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-05-12 16:26:05 +00:00
parent fea1fdb2bc
commit f8aaa60efb
115 changed files with 670 additions and 752 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/statistical-algorithms-importer-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.5.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/statistical-algorithms-importer-1.6.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,8 +1,12 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-6-0" date="2017-06-12">
<Change>Support Java 8 compatibility [ticket #8541]</Change>
</Changeset>
<Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15"> <Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15">
<Change>Updated PortalContext support[ticket #6279]</Change> <Change>Updated PortalContext support[ticket #6279]</Change>
<Change>Added support only for file data type in output <Change>Added support only for file data type in output
parameter[ticket #7120]</Change> parameter[ticket #7120]
</Change>
</Changeset> </Changeset>
<Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01"> <Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01">
<Change>Updated Storage support</Change> <Change>Updated Storage support</Change>

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>statistical-algorithms-importer</artifactId> <artifactId>statistical-algorithms-importer</artifactId>
<version>1.5.0-SNAPSHOT</version> <version>1.6.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
@ -42,7 +42,11 @@
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<configDirectory>config</configDirectory> <configDirectory>config</configDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<!-- Java -->
<maven.compiler.source>1.7</maven.compiler.source>
<!-- GWT configuration --> <!-- GWT configuration -->
<gwtVersion>2.6.1</gwtVersion> <gwtVersion>2.6.1</gwtVersion>
<gwtLogVersion>3.3.2</gwtLogVersion> <gwtLogVersion>3.3.2</gwtLogVersion>

View File

@ -4,8 +4,8 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface CommonMessages extends Messages { public interface CommonMessages extends Messages {

View File

@ -15,8 +15,8 @@ import com.sencha.gxt.widget.core.client.container.Viewport.ViewportAppearance;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class PortalViewport extends SimpleContainer { public class PortalViewport extends SimpleContainer {
@ -24,13 +24,12 @@ public class PortalViewport extends SimpleContainer {
protected int rightScrollBarSize = 17; protected int rightScrollBarSize = 17;
protected boolean enableScroll; protected boolean enableScroll;
/** /**
* Creates a viewport layout container with the default appearance. * Creates a viewport layout container with the default appearance.
*/ */
public PortalViewport() { public PortalViewport() {
this(GWT.<ViewportAppearance> create(ViewportAppearance.class)); this(GWT.<ViewportAppearance>create(ViewportAppearance.class));
} }
/** /**
@ -45,15 +44,14 @@ public class PortalViewport extends SimpleContainer {
SafeHtmlBuilder sb = new SafeHtmlBuilder(); SafeHtmlBuilder sb = new SafeHtmlBuilder();
appearance.render(sb); appearance.render(sb);
XElement element=XDOM.create(sb.toSafeHtml()); XElement element = XDOM.create(sb.toSafeHtml());
setElement((Element)element); setElement((Element) element);
monitorWindowResize = true; monitorWindowResize = true;
forceLayoutOnResize = true; forceLayoutOnResize = true;
getFocusSupport().setIgnore(false); getFocusSupport().setIgnore(false);
resize(); resize();
} catch (Exception e) { } catch (Exception e) {
Log.error("PortalViewport: constructor error " Log.error("PortalViewport: constructor error " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
} }
} }
@ -102,21 +100,19 @@ public class PortalViewport extends SimpleContainer {
protected void resize() { protected void resize() {
int viewWidth; int viewWidth;
if(enableScroll){ if (enableScroll) {
viewWidth= calculateWidth() - rightScrollBarSize; viewWidth = calculateWidth() - rightScrollBarSize;
} else { } else {
viewWidth = calculateWidth(); viewWidth = calculateWidth();
} }
int viewHeight = calculateHeight(); int viewHeight = calculateHeight();
Log.info("AM resize viewWidth: " + viewWidth + " viewHeight: " Log.info("AM resize viewWidth: " + viewWidth + " viewHeight: " + viewHeight + " clientWidth: "
+ viewHeight + " clientWidth: " + Window.getClientWidth() + Window.getClientWidth() + " clientHeight: " + Window.getClientHeight());
+ " clientHeight: " + Window.getClientHeight());
try { try {
setPixelSize(viewWidth, viewHeight); setPixelSize(viewWidth, viewHeight);
} catch (Exception e) { } catch (Exception e) {
Log.error("PortalViewport: error in resize() at setPixelSize " Log.error("PortalViewport: error in resize() at setPixelSize " + e.getLocalizedMessage());
+ e.getLocalizedMessage());
} }
} }
@ -127,52 +123,20 @@ public class PortalViewport extends SimpleContainer {
protected void onWindowResize(int width, int height) { protected void onWindowResize(int width, int height) {
int viewWidth = calculateWidth(); int viewWidth = calculateWidth();
int viewHeight = calculateHeight(); int viewHeight = calculateHeight();
Log.trace("AM onWindowResize viewWidth: " + viewWidth Log.trace("AM onWindowResize viewWidth: " + viewWidth + " viewHeight: " + viewHeight + " clientWidth: "
+ " viewHeight: " + viewHeight + " clientWidth: " + Window.getClientWidth() + " clientHeight: " + Window.getClientHeight());
+ Window.getClientWidth() + " clientHeight: "
+ Window.getClientHeight());
setPixelSize(viewWidth, viewHeight); setPixelSize(viewWidth, viewHeight);
} }
/**
* Update window size
*/
/*
* public void resize(){
*
* RootPanel workspace = RootPanel.get("tdp");
*
* int topBorder = workspace.getAbsoluteTop();
*
* int leftBorder = workspace.getAbsoluteLeft();
*
* int footer = 85;
*
* int rootHeight = (Window.getClientHeight() - topBorder - 4 - footer);// -
* ((footer == null)?0:(footer.getOffsetHeight()-15));
*
* if (rootHeight < 550) rootHeight = 550;
*
* int rootWidth = Window.getClientWidth() - 2* leftBorder; //-
* rightScrollBar;
*
* System.out.println("New workspace dimension Height: "+rootHeight+" Width: "
* +rootWidth);
*
* this.setHeight(rootHeight); this.setWidth(rootWidth); }
*/
protected int calculateWidth() { protected int calculateWidth() {
int leftBorder = getAbsoluteLeft(); int leftBorder = getAbsoluteLeft();
Log.info("AM width: " Log.info("AM width: " + String.valueOf(Window.getClientWidth() - 2 * leftBorder));
+ String.valueOf(Window.getClientWidth() - 2 * leftBorder));
return Window.getClientWidth() - 2 * leftBorder; return Window.getClientWidth() - 2 * leftBorder;
} }
protected int calculateHeight() { protected int calculateHeight() {
int topBorder = getAbsoluteTop(); int topBorder = getAbsoluteTop();
Log.info("AM height: " Log.info("AM height: " + String.valueOf(Window.getClientHeight() - topBorder - 34));
+ String.valueOf(Window.getClientHeight() - topBorder - 34));
return Window.getClientHeight() - topBorder - 34; return Window.getClientHeight() - topBorder - 34;
} }

View File

@ -22,8 +22,8 @@ import com.sencha.gxt.widget.core.client.container.Viewport;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporter implements EntryPoint { public class StatAlgoImporter implements EntryPoint {

View File

@ -40,8 +40,8 @@ import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterController { public class StatAlgoImporterController {

View File

@ -9,8 +9,8 @@ import com.google.gwt.regexp.shared.RegExp;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeParser { public class CodeParser {

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Main Code Set Event * Main Code Set Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class DeleteItemEvent extends public class DeleteItemEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Import Code Event * Import Code Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ImportCodeEvent extends public class ImportCodeEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Input Save Ready Event * Input Save Ready Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputReadyEvent extends public class InputReadyEvent extends

View File

@ -9,8 +9,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Input Save Event * Input Save Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputRequestEvent extends public class InputRequestEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Main Code Set Event * Main Code Set Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class MainCodeSetEvent extends public class MainCodeSetEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Main Code Set Event * Main Code Set Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class NewMainCodeEvent extends public class NewMainCodeEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Input Save Event * Input Save Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class NewSelectedRowsVariableEvent public class NewSelectedRowsVariableEvent

View File

@ -12,8 +12,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Project Status Event * Project Status Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ProjectStatusEvent extends public class ProjectStatusEvent extends

View File

@ -10,8 +10,8 @@ import com.google.gwt.event.shared.HasHandlers;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class SessionExpiredEvent extends GwtEvent<SessionExpiredEvent.SessionExpiredEventHandler> { public class SessionExpiredEvent extends GwtEvent<SessionExpiredEvent.SessionExpiredEventHandler> {

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* Show Code Event * Show Code Event
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ShowCodeEvent extends public class ShowCodeEvent extends

View File

@ -9,8 +9,8 @@ import com.google.gwt.event.shared.HasHandlers;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterRibbonEvent extends public class StatAlgoImporterRibbonEvent extends

View File

@ -11,8 +11,8 @@ import com.google.gwt.event.shared.HasHandlers;
* *
* *
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ControllerRequestEvent extends public class ControllerRequestEvent extends

View File

@ -4,8 +4,8 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface CodeEditMessages extends Messages { public interface CodeEditMessages extends Messages {

View File

@ -50,8 +50,8 @@ import edu.ycp.cs.dh.acegwt.client.ace.AceSelectionListener;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeEditPanel extends ContentPanel { public class CodeEditPanel extends ContentPanel {

View File

@ -46,8 +46,8 @@ import com.sencha.gxt.widget.core.client.menu.MenuItem;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeViewerPanel extends ContentPanel { public class CodeViewerPanel extends ContentPanel {

View File

@ -11,8 +11,8 @@ import com.sencha.gxt.widget.core.client.container.SimpleContainer;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class MainDataPanel extends SimpleContainer { public class MainDataPanel extends SimpleContainer {

View File

@ -5,30 +5,33 @@ import com.sencha.gxt.widget.core.client.box.AutoProgressMessageBox;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterMonitor extends AutoProgressMessageBox { public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
public StatAlgoImporterMonitor(){ public StatAlgoImporterMonitor() {
super("Waiting", "Please wait..."); super("Waiting", "Please wait...");
create(); create();
} }
/** /**
* *
* @param headingHtml * @param headingHtml
* head
* @param messageHtml * @param messageHtml
* message
*/ */
public StatAlgoImporterMonitor(SafeHtml headingHtml, SafeHtml messageHtml) { public StatAlgoImporterMonitor(SafeHtml headingHtml, SafeHtml messageHtml) {
super(headingHtml, messageHtml); super(headingHtml, messageHtml);
create(); create();
} }
/** /**
* *
* @param headingHtml * @param headingHtml
* head
*/ */
public StatAlgoImporterMonitor(SafeHtml headingHtml) { public StatAlgoImporterMonitor(SafeHtml headingHtml) {
super(headingHtml); super(headingHtml);
@ -38,7 +41,9 @@ public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
/** /**
* *
* @param headingHtml * @param headingHtml
* head
* @param messageHtml * @param messageHtml
* message
*/ */
public StatAlgoImporterMonitor(String headingHtml, String messageHtml) { public StatAlgoImporterMonitor(String headingHtml, String messageHtml) {
super(headingHtml, messageHtml); super(headingHtml, messageHtml);
@ -48,6 +53,7 @@ public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
/** /**
* *
* @param headingHtml * @param headingHtml
* head
*/ */
public StatAlgoImporterMonitor(String headingHtml) { public StatAlgoImporterMonitor(String headingHtml) {
super(headingHtml); super(headingHtml);
@ -59,7 +65,5 @@ public class StatAlgoImporterMonitor extends AutoProgressMessageBox {
auto(); auto();
show(); show();
} }
} }

View File

@ -35,8 +35,8 @@ import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ProjectManager { public class ProjectManager {

View File

@ -10,7 +10,7 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface CodeDataProperties extends PropertyAccess<CodeData> { public interface CodeDataProperties extends PropertyAccess<CodeData> {

View File

@ -9,8 +9,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */

View File

@ -9,8 +9,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface GlobalVariablesProperties extends public interface GlobalVariablesProperties extends

View File

@ -9,8 +9,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */

View File

@ -10,8 +10,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface InputOutputVariablesProperties extends public interface InputOutputVariablesProperties extends

View File

@ -8,8 +8,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface InterpreterPackageInfoProperties extends public interface InterpreterPackageInfoProperties extends

View File

@ -8,8 +8,8 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface RequestedVREProperties extends PropertyAccess<RequestedVRE> { public interface RequestedVREProperties extends PropertyAccess<RequestedVRE> {

View File

@ -7,8 +7,8 @@ import com.google.gwt.resources.client.CssResource;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface SAIStyles extends CssResource { public interface SAIStyles extends CssResource {

View File

@ -10,8 +10,8 @@ import com.google.gwt.resources.client.ImageResource;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface StatAlgoImporterResources extends ClientBundle { public interface StatAlgoImporterResources extends ClientBundle {

View File

@ -5,7 +5,7 @@ import com.sencha.gxt.widget.core.client.ContentPanel;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class EmptyPanel extends ContentPanel { public class EmptyPanel extends ContentPanel {

View File

@ -28,8 +28,8 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class HomeToolBar { public class HomeToolBar {

View File

@ -4,8 +4,8 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface HomeToolBarMessages extends Messages { public interface HomeToolBarMessages extends Messages {

View File

@ -8,7 +8,7 @@ import com.sencha.gxt.widget.core.client.TabPanel;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterMenu extends TabPanel { public class StatAlgoImporterMenu extends TabPanel {

View File

@ -13,8 +13,8 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterRibbon { public class StatAlgoImporterRibbon {

View File

@ -6,7 +6,7 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface StatAlgoImporterRibbonMessages extends Messages { public interface StatAlgoImporterRibbonMessages extends Messages {

View File

@ -15,8 +15,8 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
@RemoteServiceRelativePath("statalgoimporterservice") @RemoteServiceRelativePath("statalgoimporterservice")
@ -26,6 +26,7 @@ public interface StatAlgoImporterService extends RemoteService {
* *
* @return UserInfo user inforamations * @return UserInfo user inforamations
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public UserInfo hello() throws StatAlgoImporterServiceException; public UserInfo hello() throws StatAlgoImporterServiceException;
@ -33,48 +34,37 @@ public interface StatAlgoImporterService extends RemoteService {
/** /**
* Get File Upload Monitor during the file upload operation in Import CSV * Get File Upload Monitor during the file upload operation in Import CSV
* *
* @return FileUploadMonitor * @return FileUploadMonitor file upload monitor
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public FileUploadMonitor getFileUploadMonitor() public FileUploadMonitor getFileUploadMonitor() throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
// Code // Code
public ArrayList<CodeData> getCode() public ArrayList<CodeData> getCode() throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public void createProjectOnWorkspace(ItemDescription itemDescription) public void createProjectOnWorkspace(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
// //
public Project setMainCode(ItemDescription itemDescription) public Project setMainCode(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public void addResourceToProject(ItemDescription itemDescription) public void addResourceToProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public Project deleteResourceOnProject(ItemDescription itemDescription) public Project deleteResourceOnProject(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public void saveProject(InputData inputData) public void saveProject(InputData inputData) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public Project openProjectOnWorkspace(ItemDescription newProjectFolder) public Project openProjectOnWorkspace(ItemDescription newProjectFolder) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public void saveCode(String code) throws StatAlgoImporterServiceException; public void saveCode(String code) throws StatAlgoImporterServiceException;
public void createSoftware(InputData inputData) public void createSoftware(InputData inputData) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public String getPublicLink(ItemDescription itemDescription) public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public Project restoreUISession(String value) public Project restoreUISession(String value) throws StatAlgoImporterServiceException;
throws StatAlgoImporterServiceException;
public Project setNewMainCode(ItemDescription itemDescription, public Project setNewMainCode(ItemDescription itemDescription, String code) throws StatAlgoImporterServiceException;
String code) throws StatAlgoImporterServiceException;
public void publishSoftware() throws StatAlgoImporterServiceException; public void publishSoftware() throws StatAlgoImporterServiceException;

View File

@ -17,8 +17,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface StatAlgoImporterServiceAsync { public interface StatAlgoImporterServiceAsync {
@ -26,43 +26,31 @@ public interface StatAlgoImporterServiceAsync {
public static StatAlgoImporterServiceAsync INSTANCE = (StatAlgoImporterServiceAsync) GWT public static StatAlgoImporterServiceAsync INSTANCE = (StatAlgoImporterServiceAsync) GWT
.create(StatAlgoImporterService.class); .create(StatAlgoImporterService.class);
/**
*
* @param callback
*/
void hello(AsyncCallback<UserInfo> callback); void hello(AsyncCallback<UserInfo> callback);
void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback); void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback);
void getCode(AsyncCallback<ArrayList<CodeData>> callback); void getCode(AsyncCallback<ArrayList<CodeData>> callback);
void createProjectOnWorkspace(ItemDescription itemDescription, void createProjectOnWorkspace(ItemDescription itemDescription, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void setMainCode(ItemDescription itemDescription,
AsyncCallback<Project> callback);
void addResourceToProject(ItemDescription itemDescription, void setMainCode(ItemDescription itemDescription, AsyncCallback<Project> callback);
AsyncCallback<Void> asyncCallback);
void saveProject(InputData inputData, void addResourceToProject(ItemDescription itemDescription, AsyncCallback<Void> asyncCallback);
AsyncCallback<Void> asyncCallback);
void deleteResourceOnProject(ItemDescription itemDescription, void saveProject(InputData inputData, AsyncCallback<Void> asyncCallback);
AsyncCallback<Project> asyncCallback);
void openProjectOnWorkspace(ItemDescription newProjectFolder, void deleteResourceOnProject(ItemDescription itemDescription, AsyncCallback<Project> asyncCallback);
AsyncCallback<Project> asyncCallback);
void openProjectOnWorkspace(ItemDescription newProjectFolder, AsyncCallback<Project> asyncCallback);
void saveCode(String code, AsyncCallback<Void> asyncCallback); void saveCode(String code, AsyncCallback<Void> asyncCallback);
void setNewMainCode(ItemDescription itemDescription, String code, void setNewMainCode(ItemDescription itemDescription, String code, AsyncCallback<Project> asyncCallback);
AsyncCallback<Project> asyncCallback);
void createSoftware(InputData inputData, AsyncCallback<Void> callback); void createSoftware(InputData inputData, AsyncCallback<Void> callback);
void getPublicLink(ItemDescription itemDescription, void getPublicLink(ItemDescription itemDescription, AsyncCallback<String> asyncCallback);
AsyncCallback<String> asyncCallback);
void restoreUISession(String value, AsyncCallback<Project> asyncCallback); void restoreUISession(String value, AsyncCallback<Project> asyncCallback);

View File

@ -14,8 +14,8 @@ import com.sencha.gxt.widget.core.client.container.MarginData;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ToolsPanel extends ContentPanel { public class ToolsPanel extends ContentPanel {

View File

@ -39,8 +39,8 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ExplorerProjectPanel extends ContentPanel { public class ExplorerProjectPanel extends ContentPanel {

View File

@ -60,8 +60,8 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class GlobalVariablesPanel extends ContentPanel { public class GlobalVariablesPanel extends ContentPanel {

View File

@ -59,8 +59,8 @@ import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputOutputVariablesPanel extends ContentPanel { public class InputOutputVariablesPanel extends ContentPanel {

View File

@ -7,7 +7,7 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface InputTypeMessages extends Messages { public interface InputTypeMessages extends Messages {

View File

@ -4,8 +4,8 @@ import com.google.gwt.i18n.client.Messages;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface InputVariableMessages extends Messages { public interface InputVariableMessages extends Messages {

View File

@ -13,8 +13,8 @@ import com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.Acco
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputVariablePanel extends ContentPanel { public class InputVariablePanel extends ContentPanel {

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum InputVariablePanelState { public enum InputVariablePanelState {

View File

@ -15,8 +15,8 @@ import com.sencha.gxt.widget.core.client.TabPanel;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputVariableTabPanel extends TabPanel { public class InputVariableTabPanel extends TabPanel {

View File

@ -48,8 +48,8 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InterpreterInfoPanel extends ContentPanel { public class InterpreterInfoPanel extends ContentPanel {

View File

@ -19,8 +19,8 @@ import com.sencha.gxt.widget.core.client.form.validator.RegExValidator;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ProjectInfoPanel extends ContentPanel { public class ProjectInfoPanel extends ContentPanel {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum ControllerRequestEventType { public enum ControllerRequestEventType {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum ImportCodeType { public enum ImportCodeType {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum ProjectStatusEventType { public enum ProjectStatusEventType {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum SessionExpiredType { public enum SessionExpiredType {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum StatAlgoImporterRibbonType { public enum StatAlgoImporterRibbonType {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.type;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum UIStateType { public enum UIStateType {

View File

@ -8,8 +8,8 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/** /**
* Dialog for Code Upload * Dialog for Code Upload
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeUploadDialog extends Window { public class CodeUploadDialog extends Window {

View File

@ -31,8 +31,8 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeUploadPanel extends FormPanel { public class CodeUploadPanel extends FormPanel {

View File

@ -4,8 +4,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ImportC
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ImportCodeDescription { public class ImportCodeDescription {

View File

@ -10,8 +10,8 @@ import com.sencha.gxt.widget.core.client.ProgressBar;
/** /**
* Updates a {@link ProgressBar} progress and text based on {@link FileUploadProgressListener} events. * Updates a {@link ProgressBar} progress and text based on {@link FileUploadProgressListener} events.
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class FileUploadProgressBarUpdater implements FileUploadProgressListener { public class FileUploadProgressBarUpdater implements FileUploadProgressListener {

View File

@ -8,8 +8,8 @@ import com.allen_sauer.gwt.log.client.Log;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class FileUploadProgressCardUpdater implements FileUploadProgressListener { public class FileUploadProgressCardUpdater implements FileUploadProgressListener {

View File

@ -3,30 +3,28 @@
*/ */
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress; package org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.progress;
/** /**
* Defines a listener for file upload progress. * Defines a listener for file upload progress.
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public interface FileUploadProgressListener { public interface FileUploadProgressListener {
/** /**
* Called when the operation is starting. * Called when the operation is starting.
*/ */
public void operationInitializing(); public void operationInitializing();
/** /**
* Called when there is a progress for the operation. * Called when there is a progress for the operation.
* @param elaborated the elaborated part. *
* @param elaborated
* the elaborated part.
*/ */
public void operationUpdate(float elaborated); public void operationUpdate(float elaborated);
/** /**
* Called when the operation is complete. * Called when the operation is complete.
*/ */
@ -34,8 +32,14 @@ public interface FileUploadProgressListener {
/** /**
* Called when the operation is failed. * Called when the operation is failed.
* @param caught the failure exception. *
* @param reason the failure reason. *
* @param caught
* error
* @param reason
* reason
* @param failureDetails
* details
*/ */
public void operationFailed(Throwable caught, String reason, String failureDetails); public void operationFailed(Throwable caught, String reason, String failureDetails);
} }

View File

@ -15,15 +15,14 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* *
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class FileUploadProgressUpdater extends Timer { public class FileUploadProgressUpdater extends Timer {
protected ArrayList<FileUploadProgressListener> listeners = new ArrayList<FileUploadProgressListener>(); protected ArrayList<FileUploadProgressListener> listeners = new ArrayList<FileUploadProgressListener>();
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -32,97 +31,87 @@ public class FileUploadProgressUpdater extends Timer {
Log.debug("requesting operation progress"); Log.debug("requesting operation progress");
StatAlgoImporterServiceAsync.INSTANCE.getFileUploadMonitor(new AsyncCallback<FileUploadMonitor>() { StatAlgoImporterServiceAsync.INSTANCE.getFileUploadMonitor(new AsyncCallback<FileUploadMonitor>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
cancel(); cancel();
Log.error("Error retrieving the operation state", caught); Log.error("Error retrieving the operation state", caught);
String message = getStack(caught); String message = getStack(caught);
fireOperationFailed(caught, "Failed getting operation updates", message); fireOperationFailed(caught, "Failed getting operation updates", message);
} }
public void onSuccess(FileUploadMonitor result) { public void onSuccess(FileUploadMonitor result) {
Log.info("retrieved FileUploadMonitor: "+result.getState()); Log.info("retrieved FileUploadMonitor: " + result.getState());
switch (result.getState()) { switch (result.getState()) {
case STARTED: case STARTED:
Log.debug("File Upload Started"); Log.debug("File Upload Started");
break; break;
case INPROGRESS: case INPROGRESS:
Log.debug("Progress: "+result.getElaboratedLenght()+" of "+result.getTotalLenght()); Log.debug("Progress: " + result.getElaboratedLenght() + " of " + result.getTotalLenght());
fireOperationUpdate(result.getPercentDone()); fireOperationUpdate(result.getPercentDone());
break; break;
case FAILED: case FAILED:
Log.debug("File Upload Failed"); Log.debug("File Upload Failed");
cancel(); cancel();
fireOperationFailed(new Throwable("File Upload Failed") ,result.getFailureReason(), result.getFailureDetails()); fireOperationFailed(new Throwable("File Upload Failed"), result.getFailureReason(),
result.getFailureDetails());
break; break;
case COMPLETED: case COMPLETED:
cancel(); cancel();
Log.debug("File Upload Completed"); Log.debug("File Upload Completed");
fireOperationComplete(); fireOperationComplete();
break; break;
default: default:
break; break;
} }
} }
}); });
} }
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
protected String getStack(Throwable e)
{
String message = e.getLocalizedMessage()+" -> <br>";
Throwable c = e.getCause(); Throwable c = e.getCause();
if (c!=null) message += getStack(c); if (c != null)
message += getStack(c);
return message; return message;
} }
protected void fireOperationInitializing() protected void fireOperationInitializing() {
{ for (FileUploadProgressListener listener : listeners)
for (FileUploadProgressListener listener:listeners) listener.operationInitializing(); listener.operationInitializing();
}
protected void fireOperationUpdate(float elaborated)
{
for (FileUploadProgressListener listener:listeners) listener.operationUpdate(elaborated);
} }
protected void fireOperationComplete() protected void fireOperationUpdate(float elaborated) {
{ for (FileUploadProgressListener listener : listeners)
for (FileUploadProgressListener listener:listeners) listener.operationComplete(); listener.operationUpdate(elaborated);
} }
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails) protected void fireOperationComplete() {
{ for (FileUploadProgressListener listener : listeners)
for (FileUploadProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails); listener.operationComplete();
} }
protected void fireOperationFailed(Throwable caught, String failure, String failureDetails) {
for (FileUploadProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
/** /**
* *
* @param listener * @param listener
* listener
*/ */
public void addListener(FileUploadProgressListener listener) public void addListener(FileUploadProgressListener listener) {
{
listeners.add(listener); listeners.add(listener);
} }
/** /**
* *
* @param listener * @param listener
* listener
*/ */
public void removeListener(FileUploadProgressListener listener) public void removeListener(FileUploadProgressListener listener) {
{
listeners.remove(listener); listeners.remove(listener);
} }
} }

View File

@ -5,8 +5,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class Format { public class Format {

View File

@ -4,8 +4,8 @@ import com.sencha.gxt.widget.core.client.box.MessageBox;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InfoMessageBox extends MessageBox { public class InfoMessageBox extends MessageBox {

View File

@ -11,8 +11,8 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class UtilsGXT3 { public class UtilsGXT3 {

View File

@ -33,8 +33,8 @@ import com.allen_sauer.gwt.log.client.Log;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class LocalUploadServlet extends HttpServlet { public class LocalUploadServlet extends HttpServlet {

View File

@ -11,10 +11,10 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
* @param <T> *
* @param <T> type
*/ */
public class SessionOp<T> { public class SessionOp<T> {

View File

@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class SessionUtil { public class SessionUtil {
@ -38,11 +38,12 @@ public class SessionUtil {
/** /**
* *
* @param httpServletRequest * @param httpServletRequest
* @return * http servlet request
* @throws TDGWTServiceException * @return service credentials
* @throws StatAlgoImporterServiceException
* exception
*/ */
public static ServiceCredentials getServiceCredentials( public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest)
HttpServletRequest httpServletRequest)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
return getServiceCredentials(httpServletRequest, null); return getServiceCredentials(httpServletRequest, null);
} }
@ -50,12 +51,14 @@ public class SessionUtil {
/** /**
* *
* @param httpServletRequest * @param httpServletRequest
* http servlet request
* @param scopeGroupId * @param scopeGroupId
* @return * scope group id
* @throws TDGWTServiceException * @return service credentials
* @throws StatAlgoImporterServiceException
* exception
*/ */
public static ServiceCredentials getServiceCredentials( public static ServiceCredentials getServiceCredentials(HttpServletRequest httpServletRequest, String scopeGroupId)
HttpServletRequest httpServletRequest, String scopeGroupId)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
ServiceCredentials sCredentials = null; ServiceCredentials sCredentials = null;
@ -113,8 +116,7 @@ public class SessionUtil {
GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest); GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
if (gCubeUser == null) { if (gCubeUser == null) {
String error = "Error retrieving gCubeUser in scope " + scope String error = "Error retrieving gCubeUser in scope " + scope + ": " + gCubeUser;
+ ": " + gCubeUser;
logger.error(error); logger.error(error);
throw new StatAlgoImporterServiceException(error); throw new StatAlgoImporterServiceException(error);
} }
@ -122,8 +124,7 @@ public class SessionUtil {
userName = gCubeUser.getUsername(); userName = gCubeUser.getUsername();
if (userName == null || userName.isEmpty()) { if (userName == null || userName.isEmpty()) {
String error = "Error retrieving username in scope " + scope String error = "Error retrieving username in scope " + scope + ": " + userName;
+ ": " + userName;
logger.error(error); logger.error(error);
throw new StatAlgoImporterServiceException(error); throw new StatAlgoImporterServiceException(error);
} }
@ -131,8 +132,7 @@ public class SessionUtil {
token = pContext.getCurrentUserToken(scope, userName); token = pContext.getCurrentUserToken(scope, userName);
if (token == null || token.isEmpty()) { if (token == null || token.isEmpty()) {
String error = "Error retrieving token for " + userName String error = "Error retrieving token for " + userName + " in " + scope + ": " + token;
+ " in " + scope + ": " + token;
logger.error(error); logger.error(error);
throw new StatAlgoImporterServiceException(error); throw new StatAlgoImporterServiceException(error);
} }
@ -176,16 +176,14 @@ public class SessionUtil {
} else { } else {
groupId = String.valueOf(pContext groupId = String.valueOf(pContext.getCurrentGroupId(httpServletRequest));
.getCurrentGroupId(httpServletRequest));
groupName = pContext.getCurrentGroupName(httpServletRequest); groupName = pContext.getCurrentGroupName(httpServletRequest);
} }
sCredentials = new ServiceCredentials(userName, fullName, name, sCredentials = new ServiceCredentials(userName, fullName, name, lastName, email, scope, groupId, groupName,
lastName, email, scope, groupId, groupName, userAvatarURL, userAvatarURL, token);
token);
} }
logger.info("ServiceCredentials: " + sCredentials); logger.info("ServiceCredentials: " + sCredentials);
@ -194,17 +192,14 @@ public class SessionUtil {
} }
// //
public static ArrayList<Recipient> getRecipients( public static ArrayList<Recipient> getRecipients(ServletContext servletContest) {
ServletContext servletContest) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<Recipient> recipients = (ArrayList<Recipient>) servletContest ArrayList<Recipient> recipients = (ArrayList<Recipient>) servletContest.getAttribute(Constants.RECIPIENTS);
.getAttribute(Constants.RECIPIENTS);
return recipients; return recipients;
} }
public static ArrayList<Recipient> setRecipients( public static ArrayList<Recipient> setRecipients(ServletContext servletContest, ArrayList<Recipient> recipients) {
ServletContext servletContest, ArrayList<Recipient> recipients) {
servletContest.setAttribute(Constants.RECIPIENTS, recipients); servletContest.setAttribute(Constants.RECIPIENTS, recipients);
return recipients; return recipients;
@ -214,60 +209,45 @@ public class SessionUtil {
public static FileUploadMonitor getFileUploadMonitor(HttpServletRequest httpRequest, public static FileUploadMonitor getFileUploadMonitor(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) throws Exception { ServiceCredentials serviceCredentials) throws Exception {
SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>(); SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>();
FileUploadMonitor fileUploadMonitor = sessionOp.get(httpRequest, FileUploadMonitor fileUploadMonitor = sessionOp.get(httpRequest, serviceCredentials,
serviceCredentials, SessionConstants.FILE_UPLOAD_MONITOR, FileUploadMonitor.class);
SessionConstants.FILE_UPLOAD_MONITOR,FileUploadMonitor.class);
return fileUploadMonitor; return fileUploadMonitor;
} }
public static void setFileUploadMonitor(HttpServletRequest httpRequest, public static void setFileUploadMonitor(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
ServiceCredentials serviceCredentials,
FileUploadMonitor fileUploadMonitor) { FileUploadMonitor fileUploadMonitor) {
SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>(); SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials, sessionOp.set(httpRequest, serviceCredentials, SessionConstants.FILE_UPLOAD_MONITOR, fileUploadMonitor);
SessionConstants.FILE_UPLOAD_MONITOR,
fileUploadMonitor);
} }
// //
public static CodeFileUploadSession getCodeFileUploadSession( public static CodeFileUploadSession getCodeFileUploadSession(HttpServletRequest httpRequest,
HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) { ServiceCredentials serviceCredentials) {
SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>(); SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>();
CodeFileUploadSession fileUploadSession = sessionOp.get(httpRequest, CodeFileUploadSession fileUploadSession = sessionOp.get(httpRequest, serviceCredentials,
serviceCredentials,
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION); SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
return fileUploadSession; return fileUploadSession;
} }
public static void setCodeFileUploadSession(HttpServletRequest httpRequest, public static void setCodeFileUploadSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
ServiceCredentials serviceCredentials,
CodeFileUploadSession codeFileUploadSession) { CodeFileUploadSession codeFileUploadSession) {
SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>(); SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials, sessionOp.set(httpRequest, serviceCredentials, SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION,
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION,
codeFileUploadSession); codeFileUploadSession);
} }
// //
public static Project getProjectSession(HttpServletRequest httpRequest, public static Project getProjectSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials) {
ServiceCredentials serviceCredentials) {
SessionOp<Project> sessionOp = new SessionOp<>(); SessionOp<Project> sessionOp = new SessionOp<>();
Project project = sessionOp.get(httpRequest, serviceCredentials, Project project = sessionOp.get(httpRequest, serviceCredentials, SessionConstants.PROJECT);
SessionConstants.PROJECT);
return project; return project;
} }
public static void setProjectSession(HttpServletRequest httpRequest, public static void setProjectSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
ServiceCredentials serviceCredentials, Project project) { Project project) {
SessionOp<Project> sessionOp = new SessionOp<>(); SessionOp<Project> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials, sessionOp.set(httpRequest, serviceCredentials, SessionConstants.PROJECT, project);
SessionConstants.PROJECT, project);
} }
} }

View File

@ -30,8 +30,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class WPS4RParser { public class WPS4RParser {

View File

@ -7,8 +7,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputO
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class WPSAlgorithmInfo implements Serializable { public class WPSAlgorithmInfo implements Serializable {

View File

@ -7,8 +7,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUpl
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeFileUploadSession implements Serializable { public class CodeFileUploadSession implements Serializable {

View File

@ -20,8 +20,8 @@ import org.slf4j.LoggerFactory;
* *
* Read code and convert it in ArrayList * Read code and convert it in ArrayList
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeReader { public class CodeReader {

View File

@ -11,8 +11,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class FileUploadListener implements ProgressListener { public class FileUploadListener implements ProgressListener {

View File

@ -17,15 +17,18 @@ import org.apache.commons.io.IOUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class FileUtil { public class FileUtil {
protected static final Logger logger = LoggerFactory protected static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
.getLogger(FileUtil.class);
public static final String[] ZIP_MIMETYPES = new String[] { public static final String[] ZIP_MIMETYPES = new String[] { "application/x-compress", "application/x-compressed",
"application/x-compress", "application/x-compressed", "application/x-gzip", "application/x-winzip", "application/x-zip", "application/zip", "multipart/x-zip" };
"application/x-gzip", "application/x-winzip", "application/x-zip",
"application/zip", "multipart/x-zip" };
/** /**
* Check if the content type is a zip type. * Check if the content type is a zip type.
@ -48,10 +51,12 @@ public class FileUtil {
* the zip stream. * the zip stream.
* @param os * @param os
* the output stream. * the output stream.
* @return zip entry name
* @throws Exception * @throws Exception
* exception
*/ */
public static String unZip(InputStream is, OutputStream os)
throws Exception { public static String unZip(InputStream is, OutputStream os) throws Exception {
try { try {
ZipInputStream zis = new ZipInputStream(is); ZipInputStream zis = new ZipInputStream(is);
ZipEntry entry; ZipEntry entry;
@ -87,20 +92,18 @@ public class FileUtil {
return message.toString(); return message.toString();
} }
public static void setImportCodeFile(CodeFileUploadSession fileUploadSession, public static void setImportCodeFile(CodeFileUploadSession fileUploadSession, InputStream is, String name,
InputStream is, String name, String mimeType) throws Exception { String mimeType) throws Exception {
File csvTmp = setImportFile(is, "import", ".code", name, mimeType); File csvTmp = setImportFile(is, "import", ".code", name, mimeType);
fileUploadSession.setCodeName(name); fileUploadSession.setCodeName(name);
fileUploadSession.setCodeFile(csvTmp); fileUploadSession.setCodeFile(csvTmp);
} }
public static File setImportFile(InputStream is, String tempName, public static File setImportFile(InputStream is, String tempName, String extention, String name, String mimeType)
String extention, String name, String mimeType) throws Exception { throws Exception {
File fileTmp = File.createTempFile(tempName, extention); File fileTmp = File.createTempFile(tempName, extention);
fileTmp.deleteOnExit(); fileTmp.deleteOnExit();

View File

@ -22,8 +22,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class AlgorithmGenerator { public class AlgorithmGenerator {

View File

@ -16,8 +16,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InfoGenerator { public class InfoGenerator {

View File

@ -31,8 +31,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ProjectBuilder { public class ProjectBuilder {

View File

@ -18,7 +18,7 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author giancarlo * @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterPortlet extends GenericPortlet { public class StatAlgoImporterPortlet extends GenericPortlet {

View File

@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory;
/** /**
* TDMNotification notification sharing TR, templates or rules * TDMNotification notification sharing TR, templates or rules
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class AlgorithmNotification extends Thread { public class AlgorithmNotification extends Thread {

View File

@ -4,8 +4,8 @@ import java.io.Serializable;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class Recipient implements Serializable { public class Recipient implements Serializable {

View File

@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
@ -35,8 +35,7 @@ public class FilesStorage {
private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION = "Statistical Algorithm Project File"; private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION = "Statistical Algorithm Project File";
private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_NAME = "stat_algo.project"; private static final String STATISTICAL_ALGORITHM_PROJECT_FILE_NAME = "stat_algo.project";
public static final Logger logger = LoggerFactory public static final Logger logger = LoggerFactory.getLogger(FilesStorage.class);
.getLogger(FilesStorage.class);
/** /**
* *
@ -44,28 +43,25 @@ public class FilesStorage {
* User * User
* @param itemId * @param itemId
* Item id * Item id
* @return Public link * @return public link
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public String getPublicLink(String user, String itemId) public String getPublicLink(String user, String itemId) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Get public link: [user=" + user + ", itemId=" + itemId logger.info("Get public link: [user=" + user + ", itemId=" + itemId + "]");
+ "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId); WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem.isFolder()) { if (workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Attention this is a folder!");
"Attention this is a folder!");
} }
if (workSpaceItem instanceof FolderItem) { if (workSpaceItem instanceof FolderItem) {
return workSpaceItem.getPublicLink(false); return workSpaceItem.getPublicLink(false);
} else { } else {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Attention no public link for this item!");
"Attention no public link for this item!");
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -83,30 +79,28 @@ public class FilesStorage {
* Item id * Item id
* @param folderId * @param folderId
* Folder id * Folder id
* @return workspace item
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public WorkspaceItem copyItemOnFolder(String user, String itemId, public WorkspaceItem copyItemOnFolder(String user, String itemId, String folderId)
String folderId) throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Copy item on folder: [user=" + user + ", itemId=" logger.info("Copy item on folder: [user=" + user + ", itemId=" + itemId + ", folderId=" + folderId + "]");
+ itemId + ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Destination is not a folder!");
"Destination is not a folder!");
} }
WorkspaceItem item = ws.copy(itemId, folderId); WorkspaceItem item = ws.copy(itemId, folderId);
return item; return item;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Copy item on folder on workspace: " + e.getLocalizedMessage(), e);
"Copy item on folder on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -122,33 +116,29 @@ public class FilesStorage {
* Destination folder id * Destination folder id
* @param newName * @param newName
* New name * New name
* * @return workspace item
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public WorkspaceItem copyItemOnFolderWithNewName(String user, public WorkspaceItem copyItemOnFolderWithNewName(String user, String itemId, String folderId, String newName)
String itemId, String folderId, String newName)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Copy item on folder with new name: [user=" + user logger.info("Copy item on folder with new name: [user=" + user + ", itemId=" + itemId + ", folderId="
+ ", itemId=" + itemId + ", folderId=" + folderId + folderId + ", newName=" + newName + "]");
+ ", newName=" + newName + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Destination is not a folder!");
"Destination is not a folder!");
} }
WorkspaceItem item = ws.copy(itemId, newName, folderId); WorkspaceItem item = ws.copy(itemId, newName, folderId);
return item; return item;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Copy item on folder with new name on workspace: " + e.getLocalizedMessage(), e);
"Copy item on folder with new name on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -161,21 +151,19 @@ public class FilesStorage {
* @param itemId * @param itemId
* Item id * Item id
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public void deleteItemOnFolder(String user, String itemId) public void deleteItemOnFolder(String user, String itemId) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Delete item on folder: [user=" + user + ", itemId=" logger.info("Delete item on folder: [user=" + user + ", itemId=" + itemId + "]");
+ itemId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
ws.removeItems(itemId); ws.removeItems(itemId);
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Delete Item on workspace: " + e.getLocalizedMessage(), e);
"Delete Item on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -185,24 +173,24 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* User * user
* @param parentId * @param parentId
* Foler id * parent id
* @param folderName
* folder name
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public void deleteFolder(String user, String parentId, String folderName) public void deleteFolder(String user, String parentId, String folderName) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Delete folder: [user=" + user + ", parentId=" logger.info("Delete folder: [user=" + user + ", parentId=" + parentId + ", folderName=" + folderName + "]");
+ parentId + ", folderName=" + folderName + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(parentId); WorkspaceItem workSpaceItem = ws.getItem(parentId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No valid project folder!");
"No valid project folder!");
} }
WorkspaceItem target = ws.find(folderName, parentId); WorkspaceItem target = ws.find(folderName, parentId);
@ -213,8 +201,7 @@ public class FilesStorage {
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Delete folder on workspace: " + e.getLocalizedMessage(), e);
"Delete folder on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -224,36 +211,36 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* User * user
* @param parentId * @param parentId
* Destination folder id * parent id
* @return Folder * @param folderName
* folder name
* @param folderDescription
* folder description
* @return workspace folder
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public WorkspaceFolder createFolder(String user, String parentId, public WorkspaceFolder createFolder(String user, String parentId, String folderName, String folderDescription)
String folderName, String folderDescription)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Create folder: [user=" + user + ", parentId=" logger.info("Create folder: [user=" + user + ", parentId=" + parentId + ", folderName=" + folderName
+ parentId + ", folderName=" + folderName
+ ", folderDescription=" + folderDescription + "]"); + ", folderDescription=" + folderDescription + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(parentId); WorkspaceItem workSpaceItem = ws.getItem(parentId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No valid project folder!");
"No valid project folder!");
} }
WorkspaceFolder projectTargetFolder = ws.createFolder(folderName, WorkspaceFolder projectTargetFolder = ws.createFolder(folderName, folderDescription, parentId);
folderDescription, parentId);
return projectTargetFolder; return projectTargetFolder;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Create folder on workspace: " + e.getLocalizedMessage(), e);
"Create folder on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -265,23 +252,23 @@ public class FilesStorage {
* @param user * @param user
* User * User
* @param parentId * @param parentId
* Destination folder id * Parent id
* @return Folder * @param name
* Name
* @return workspace item
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public WorkspaceItem find(String user, String parentId, String name) public WorkspaceItem find(String user, String parentId, String name) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Find: [user=" + user + ", parentId=" + parentId logger.info("Find: [user=" + user + ", parentId=" + parentId + ", name=" + name + "]");
+ ", name=" + name + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(parentId); WorkspaceItem workSpaceItem = ws.getItem(parentId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No valid project folder!");
"No valid project folder!");
} }
return ws.find(name, parentId); return ws.find(name, parentId);
@ -297,45 +284,40 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* user * User
* @param inputStream * @param inputStream
* input stream * Input stream
* @param folderId * @param folderId
* destination folder * Folder id
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public void saveStatisticalAlgorithmProject(String user, public void saveStatisticalAlgorithmProject(String user, InputStream inputStream, String folderId)
InputStream inputStream, String folderId)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Save project: [user=" + user + ", folderId=" logger.info("Save project: [user=" + user + ", folderId=" + folderId + "]");
+ folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Destination is not a folder!");
"Destination is not a folder!");
} }
WorkspaceItem projectItem = ws.find( WorkspaceItem projectItem = ws.find(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
if (projectItem == null) { if (projectItem == null) {
ws.createExternalFile(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, ws.createExternalFile(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME,
STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION, STATISTICAL_ALGORITHM_PROJECT_FILE_DESCRIPTION, STATISTICAL_ALGORITHM_PROJECT_MIMETYPE,
STATISTICAL_ALGORITHM_PROJECT_MIMETYPE, inputStream, inputStream, folderId);
folderId);
} else { } else {
ws.updateItem(projectItem.getId(), inputStream); ws.updateItem(projectItem.getId(), inputStream);
} }
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Save project on workspace: " + e.getLocalizedMessage(), e);
"Save project on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -344,49 +326,45 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* user * User
* @param inputStream * @param inputStream
* input stream * Input stream
* @param name * @param name
* item name * Name
* @param description * @param description
* item description * Description
* @param mimeType * @param mimeType
* item mimetype * Mimetype
* @param folderId * @param folderId
* destination folder * Folder destination
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public void saveItemOnWorkspace(String user, InputStream inputStream, public void saveItemOnWorkspace(String user, InputStream inputStream, String name, String description,
String name, String description, String mimeType, String folderId) String mimeType, String folderId) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Save item on workspace: [user=" + user + ", name=" logger.info("Save item on workspace: [user=" + user + ", name=" + name + ", description=" + description
+ name + ", description=" + description + ", mimeType=" + ", mimeType=" + mimeType + ", folderId=" + folderId + "]");
+ mimeType + ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Destination is not a folder!");
"Destination is not a folder!");
} }
WorkspaceItem projectItem = ws.find(name, folderId); WorkspaceItem projectItem = ws.find(name, folderId);
if (projectItem == null) { if (projectItem == null) {
ws.createExternalFile(name, description, mimeType, inputStream, ws.createExternalFile(name, description, mimeType, inputStream, folderId);
folderId);
} else { } else {
ws.updateItem(projectItem.getId(), inputStream); ws.updateItem(projectItem.getId(), inputStream);
} }
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Save item on workspace: " + e.getLocalizedMessage(), logger.error("Save item on workspace: " + e.getLocalizedMessage(), e);
e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -408,32 +386,27 @@ public class FilesStorage {
* Destination folder * Destination folder
* @return Workspace item * @return Workspace item
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exceptioon
*/ */
public WorkspaceItem createItemOnWorkspace(String user, public WorkspaceItem createItemOnWorkspace(String user, InputStream inputStream, String name, String description,
InputStream inputStream, String name, String description, String mimeType, String folderId) throws StatAlgoImporterServiceException {
String mimeType, String folderId)
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Create item on workspace: [user=" + user + ", name=" logger.info("Create item on workspace: [user=" + user + ", name=" + name + ", description=" + description
+ name + ", description=" + description + ", mimeType=" + ", mimeType=" + mimeType + ", folderId=" + folderId + "]");
+ mimeType + ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Destination is not a folder!");
"Destination is not a folder!");
} }
ExternalFile workspaceItem = ws.createExternalFile(name, ExternalFile workspaceItem = ws.createExternalFile(name, description, mimeType, inputStream, folderId);
description, mimeType, inputStream, folderId);
return workspaceItem; return workspaceItem;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Create item on workspace: " + e.getLocalizedMessage(), e);
"Create item on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -447,36 +420,32 @@ public class FilesStorage {
* Folder id * Folder id
* @return Input stream * @return Input stream
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*
*/ */
public InputStream retrieveProjectItemOnWorkspace(String user, public InputStream retrieveProjectItemOnWorkspace(String user, String folderId)
String folderId) throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Retrieve project item on workspace: [user=" + user logger.info("Retrieve project item on workspace: [user=" + user + ", folderId=" + folderId + "]");
+ ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is not valid folder!");
"Item is not valid folder!");
} }
WorkspaceItem projectItem = ws.find( WorkspaceItem projectItem = ws.find(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
if (projectItem == null) { if (projectItem == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No project found in this folder!");
"No project found in this folder!");
} }
return retrieveInputStream(user, projectItem); return retrieveInputStream(user, projectItem);
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Retrieve project item on workspace: " + e.getLocalizedMessage(), e);
"Retrieve project item on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
@ -484,27 +453,26 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* User
* @param folderId * @param folderId
* @return boolean * Folder id
* @return boolean True if exist
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public boolean existProjectItemOnWorkspace(String user, String folderId) public boolean existProjectItemOnWorkspace(String user, String folderId) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Exist project item on workspace: [user=" + user logger.info("Exist project item on workspace: [user=" + user + ", folderId=" + folderId + "]");
+ ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is not valid folder!");
"Item is not valid folder!");
} }
WorkspaceItem projectItem = ws.find( WorkspaceItem projectItem = ws.find(STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
STATISTICAL_ALGORITHM_PROJECT_FILE_NAME, folderId);
if (projectItem == null) { if (projectItem == null) {
return false; return false;
@ -513,9 +481,7 @@ public class FilesStorage {
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Exist project item on workspace: " + e.getLocalizedMessage(), e);
"Exist project item on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
@ -523,16 +489,18 @@ public class FilesStorage {
/** /**
* *
* @param user * @param user
* User
* @param itemId * @param itemId
* @return WorkspaceItem * Item id
* @return Workspace Item
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public WorkspaceItem retrieveItemInfoOnWorkspace(String user, String itemId) public WorkspaceItem retrieveItemInfoOnWorkspace(String user, String itemId)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Retrieve item info on workspace: [user=" + user logger.info("Retrieve item info on workspace: [user=" + user + ", itemId=" + itemId + "]");
+ ", itemId=" + itemId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
@ -540,9 +508,7 @@ public class FilesStorage {
return workSpaceItem; return workSpaceItem;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Retrieve item info on workspace: " + e.getLocalizedMessage(), e);
"Retrieve item info on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
@ -555,27 +521,24 @@ public class FilesStorage {
* Item id * Item id
* @return Input stream * @return Input stream
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Excetpion
*/ */
public InputStream retrieveItemOnWorkspace(String user, String itemId) public InputStream retrieveItemOnWorkspace(String user, String itemId) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Retrieve item on workspace: [user=" + user logger.info("Retrieve item on workspace: [user=" + user + ", itemId=" + itemId + "]");
+ ", itemId=" + itemId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId); WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem.isFolder()) { if (workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Folder Item is not valid!");
"Folder Item is not valid!");
} }
return retrieveInputStream(user, workSpaceItem); return retrieveInputStream(user, workSpaceItem);
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Retieve item on workspace: " + e.getLocalizedMessage(), e);
"Retieve item on workspace: " + e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
@ -586,28 +549,24 @@ public class FilesStorage {
* @param user * @param user
* User * User
* @param wi * @param wi
* WorkspaceItem * Workspace item
* @return InputStream * @return InputStream
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public InputStream retrieveInputStream(String user, WorkspaceItem wi) public InputStream retrieveInputStream(String user, WorkspaceItem wi) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
InputStream is = null; InputStream is = null;
try { try {
logger.info("Retrieve input stream: [user=" + user logger.info("Retrieve input stream: [user=" + user + ", workspaceItem=" + wi + "]");
+ ", workspaceItem=" + wi + "]");
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi); org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
is = gcubeItem.getData(); is = gcubeItem.getData();
return is; return is;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Error retrieving file from storage: " + e.getLocalizedMessage(), e);
"Error retrieving file from storage: " throw new StatAlgoImporterServiceException("Error retrieving file from storage: " + e.getLocalizedMessage(),
+ e.getLocalizedMessage(), e); e);
throw new StatAlgoImporterServiceException(
"Error retrieving file from storage: "
+ e.getLocalizedMessage(), e);
} }
} }
@ -621,24 +580,21 @@ public class FilesStorage {
* @param data * @param data
* String to save * String to save
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public void saveStringInItem(String user, String itemId, String data) public void saveStringInItem(String user, String itemId, String data) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Save string in item: [user=" + user + ", itemId=" logger.info("Save string in item: [user=" + user + ", itemId=" + itemId + "]");
+ itemId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId); WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem == null) { if (workSpaceItem == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No item retrieved on workspace!");
"No item retrieved on workspace!");
} else { } else {
if (workSpaceItem.isFolder()) { if (workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is a folder!");
"Item is a folder!");
} else { } else {
} }
@ -651,30 +607,36 @@ public class FilesStorage {
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Save string in item on workspace: " + e.getLocalizedMessage(), e);
"Save string in item on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
/**
*
* @param user
* User
* @param itemId
* Item id
* @param is
* Input stream
* @throws StatAlgoImporterServiceException
* Exception
*/
public void saveInputStreamInItem(String user, String itemId, InputStream is) public void saveInputStreamInItem(String user, String itemId, InputStream is)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Save input stream in item: [user=" + user + ", itemId=" logger.info("Save input stream in item: [user=" + user + ", itemId=" + itemId + "]");
+ itemId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId); WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem == null) { if (workSpaceItem == null) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("No item retrieved on workspace!");
"No item retrieved on workspace!");
} else { } else {
if (workSpaceItem.isFolder()) { if (workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is a folder!");
"Item is a folder!");
} else { } else {
} }
@ -685,26 +647,31 @@ public class FilesStorage {
return; return;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Save input stream in item on workspace: " + e.getLocalizedMessage(), e);
"Save input stream in item on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
public File zipFolder(String user, String folderId) /**
throws StatAlgoImporterServiceException { *
* @param user
* User
* @param folderId
* Folder Id
* @return Zip folder
* @throws StatAlgoImporterServiceException
* Exception
*/
public File zipFolder(String user, String folderId) throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Zip folder: [user=" + user + ", folderId=" logger.info("Zip folder: [user=" + user + ", folderId=" + folderId + "]");
+ folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is not valid folder!");
"Item is not valid folder!");
} }
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem; WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
@ -714,26 +681,35 @@ public class FilesStorage {
return fileZip; return fileZip;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Zip folder on workspace: " + e.getLocalizedMessage(), logger.error("Zip folder on workspace: " + e.getLocalizedMessage(), e);
e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
public File zipFolder(String user, String folderId, /**
List<String> idsToExclude) throws StatAlgoImporterServiceException { *
* @param user
* User
* @param folderId
* Folder id
* @param idsToExclude
* List of ids to exclude
* @return Zip folder
* @throws StatAlgoImporterServiceException
* Exception
*/
public File zipFolder(String user, String folderId, List<String> idsToExclude)
throws StatAlgoImporterServiceException {
Workspace ws; Workspace ws;
try { try {
logger.info("Zip folder with exclude: [user=" + user + ", folderId=" logger.info("Zip folder with exclude: [user=" + user + ", folderId=" + folderId + "]");
+ folderId + "]");
ws = HomeLibrary.getUserWorkspace(user); ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId); WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) { if (!workSpaceItem.isFolder()) {
throw new StatAlgoImporterServiceException( throw new StatAlgoImporterServiceException("Item is not valid folder!");
"Item is not valid folder!");
} }
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem; WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
@ -743,21 +719,25 @@ public class FilesStorage {
return fileZip; return fileZip;
} catch (Throwable e) { } catch (Throwable e) {
logger.error( logger.error("Zip folder with exclude on workspace: " + e.getLocalizedMessage(), e);
"Zip folder with exclude on workspace: "
+ e.getLocalizedMessage(), e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
} }
public void downloadInputFile(String fileUrl, Path destination) /**
throws StatAlgoImporterServiceException { *
* @param fileUrl
* Url
* @param destination
* Destination
* @throws StatAlgoImporterServiceException
* Exception
*/
public void downloadInputFile(String fileUrl, Path destination) throws StatAlgoImporterServiceException {
try { try {
logger.info("Download input file: [fileUrl=" + fileUrl + ", destination=" logger.info("Download input file: [fileUrl=" + fileUrl + ", destination=" + destination + "]");
+ destination + "]");
URL smpFile = new URL(fileUrl); URL smpFile = new URL(fileUrl);
URLConnection uc = (URLConnection) smpFile.openConnection(); URLConnection uc = (URLConnection) smpFile.openConnection();
@ -771,8 +751,7 @@ public class FilesStorage {
} }
} }
private void inputStreamToFile(InputStream is, Path destination) private void inputStreamToFile(InputStream is, Path destination) throws FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
FileOutputStream out = new FileOutputStream(destination.toFile()); FileOutputStream out = new FileOutputStream(destination.toFile());
byte buf[] = new byte[1024]; byte buf[] = new byte[1024];
int len = 0; int len = 0;

View File

@ -17,15 +17,14 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class MainCodeSave { public class MainCodeSave {
private static final String ALGORITHM_DESCRIPTION = "Algorithm"; private static final String ALGORITHM_DESCRIPTION = "Algorithm";
private static final String ALGORITHM_MIMETYPE = "text/plain"; private static final String ALGORITHM_MIMETYPE = "text/plain";
public static final Logger logger = LoggerFactory public static final Logger logger = LoggerFactory.getLogger(MainCodeSave.class);
.getLogger(MainCodeSave.class);
public MainCodeSave() { public MainCodeSave() {
@ -34,39 +33,44 @@ public class MainCodeSave {
/** /**
* *
* @param serviceCredentials * @param serviceCredentials
* Service credentials
* @param file * @param file
* File
* @param code * @param code
* Code
* @param project * @param project
* Prject
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* Exception
*/ */
public void save(ServiceCredentials serviceCredentials, ItemDescription file, public void save(ServiceCredentials serviceCredentials, ItemDescription file, String code, Project project)
String code, Project project) throws StatAlgoImporterServiceException{ throws StatAlgoImporterServiceException {
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();
filesStorage.saveStringInItem(serviceCredentials.getUserName(), file.getId(), code); filesStorage.saveStringInItem(serviceCredentials.getUserName(), file.getId(), code);
} }
/** /**
* *
* @param serviceCredentials * @param serviceCredentials
* @param file description of destination file * Service credentials
* @param code code to insert in the file * @param file
* @param project * Description of destination file
* @return ItemDescription * @param code
* Code to insert in the file
* @param project
* Project
* @return ItemDescription Item description
* @throws StatAlgoImporterServiceException * @throws StatAlgoImporterServiceException
* exception
*/ */
public ItemDescription saveNew(ServiceCredentials serviceCredentials, ItemDescription file, public ItemDescription saveNew(ServiceCredentials serviceCredentials, ItemDescription file, String code,
String code, Project project) Project project) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
Path tempFile = createTempFile(file, code); Path tempFile = createTempFile(file, code);
ItemDescription mainCode = saveInWorkspace(tempFile, serviceCredentials, file, ItemDescription mainCode = saveInWorkspace(tempFile, serviceCredentials, file, project);
project);
return mainCode; return mainCode;
} }
private Path createTempFile(ItemDescription file, String code) throws StatAlgoImporterServiceException {
private Path createTempFile(ItemDescription file, String code)
throws StatAlgoImporterServiceException {
try { try {
Path tempFile = Files.createTempFile(file.getName(), ""); Path tempFile = Files.createTempFile(file.getName(), "");
@ -78,36 +82,29 @@ public class MainCodeSave {
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
e);
} }
} }
private ItemDescription saveInWorkspace(Path tempFile, private ItemDescription saveInWorkspace(Path tempFile, ServiceCredentials serviceCredentials, ItemDescription file,
ServiceCredentials serviceCredentials, ItemDescription file, Project project) Project project) throws StatAlgoImporterServiceException {
throws StatAlgoImporterServiceException {
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();
WorkspaceItem mainCodeItem; WorkspaceItem mainCodeItem;
try { try {
mainCodeItem = filesStorage.createItemOnWorkspace( mainCodeItem = filesStorage.createItemOnWorkspace(serviceCredentials.getUserName(),
serviceCredentials.getUserName(), Files.newInputStream(tempFile, StandardOpenOption.READ), file.getName(), ALGORITHM_DESCRIPTION,
Files.newInputStream(tempFile, StandardOpenOption.READ), ALGORITHM_MIMETYPE, project.getProjectFolder().getFolder().getId());
file.getName(), ALGORITHM_DESCRIPTION, ALGORITHM_MIMETYPE,
project.getProjectFolder().getFolder().getId());
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
e);
} }
ItemDescription mainCode; ItemDescription mainCode;
try { try {
mainCode = new ItemDescription(mainCodeItem.getId(), mainCode = new ItemDescription(mainCodeItem.getId(), mainCodeItem.getName(),
mainCodeItem.getName(), mainCodeItem.getOwner() mainCodeItem.getOwner().getPortalLogin(), mainCodeItem.getPath(), mainCodeItem.getType().name());
.getPortalLogin(), mainCodeItem.getPath(),
mainCodeItem.getType().name());
} catch (InternalErrorException e) { } catch (InternalErrorException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();

View File

@ -19,8 +19,8 @@ import org.slf4j.LoggerFactory;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ProjectArchiver { public class ProjectArchiver {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server.uriresolver
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum ApplicationType { public enum ApplicationType {

View File

@ -4,8 +4,8 @@ import java.io.Serializable;
/** /**
* *
* @author Giancarlo Panichi email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class ServiceCredentials implements Serializable { public class ServiceCredentials implements Serializable {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class Constants { public class Constants {

View File

@ -4,8 +4,8 @@ import java.io.Serializable;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class CodeData implements Serializable { public class CodeData implements Serializable {

View File

@ -5,16 +5,14 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class StatAlgoImporterServiceException extends Exception { public class StatAlgoImporterServiceException extends Exception {
private static final long serialVersionUID = -2255657546267656458L; private static final long serialVersionUID = -2255657546267656458L;
/** /**
* *
*/ */
@ -24,15 +22,22 @@ public class StatAlgoImporterServiceException extends Exception {
/** /**
* @param message * @param message
* message
*/ */
public StatAlgoImporterServiceException(String message) { public StatAlgoImporterServiceException(String message) {
super(message); super(message);
} }
/**
public StatAlgoImporterServiceException(String message,Throwable t) { *
super(message,t); * @param message
* message
* @param throwable
* throwable
*
*/
public StatAlgoImporterServiceException(String message, Throwable throwable) {
super(message, throwable);
} }
} }

View File

@ -3,10 +3,10 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception;
/** /**
* ASL Session Expired Exception * ASL Session Expired Exception
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* *
*/ */
public class StatAlgoImporterSessionExpiredException extends StatAlgoImporterServiceException { public class StatAlgoImporterSessionExpiredException extends StatAlgoImporterServiceException {
private static final long serialVersionUID = -4831171355042165166L; private static final long serialVersionUID = -4831171355042165166L;
@ -19,18 +19,21 @@ public class StatAlgoImporterSessionExpiredException extends StatAlgoImporterSe
/** /**
* @param message * @param message
* message
*/ */
public StatAlgoImporterSessionExpiredException(String message) { public StatAlgoImporterSessionExpiredException(String message) {
super(message); super(message);
} }
/** /**
* *
* @param message * @param message
* @param t * message
* @param throwable
* throwable
*/ */
public StatAlgoImporterSessionExpiredException(String message,Throwable t) { public StatAlgoImporterSessionExpiredException(String message, Throwable throwable) {
super(message,t); super(message, throwable);
} }
} }

View File

@ -7,22 +7,22 @@ import java.io.Serializable;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class FileUploadMonitor implements Serializable { public class FileUploadMonitor implements Serializable {
private static final long serialVersionUID = -1150111422206443617L; private static final long serialVersionUID = -1150111422206443617L;
protected long totalLenght; protected long totalLenght;
protected long elaboratedLenght; protected long elaboratedLenght;
protected FileUploadState state; protected FileUploadState state;
protected String failureReason; protected String failureReason;
protected String failureDetails; protected String failureDetails;
protected float percentDone; protected float percentDone;
public FileUploadMonitor(){ public FileUploadMonitor() {
state = FileUploadState.INPROGRESS; state = FileUploadState.INPROGRESS;
} }
@ -31,7 +31,7 @@ public class FileUploadMonitor implements Serializable {
this.elaboratedLenght = elaboratedLenght; this.elaboratedLenght = elaboratedLenght;
this.state = state; this.state = state;
this.failureReason = failureReason; this.failureReason = failureReason;
this.percentDone=0; this.percentDone = 0;
} }
/** /**
@ -40,7 +40,7 @@ public class FileUploadMonitor implements Serializable {
public long getTotalLenght() { public long getTotalLenght() {
return totalLenght; return totalLenght;
} }
/** /**
* @return the elaboratedLenght * @return the elaboratedLenght
*/ */
@ -48,8 +48,7 @@ public class FileUploadMonitor implements Serializable {
return elaboratedLenght; return elaboratedLenght;
} }
public FileUploadState getState() {
public FileUploadState getState(){
return state; return state;
} }
@ -76,8 +75,7 @@ public class FileUploadMonitor implements Serializable {
this.failureDetails = failureDetails; this.failureDetails = failureDetails;
} }
public void setState(FileUploadState state) public void setState(FileUploadState state) {
{
this.state = state; this.state = state;
} }
@ -90,7 +88,8 @@ public class FileUploadMonitor implements Serializable {
} }
/** /**
* @param totalLenght the totalLenght to set * @param totalLenght
* the totalLenght to set
*/ */
public void setTotalLenght(long totalLenght) { public void setTotalLenght(long totalLenght) {
this.totalLenght = totalLenght; this.totalLenght = totalLenght;
@ -99,6 +98,7 @@ public class FileUploadMonitor implements Serializable {
/** /**
* *
* @param elaboratedLenght * @param elaboratedLenght
* elaborated lenght
*/ */
public void setElaboratedLenght(long elaboratedLenght) { public void setElaboratedLenght(long elaboratedLenght) {
this.elaboratedLenght = elaboratedLenght; this.elaboratedLenght = elaboratedLenght;
@ -107,7 +107,9 @@ public class FileUploadMonitor implements Serializable {
/** /**
* *
* @param failureReason * @param failureReason
* failure reason
* @param failureDetails * @param failureDetails
* failure details
*/ */
public void setFailed(String failureReason, String failureDetails) { public void setFailed(String failureReason, String failureDetails) {
this.state = FileUploadState.FAILED; this.state = FileUploadState.FAILED;
@ -117,11 +119,9 @@ public class FileUploadMonitor implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "FileUploadMonitor [totalLenght=" + totalLenght return "FileUploadMonitor [totalLenght=" + totalLenght + ", elaboratedLenght=" + elaboratedLenght + ", state="
+ ", elaboratedLenght=" + elaboratedLenght + ", state=" + state + state + ", failureReason=" + failureReason + ", failureDetails=" + failureDetails + ", percentDone="
+ ", failureReason=" + failureReason + ", failureDetails=" + percentDone + "]";
+ failureDetails + ", percentDone=" + percentDone + "]";
} }
} }

View File

@ -4,11 +4,16 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file; package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file;
/** /**
* @author Federico De Faveri defaveri@isti.cnr.it *
* @author Giancarlo Panichi
*
* *
*/ */
public enum FileUploadState { public enum FileUploadState {
/**
* The operation is started
*/
STARTED, STARTED,
/** /**

View File

@ -5,8 +5,8 @@ import java.util.List;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum DataType { public enum DataType {

View File

@ -4,8 +4,8 @@ import java.io.Serializable;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class GlobalVariables implements Serializable { public class GlobalVariables implements Serializable {
@ -23,14 +23,18 @@ public class GlobalVariables implements Serializable {
/** /**
* *
* @param id * @param id
* id
* @param name * @param name
* name
* @param description * @param description
* description
* @param defaultValue * @param defaultValue
* default value
* @param dataType * @param dataType
* data type
*/ */
public GlobalVariables(int id, String name, String description, public GlobalVariables(int id, String name, String description, String defaultValue, DataType dataType) {
String defaultValue, DataType dataType) {
super(); super();
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -81,12 +85,8 @@ public class GlobalVariables implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "GlobalVariables [id=" + id + ", name=" + name return "GlobalVariables [id=" + id + ", name=" + name + ", description=" + description + ", defaultValue="
+ ", description=" + description + ", defaultValue="
+ defaultValue + ", dataType=" + dataType + "]"; + defaultValue + ", dataType=" + dataType + "]";
} }
} }

View File

@ -5,8 +5,8 @@ import java.util.List;
/** /**
* *
* @author "Giancarlo Panichi" * @author Giancarlo Panichi
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public enum IOType { public enum IOType {

View File

@ -4,8 +4,8 @@ import java.io.Serializable;
/** /**
* *
* @author giancarlo email: <a * @author Giancarlo Panichi
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> *
* *
*/ */
public class InputOutputVariables implements Serializable { public class InputOutputVariables implements Serializable {

Some files were not shown because too many files have changed in this diff Show More