fix missing sources, pom was not copying source into WEB-INF/classes

some cleanup and better logging while I was in there
This commit is contained in:
rlawson 2014-08-24 13:46:02 -04:00
parent 3aa6cb044b
commit 243d88b6d1
4 changed files with 41 additions and 28 deletions

42
pom.xml
View File

@ -22,6 +22,14 @@
</properties> </properties>
<build> <build>
<resources>
<resource>
<directory>${basedir}/src/main/java</directory>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -33,23 +41,23 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.tomcat.maven</groupId> <groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId> <artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version> <version>2.1</version>
<executions> <executions>
<execution> <execution>
<id>tomcat-run</id> <id>tomcat-run</id>
<goals> <goals>
<goal>exec-war-only</goal> <goal>exec-war-only</goal>
</goals> </goals>
<phase>package</phase> <phase>package</phase>
<configuration> <configuration>
<url>http://localhost:8080/manager</url> <url>http://localhost:8080/manager</url>
<path>/WebGoat</path> <path>/WebGoat</path>
<attachArtifactClassifier>exec</attachArtifactClassifier> <attachArtifactClassifier>exec</attachArtifactClassifier>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -30,6 +30,8 @@ import org.owasp.webgoat.session.Screen;
import org.owasp.webgoat.session.WebSession; import org.owasp.webgoat.session.WebSession;
import org.owasp.webgoat.session.WebgoatContext; import org.owasp.webgoat.session.WebgoatContext;
import org.owasp.webgoat.session.WebgoatProperties; import org.owasp.webgoat.session.WebgoatProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* ************************************************************************************************* * *************************************************************************************************
@ -66,6 +68,8 @@ import org.owasp.webgoat.session.WebgoatProperties;
*/ */
public abstract class AbstractLesson extends Screen implements Comparable<Object> { public abstract class AbstractLesson extends Screen implements Comparable<Object> {
final Logger logger = LoggerFactory.getLogger(AbstractLesson.class);
/** /**
* Description of the Field * Description of the Field
*/ */
@ -496,8 +500,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
String src; String src;
try { try {
// System.out.println("Loading source file: " + logger.debug("Loading source file: " + getSourceFileName());
// getSourceFileName());
src = readFromFile(new BufferedReader(new FileReader(s.getWebResource(getSourceFileName()))), true); src = readFromFile(new BufferedReader(new FileReader(s.getWebResource(getSourceFileName()))), true);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -782,8 +785,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
} }
public void setSourceFileName(String sourceFileName) { public void setSourceFileName(String sourceFileName) {
// System.out.println("Setting source file of lesson " + this + " to: " logger.debug("Setting source file of lesson " + this + " to: " + sourceFileName);
// + sourceFileName);
this.sourceFileName = sourceFileName; this.sourceFileName = sourceFileName;
} }

View File

@ -346,32 +346,35 @@ public class Course {
*/ */
private void loadResources() { private void loadResources() {
for (AbstractLesson lesson : lessons) { for (AbstractLesson lesson : lessons) {
logger.info("Loading resources for lesson -> " + lesson.getName());
String className = lesson.getClass().getName(); String className = lesson.getClass().getName();
String classFile = getSourceFile(className); String classFile = getSourceFile(className);
logger.info("Lesson classname: " + className);
logger.info("Lesson java file: " + classFile);
for (String absoluteFile : files) { for (String absoluteFile : files) {
String fileName = getFileName(absoluteFile); String fileName = getFileName(absoluteFile);
logger.debug("Course: looking at file: " + absoluteFile); //logger.debug("Course: looking at file: " + absoluteFile);
if (absoluteFile.endsWith(classFile)) { if (absoluteFile.endsWith(classFile)) {
// System.out.println("Set source file for " + classFile); logger.info("Set source file for " + classFile);
lesson.setSourceFileName(absoluteFile); lesson.setSourceFileName(absoluteFile);
} }
if (absoluteFile.startsWith("/lesson_plans") && absoluteFile.endsWith(".html") if (absoluteFile.startsWith("/lesson_plans") && absoluteFile.endsWith(".html")
&& className.endsWith(fileName)) { && className.endsWith(fileName)) {
logger.debug("DEBUG: setting lesson plan file " + absoluteFile + " for lesson " logger.info("setting lesson plan file " + absoluteFile + " for lesson "
+ lesson.getClass().getName()); + lesson.getClass().getName());
logger.debug("fileName: " + fileName + " == className: " + className); logger.info("fileName: " + fileName + " == className: " + className);
String language = getLanguageFromFileName("/lesson_plans", absoluteFile); String language = getLanguageFromFileName("/lesson_plans", absoluteFile);
lesson.setLessonPlanFileName(language, absoluteFile); lesson.setLessonPlanFileName(language, absoluteFile);
WebGoatI18N.loadLanguage(language); WebGoatI18N.loadLanguage(language);
} }
if (absoluteFile.startsWith("/lesson_solutions") && absoluteFile.endsWith(".html") if (absoluteFile.startsWith("/lesson_solutions") && absoluteFile.endsWith(".html")
&& className.endsWith(fileName)) { && className.endsWith(fileName)) {
logger.debug("DEBUG: setting lesson solution file " + absoluteFile + " for lesson " logger.info("setting lesson solution file " + absoluteFile + " for lesson "
+ lesson.getClass().getName()); + lesson.getClass().getName());
logger.debug("fileName: " + fileName + " == className: " + className); logger.info("fileName: " + fileName + " == className: " + className);
lesson.setLessonSolutionFileName(absoluteFile); lesson.setLessonSolutionFileName(absoluteFile);
} }
} }

View File

@ -219,7 +219,7 @@ public class WebSession {
/** /**
* Constructor for the WebSession object * Constructor for the WebSession object
* *
* @param servlet Description of the Parameter * @param webgoatContext
* @param context Description of the Parameter * @param context Description of the Parameter
*/ */
public WebSession(WebgoatContext webgoatContext, ServletContext context) { public WebSession(WebgoatContext webgoatContext, ServletContext context) {