This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/master by this push: new 28c9411 delete deprecated sitegraph plugin new 9a14323 Merge pull request #332 from yasserzamani/delete_sitegraph 28c9411 is described below commit 28c94110155ccf8437cfc0151d609b436131dae8 Author: Yasser Zamani <yasserzam...@apache.org> AuthorDate: Mon Feb 11 16:53:20 2019 +0330 delete deprecated sitegraph plugin --- .gitignore | 1 - assembly/pom.xml | 5 - assembly/src/main/assembly/all.xml | 4 - assembly/src/main/assembly/docs.xml | 4 - bom/pom.xml | 5 - plugins/pom.xml | 1 - plugins/sitegraph/pom.xml | 170 --------------- .../src/main/java/org/apache/struts2/Main.java | 230 -------------------- .../org/apache/struts2/sitegraph/SiteGraph.java | 141 ------------ .../struts2/sitegraph/StrutsConfigRetriever.java | 199 ----------------- .../struts2/sitegraph/entities/FileBasedView.java | 104 --------- .../struts2/sitegraph/entities/FreeMarkerView.java | 38 ---- .../apache/struts2/sitegraph/entities/JspView.java | 38 ---- .../apache/struts2/sitegraph/entities/Target.java | 69 ------ .../struts2/sitegraph/entities/VelocityView.java | 38 ---- .../apache/struts2/sitegraph/entities/View.java | 44 ---- .../apache/struts2/sitegraph/model/ActionNode.java | 31 --- .../org/apache/struts2/sitegraph/model/Graph.java | 85 -------- .../struts2/sitegraph/model/IndentWriter.java | 60 ------ .../org/apache/struts2/sitegraph/model/Link.java | 92 -------- .../org/apache/struts2/sitegraph/model/Render.java | 27 --- .../struts2/sitegraph/model/SiteGraphNode.java | 65 ------ .../apache/struts2/sitegraph/model/SubGraph.java | 125 ----------- .../apache/struts2/sitegraph/model/ViewNode.java | 31 --- .../struts2/sitegraph/renderers/DOTRenderer.java | 239 --------------------- plugins/sitegraph/src/main/resources/LICENSE.txt | 174 --------------- plugins/sitegraph/src/main/resources/NOTICE.txt | 5 - .../apache/struts2/sitegraph/sitegraph-usage.txt | 7 - plugins/sitegraph/src/site/site.xml | 56 ----- .../apache/struts2/sitegraph/SiteGraphTest.java | 57 ----- .../org/apache/struts2/sitegraph/hello.jsp | 23 -- .../resources/org/apache/struts2/sitegraph/out.txt | 33 --- .../org/apache/struts2/sitegraph/struts.xml | 58 ----- .../sitegraph/tutorial/sitegraph/guess-error.ftl | 21 -- .../sitegraph/tutorial/sitegraph/guess-input.ftl | 32 --- .../sitegraph/tutorial/sitegraph/guess-success.jsp | 23 -- pom.xml | 6 - 37 files changed, 2341 deletions(-) diff --git a/.gitignore b/.gitignore index 025e545..31bc74e 100644 --- a/.gitignore +++ b/.gitignore @@ -47,7 +47,6 @@ plugins/jasperreports/target plugins/json/target plugins/portlet-tiles/target plugins/portlet/target -plugins/sitegraph/target plugins/sitemesh/target plugins/javatemplates/target bundles/demo/target diff --git a/assembly/pom.xml b/assembly/pom.xml index 4a72c94..4ad7362 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -206,11 +206,6 @@ <dependency> <groupId>org.apache.struts</groupId> - <artifactId>struts2-sitegraph-plugin</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.struts</groupId> <artifactId>struts2-sitemesh-plugin</artifactId> </dependency> <dependency> diff --git a/assembly/src/main/assembly/all.xml b/assembly/src/main/assembly/all.xml index dffb6b9..36ca3f5 100644 --- a/assembly/src/main/assembly/all.xml +++ b/assembly/src/main/assembly/all.xml @@ -194,10 +194,6 @@ <outputDirectory>docs/struts2-plugins/struts2-rest-plugin/apidocs</outputDirectory> </fileSet> <fileSet> - <directory>../plugins/sitegraph/target/apidocs</directory> - <outputDirectory>docs/struts2-plugins/struts2-sitegraph-plugin/apidocs</outputDirectory> - </fileSet> - <fileSet> <directory>../plugins/sitemesh/target/apidocs</directory> <outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin/apidocs</outputDirectory> </fileSet> diff --git a/assembly/src/main/assembly/docs.xml b/assembly/src/main/assembly/docs.xml index b564bb3..00f7b8b 100644 --- a/assembly/src/main/assembly/docs.xml +++ b/assembly/src/main/assembly/docs.xml @@ -129,10 +129,6 @@ <outputDirectory>docs/struts2-plugins/struts2-rest-plugin/apidocs</outputDirectory> </fileSet> <fileSet> - <directory>../plugins/sitegraph/target/apidocs</directory> - <outputDirectory>docs/struts2-plugins/struts2-sitegraph-plugin/apidocs</outputDirectory> - </fileSet> - <fileSet> <directory>../plugins/sitemesh/target/apidocs</directory> <outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin/apidocs</outputDirectory> </fileSet> diff --git a/bom/pom.xml b/bom/pom.xml index c6a3889..aeed166 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -153,11 +153,6 @@ </dependency> <dependency> <groupId>org.apache.struts</groupId> - <artifactId>struts2-sitegraph-plugin</artifactId> - <version>${struts-version.version}</version> - </dependency> - <dependency> - <groupId>org.apache.struts</groupId> <artifactId>struts2-sitemesh-plugin</artifactId> <version>${struts-version.version}</version> </dependency> diff --git a/plugins/pom.xml b/plugins/pom.xml index 2c203fb..4ecdd0e 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -51,7 +51,6 @@ <module>portlet</module> <module>portlet-tiles</module> <module>rest</module> - <module>sitegraph</module> <module>sitemesh</module> <module>spring</module> <module>testng</module> diff --git a/plugins/sitegraph/pom.xml b/plugins/sitegraph/pom.xml deleted file mode 100644 index 8da57f0..0000000 --- a/plugins/sitegraph/pom.xml +++ /dev/null @@ -1,170 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.struts</groupId> - <artifactId>struts2-plugins</artifactId> - <version>2.6-SNAPSHOT</version> - </parent> - - <artifactId>struts2-sitegraph-plugin</artifactId> - <packaging>jar</packaging> - <name>DEPRECATED: Struts 2 Sitegraph Plugin</name> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.apache.struts2.sitegraph.SiteGraph</mainClass> - <addClasspath>true</addClasspath> - </manifest> - </archive> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>struts2-junit-plugin</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>javax.servlet.jsp</groupId> - <artifactId>jsp-api</artifactId> - <scope>provided</scope> - </dependency> - - <!-- Quickstart --> - <dependency> - <groupId>jetty</groupId> - <artifactId>org.mortbay.jetty</artifactId> - <version>5.1.4</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>eclipse</groupId> - <artifactId>jdtcore</artifactId> - <version>3.1.0</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>ant</groupId> - <artifactId>ant</artifactId> - <version>1.6.5</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler</artifactId> - <version>5.5.12</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-runtime</artifactId> - <version>5.5.12</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler-jdt</artifactId> - <version>5.5.12</version> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>commons-el</groupId> - <artifactId>commons-el</artifactId> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <optional>true</optional> - </dependency> - - <!-- Test dependencies --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-core</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - - <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. - This is only necessary in tests--> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> - <scope>test</scope> - </dependency> - - </dependencies> - - <reporting> - <plugins> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <configuration> - <includes> - <include>pom.xml</include> - <include>src/**</include> - </includes> - <excludes> - <exclude>src/main/resources/org/apache/struts2/sitegraph/sitegraph-usage.txt</exclude> - <exclude>src/test/resources/org/apache/struts2/sitegraph/out.txt</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </reporting> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> -</project> diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/Main.java b/plugins/sitegraph/src/main/java/org/apache/struts2/Main.java deleted file mode 100644 index 6b1870f..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/Main.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2; - -import java.io.File; -import java.io.FilenameFilter; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * <!-- START SNIPPET: javadoc --> - * <p> - * Struts comes with various related tools included in the struts-core-VERSION.jar file. You can access these - * tools by simply unpacking the Struts distribution and running <b>java -jar struts-core-VERSION.jar</b>. - * Struts will automatically include all jars in the same directory as the struts-core-VERSION.jar file as well as all - * jars in the <i>lib</i> directory. This means you can invoke these tools either from within the standard directory - * structure found in the Struts distribution, or from within your WEB-INF/lib directory. - * </p> - * - * <p>You can access the help information for these tools by simply running the jar without any arguments.</p> - * - * <!-- END SNIPPET: javadoc --> - * @deprecated - */ -@Deprecated -public class Main { - public static void main(String[] args) { - if (args.length == 0) { - System.out.println("Usage:"); - System.out.println(" java -jar struts-toolbox.jar [command] (optional command args)"); - System.out.println(""); - System.out.println("Where [command] is one of the following:"); - System.out.println(" sitegraph"); - System.out.println(" sitegraph:xxx"); - System.out.println(""); - System.out.println("Execute the commands for additional usage instructions."); - System.out.println("Note: the *:xxx commands are just shortcuts for "); - System.out.println(" running the command on a webapp in the apps dir."); - return; - } - - - String javaHome = System.getProperty("java.home"); - ArrayList<URL> urls = new ArrayList<URL>(); - try { - findJars(new File("lib"), urls); - - // use all the jars in the current that aren't the src jar - File wd = new File("."); - File[] jars = wd.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.endsWith(".jar") && !name.contains("-src."); - } - }); - for (File jar : jars) { - urls.add(jar.toURL()); - } - - // ... but there might not be any (ie: we're in development in IDEA), so use this as backup - urls.add(new File(System.getProperty("struts.classes", "build/java")).toURL()); - urls.add(new File(System.getProperty("xwork.classes", "../xwork/build/java/")).toURL()); - - // load tools.jar from JAVA_HOME - File tools = new File(javaHome, "lib/tools.jar"); - if (!tools.exists()) { - // hmm, not there, how about java.home? - tools = new File(javaHome, "../lib/tools.jar"); - } - if (!tools.exists()) { - // try the OS X common path - tools = new File(javaHome, "../Classes/classes.jar"); - } - if (!tools.exists()) { - // try the other OS X common path - tools = new File(javaHome, "../Classes/classes.jar"); - } - if (!tools.exists()) { - // did the user specify it by hand? - String prop = System.getProperty("tools"); - if (prop != null) { - tools = new File(prop); - } - } - if (!tools.exists()) { - System.out.println("Error: Could not find tools.jar! Please do one of the following: "); - System.out.println(""); - System.out.println(" - Use the JDK's JVM (ie: c:\\jdk1.5.0\\bin\\java)"); - System.out.println(" - Specify JAVA_HOME to point to your JDK 1.5 home"); - System.out.println(" - Specify a direct path to tools.jar via, as shown below:"); - System.out.println(""); - System.out.println(" java -Dtools=/path/to/tools.jar -jar struts.jar ..."); - return; - } - - // finally, add the verified tools.jar - urls.add(tools.toURL()); - } catch (MalformedURLException e) { - e.printStackTrace(); - System.out.println("Could not find URLs -- see stack trace."); - } - - String command = args[0]; - String[] programArgs = new String[args.length - 1]; - System.arraycopy(args, 1, programArgs, 0, programArgs.length); - - if (command.startsWith("sitegraph:")) { - command = "sitegraph"; - String name = checkWebAppArgs(args); - programArgs = new String[]{"-config", "apps/" + name + "/src/webapp/WEB-INF/classes", - "-views", "apps/" + name + "/src/webapp", - "-output", "."}; - } - - if ("sitegraph".equals(command)) { - launch("org.apache.struts2.sitegraph.SiteGraph", programArgs, urls); - } - } - - private static String checkWebAppArgs(String[] args) { - int colon = args[0].indexOf(':'); - String name = null; - try { - name = args[0].substring(colon + 1); - } catch (Exception e) { - //this is OK to skip - } - if (name == null || name.equals("")) { - System.out.println("Error: you must specify the webapp you wish"); - System.out.println(" to deploy. The webapp name must be the"); - System.out.println(" name of the directory found in apps/."); - System.out.println(""); - System.out.println("Example: java -jar struts-core-VERSION.jar quickstart:sandbox"); - System.exit(1); - } - - return name; - } - - private static void launch(String program, String[] programArgs, List<URL> urls) { - Collections.reverse(urls); - URL[] urlArray = urls.toArray(new URL[urls.size()]); - URLClassLoader cl = new MainClassLoader(urlArray); - Thread.currentThread().setContextClassLoader(cl); - try { - Class clazz = cl.loadClass(program); - Method main = clazz.getDeclaredMethod("main", new Class[]{String[].class}); - main.invoke(null, new Object[]{programArgs}); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static void findJars(File file, ArrayList<URL> urls) throws MalformedURLException { - File[] files = file.listFiles(); - if (files == null) { - return; - } - - for (File f : files) { - if (f.isDirectory()) { - findJars(f, urls); - } else if (f.getName().endsWith(".jar")) { - if (isValid(f.getName())) { - urls.add(f.toURL()); - } - } - } - } - - private static boolean isValid(String name) { - return !"dom.jar".equals(name); - } - - /** - * Reverses the typical order of classloading to defer only to the parent if the current class loader can't be - * found. This is required to allow for the launcher to be embedded within struts.jar (otherwise the dependencies - * wouldn't be found by the system ClassLoader when invoking using "java -jar struts-core-VERSION.jar ..."). - */ - public static class MainClassLoader extends URLClassLoader { - public MainClassLoader(URL[] urls) { - super(urls); - } - - public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { - if (name.startsWith("org.xml.") || name.startsWith("org.w3c.") - || name.startsWith("java.") || name.startsWith("javax.") - || name.startsWith("sun.") || name.startsWith("com.sun.")) { - return super.loadClass(name, resolve); - } - - ClassLoader parent = getParent(); - // First, check if the class has already been loaded - Class c = findLoadedClass(name); - if (c == null) { - try { - c = findClass(name); - } catch (Throwable t) { - // If still not found, only then ask the parent - c = parent.loadClass(name); - } - } - if (resolve) { - resolveClass(c); - } - - return c; - } - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java deleted file mode 100644 index deb8edc..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/SiteGraph.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.apache.struts2.StrutsException; -import org.apache.struts2.sitegraph.renderers.DOTRenderer; - -import java.io.*; - -/** - * <!-- START SNIPPET: javadocs-intro --> - * <p> - * SiteGraph is a tool that renders out GraphViz-generated images depicting your - * Struts-powered web application's flow. SiteGraph requires GraphViz be installed - * and that the "dot" executable be in your command path. You can find GraphViz - * at http://www.graphviz.org. - * </p> - * <!-- END SNIPPET: javadocs-intro --> - * - * <!-- START SNIPPET: javadocs-api --> - * <p> - * If you wish to use SiteGraph through its API rather than through the command line, - * you can do that as well. All you need to do is create a new SiteGraph instance, - * optionally specify a {@link Writer} to output the dot content to, and then call - * {@link #prepare()}. - * </p> - * <!-- END SNIPPET: javadocs-api --> - */ -public class SiteGraph { - - private static final Logger LOG = LogManager.getLogger(SiteGraph.class); - - private String configDir; - private String views; - private String output; - private String namespace; - private Writer writer; - - public SiteGraph(String configDir, String views, String output, String namespace) { - this.configDir = configDir; - this.views = views; - this.output = output; - this.namespace = namespace; - } - - public static void main(String[] args) throws IOException { - if (LOG.isInfoEnabled()) { - LOG.info("SiteGraph starting..."); - } - - if (args.length != 8 && args.length != 6) { - try (InputStream is = SiteGraph.class.getResourceAsStream("sitegraph-usage.txt"); - ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - byte[] buffer = new byte[2048]; - int length; - while ((length = is.read(buffer)) != -1) { - baos.write(buffer, 0, length); - } - - String usage = baos.toString(); - System.out.println(usage.replaceAll("//.*", "")); - } - return; - } - - String configDir = getArg(args, "config"); - String views = getArg(args, "views"); - String output = getArg(args, "output"); - String namespace = getArg(args, "ns"); - - /** <!-- START SNIPPET: example-api --> */ - SiteGraph siteGraph = new SiteGraph(configDir, views, output, namespace); - siteGraph.prepare(); - siteGraph.render(); - /** <!-- END SNIPPET: example-api --> */ - } - - private static String getArg(String[] args, String arg) { - for (int i = 0; i < args.length; i++) { - if (("-" + arg).equals(args[i]) && ((i + 1) < args.length)) { - return args[i + 1]; - } - } - - return ""; - } - - /** - * Prepares the dot generated content and writes out to the provided writer - * object. If no writer has been given, that a {@link FileWriter} pointing to "out.dot" - * in the specified output directly shall be used. - */ - public void prepare() { - if (writer == null) { - try { - writer = new FileWriter(output + "/out.dot"); - } catch (IOException e) { - throw new StrutsException(e); - } - } - - StrutsConfigRetriever.setConfiguration(configDir, views.split("[,]+")); - DOTRenderer renderer = new DOTRenderer(writer); - renderer.render(namespace); - } - - /** - * Invokes the dot command, cause GraphViz to render out.dot in the form of out.gif, - * located in the specified output directory. If an error occurs during this process, - * the error is logged and the method completes without throwing an exception. - */ - public void render() { - try { - Runtime.getRuntime().exec("dot -o" + output + "/out.gif -Tgif " + output + "/out.dot"); - } catch (IOException e) { - LOG.error("Could not invoke dot", e); - } - } - - public void setWriter(Writer writer) { - this.writer = writer; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java deleted file mode 100644 index cb830a8..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph; - -import com.opensymphony.xwork2.config.ConfigurationManager; -import com.opensymphony.xwork2.config.ConfigurationProvider; -import com.opensymphony.xwork2.config.entities.ActionConfig; -import com.opensymphony.xwork2.config.entities.ResultConfig; -import com.opensymphony.xwork2.inject.Container; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.apache.struts2.config.DefaultBeanSelectionProvider; -import org.apache.struts2.config.DefaultPropertiesProvider; -import org.apache.struts2.config.PropertiesConfigurationProvider; -import org.apache.struts2.config.StrutsXmlConfigurationProvider; -import org.apache.struts2.sitegraph.entities.FreeMarkerView; -import org.apache.struts2.sitegraph.entities.JspView; -import org.apache.struts2.sitegraph.entities.VelocityView; -import org.apache.struts2.sitegraph.entities.View; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -/** - * Initializes and retrieves XWork config elements - */ -public class StrutsConfigRetriever { - - private static final Logger LOG = LogManager.getLogger(StrutsConfigRetriever.class); - private static String configDir; - private static String[] views; - private static boolean isXWorkStarted = false; - private static Map<String, View> viewCache = new LinkedHashMap<String, View>(); - private static ConfigurationManager cm; - - /** - * Returns a Map of all action names/configs - * - * @return Map of all action names/configs - */ - public static Map<String, Map<String,ActionConfig>> getActionConfigs() { - if (!isXWorkStarted) - initXWork(); - return cm.getConfiguration().getRuntimeConfiguration().getActionConfigs(); - } - - private static void initXWork() { - String configFilePath = configDir + "/struts.xml"; - File configFile = new File(configFilePath); - try { - ConfigurationProvider configProvider = new StrutsXmlConfigurationProvider(configFile.getCanonicalPath(), true, null); - cm = new ConfigurationManager(Container.DEFAULT_NAME); - cm.addContainerProvider(new DefaultPropertiesProvider()); - cm.addContainerProvider(new StrutsXmlConfigurationProvider("struts-default.xml", false, null)); - cm.addContainerProvider(configProvider); - cm.addContainerProvider(new PropertiesConfigurationProvider()); - cm.addContainerProvider(new DefaultBeanSelectionProvider()); - isXWorkStarted = true; - } catch (IOException e) { - LOG.error("IOException", e); - } - } - - public static Set<String> getNamespaces() { - Set<String> namespaces= Collections.emptySet(); - Map<String, Map<String, ActionConfig>> allActionConfigs = getActionConfigs(); - if (allActionConfigs != null) { - namespaces = allActionConfigs.keySet(); - } - return namespaces; - } - - /** - * Return a Set of the action names for this namespace. - * - * @param namespace - * @return Set of the action names for this namespace. - */ - public static Set<String> getActionNames(String namespace) { - Set<String> actionNames = Collections.emptySet(); - Map<String, Map<String, ActionConfig>> allActionConfigs = getActionConfigs(); - if (allActionConfigs != null) { - Map<String, ActionConfig> actionMappings = allActionConfigs.get(namespace); - if (actionMappings != null) { - actionNames = actionMappings.keySet(); - } - } - return actionNames; - } - - /** - * Returns the ActionConfig for this action name at this namespace. - * - * @param namespace - * @param actionName - * @return The ActionConfig for this action name at this namespace. - */ - public static ActionConfig getActionConfig(String namespace, String actionName) { - ActionConfig config = null; - Map allActionConfigs = getActionConfigs(); - if (allActionConfigs != null) { - Map actionMappings = (Map) allActionConfigs.get(namespace); - if (actionMappings != null) { - config = (ActionConfig) actionMappings.get(actionName); - } - } - return config; - } - - public static ResultConfig getResultConfig(String namespace, String actionName, - String resultName) { - ResultConfig result = null; - ActionConfig actionConfig = getActionConfig(namespace, actionName); - if (actionConfig != null) { - Map resultMap = actionConfig.getResults(); - result = (ResultConfig) resultMap.get(resultName); - } - return result; - } - - public static File getViewFile(String namespace, String actionName, String resultName) { - ResultConfig result = getResultConfig(namespace, actionName, resultName); - String location = result.getParams().get("location"); - for (String viewRoot : views) { - File viewFile = getViewFileInternal(viewRoot, location, namespace); - if (viewFile != null) { - return viewFile; - } - } - - return null; - } - - private static File getViewFileInternal(String root, String location, String namespace) { - StringBuilder filePath = new StringBuilder(root); - if (!location.startsWith("/")) { - filePath.append(namespace).append('/'); - } - filePath.append(location); - File viewFile = new File(filePath.toString()); - if (viewFile.exists()) { - return viewFile; - } else { - return null; - } - } - - public static View getView(String namespace, String actionName, String resultName, int type) { - String viewId = namespace + "/" + actionName + "/" + resultName; - View view = viewCache.get(viewId); - if (view == null) { - File viewFile = StrutsConfigRetriever.getViewFile(namespace, actionName, resultName); - if (viewFile != null) { - switch (type) { - case View.TYPE_JSP: - view = new JspView(viewFile); - break; - case View.TYPE_FTL: - view = new FreeMarkerView(viewFile); - break; - case View.TYPE_VM: - view = new VelocityView(viewFile); - break; - default: - return null; - } - - viewCache.put(viewId, view); - } - } - return view; - } - - public static void setConfiguration(String configDir, String[] views) { - StrutsConfigRetriever.configDir = configDir; - StrutsConfigRetriever.views = views; - isXWorkStarted = false; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java deleted file mode 100644 index a5a7b51..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.apache.struts2.sitegraph.model.Link; - -import java.io.*; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - */ -public abstract class FileBasedView implements View { - private String name; - private String contents; - - private static final Logger LOG = LogManager.getLogger(FileBasedView.class); - - public FileBasedView(File file) { - this.name = file.getName(); - // get the contents as a single line - this.contents = readFile(file).replaceAll("[\r\n ]+", " "); - } - - public String getName() { - return name; - } - - public Set<Target> getTargets() { - TreeSet<Target> targets = new TreeSet<Target>(); - - // links - matchPatterns(getLinkPattern(), targets, Link.TYPE_HREF); - - // actions - matchPatterns(getActionPattern(), targets, Link.TYPE_ACTION); - - // forms - matchPatterns(getFormPattern(), targets, Link.TYPE_FORM); - - return targets; - } - - protected Pattern getLinkPattern() { - // FIXME: work with new configuration style - //Object ext = Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); - String ext = "action"; - String actionRegex = "([A-Za-z0-9\\._\\-!]+\\." + ext + ")"; - return Pattern.compile(actionRegex); - } - - private void matchPatterns(Pattern pattern, Set<Target> targets, int type) { - Matcher matcher = pattern.matcher(contents); - while (matcher.find()) { - String target = matcher.group(1); - targets.add(new Target(target, type)); - } - } - - protected abstract Pattern getActionPattern(); - - protected abstract Pattern getFormPattern(); - - protected String readFile(File file) { - try (BufferedReader in = new BufferedReader(new FileReader(file))) { - String s; - StringBuilder buffer = new StringBuilder(); - - while ((s = in.readLine()) != null) { - buffer.append(s).append('\n'); - } - - return buffer.toString(); - } catch (FileNotFoundException e) { - if (LOG.isWarnEnabled()) { - LOG.warn("File not found"); - } - } catch (IOException e) { - LOG.error("Cannot read file: "+file, e); - } - - return null; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FreeMarkerView.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FreeMarkerView.java deleted file mode 100644 index 9f23479..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/FreeMarkerView.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - -import java.io.File; -import java.util.regex.Pattern; - -/** - */ -public class FreeMarkerView extends FileBasedView { - public FreeMarkerView(File file) { - super(file); - } - - protected Pattern getActionPattern() { - return Pattern.compile("<@s.action [^>]*name=\"([^\"]+)\"[^>]*>"); - } - - protected Pattern getFormPattern() { - return Pattern.compile("<@s.form [^>]*action=\"([^\"]+)\"[^>]*>"); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/JspView.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/JspView.java deleted file mode 100644 index 767d219..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/JspView.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - -import java.io.File; -import java.util.regex.Pattern; - -/** - */ -public class JspView extends FileBasedView { - public JspView(File file) { - super(file); - } - - protected Pattern getActionPattern() { - return Pattern.compile("<a:action [^>]*name=\"([^\"]+)\"[^>]*>"); - } - - protected Pattern getFormPattern() { - return Pattern.compile("<a:form [^>]*action=\"([^\"]+)\"[^>]*>"); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/Target.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/Target.java deleted file mode 100644 index 8f730bf..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/Target.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - - -/** - */ -public class Target implements Comparable<Target> { - - private String target; - private int type; - - public Target(String target, int type) { - this.target = target; - this.type = type; - } - - public String getTarget() { - return target; - } - - public int getType() { - return type; - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Target)) return false; - - final Target target1 = (Target) o; - - if (type != target1.type) return false; - if (target != null ? !target.equals(target1.target) : target1.target != null) return false; - - return true; - } - - public int hashCode() { - int result; - result = (target != null ? target.hashCode() : 0); - result = 29 * result + type; - return result; - } - - public int compareTo(Target o) { - if (o.target != null && target != null) { - return o.target.compareTo(target); - } else { - return 0; - } - } - -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/VelocityView.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/VelocityView.java deleted file mode 100644 index 505fb57..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/VelocityView.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - -import java.io.File; -import java.util.regex.Pattern; - -/** - */ -public class VelocityView extends FileBasedView { - public VelocityView(File file) { - super(file); - } - - protected Pattern getActionPattern() { - return Pattern.compile("#tag( Action [^)]*name=\"([^\"]+)\"[^)]*)"); - } - - protected Pattern getFormPattern() { - return Pattern.compile("#tag \\(Form [^)]*action=\"([^\"]+)\"[^)]*\\)"); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/View.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/View.java deleted file mode 100644 index 6db3972..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/entities/View.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.entities; - -import java.util.Set; - -/** - * TODO Describe View - */ -public interface View { - public static final int TYPE_JSP = 0; - public static final int TYPE_VM = 1; - public static final int TYPE_FTL = 2; - - /** - * Name of view file - * - * @return The name of the view file. - */ - public String getName(); - - /** - * Returns Set of Commands linked to by this view - * - * @return a set of Targets - */ - public Set<Target> getTargets(); -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ActionNode.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ActionNode.java deleted file mode 100644 index 436bb33..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ActionNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -/** - */ -public class ActionNode extends SiteGraphNode { - public ActionNode(String name) { - super(name); - } - - public String getColor() { - return "coral1"; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Graph.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Graph.java deleted file mode 100644 index c66b103..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Graph.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -/** - */ -public class Graph extends SubGraph { - private Set<Link> links; - public static Map<String,SiteGraphNode> nodeMap = new LinkedHashMap<String,SiteGraphNode>(); - - public Graph() { - super(""); - this.links = new TreeSet<Link>(); - } - - public void addLink(Link link) { - links.add(link); - } - - public void render(IndentWriter writer) throws IOException { - // write out the header - writer.write("digraph mygraph {", true); - writer.write("fontsize=10;"); - writer.write("fontname=helvetica;"); - writer.write("node [fontsize=10, fontname=helvetica, style=filled, shape=rectangle]"); - writer.write("edge [fontsize=10, fontname=helvetica]"); - - // render all the subgraphs - for (SubGraph subGraph : subGraphs) { - subGraph.render(new IndentWriter(writer)); - } - - // render all the nodes - for (SiteGraphNode siteGraphNode : nodes) { - siteGraphNode.render(writer); - } - - // finally, render the links - for (Link link : links) { - link.render(writer); - } - - // and now the footer - writer.write("}", true); - } - - public SiteGraphNode findNode(String location, SiteGraphNode ref) { - if (location.startsWith("/")) { - location = location.substring(1); - } else { - // not absolute, so use the reference node - String prefix; - if (ref.getParent() != null) { - prefix = ref.getParent().getPrefix(); - location = prefix + "_" + location; - } - } - - location = location.replaceAll("[\\./\\-\\$\\{\\}]", "_"); - - return nodeMap.get(location); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/IndentWriter.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/IndentWriter.java deleted file mode 100644 index ddf0f13..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/IndentWriter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; -import java.io.Writer; - -/** - */ -public class IndentWriter extends Writer { - Writer writer; - - public IndentWriter(Writer writer) { - this.writer = writer; - } - - public void close() throws IOException { - writer.close(); - } - - public void flush() throws IOException { - writer.flush(); - } - - public void write(String str) throws IOException { - write(str, false); - } - - public void write(String str, boolean noIndent) throws IOException { - if (!noIndent) { - str = " " + str; - } - - if (writer instanceof IndentWriter) { - ((IndentWriter) writer).write(str, false); - } else { - writer.write(str + "\n"); - } - } - - public void write(char cbuf[], int off, int len) throws IOException { - writer.write(cbuf, off, len); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Link.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Link.java deleted file mode 100644 index 7bfde7e..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Link.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; - -/** - */ -public class Link implements Render, Comparable { - public static final int TYPE_FORM = 0; - public static final int TYPE_ACTION = 1; - public static final int TYPE_HREF = 2; - public static final int TYPE_RESULT = 3; - public static final int TYPE_REDIRECT = 4; - - private SiteGraphNode from; - private SiteGraphNode to; - private int type; - private String label; - - public Link(SiteGraphNode from, SiteGraphNode to, int type, String label) { - this.from = from; - this.to = to; - this.type = type; - this.label = label; - } - - public void render(IndentWriter writer) throws IOException { - writer.write(from.getFullName() + " -> " + to.getFullName() + " [label=\"" + getRealLabel() + "\"" + getColor() + "];"); - } - - private String getRealLabel() { - switch (type) { - case TYPE_ACTION: - return "action" + label; - case TYPE_FORM: - return "form" + label; - case TYPE_HREF: - return "href" + label; - case TYPE_REDIRECT: - return "redirect: " + label; - case TYPE_RESULT: - return label; - } - - return ""; - } - - private String getColor() { - if (type == TYPE_RESULT || type == TYPE_ACTION) { - return ",color=\"darkseagreen2\""; - } else { - return ""; - } - } - - public int compareTo(Object o) { - Link other = (Link) o; - int result = from.compareTo(other.from); - if (result != 0) { - return result; - } - - result = to.compareTo(other.to); - if (result != 0) { - return result; - } - - result = label.compareTo(other.label); - if (result != 0) { - return result; - } - - return new Integer(type).compareTo(other.type); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Render.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Render.java deleted file mode 100644 index 65179c6..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/Render.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; - -/** - */ -public interface Render { - public void render(IndentWriter writer) throws IOException; -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SiteGraphNode.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SiteGraphNode.java deleted file mode 100644 index c844417..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SiteGraphNode.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; - -/** - */ -public abstract class SiteGraphNode implements Render, Comparable { - private String name; - private SubGraph parent; - - public SiteGraphNode(String name) { - this.name = name; - } - - public SubGraph getParent() { - return parent; - } - - public void setParent(SubGraph parent) { - this.parent = parent; - } - - public void render(IndentWriter writer) throws IOException { - writer.write(getFullName() + " [label=\"" + name + "\",color=\"" + getColor() + "\"];"); - } - - public String getFullName() { - String prefix = ""; - if (parent != null) { - String parentPrefix = parent.getPrefix(); - if (!parentPrefix.equals("")) { - prefix = parentPrefix + "_"; - } - } - return prefix + cleanName(); - } - - private String cleanName() { - return name.replaceAll("[\\./\\-\\$\\{\\}]", "_"); - } - - public abstract String getColor(); - - public int compareTo(Object o) { - return name.compareTo(((SiteGraphNode) o).name); - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SubGraph.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SubGraph.java deleted file mode 100644 index 26e9917..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/SubGraph.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - */ -public class SubGraph implements Render { - protected String name; - protected SubGraph parent; - protected List<SubGraph> subGraphs; - protected List<SiteGraphNode> nodes; - - public SubGraph(String name) { - this.name = name; - this.subGraphs = new ArrayList<SubGraph>(); - this.nodes = new ArrayList<SiteGraphNode>(); - } - - public String getName() { - return name; - } - - public void addSubGraph(SubGraph subGraph) { - subGraph.setParent(this); - subGraphs.add(subGraph); - } - - public void setParent(SubGraph parent) { - this.parent = parent; - } - - public void addNode(SiteGraphNode node) { - node.setParent(this); - Graph.nodeMap.put(node.getFullName(), node); - nodes.add(node); - } - - public void render(IndentWriter writer) throws IOException { - // write the header - writer.write("subgraph cluster_" + getPrefix() + " {", true); - writer.write("color=grey;"); - writer.write("fontcolor=grey;"); - writer.write("label=\"" + name + "\";"); - - // write out the subgraphs - for (SubGraph subGraph : subGraphs) { - subGraph.render(new IndentWriter(writer)); - } - - // write out the actions - for (SiteGraphNode siteGraphNode : nodes) { - siteGraphNode.render(writer); - } - - // .. footer - writer.write("}", true); - } - - public String getPrefix() { - if (parent == null) { - return name; - } else { - String prefix = parent.getPrefix(); - if (prefix.equals("")) { - return name; - } else { - return prefix + "_" + name; - } - } - } - - public SubGraph create(String namespace) { - if (namespace.equals("")) { - return this; - } - - String[] parts = namespace.split("/"); - SubGraph last = this; - for (String part : parts) { - if (part.equals("")) { - continue; - } - - SubGraph subGraph = findSubGraph(part); - if (subGraph == null) { - subGraph = new SubGraph(part); - last.addSubGraph(subGraph); - } - - last = subGraph; - } - - return last; - } - - private SubGraph findSubGraph(String name) { - for (SubGraph subGraph : subGraphs) { - if (subGraph.getName().equals(name)) { - return subGraph; - } - } - - return null; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ViewNode.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ViewNode.java deleted file mode 100644 index 3cc2e7f..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/model/ViewNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.model; - -/** - */ -public class ViewNode extends SiteGraphNode { - public ViewNode(String name) { - super(name); - } - - public String getColor() { - return "darkseagreen2"; - } -} diff --git a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java b/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java deleted file mode 100644 index 637e499..0000000 --- a/plugins/sitegraph/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph.renderers; - -import com.opensymphony.xwork2.ActionChainResult; -import com.opensymphony.xwork2.config.entities.ActionConfig; -import com.opensymphony.xwork2.config.entities.ResultConfig; -import org.apache.struts2.sitegraph.StrutsConfigRetriever; -import org.apache.struts2.sitegraph.entities.Target; -import org.apache.struts2.sitegraph.entities.View; -import org.apache.struts2.sitegraph.model.*; - -import java.io.IOException; -import java.io.Writer; -import java.util.*; - -/** - * Renders flow diagram to the console at info level - */ -public class DOTRenderer { - - private Writer writer; - private List<TempLink> links = new ArrayList<TempLink>(); - - public DOTRenderer(Writer writer) { - this.writer = writer; - } - - public void render(String ns) { - Graph graph = new Graph(); - - TreeMap<ViewNode, View> viewMap = new TreeMap<ViewNode, View>(new Comparator<ViewNode>() { - public int compare(ViewNode v1, ViewNode v2) { - - return v1.getFullName().compareTo(v2.getFullName()); - } - }); - - Set<String> namespaces = StrutsConfigRetriever.getNamespaces(); - for (String namespace : namespaces) { - if (!namespace.startsWith(ns)) { - continue; - } - - SubGraph subGraph = graph.create(namespace); - - Set<String> actionNames = StrutsConfigRetriever.getActionNames(namespace); - for (String actionName : actionNames) { - ActionConfig actionConfig = StrutsConfigRetriever.getActionConfig(namespace, - actionName); - - ActionNode action = new ActionNode(actionName); - subGraph.addNode(action); - - Set<String> resultNames = actionConfig.getResults().keySet(); - for (String resultName : resultNames) { - ResultConfig resultConfig = actionConfig.getResults().get(resultName); - String resultClassName = resultConfig.getClassName(); - - if (resultClassName.equals(ActionChainResult.class.getName())) { - - } else if (resultClassName.contains("Dispatcher") - || resultClassName.contains("Velocity") - || resultClassName.contains("Freemarker")) { - if (resultConfig.getParams().get("location") == null) { - continue; - } - - String location = getViewLocation(resultConfig.getParams().get("location"), namespace); - // FIXME: work with new configuration style - if (location.endsWith("action")) { - addTempLink(action, location, Link.TYPE_RESULT, resultConfig.getName()); - } else { - ViewNode view = new ViewNode(stripLocation(location)); - subGraph.addNode(view); - - addTempLink(action, location, Link.TYPE_RESULT, resultConfig.getName()); - - View viewFile = getView(namespace, actionName, resultName, location); - if (viewFile != null) { - viewMap.put(view, viewFile); - } - } - } else if (resultClassName.contains("Jasper")) { - - } else if (resultClassName.contains("XSLT")) { - - } else if (resultClassName.contains("Redirect")) { - // check if the redirect is to an action -- if so, link it - String locationConfig = resultConfig.getParams().get("location"); - if (locationConfig == null) { - locationConfig = resultConfig.getParams().get("actionName"); - } - String location = getViewLocation(locationConfig, namespace); - // FIXME: work with new configuration style - if (location.endsWith("action")) { - addTempLink(action, location, Link.TYPE_REDIRECT, resultConfig.getName()); - } else { - ViewNode view = new ViewNode(stripLocation(location)); - subGraph.addNode(view); - - addTempLink(action, location, Link.TYPE_REDIRECT, resultConfig.getName()); - - View viewFile = getView(namespace, actionName, resultName, location); - if (viewFile != null) { - viewMap.put(view, viewFile); - } - } - } - } - } - } - - // now look for links in the view - for (Map.Entry<ViewNode, View> viewNodeViewEntry : viewMap.entrySet()) { - ViewNode view = viewNodeViewEntry.getKey(); - View viewFile = viewNodeViewEntry.getValue(); - Set<Target> targets = viewFile.getTargets(); - for (Target target : targets) { - String viewTarget = target.getTarget(); - addTempLink(view, viewTarget, target.getType(), ""); - } - } - - // finally, let's match up these links as real Link objects - for (TempLink temp : links) { - String location = temp.location; - - // FIXME: work with new configuration style - if (location.endsWith("action")) { - location = location.substring(0, location.indexOf("action") - 1); - - if (location.indexOf('!') != -1) { - temp.label = temp.label + "\\n(" + location.substring(location.indexOf('!')) + ")"; - location = location.substring(0, location.indexOf('!')); - } - } - SiteGraphNode to = graph.findNode(location, temp.node); - if (to != null) { - graph.addLink(new Link(temp.node, to, temp.typeResult, temp.label)); - } - } - - try { - //writer.write(graph.to_s(true)); - graph.render(new IndentWriter(writer)); - writer.flush(); - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void addTempLink(SiteGraphNode node, String location, int type, String label) { - links.add(new TempLink(node, location, type, label)); - } - - private String stripLocation(String location) { - return location.substring(location.lastIndexOf('/') + 1); - } - - private View getView(String namespace, String actionName, String resultName, String location) { - int type = View.TYPE_JSP; - if (location.endsWith(".fm") || location.endsWith(".ftl")) { - type = View.TYPE_FTL; - } else if (location.endsWith(".vm")) { - type = View.TYPE_VM; - } - return StrutsConfigRetriever.getView(namespace, actionName, resultName, type); - } - - private String getViewLocation(String location, String namespace) { - String view; - if (!location.startsWith("/")) { - view = namespace + "/" + location; - } else { - view = location; - } - - if (view.indexOf('?') != -1) { - view = view.substring(0, view.indexOf('?')); - } - - return view; - } - - class TempLink { - SiteGraphNode node; - String location; - int typeResult; - String label; - - public TempLink(SiteGraphNode node, String location, int typeResult, String label) { - this.node = node; - this.location = location; - this.typeResult = typeResult; - this.label = label; - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof TempLink)) return false; - - final TempLink tempLink = (TempLink) o; - - if (typeResult != tempLink.typeResult) return false; - if (label != null ? !label.equals(tempLink.label) : tempLink.label != null) return false; - if (location != null ? !location.equals(tempLink.location) : tempLink.location != null) return false; - if (node != null ? !node.equals(tempLink.node) : tempLink.node != null) return false; - - return true; - } - - public int hashCode() { - int result; - result = (node != null ? node.hashCode() : 0); - result = 29 * result + (location != null ? location.hashCode() : 0); - result = 29 * result + typeResult; - result = 29 * result + (label != null ? label.hashCode() : 0); - return result; - } - } -} diff --git a/plugins/sitegraph/src/main/resources/LICENSE.txt b/plugins/sitegraph/src/main/resources/LICENSE.txt deleted file mode 100644 index dd5b3a5..0000000 --- a/plugins/sitegraph/src/main/resources/LICENSE.txt +++ /dev/null @@ -1,174 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. diff --git a/plugins/sitegraph/src/main/resources/NOTICE.txt b/plugins/sitegraph/src/main/resources/NOTICE.txt deleted file mode 100644 index bfba90c..0000000 --- a/plugins/sitegraph/src/main/resources/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -Apache Struts -Copyright 2000-2011 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/plugins/sitegraph/src/main/resources/org/apache/struts2/sitegraph/sitegraph-usage.txt b/plugins/sitegraph/src/main/resources/org/apache/struts2/sitegraph/sitegraph-usage.txt deleted file mode 100644 index b11d8fc..0000000 --- a/plugins/sitegraph/src/main/resources/org/apache/struts2/sitegraph/sitegraph-usage.txt +++ /dev/null @@ -1,7 +0,0 @@ -<!-- START SNIPPET: sitegraph-usage --> -Usage: -config CONFIG_DIR -views VIEWS_DIRS -output OUTPUT [-ns NAMESPACE] - CONFIG_DIR => a directory containing struts.xml - VIEWS_DIRS => comma seperated list of dirs containing JSPs, VMs, etc - OUPUT => the directory where the output should go - NAMESPACE => the namespace path restriction (/, /foo, etc) -<!-- END SNIPPET: sitegraph-usage --> diff --git a/plugins/sitegraph/src/site/site.xml b/plugins/sitegraph/src/site/site.xml deleted file mode 100644 index 54fdcf4..0000000 --- a/plugins/sitegraph/src/site/site.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---> -<project name="Apache Struts"> - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>${fluido-skin.version}</version> - </skin> - <bannerLeft> - <name>Apache Software Foundation</name> - <src>http://www.apache.org/images/asf-logo.gif</src> - <href>http://www.apache.org/</href> - </bannerLeft> - <bannerRight> - <name>Apache Struts</name> - <src>http://struts.apache.org/img/struts-logo.svg</src> - <href>http://struts.apache.org/</href> - </bannerRight> - <publishDate position="left"/> - <version position="right"/> - <body> - <links> - <item name="Apache" href="http://www.apache.org/"/> - <item name="Struts" href="http://struts.apache.org/"/> - </links> - - <menu ref="parent"/> - <menu ref="reports"/> - - <footer> - <![CDATA[<div class="row span12"> - Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project - logos are trademarks of The Apache Software Foundation. - </div>]]> - </footer> - </body> -</project> diff --git a/plugins/sitegraph/src/test/java/org/apache/struts2/sitegraph/SiteGraphTest.java b/plugins/sitegraph/src/test/java/org/apache/struts2/sitegraph/SiteGraphTest.java deleted file mode 100644 index a874d87..0000000 --- a/plugins/sitegraph/src/test/java/org/apache/struts2/sitegraph/SiteGraphTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.struts2.sitegraph; - -import com.opensymphony.xwork2.util.ClassLoaderUtil; -import org.apache.struts2.StrutsTestCase; - -import java.io.File; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.URL; - -/** - */ -public class SiteGraphTest extends StrutsTestCase { - public void testWebFlow() throws Exception { - // use the classloader rather than relying on the - // working directory being an assumed value when - // running the test: so let's get this class's parent dir - URL url = ClassLoaderUtil.getResource("org/apache/struts2/sitegraph/struts.xml", SiteGraphTest.class); - File file = new File(url.toURI()); - String dir = file.getParent(); - - SiteGraph siteGraph = new SiteGraph(dir, dir, dir, ""); - StringWriter writer = new StringWriter(); - siteGraph.setWriter(writer); - siteGraph.prepare(); - - URL compare = SiteGraphTest.class.getResource("out.txt"); - StringBuilder buffer = new StringBuilder(128); - try (InputStream in = compare.openStream()){ - byte[] buf = new byte[4096]; - int nbytes; - - while ((nbytes = in.read(buf)) > 0) { - buffer.append(new String(buf, 0, nbytes)); - } - } - assertEquals(buffer.toString().replaceAll("\r\n", "\n"), writer.toString().replaceAll("\r\n", "\n")); - } -} diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/hello.jsp b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/hello.jsp deleted file mode 100644 index a793f75..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/hello.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---%> -nothing here, move along... diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/out.txt b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/out.txt deleted file mode 100644 index 5e40cae..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/out.txt +++ /dev/null @@ -1,33 +0,0 @@ -digraph mygraph { - fontsize=10; - fontname=helvetica; - node [fontsize=10, fontname=helvetica, style=filled, shape=rectangle] - edge [fontsize=10, fontname=helvetica] - subgraph cluster_tutorial { - color=grey; - fontcolor=grey; - label="tutorial"; - subgraph cluster_tutorial_sitegraph { - color=grey; - fontcolor=grey; - label="sitegraph"; - tutorial_sitegraph_guess [label="guess",color="coral1"]; - tutorial_sitegraph_guess_success_jsp [label="guess-success.jsp",color="darkseagreen2"]; - tutorial_sitegraph_guess_input_ftl [label="guess-input.ftl",color="darkseagreen2"]; - tutorial_sitegraph_guess_error_ftl [label="guess-error.ftl",color="darkseagreen2"]; - } - tutorial_test [label="test",color="coral1"]; - tutorial_guess_input_ftl [label="guess-input.ftl",color="darkseagreen2"]; - } - hello [label="hello",color="coral1"]; - hello_jsp [label="hello.jsp",color="darkseagreen2"]; - tutorial_sitegraph_guess -> tutorial_sitegraph_guess_error_ftl [label="error",color="darkseagreen2"]; - tutorial_sitegraph_guess -> tutorial_sitegraph_guess_input_ftl [label="input",color="darkseagreen2"]; - tutorial_sitegraph_guess -> tutorial_sitegraph_guess_success_jsp [label="redirect: success"]; - tutorial_sitegraph_guess_input_ftl -> tutorial_sitegraph_guess [label="form"]; - tutorial_sitegraph_guess_success_jsp -> tutorial_sitegraph_guess [label="href\n(!default)"]; - hello -> hello_jsp [label="success",color="darkseagreen2"]; - hello -> tutorial_test [label="redirect: tutorial"]; - hello -> tutorial_test [label="redirect: tutorial2"]; - tutorial_test -> tutorial_sitegraph_guess_input_ftl [label="input",color="darkseagreen2"]; -} diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/struts.xml b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/struts.xml deleted file mode 100644 index 4a931f2..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/struts.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---> -<!DOCTYPE struts PUBLIC - "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" - "http://struts.apache.org/dtds/struts-2.0.dtd"> - -<struts> - <package name="default" extends="struts-default"> - <action name="hello" class="com.opensymphony.xwork2.ActionSupport"> - <result name="success">hello.jsp</result> - <result name="tutorial" type="redirect">/tutorial/test.action</result> - <result name="tutorial2" type="redirectAction">/tutorial/test.action</result> - </action> - </package> - - <package name="tutorial" namespace="/tutorial" extends="struts-default"> - <result-types> - <result-type name="freemarker" default="true" - class="org.apache.struts2.views.freemarker.FreemarkerResult"/> - </result-types> - - <action name="test" class="com.opensymphony.xwork2.ActionSupport"> - <result name="input">sitegraph/guess-input.ftl</result> - </action> - </package> - - <package name="sitegraph" namespace="/tutorial/sitegraph" extends="struts-default"> - <result-types> - <result-type name="freemarker" default="true" - class="org.apache.struts2.views.freemarker.FreemarkerResult"/> - </result-types> - - <action name="guess" class="com.opensymphony.xwork2.ActionSupport"> - <result name="success" type="redirect">guess-success.jsp</result> - <result name="input">guess-input.ftl</result> - <result name="error">guess-error.ftl</result> - </action> - </package> -</struts> diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-error.ftl b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-error.ftl deleted file mode 100644 index 8e670c1..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-error.ftl +++ /dev/null @@ -1,21 +0,0 @@ -<#-- -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---> -Error! diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-input.ftl b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-input.ftl deleted file mode 100644 index 3c9c901..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-input.ftl +++ /dev/null @@ -1,32 +0,0 @@ -<#-- -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---> -<html> -<head> - <title>Guess a number</title> -</head> - -<body> -<@s.form action="guess" method="post"> - <@s.textfield label="Guess a number" name="guess"/> - <@s.submit value="Guess"/> -</@s.form> -</body> -</html> diff --git a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-success.jsp b/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-success.jsp deleted file mode 100644 index 0f4ef85..0000000 --- a/plugins/sitegraph/src/test/resources/org/apache/struts2/sitegraph/tutorial/sitegraph/guess-success.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%-- -/* - * $Id$ - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ ---%> -You guessed correctly! Want to play <a href="guess!default.action">again</a>? diff --git a/pom.xml b/pom.xml index b010cc8..92cc11d 100644 --- a/pom.xml +++ b/pom.xml @@ -366,7 +366,6 @@ <exclude>src/main/webapp/**/*.js</exclude> <exclude>src/main/webapp/**/*.svg</exclude> <exclude>src/main/webapp/**/*.txt</exclude> - <exclude>src/main/resources/**/sitegraph-usage.txt</exclude> <exclude>src/main/resources/**/docs-urls.txt</exclude> <exclude>src/etc/header.txt</exclude> <exclude>src/main/resources/static/css/**/*.css</exclude> @@ -645,11 +644,6 @@ </dependency> <dependency> <groupId>org.apache.struts</groupId> - <artifactId>struts2-sitegraph-plugin</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.struts</groupId> <artifactId>struts2-sitemesh-plugin</artifactId> <version>${project.version}</version> </dependency>