Author: tfennelly
Date: 2011-05-06 12:56:56 -0400 (Fri, 06 May 2011)
New Revision: 31129
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java
branches/jbosstools-3.2.x/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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/core/XSDFileCollect.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -19,7 +19,6 @@
if (file.isFile()) {
String name = file.getName();
if(name.endsWith(".xsd")){ //$NON-NLS-1$
- System.out.println(file.getName());
}
}
}
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/common/Test.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksXMLEditor.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/freemarker/FreemarkerCSVNodeEditPart.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -261,7 +261,6 @@
*/
@Override
public void treeCollapsed(TreeFigureExpansionEvent event) {
- System.out.println();
}
/*
Modified:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/freemarker/FreemarkerTemplateGraphicalModel.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/template/FreemarkerTemplateGraphicalModelFactory.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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:
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java
===================================================================
---
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-06
16:54:10 UTC (rev 31128)
+++
branches/jbosstools-3.2.x/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/launch/SmooksLauncher.java 2011-05-06
16:56:56 UTC (rev 31129)
@@ -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$