[jboss-svn-commits] JBL Code SVN: r11061 - in labs/jbosslabs/trunk/migration/project.xml-migration: src/java/org/jboss/forge/migration and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Apr 17 07:23:21 EDT 2007


Author: wrzep
Date: 2007-04-17 07:23:21 -0400 (Tue, 17 Apr 2007)
New Revision: 11061

Removed:
   labs/jbosslabs/trunk/migration/project.xml-migration/test/project.new.xml
Modified:
   labs/jbosslabs/trunk/migration/project.xml-migration/build.xml
   labs/jbosslabs/trunk/migration/project.xml-migration/src/java/org/jboss/forge/migration/Migrator.java
   labs/jbosslabs/trunk/migration/project.xml-migration/test/project.xml
Log:
migrator continued
JBLAB-855


Modified: labs/jbosslabs/trunk/migration/project.xml-migration/build.xml
===================================================================
--- labs/jbosslabs/trunk/migration/project.xml-migration/build.xml	2007-04-17 10:57:50 UTC (rev 11060)
+++ labs/jbosslabs/trunk/migration/project.xml-migration/build.xml	2007-04-17 11:23:21 UTC (rev 11061)
@@ -11,15 +11,20 @@
 		
 	<target name="build">
 		<javac srcdir="src/java" destdir="target/classes" classpathref="classpath"/>
+		<copy todir="target/classes">
+			 <fileset dir="lib" includes="**/*.jar"/>
+		</copy>
 		
 		<jar destfile="target/migrate.jar" basedir="target/classes">
 			<manifest>
 	              <attribute name="Main-Class" value="org.jboss.forge.migration.Main"/>
+	              <attribute name="Class-Path" value="resolver.jar serializer.jar xercesImpl.jar xml-apis.jar"/>
 	        </manifest>
 		</jar>
 	</target>
 		
 	<target name="run">
+		<delete file="test/project.new.xml"/>
 		<java fork="true" classname="org.jboss.forge.migration.Main">
 			<arg value="test/project.xml"/>
 			<arg value="test/project.new.xml"/>			

Modified: labs/jbosslabs/trunk/migration/project.xml-migration/src/java/org/jboss/forge/migration/Migrator.java
===================================================================
--- labs/jbosslabs/trunk/migration/project.xml-migration/src/java/org/jboss/forge/migration/Migrator.java	2007-04-17 10:57:50 UTC (rev 11060)
+++ labs/jbosslabs/trunk/migration/project.xml-migration/src/java/org/jboss/forge/migration/Migrator.java	2007-04-17 11:23:21 UTC (rev 11061)
@@ -1,6 +1,9 @@
 package org.jboss.forge.migration;
 
-import org.w3c.dom.DOMConfiguration;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.Element;
@@ -11,10 +14,14 @@
 	private Document oldDoc;
 	private Document newDoc;
 	private Element root;
+	BufferedReader stdin;
 	
 	public Migrator(Document oldDoc) {
 		
 		this.oldDoc = oldDoc;
+		
+	    InputStreamReader isr = new InputStreamReader( System.in );
+	    stdin = new BufferedReader( isr );
 	}
 	
 	public Document migrate() {
@@ -29,28 +36,181 @@
 		copyElement("company-name");
 		copyElement("logo");
 		
-		//TODO info
+		addInfo();
 		
-		//TODO developers 
+		System.out.println("Project: " + getElement("id").getTextContent());
 		
+		inputDevelopers();
+		
 		Filter jemsFilter = new JEMSFilter();
 		copyElements("jems", jemsFilter);
 		
-		//TODO repo
+		addRepositories();
 		
 		copyElement("issue-tracker");
 		
-		//TODO forums
+		inputForums();
 		
-		//TODO link
+		addLinks();
 		
-		//TODO pages
+		addPages();
 		
 		copyElement("downloads");
 		
 		return newDoc;
 	}
 
