Author: tfennelly
Date: 2009-12-02 05:48:51 -0500 (Wed, 02 Dec 2009)
New Revision: 18978
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5351
Remove unnecessary setSmooksConfig method on the RuntimeMetadata class
Modified:
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java
===================================================================
---
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2009-12-02
10:48:46 UTC (rev 18977)
+++
branches/jbosstools-3.1.0.RC1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/RuntimeMetadata.java 2009-12-02
10:48:51 UTC (rev 18978)
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -150,35 +149,8 @@
if (file != null) {
configFile = file;
if (configFile.exists() && configFile.isFile()) {
- ExecutionContext execContext = metadataExtractor.createExecutionContext();
- Properties inputParams = new Properties();
-
try {
- // Filter the config and capture the input params...
- execContext.setAttribute(InputParamExtractor.class, inputParams);
- execContext.setAttribute(RuntimeMetadata.class, this);
-
- metadataExtractor.filterSource(execContext, new StreamSource(new
FileInputStream(configFile)));
-
- inputType = inputParams.getProperty(SmooksModelUtils.INPUT_TYPE);
- if (inputType != null) {
- String inputPath = inputParams.getProperty(inputType);
- if (inputPath != null) {
- String resolvedFilePath;
- try {
- resolvedFilePath = SmooksUIUtils.parseFilePath(inputPath.trim());
- } catch (Exception e) {
- // It's not a valid config...
- inputFile = new File(inputPath.trim());
- return;
- }
-
- inputFile = new File(resolvedFilePath);
- if (inputFile.exists() && inputFile.isFile()) {
- isValidSmooksConfig = true;
- }
- }
- }
+ digestSmooksConfig(new FileInputStream(configFile));
} catch (Exception e) {
// Not a valid Smooks config file
}
@@ -187,50 +159,48 @@
}
public void setSmooksConfig(File file, InputStream inputStream) {
- reset();
- if (file != null) {
+ if (inputStream == null) {
+ setSmooksConfig(file);
+ } else {
configFile = file;
if (configFile.exists() && configFile.isFile()) {
- if (inputStream == null) {
- try {
- inputStream = new FileInputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- ExecutionContext execContext = metadataExtractor.createExecutionContext();
- Properties inputParams = new Properties();
+ digestSmooksConfig(inputStream);
+ }
+ }
+ }
- try {
- // Filter the config and capture the input params...
- execContext.setAttribute(InputParamExtractor.class, inputParams);
- execContext.setAttribute(RuntimeMetadata.class, this);
+ private void digestSmooksConfig(InputStream inputStream) {
+ ExecutionContext execContext = metadataExtractor.createExecutionContext();
+ Properties inputParams = new Properties();
- metadataExtractor.filterSource(execContext, new StreamSource(inputStream));
+ try {
+ // Filter the config and capture the input params...
+ execContext.setAttribute(InputParamExtractor.class, inputParams);
+ execContext.setAttribute(RuntimeMetadata.class, this);
- inputType = inputParams.getProperty(SmooksModelUtils.INPUT_TYPE);
- if (inputType != null) {
- String inputPath = inputParams.getProperty(inputType);
- if (inputPath != null) {
- String resolvedFilePath;
- try {
- resolvedFilePath = SmooksUIUtils.parseFilePath(inputPath.trim());
- } catch (Exception e) {
- // It's not a valid config...
- inputFile = new File(inputPath.trim());
- return;
- }
+ metadataExtractor.filterSource(execContext, new StreamSource(inputStream));
- inputFile = new File(resolvedFilePath);
- if (inputFile.exists() && inputFile.isFile()) {
- isValidSmooksConfig = true;
- }
- }
+ inputType = inputParams.getProperty(SmooksModelUtils.INPUT_TYPE);
+ if (inputType != null) {
+ String inputPath = inputParams.getProperty(inputType);
+ if (inputPath != null) {
+ String resolvedFilePath;
+ try {
+ resolvedFilePath = SmooksUIUtils.parseFilePath(inputPath.trim());
+ } catch (Exception e) {
+ // It's not a valid config...
+ inputFile = new File(inputPath.trim());
+ return;
}
- } catch (Exception e) {
- // Not a valid Smooks config file
+
+ inputFile = new File(resolvedFilePath);
+ if (inputFile.exists() && inputFile.isFile()) {
+ isValidSmooksConfig = true;
+ }
}
}
+ } catch (Exception e) {
+ // Not a valid Smooks config file
}
}