Author: tfennelly
Date: 2011-05-09 07:19:11 -0400 (Mon, 09 May 2011)
New Revision: 31144
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java
Log:
https://issues.jboss.org/browse/JBIDE-8520
Smooks process invalid xml files without validation
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -19,7 +19,6 @@
if (file.isFile()) {
String name = file.getName();
if(name.endsWith(".xsd")){ //$NON-NLS-1$
- System.out.println(file.getName());
}
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -36,9 +36,7 @@
List<?> list1 = sr.getAbstractResourceConfig();
for (Iterator<?> iterator = list1.iterator(); iterator.hasNext();) {
AbstractResourceConfig arc = (AbstractResourceConfig) iterator.next();
- System.out.println(arc);
}
- System.out.println(obj);
} catch (IOException e) {
e.printStackTrace();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -49,9 +49,6 @@
@Override
public void doSetInput(IEditorInput input) throws CoreException {
- System.out.println(((IFileEditorInput) input).getFile()
- .getFileExtension());
-
final IFile newFile = ((IFileEditorInput) input).getFile();
if ("xml".equals(newFile.getFileExtension())) {
// try {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -10,6 +10,7 @@
public static String XMLTemplateCreationWizardPage_Button_Load;
public static String XMLTemplateCreationWizardPage_Error_Must_Click_Load;
public static String XMLTemplateCreationWizardPage_Error_Must_Select_Root;
+ public static String XMLTemplateCreationWizardPage_Error_Invalid_Sample_XML;
public static String XMLTemplateCreationWizardPage_FileLabel;
public static String XMLTemplateCreationWizardPage_Label_Select_Root;
public static String XMLTemplateCreationWizardPage_page_description;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -40,6 +40,7 @@
import org.jboss.tools.smooks.SmooksModelUtils;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.templating.model.ModelBuilderException;
+import org.jboss.tools.smooks.templating.model.xml.XMLSampleModelBuilder;
import org.jboss.tools.smooks.templating.model.xml.XSDModelBuilder;
import org.xml.sax.SAXException;
@@ -119,6 +120,20 @@
}
setErrorMessage(errorMessage);
setPageComplete(errorMessage == null);
+ } else if(templateSourceType == TemplateSourceType.xml) {
+ // Make sure a model can be created from the selected sample XML...
+ try {
+ String file = SmooksUIUtils.parseFilePath(this.fileText.getText());
+ new XMLSampleModelBuilder(URI.createFileURI(file));
+ } catch (Exception e) {
+ e.printStackTrace();
+ if(e.getCause() != null) {
+ setErrorMessage(Messages.XMLTemplateCreationWizardPage_Error_Invalid_Sample_XML +
" " + e.getCause().getMessage()); //$NON-NLS-1$
+ } else {
+ setErrorMessage(Messages.XMLTemplateCreationWizardPage_Error_Invalid_Sample_XML);
+ }
+ setPageComplete(false);
+ }
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties 2011-05-09
11:19:11 UTC (rev 31144)
@@ -4,11 +4,12 @@
XMLTemplateCreationWizardPage_Button_Load=Load
XMLTemplateCreationWizardPage_Error_Must_Click_Load=Press 'Load' button to load
XSD root element names.
XMLTemplateCreationWizardPage_Error_Must_Select_Root=Must select a root element.
+XMLTemplateCreationWizardPage_Error_Invalid_Sample_XML=Invalid Sample XML resource
selection.
XMLTemplateCreationWizardPage_FileLabel=Create Template From:
XMLTemplateCreationWizardPage_Label_Select_Root=Select root element
XMLTemplateCreationWizardPage_page_description=Select template generation source
XMLTemplateCreationWizardPage_Page_Title=Apply XML Template
XMLTemplateCreationWizardPage_XMLSampleType=Sample XML
-XMLTemplateCreationWizardPage_XMLTemplateLoadError=Unexpected XML Template source
selection. Code must be updated to accomodate new source type.
+XMLTemplateCreationWizardPage_XMLTemplateLoadError=Unexpected XML Template source
selection. Code must be updated to accommodate new source type.
XMLTemplateCreationWizardPage_XSDParsingError1=Can't get the elements in the XSD
file.
XMLTemplateCreationWizardPage_XSDType=XSD
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -261,7 +261,6 @@
*/
@Override
public void treeCollapsed(TreeFigureExpansionEvent event) {
- System.out.println();
}
/*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -61,24 +61,16 @@
private TemplateBuilder templateBuilder = null;
public FreemarkerTemplateGraphicalModel(Object data, ITreeContentProvider
contentProvider,
- ILabelProvider labelProvider, ISmooksModelProvider domainProvider) {
+ ILabelProvider labelProvider, ISmooksModelProvider domainProvider) throws
TemplateBuilderException {
super(data, contentProvider, labelProvider, domainProvider);
this.smooksModelProvider = domainProvider;
graphModelProvider = createFreemarkerTemplateContentGraphModelProvider();
try {
templateBuilder = graphModelProvider.getTemplateBuilder(this);
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ModelBuilderException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
} catch (TemplateBuilderException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw e;
+ } catch (Exception e) {
+ throw new TemplateBuilderException("Failed to create template Builder
instance.", e);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -30,6 +30,7 @@
import org.jboss.tools.smooks.graphical.editors.process.TaskType;
import org.jboss.tools.smooks.model.freemarker.Freemarker;
import org.jboss.tools.smooks.model.javabean12.BeanType;
+import org.jboss.tools.smooks.templating.template.exception.TemplateBuilderException;
/**
* @author Dart
@@ -70,8 +71,12 @@
templateLP = new FreemarkerTemplateModelLabelProvider();
}
if (taskType.inTheTask((Freemarker)model)) {
- graphModel = new FreemarkerTemplateGraphicalModel(model, new
FreemarkerContentProvider(
- contentProvider), templateLP, provider);
+ try {
+ graphModel = new FreemarkerTemplateGraphicalModel(model, new
FreemarkerContentProvider(
+ contentProvider), templateLP, provider);
+ } catch (TemplateBuilderException e) {
+ return null;
+ }
((TreeContainerModel) graphModel).setHeaderVisable(true);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-07
12:44:01 UTC (rev 31143)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-09
11:19:11 UTC (rev 31144)
@@ -100,7 +100,6 @@
} else {
smooks.filterSource(inputSource, javaResult);
}
- System.out.println("successfully");
Collection<ObjectSerializer> serializedJavaResults =
ObjectSerializer.serialize(javaResult);
if(!serializedJavaResults.isEmpty()) {
System.out.println("[" +
localizedMessages.getProperty("SmooksLauncher_Java_Mapping_Results") +
"...]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$