diff --git a/exec/impl/src/main/java/org/jboss/windup/exec/config/Configuration.java b/exec/impl/src/main/java/org/jboss/windup/exec/config/Configuration.java new file mode 100644 index 0000000000..1a9985c7e6 --- /dev/null +++ b/exec/impl/src/main/java/org/jboss/windup/exec/config/Configuration.java @@ -0,0 +1,80 @@ +package org.jboss.windup.exec.config; + +import java.util.LinkedList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Holds global configuration and plugin-specific configuration. + * + * @author Ondrej Zizka + */ +@XmlRootElement(name="config") +@XmlAccessorType( XmlAccessType.NONE ) +public class Configuration { + + @XmlElement + private CoreConfiguration globalConfig = new CoreConfiguration(); + + private List rulesetConfigs = new LinkedList(); + + + + /** + * What to do if some resource already exists. + * MERGE (ModelNode into current model) and ASK (interactive) are not supported yet. + */ + public enum IfExists { + FAIL, WARN, SKIP, MERGE, OVERWRITE, ASK, GUI; + + /** The same as valueOf(), only case-insensitive. */ + public static IfExists valueOf_Custom(String str) throws IllegalArgumentException { + try { + return valueOf( str.toUpperCase() ); + } + catch( IllegalArgumentException | NullPointerException ex ){ + throw new IllegalArgumentException("ifExists must be one of FAIL, WARN, SKIP, MERGE, OVERWRITE, ASK. Was: " + str); + } + } + + public static final String PARAM_NAME = "ifExists"; + }// enum + + + + + /** + * Triplet for module specific property, e.g --conf.logging.merge=true . + */ + public static class RulesetSpecificProperty{ + + private String moduleId; + private String propName; + private String value; + + public RulesetSpecificProperty(String moduleId, String propName, String value) { + this.moduleId = moduleId; + this.propName = propName; + this.value = value; + } + + public String getModuleId() { return moduleId; } + public void setModuleId(String moduleId) { this.moduleId = moduleId; } + public String getPropName() { return propName; } + public void setPropName(String propName) { this.propName = propName; } + public String getValue() { return value; } + public void setValue(String value) { this.value = value; } + } + + + // + public CoreConfiguration getGlobal() { return globalConfig; } + public void setGlobalConfig(CoreConfiguration options) { this.globalConfig = options; } + public List getModuleConfigs() { return rulesetConfigs; } + public void setModuleConfigs(List moduleConfigs) { this.rulesetConfigs = moduleConfigs; } + // + +}// class diff --git a/exec/impl/src/main/java/org/jboss/windup/exec/config/CoreConfiguration.java b/exec/impl/src/main/java/org/jboss/windup/exec/config/CoreConfiguration.java new file mode 100644 index 0000000000..7092021fc8 --- /dev/null +++ b/exec/impl/src/main/java/org/jboss/windup/exec/config/CoreConfiguration.java @@ -0,0 +1,76 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + */ +package org.jboss.windup.exec.config; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.xml.bind.annotation.XmlRootElement; + + +/** + * Class for storing global information needed for migration. Like dir of AS7, AS5, and profiles + *

+ * With regard of possibility to migrate from other vendors' AS, + * split to AS 7 config class, and then have 1 class per server (AS 5, WebLogic, ...). + */ +@XmlRootElement(name="global") +public class CoreConfiguration { + + private Set appPaths = new HashSet(); + + private boolean skipValidation = false; + + private boolean dryRun = false; + + private boolean isTestRun = false; + + // This is rather for test purposes. If null, all are used. + private List onlyRulesets = new LinkedList(); + + private String reportDir = "MigrationReport"; + + private String externalMigratorsDir; + + // User vars - accessible in EL's and Groovy scripts. WINDUP-132 + private Map userVars = new HashMap(); + + + + // + public Set getDeploymentsPaths() { return appPaths; } + public void addDeploymentPath(String deplPath) { this.appPaths.add( deplPath ); } + + public boolean isSkipValidation() { return skipValidation; } + public void setSkipValidation(boolean skipValidation) { this.skipValidation = skipValidation; } + + public boolean isDryRun() { return dryRun; } + public void setDryRun( boolean dryRun ) { this.dryRun = dryRun; } + + public boolean isTestRun() { return isTestRun; } + public void setTestRun( boolean isTestRun ) { this.isTestRun = isTestRun; } + + public String getReportDir() { return reportDir; } + public void setReportDir( String reportDir ) { this.reportDir = reportDir; } + + public String getExternalMigratorsDir() { return externalMigratorsDir; } + public void setExternalMigratorsDir( String externalMigratorsDir ) { this.externalMigratorsDir = externalMigratorsDir; } + + public List getOnlyMigrators() { return onlyRulesets; } + public List addOnlyMigrator( String name ) { onlyRulesets.add(name); return onlyRulesets; } + + // WINDUP-132 + public Map getUserVars() { return userVars; } + public String getUserVar( String name) { return userVars.get(name); } + public void setUserVar( String name, String val ) { this.userVars.put( name, val ); } + // + +}// class diff --git a/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationPackageModel.java b/graph/api/src/main/java/org/jboss/windup/graph/model/PackageModel.java similarity index 81% rename from graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationPackageModel.java rename to graph/api/src/main/java/org/jboss/windup/graph/model/PackageModel.java index 457e99963e..58069e9f9f 100644 --- a/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationPackageModel.java +++ b/graph/api/src/main/java/org/jboss/windup/graph/model/PackageModel.java @@ -4,7 +4,7 @@ import com.tinkerpop.frames.modules.typedgraph.TypeValue; @TypeValue("WindupServiceConfigurationPackageModel") -public interface WindupConfigurationPackageModel extends WindupVertexFrame +public interface PackageModel extends WindupVertexFrame { @Property("packageName") public String getPackageName(); diff --git a/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationModel.java b/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationModel.java index 9ad4417b01..04ff870458 100644 --- a/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationModel.java +++ b/graph/api/src/main/java/org/jboss/windup/graph/model/WindupConfigurationModel.java @@ -12,7 +12,7 @@ import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext; import com.tinkerpop.frames.modules.typedgraph.TypeValue; -@TypeValue("WindupServiceConfiguration") +@TypeValue("WindupConfiguration") public interface WindupConfigurationModel extends WindupVertexFrame { public static final String PROPERTY_SOURCE_MODE = "sourceMode"; @@ -20,6 +20,9 @@ public interface WindupConfigurationModel extends WindupVertexFrame public static final String PROPERTY_EXCLUDE_JAVA_PACKAGES = "excludeJavaPackages"; public static final String PROPERTY_SCAN_JAVA_PACKAGES = "scanJavaPackages"; + /** + * The application to scan. + */ @JavaHandler void setInputPath(String inputPath); @@ -29,6 +32,9 @@ public interface WindupConfigurationModel extends WindupVertexFrame @Adjacency(label = "inputPath", direction = Direction.OUT) void setInputPath(FileModel inputPath); + /** + * Where to put the report. + */ @JavaHandler void setOutputPath(String outputPath); @@ -38,44 +44,66 @@ public interface WindupConfigurationModel extends WindupVertexFrame @Adjacency(label = "outputPath", direction = Direction.OUT) void setOutputPath(FileModel outputPath); + + /** + * This is for scanJavaPackageList, see Impl. + */ @Adjacency(label = PROPERTY_SCAN_JAVA_PACKAGES, direction = Direction.OUT) - Iterable getScanJavaPackages(); + Iterable getScanJavaPackages(); @Adjacency(label = PROPERTY_SCAN_JAVA_PACKAGES, direction = Direction.OUT) - void addScanJavaPackages(WindupConfigurationPackageModel scanJavaPackage); + void addScanJavaPackages(PackageModel scanJavaPackage); @Adjacency(label = PROPERTY_SCAN_JAVA_PACKAGES, direction = Direction.OUT) - void setScanJavaPackages(Iterable scanJavaPackage); + void setScanJavaPackages(Iterable scanJavaPackage); + + /** + * What Java packages to exclude during scanning of archives (blacklist). + */ @Adjacency(label = PROPERTY_EXCLUDE_JAVA_PACKAGES, direction = Direction.OUT) - Iterable getExcludeJavaPackages(); + Iterable getExcludeJavaPackages(); @Adjacency(label = PROPERTY_EXCLUDE_JAVA_PACKAGES, direction = Direction.OUT) - void addExcludeJavaPackage(WindupConfigurationPackageModel scanJavaPackage); + void addExcludeJavaPackage(PackageModel scanJavaPackage); @Adjacency(label = PROPERTY_EXCLUDE_JAVA_PACKAGES, direction = Direction.OUT) - void setExcludeJavaPackages(Iterable scanJavaPackage); + void setExcludeJavaPackages(Iterable scanJavaPackage); + /** + * ??? I guess a whitelist? + */ @JavaHandler void setScanJavaPackageList(Iterable pkgs); @JavaHandler void setExcludeJavaPackageList(Iterable pkgs); + + /** + * Not used. + */ @Property(PROPERTY_FETCH_REMOTE_RESOURCES) boolean isFetchRemoteResources(); @Property(PROPERTY_FETCH_REMOTE_RESOURCES) void setFetchRemoteResources(boolean fetchRemoteResources); + + @Property(PROPERTY_SOURCE_MODE) boolean isSourceMode(); @Property(PROPERTY_SOURCE_MODE) void setSourceMode(boolean sourceMode); + + // Implementation to be used by Frames. abstract class Impl implements WindupConfigurationModel, JavaHandlerContext { + /** + * Converts the String into a FileModel. + */ public void setInputPath(String inputPath) { FileModel fileModel = this.g().addVertex(null, FileModel.class); @@ -83,6 +111,9 @@ public void setInputPath(String inputPath) setInputPath(fileModel); } + /** + * Converts the String into a FileModel. + */ public void setOutputPath(String outputPath) { FileModel fileModel = this.g().addVertex(null, FileModel.class); @@ -90,30 +121,37 @@ public void setOutputPath(String outputPath) setOutputPath(fileModel); } + + /** + * Converts the String's into a PackageModel's. + */ public void setScanJavaPackageList(Iterable pkgs) { - setScanJavaPackages(new ArrayList()); + setScanJavaPackages(new ArrayList()); if (pkgs != null) { for (String pkg : pkgs) { - WindupConfigurationPackageModel m = g().addVertex(null, - WindupConfigurationPackageModel.class); + PackageModel m = g().addVertex(null, + PackageModel.class); m.setPackageName(pkg); addScanJavaPackages(m); } } } + /** + * Converts the String's into a PackageModel's. + */ public void setExcludeJavaPackageList(Iterable pkgs) { - setExcludeJavaPackages(new ArrayList()); + setExcludeJavaPackages(new ArrayList()); if (pkgs != null) { for (String pkg : pkgs) { - WindupConfigurationPackageModel m = g().addVertex(null, - WindupConfigurationPackageModel.class); + PackageModel m = g().addVertex(null, + PackageModel.class); m.setPackageName(pkg); addExcludeJavaPackage(m); } diff --git a/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportRuleProvider.java b/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportRuleProvider.java index 01bc91e28c..ab1525f8d6 100644 --- a/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportRuleProvider.java +++ b/reporting/impl/src/main/java/org/jboss/windup/reporting/rules/CreateApplicationReportRuleProvider.java @@ -44,16 +44,9 @@ public void perform(GraphRewrite event, EvaluationContext context, WindupConfigu ProjectModel projectModel = payload.getInputPath().getProjectModel(); if (projectModel == null) { - if (payload.isSourceMode()) - { - throw new WindupException("Error, no project found in source-based input directory: " - + payload.getInputPath().getFilePath()); - } - else - { - throw new WindupException("Error, no project found in archive: " - + payload.getInputPath().getFilePath()); - } + String msg = payload.isSourceMode() ? "source-based input directory" : "archive"; + throw new WindupException("Error, no project found in "+ msg + ": " + + payload.getInputPath().getFilePath()); } createApplicationReport(event.getGraphContext(), projectModel); }