cziegeler 01/06/22 01:32:33
Modified: . build.xml
Added: bin st.class
bin/src st.java
Log:
Added sitemap command line tool which can add component declarations during the
build process
Revision Changes Path
1.19 +21 -2 xml-cocoon2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/build.xml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- build.xml 2001/06/21 13:08:56 1.18
+++ build.xml 2001/06/22 08:32:28 1.19
@@ -348,9 +348,9 @@
</target>
<!-- =================================================================== -->
- <!-- Prapares the webapp directories -->
+ <!-- Copies the webapp directories -->
<!-- =================================================================== -->
- <target name="prepare-webapp" depends="prepare">
+ <target name="copy-webapp" depends="prepare">
<mkdir dir="${build.war}"/>
<copy todir="${build.war}" filtering="on">
@@ -374,7 +374,26 @@
<fileset dir="${webapp.dir}/i18n">
</fileset>
</copy>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prapares the webapp sitemap if php is available -->
+ <!-- =================================================================== -->
+ <target name="prepare-webapp-php" depends="copy-webapp" if="php.present">
+ <java classname="st">
+ <arg line="-i ${build.war}/sitemap.xmap -o ${build.war}/sitemap.xmap2 -a
generators php org.apache.cocoon.generation.PhpGenerator"/>
+ <classpath>
+ <pathelement location="${bin.dir}"/>
+ </classpath>
+ </java>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Prepares the webapp directories -->
+ <!-- =================================================================== -->
+ <target name="prepare-webapp" depends="copy-webapp, prepare-webapp-php">
+ <!-- Simply do nothing, just invoke all dependencies -->
</target>
<!-- =================================================================== -->
1.1 xml-cocoon2/bin/st.class
<<Binary file>>
1.1 xml-cocoon2/bin/src/st.java
Index: st.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
import java.io.*;
/**
* This is a quick and dirty commandline tool which can add new
* component definitions to the sitemap.
*
* Parameters:
* -i input sitemap
* -o output sitemap
* -a <component category> <component name> <component class> <optional conf>
*
* Example:
* st -i sitemap.xmpa -o sitemap.xmap -a transformers log
* org.apache.cocoon.transformation.LogTransformer
*
* this would add:
* <map:transformer name="log"
src="org.apache.cocoon.transformation.LogTransformer"/>
* to the transformers section (category).
*
* ToDo:
* Pretty printing
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/06/22 08:32:31 $
*/
public class st {
public static String load(String filename)
throws IOException {
FileInputStream fis;
fis = new FileInputStream(filename);
int available;
byte[] data = null;
byte[] tempData;
byte[] copyData;
do {
available = 1024;
tempData = new byte[available];
available = fis.read(tempData, 0, available);
if (available > 0) {
copyData = new byte[(data == null ? 0 : data.length) + available];
if (data != null) {
System.arraycopy(data, 0, copyData, 0, data.length);
}
System.arraycopy(tempData, 0, copyData, (data == null ? 0 :
data.length), available);
data = copyData;
}
} while (available > 0);
fis.close();
return (data != null ? new String(data) : "");
}
public static void save(String filename, String data)
throws IOException {
FileWriter fw = new FileWriter(filename);
fw.write(data);
fw.close();
}
public static void main(String[] args) {
String inputName;
String outputName;
String arg;
int mode = 0;
String arg1=null, arg2=null, arg3=null, arg4=null;
boolean clError = false;
inputName = null;
outputName = null;
int i;
i = 0;
while (i < args.length && clError == false) {
arg = args[i];
if (arg.equals("-i") == true) {
if (i + 1 < args.length)
inputName = args[i+1];
else
clError = true;
i += 2;
} else if (arg.equals("-o") == true) {
if (i + 1 < args.length)
outputName = args[i+1];
else
clError = true;
i += 2;
} else if (arg.equals("-a") == true) {
if (i + 3 < args.length && mode == 0) {
mode = 1; // add
arg1 = args[i+1];
arg2 = args[i+2];
arg3 = args[i+3];
if (i + 4 < args.length && !args[i+4].startsWith("-")) {
arg4 = args[i+4];
i++;
} else {
arg4 = null;
}
i += 4;
} else {
clError = true;
}
} else {
clError = true;
}
}
if (inputName == null || outputName == null) {
clError = true;
}
if (mode == 0) {
clError = true;
}
if (clError == true) {
System.out.println("Usage: st -i [inputsitemap] -o [outputsitemap] -a
[componentcategory]"+
" [componentname] [class]
[optionalconfigurationstring]");
} else {
try {
String data = load(inputName);
if (mode == 1) {
// add a component
// arg1 : category
// arg2 : componentname
// arg3 : class
// arg4 : optional configuration
String searchString = "</map:"+arg1+">";
int pos = data.indexOf(searchString);
System.out.println("Found ("+searchString+") at " +pos);
if (pos != -1) {
data = data.substring(0, pos)
+ "<map:"+arg1.substring(0, arg1.length()-1)
+ " name=\"" + arg2 + "\" src=\""+arg3+"\""
+ (arg4 == null ? "/>\n"
: ">\n"+arg4+"\n"
+ "</map:"+arg1.substring(0,
arg1.length()-1)+">\n")
+ data.substring(pos);
}
}
save(outputName, data);
} catch (IOException ioe) {
System.err.println("Exception: " + ioe);
ioe.printStackTrace();
}
}
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]