+	private void addPages() {
+		
+		Element pages = newDoc.createElement("pages");
+		root.appendChild(pages);
+		
+		// default page
+		Element defaultPage = newDoc.createElement("page");
+		pages.appendChild(defaultPage);
+		defaultPage.setAttribute("name", "");
+		
+		  // menu
+		Element menuPortlet = newDoc.createElement("portlet");
+		defaultPage.appendChild(menuPortlet);
+		menuPortlet.setAttribute("height", "1");
+		menuPortlet.setAttribute("region", "left");
+		menuPortlet.setAttribute("name", "menu");
+		
+		  // prj-info
+		Element infoPortlet = newDoc.createElement("portlet");
+		defaultPage.appendChild(infoPortlet);
+		infoPortlet.setAttribute("height", "1");
+		infoPortlet.setAttribute("region", "center");
+		infoPortlet.setAttribute("name", "info");
+	}
+
+	private void addLinks() {
+		
+		NodeList nl = oldDoc.getElementsByTagName("link");
+		for (int i = 0; i < nl.getLength(); i++) {
+			
+			Node n = nl.item(i);
+			System.out.println("Link " + n.getTextContent() + ". Name: ");
+			String answer;
+			
+			try {
+				answer = stdin.readLine();
+			} catch (IOException e) {
+				e.printStackTrace();
+				return;
+			}
+			
+			if ((answer != null) && (answer.length() > 0)) {
+				
+				Element toAdd = (Element) newDoc.importNode(n, true);				
+				toAdd.setAttribute("name", answer);
+				toAdd.removeAttribute("display");
+				
+				root.appendChild(toAdd);
+			}
+		}
+	}
+
+	private void addRepositories() {
+		
+		Element oldRepo = getElement("repository");
+		
+		if (oldRepo == null) { // input 
+			
+			Element type = readElement("repo-type");
+			root.appendChild(type);
+			
+			Element anonRepo = readElement("anon-repo");
+			root.appendChild(anonRepo);
+			
+			Element devRepo = readElement("commiter-repo");
+			root.appendChild(devRepo);
+			
+		} else { // guess
+			
+			String typeString = isSvnRepo(oldRepo) ? "svn" : "cvs";
+			
+			Element type = readElement("repo-type", typeString);
+			root.appendChild(type);
+			
+			Element anonRepo = readElement("anon-repo", oldRepo.getTextContent());
+			root.appendChild(anonRepo);
+			
+			Element devRepo = readElement("commiter-repo", oldRepo.getTextContent());
+			root.appendChild(devRepo);
+			
+		}
+	}
+
+	private static boolean isSvnRepo(Element repo) {
+		
+		if ((repo.getAttribute("type") == null) ||
+				"svn".equals(repo.getAttribute("type"))) {
+			return true;
+		}
+				
+		return false;
+	}
+
+	private void addInfo() {
+		
+		NodeList nl = oldDoc.getElementsByTagName("info");
+		if (nl.getLength() == 0) {
+			return;
+		}
+		
+		Document infoDoc = XMLTools.createDocument("", "p");
+		
+		NodeList infoNodes = nl.item(0).getChildNodes();
+		for (int i = 0; i < infoNodes.getLength(); i++) {
+			
+			Node n = infoNodes.item(i);
+			infoDoc.getDocumentElement().appendChild(infoDoc.importNode(n, true));
+		}
+	
+		String userDir = System.getProperty("user.dir");
+		String path = userDir.concat("/moreInfo.html");
+		
+		XMLTools.save(infoDoc, path);
+		
+		Element elem = newDoc.createElement("info");
+		elem.setTextContent("moreInfo.html");
+		root.appendChild(elem);
+	}
+
+	private void inputForums() {
+		
+		Element userForum = readElement("user-forum");
+		root.appendChild(userForum);
+		
+		Element devForum = readElement("dev-forum");
+		root.appendChild(devForum);
+	}
+
+	private void inputDevelopers() {
+		
+		Element developers = newDoc.createElement("developers");		
+		Element lead = readElement("lead-developer");
+		
+		developers.appendChild(lead);
+		root.appendChild(developers);
+	}
+
+	private Element getElement(String tagName) {
+		
+		NodeList nl = oldDoc.getElementsByTagName(tagName);
+		for (int i = 0; i < nl.getLength(); i++) {
+			
+			if (nl.item(i).getParentNode().equals(oldDoc.getDocumentElement())) {
+				
+				return (Element) nl.item(i);
+			}
+		}
+		
+		return null;
+	}
+	
 	private void copyElement(String tagName) {
 		
 		copyElement(tagName, null);
@@ -96,4 +256,30 @@
 		}
 	}
 
+	private Element readElement(String string) {
+		return readElement(string, null);
+	}
+	
+	private Element readElement(String string, String suggestion) {
+		
+		Element elem = newDoc.createElement(string);
+		
+		System.out.println(string + " (" + suggestion + ") :");
+		
+	    String input;
+		try {
+			input = stdin.readLine();
+		} catch (IOException e) {
+			e.printStackTrace();
+			return null;
+		}
+		
+		if ("".equals(input)) {
+			input = suggestion;
+		}
+		
+		elem.setTextContent(input);
+		
+		return elem;
+	}
 }

Deleted: labs/jbosslabs/trunk/migration/project.xml-migration/test/project.new.xml
===================================================================
--- labs/jbosslabs/trunk/migration/project.xml-migration/test/project.new.xml	2007-04-17 10:57:50 UTC (rev 11060)
+++ labs/jbosslabs/trunk/migration/project.xml-migration/test/project.new.xml	2007-04-17 11:23:21 UTC (rev 11061)
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://jboss.org">
-   <id>jbossws</id>
-   <name>JBoss Web Services</name>
-   <company-name>JBoss, Inc.</company-name>
-   <logo>images/header_projecttitle.gif</logo>
-   <jems>jbossas</jems>
-   <jems>jbossas</jems>
-   <jems>jbossas</jems>
-   <issue-tracker type="jira">http://jira.jboss.com/jira/browse/JBWS</issue-tracker>
-   <downloads>
-    
-    <!--
-      <categories>
-        <category>
-          <id>jbossws-1.0</id>
-          <name>JBossWS releases for JBossAS-4.0.x</name>
-          <description>Stable releases for JBossAS-4.0.4</description>
-          
-          <categories>
-            <category>
-              <id>subcat3</id> 
-              <name>Sub category 3</name>
-              <description>Desc of sub (sub) cat 3</description>
-            </category>
-          </categories>
-          
-          <files>
-            <file>
-              <id>jbossws-samples-1.0.0.GA.zip</id>
-              <name>jbossws-samples-1.0.0.GA</name>
-              <description>Samples for jbossws-1.0.0.GA</description>
-            </file>
-          </files>
-        </category>
-      </categories>
-      -->
-      
-      <name>JBossWS downloads</name>
-      <description/>
-      
-      <files>
-        <!-- jbossws-1.2.0.SP1 -->
-        <file>
-          <id>jbossws-1.2.0.SP1.zip</id>
-          <name>jbossws-1.2.0.SP1</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.2.0.SP1.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>Install-1.2.0.SP1.txt</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-src-1.2.0.SP1.zip</id>
-          <name>jbossws-src-1.2.0.SP1</name>
-          <description>JBossWS Sources</description>
-          <license>LGPL</license>
-        </file>
-        <file>
-          <id>jbossws-samples-1.2.0.SP1.zip</id>
-          <name>jbossws-1.2.0.SP1 Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-
-        <!-- jbossws-1.2.0.GA -->
-        <file>
-          <id>jbossws-1.2.0.GA.zip</id>
-          <name>jbossws-1.2.0.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.2.0.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>Install-1.2.0.GA.txt</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-src-1.2.0.GA.zip</id>
-          <name>jbossws-src-1.2.0.GA</name>
-          <description>JBossWS Sources</description>
-          <license>LGPL</license>
-        </file>
-        <file>
-          <id>jbossws-samples-1.2.0.GA.zip</id>
-          <name>jbossws-1.2.0.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-
-        <!-- jbossws-1.0.4.GA -->
-        <file>
-          <id>jbossws-1.0.4.GA.zip</id>
-          <name>jbossws-1.0.4.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.0.4.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>Install-1.0.4.GA.txt</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-src-1.0.4.GA.zip</id>
-          <name>jbossws-src-1.0.4.GA</name>
-          <description>JBossWS Sources</description>
-          <license>LGPL</license>
-        </file>
-        <file>
-          <id>jbossws-samples-1.0.4.GA.zip</id>
-          <name>jbossws-1.0.4.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-
-        <!-- jbossws-1.0.3.GA -->
-        <file>
-          <id>jbossws-1.0.3.GA.zip</id>
-          <name>jbossws-1.0.3.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.0.3.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>Install-1.0.3.GA.txt</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-samples-1.0.3.GA.zip</id>
-          <name>jbossws-1.0.3.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-
-        <!-- jbossws-1.0.2.GA -->
-        <file>
-          <id>jbossws-1.0.2.GA.zip</id>
-          <name>jbossws-1.0.2.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.0.2.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>Install-1.0.2.GA.txt</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-samples-1.0.2.GA.zip</id>
-          <name>jbossws-1.0.2.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-        
-        <!-- jbossws-1.0.1.GA -->
-        <file>
-          <id>jbossws-1.0.1.GA.zip</id>
-          <name>jbossws-1.0.1.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.0.1.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-          <button>
-            <id>http://wiki.jboss.org/wiki/Wiki.jsp?page=JBWS101Install</id>
-            <name>Installation instructions</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-samples-1.0.1.GA.zip</id>
-          <name>jbossws-1.0.1.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-        
-        <!-- jbossws-1.0.0.GA -->
-        <file>
-          <id>jbossws-1.0.0.GA.zip</id>
-          <name>jbossws-1.0.0.GA</name>
-          <description>Binaries, Docs, Samples</description>
-          <license>LGPL</license>
-          <button>
-            <id>ReleaseNotes-1.0.0.GA.txt</id>
-            <name>Release Notes</name>
-          </button>
-        </file>
-        <file>
-          <id>jbossws-samples-1.0.0.GA.zip</id>
-          <name>jbossws-1.0.0.GA Samples</name>
-          <description>User Guide Samples</description>
-          <license>LGPL</license>
-        </file>
-        
-      </files>
-</downloads>
-</project>

Modified: labs/jbosslabs/trunk/migration/project.xml-migration/test/project.xml
===================================================================
--- labs/jbosslabs/trunk/migration/project.xml-migration/test/project.xml	2007-04-17 10:57:50 UTC (rev 11060)
+++ labs/jbosslabs/trunk/migration/project.xml-migration/test/project.xml	2007-04-17 11:23:21 UTC (rev 11061)
@@ -6,6 +6,8 @@
   <logo>images/header_projecttitle.gif</logo>
 
   <description>projectDescription.html</description>
+
+  <info><a href="http:/jboss.org/moreInformation">howk!</a><h2>seems really interesting</h2></info>
 
   <jems>as</jems>
   <jems>portal</jems>




More information about the jboss-svn-commits mailing list