diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java index c278dcc..8720335 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/codeparser/CodeParser.java @@ -16,7 +16,7 @@ import com.google.gwt.regexp.shared.RegExp; public class CodeParser { private static final String IMAGE_PATTERN = "([^\\s]+(\\.(jpg|png|gif|bmp)\"))"; - private static final String FILE_PATTERN = "([^\\s]+(\\.(txt|csv|pdf|doc)\"))"; + private static final String FILE_PATTERN = "([^\\s]+(\\.(txt|csv|pdf|doc|zip|bin|dat|mat|java|m|exe|sh|tar|gz|r)\"))"; private static final String ENUM1_PATTERN = "(c\\([^\\)]*\\))"; private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})"; @@ -33,7 +33,7 @@ public class CodeParser { if (parameter.contains("<-")) { String[] varDescription = parameter.split("<-"); - String checkDataTypeValue=varDescription[1].trim(); + String checkDataTypeValue = varDescription[1].trim(); if (checkDataTypeValue.endsWith(";")) checkDataTypeValue = checkDataTypeValue.substring(0, checkDataTypeValue.length() - 1); @@ -49,12 +49,12 @@ public class CodeParser { selectedRowsVariables = new InputOutputVariables( varDescription[0].trim(), varDescription[0].trim(), - defaultValue, checkDataType(checkDataTypeValue), - ioType, parameter); + defaultValue, checkDataType(checkDataTypeValue), ioType, + parameter); } else { if (parameter.contains("=")) { String[] varDescription = parameter.split("="); - String checkDataTypeValue=varDescription[1].trim(); + String checkDataTypeValue = varDescription[1].trim(); if (checkDataTypeValue.endsWith(";")) checkDataTypeValue = checkDataTypeValue.substring(0, checkDataTypeValue.length() - 1); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java index 7b82961..8fb370b 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/GlobalVariablesPanel.java @@ -42,6 +42,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.form.ComboBox; import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.form.validator.RegExValidator; import com.sencha.gxt.widget.core.client.grid.ColumnConfig; import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.Grid; @@ -190,16 +191,27 @@ public class GlobalVariablesPanel extends ContentPanel { comboInputType.setTriggerAction(TriggerAction.ALL); addHandlersForComboInputType(inputTypePropertiesCombo.label()); - + + // + TextField nameColumnEditing = new TextField(); + nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField descriptionColumnEditing = new TextField(); + descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField defaultValueColumnEditing = new TextField(); + defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + gridGlobalVariableEditing = new GridRowEditing( gridGlobalVariable); - gridGlobalVariableEditing.addEditor(nameColumn, new TextField()); + gridGlobalVariableEditing.addEditor(nameColumn, nameColumnEditing); gridGlobalVariableEditing.addEditor(descriptionColumn, - new TextField()); + descriptionColumnEditing); gridGlobalVariableEditing.addEditor(inputTypeColumn, comboInputType); gridGlobalVariableEditing.addEditor(defaultValueColumn, - new TextField()); + defaultValueColumnEditing); btnAdd = new TextButton("Add"); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java index cacb267..a1b83cf 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputOutputVariablesPanel.java @@ -41,6 +41,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.form.ComboBox; import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.form.validator.RegExValidator; import com.sencha.gxt.widget.core.client.grid.ColumnConfig; import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.Grid; @@ -163,12 +164,14 @@ public class InputOutputVariablesPanel extends ContentPanel { ColumnModel columns = new ColumnModel( l); - storeInputOutputVariables = new ListStore(props.id()); + storeInputOutputVariables = new ListStore( + props.id()); /* - * ArrayList list = new ArrayList<>(); for (int i - * = 0; i < 10; i++) { list.add(new InputOutputVariablesVariables(i, "Test" + i, - * "Desc", "defaultValue", InputType.STRING)); } + * ArrayList list = new ArrayList<>(); + * for (int i = 0; i < 10; i++) { list.add(new + * InputOutputVariablesVariables(i, "Test" + i, "Desc", "defaultValue", + * InputType.STRING)); } * * storeEnvironmentVariable.addAll(list); */ @@ -182,8 +185,8 @@ public class InputOutputVariablesPanel extends ContentPanel { final GridSelectionModel sm = new GridSelectionModel(); sm.setSelectionMode(SelectionMode.SINGLE); - gridInputOutputVariables = new Grid(storeInputOutputVariables, - columns); + gridInputOutputVariables = new Grid( + storeInputOutputVariables, columns); gridInputOutputVariables.setSelectionModel(sm); gridInputOutputVariables.getView().setStripeRows(true); gridInputOutputVariables.getView().setColumnLines(true); @@ -194,18 +197,21 @@ public class InputOutputVariablesPanel extends ContentPanel { /* * GridDragSource ds = new - * GridDragSource( gridEnvironmentVariable); - * ds.addDragStartHandler(new DndDragStartHandler() { + * GridDragSource( + * gridEnvironmentVariable); ds.addDragStartHandler(new + * DndDragStartHandler() { * * @Override public void onDragStart(DndDragStartEvent event) { * - * @SuppressWarnings("unchecked") ArrayList - * draggingSelection = (ArrayList) event - * .getData(); Log.debug("Start Drag: " + draggingSelection); + * @SuppressWarnings("unchecked") + * ArrayList draggingSelection = + * (ArrayList) event .getData(); + * Log.debug("Start Drag: " + draggingSelection); * * } }); GridDropTarget dt = new - * GridDropTarget( gridEnvironmentVariable); - * dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true); + * GridDropTarget( + * gridEnvironmentVariable); dt.setFeedback(Feedback.BOTH); + * dt.setAllowSelfAsSource(true); */ // EDITING // @@ -248,14 +254,26 @@ public class InputOutputVariablesPanel extends ContentPanel { storeComboIOType.commitChanges(); // + TextField nameColumnEditing = new TextField(); + nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField descriptionColumnEditing = new TextField(); + descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField defaultValueColumnEditing = new TextField(); + defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); gridInputOutputVariablesEditing = new GridRowEditing( gridInputOutputVariables); - gridInputOutputVariablesEditing.addEditor(nameColumn, new TextField()); - gridInputOutputVariablesEditing.addEditor(descriptionColumn, new TextField()); - gridInputOutputVariablesEditing.addEditor(dataTypeColumn, comboDataType); - gridInputOutputVariablesEditing.addEditor(defaultValueColumn, new TextField()); - + gridInputOutputVariablesEditing + .addEditor(nameColumn, nameColumnEditing); + gridInputOutputVariablesEditing.addEditor(descriptionColumn, + descriptionColumnEditing); + gridInputOutputVariablesEditing + .addEditor(dataTypeColumn, comboDataType); + gridInputOutputVariablesEditing.addEditor(defaultValueColumn, + defaultValueColumnEditing); gridInputOutputVariablesEditing.addEditor(ioTypeColumn, comboIOType); btnAdd = new TextButton(); @@ -282,27 +300,29 @@ public class InputOutputVariablesPanel extends ContentPanel { storeInputOutputVariables.remove(rowIndex); storeInputOutputVariables.commitChanges(); - gridInputOutputVariablesEditing.getCancelButton().setVisible(true); + gridInputOutputVariablesEditing.getCancelButton().setVisible( + true); btnAdd.setEnabled(true); if (addStatus) { addStatus = false; } - - List listIOVariables=storeInputOutputVariables.getAll(); - List listNewIOVariables= new ArrayList(); - for(int i=0; i listIOVariables = storeInputOutputVariables + .getAll(); + List listNewIOVariables = new ArrayList(); + for (int i = 0; i < listIOVariables.size(); i++) { + InputOutputVariables var = listIOVariables.get(i); var.setId(i); listNewIOVariables.add(var); } - + storeInputOutputVariables.clear(); storeInputOutputVariables.addAll(listNewIOVariables); storeInputOutputVariables.commitChanges(); - - seq=listNewIOVariables.size(); - Log.debug("Current Seq: "+seq); - + + seq = listNewIOVariables.size(); + Log.debug("Current Seq: " + seq); + } }); ButtonBar buttonBar = gridInputOutputVariablesEditing.getButtonBar(); @@ -349,8 +369,7 @@ public class InputOutputVariablesPanel extends ContentPanel { btnAdd.setEnabled(true); } catch (Throwable e) { - Log.error("Error: " - + e.getLocalizedMessage()); + Log.error("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } } @@ -364,7 +383,8 @@ public class InputOutputVariablesPanel extends ContentPanel { vlc.setScrollMode(ScrollMode.NONE); // vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0))); - vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, new Margins(0))); + vlc.add(gridInputOutputVariables, new VerticalLayoutData(1, 1, + new Margins(0))); add(vlc, new MarginData(new Margins(0))); @@ -393,6 +413,7 @@ public class InputOutputVariablesPanel extends ContentPanel { seq++; inputOutputVariable.setId(seq); Log.debug("New Input/Output Variable: " + inputOutputVariable); + storeInputOutputVariables.add(inputOutputVariable); storeInputOutputVariables.commitChanges(); @@ -412,12 +433,14 @@ public class InputOutputVariablesPanel extends ContentPanel { seq++; InputOutputVariables newInputOutputVariablesVariable = new InputOutputVariables( seq, "", "", "", DataType.STRING, IOType.INPUT, ""); - Log.debug("New Input/Output Variable: " + newInputOutputVariablesVariable); + Log.debug("New Input/Output Variable: " + + newInputOutputVariablesVariable); gridInputOutputVariablesEditing.cancelEditing(); addStatus = true; gridInputOutputVariablesEditing.getCancelButton().setVisible(false); storeInputOutputVariables.add(newInputOutputVariablesVariable); - int row = storeInputOutputVariables.indexOf(newInputOutputVariablesVariable); + int row = storeInputOutputVariables + .indexOf(newInputOutputVariablesVariable); storeComboDataType.clear(); storeComboDataType.addAll(DataType.asList()); @@ -446,7 +469,7 @@ public class InputOutputVariablesPanel extends ContentPanel { } else { storeInputOutputVariables.clear(); storeInputOutputVariables.commitChanges(); - seq=0; + seq = 0; } } @@ -462,7 +485,7 @@ public class InputOutputVariablesPanel extends ContentPanel { storeInputOutputVariables.commitChanges(); seq = 0; forceLayout(); - + } } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java index fe79744..473b83c 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InterpreterInfoPanel.java @@ -33,6 +33,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.form.validator.RegExValidator; import com.sencha.gxt.widget.core.client.grid.ColumnConfig; import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.Grid; @@ -140,12 +141,19 @@ public class InterpreterInfoPanel extends ContentPanel { gridInterpreterPackageInfo.setColumnReordering(false); // EDITING // + TextField nameColumnEditing=new TextField(); + nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField versionColumnEditing=new TextField(); + versionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + gridInterpreterPackageInfoEditing = new GridRowEditing( gridInterpreterPackageInfo); gridInterpreterPackageInfoEditing - .addEditor(nameColumn, new TextField()); + .addEditor(nameColumn, nameColumnEditing); gridInterpreterPackageInfoEditing.addEditor(versionColumn, - new TextField()); + versionColumnEditing); btnAdd = new TextButton("Add"); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); @@ -250,6 +258,8 @@ public class InterpreterInfoPanel extends ContentPanel { interpreterVersion = new TextField(); interpreterVersion.setAllowBlank(false); interpreterVersion.setEmptyText("Enter version..."); + interpreterVersion.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); FieldLabel interpreterVersionLabel = new FieldLabel(interpreterVersion, "Version"); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java index 240c508..35b78d2 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java @@ -110,6 +110,8 @@ public class ProjectInfoPanel extends ContentPanel { algorithmDescription = new TextField(); algorithmDescription.setAllowBlank(false); algorithmDescription.setEmptyText("Enter description..."); + algorithmDescription.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); FieldLabel descriptionLabel = new FieldLabel( algorithmDescription, "Description"); descriptionLabel.setLabelWidth(LABAEL_WIDTH); @@ -121,6 +123,7 @@ public class ProjectInfoPanel extends ContentPanel { ColumnConfig nameColumn = new ColumnConfig( props.name(), 100, "Name"); // nameColumn.setMenuDisabled(true); + ColumnConfig descriptionColumn = new ColumnConfig( props.description(), 100, "Description"); @@ -169,10 +172,18 @@ public class ProjectInfoPanel extends ContentPanel { gridRequestedVRE.setColumnReordering(false); // EDITING // + TextField nameColumnEditing=new TextField(); + nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + TextField descriptionColumnEditing=new TextField(); + descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", + "Attention character \" is not allowed")); + + gridRequestedVREEditing = new GridRowEditing( gridRequestedVRE); - gridRequestedVREEditing.addEditor(nameColumn, new TextField()); - gridRequestedVREEditing.addEditor(descriptionColumn, new TextField()); + gridRequestedVREEditing.addEditor(nameColumn, nameColumnEditing); + gridRequestedVREEditing.addEditor(descriptionColumn, descriptionColumnEditing); btnAdd = new TextButton("Add"); btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16()); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java index 9c5d67a..1b58952 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/generator/ProjectBuilder.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.ProcessBuilder.Redirect; +import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -383,6 +384,7 @@ public class ProjectBuilder { throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e); } + return; } @@ -457,6 +459,21 @@ public class ProjectBuilder { int exitValue = process.waitFor(); logger.debug("Create Algo Class: Exit Value is " + exitValue); + DirectoryStream packageHomeStream = Files + .newDirectoryStream(packageHome); + boolean createdFilesClass = false; + for (Path path : packageHomeStream) { + if (path.toString().endsWith(".class")) { + createdFilesClass = true; + break; + } + } + + if (!createdFilesClass) { + throw new StatAlgoImporterServiceException( + "Error in the creation of the class files!"); + } + } catch (IOException | InterruptedException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace();