I'm working with an application that processes our content and produces an
IETM view. I want to launch the application and have it work on the
current document and have its context (for the second program) be the
folder the document is currently located.
It seemed like the the default was to use the directory where the current
document was. I got several successful runs of the program where this was
true. Then it started writing files to the desktop instead of the folder I
was using. Thought it might have something to do with double clicking the
document and launching Arbortext vs dragging the document into an existing
session, but that doesn't seem to make a difference.
Here is the sequence of events I'm trying to control:
1) For an open document, select a range of content that will be used later.
2) Create a Ant build properties file (always the same content).
3) Generate a new XML publication module using content selected in step 1
and create the file.
4) Launch build application (3rd party tool) that uses the
build.properties, the publication module, the document we started with in
step 1 and any associated graphics or referenced files.
4a) Application builds new directory in working folder, indexes files,
validates content, etc. It then zips the files together in the working
folder and then deploys them to another location on the locat machine.
5) Launch the viewer application.
So step 1 is achieved with some simple ACL. Steps 2, 3, 4 and 5 are all
done with Java methods - separate methods/calls.
Sometimes I see the files created in 2, 3 and 4 being created on my
desktop, other times I'm not sure where they are built. In step 4a the
process seems to get all the way to the point of zipping up the file and
then it hangs. At least that is where I get the last message in the
console. This process is basically running an Ant script. It seems that
once this process gets hosed, I'm then locked out of the editor.
Besides getting the working directory nailed down, I need to find a
graceful way to kill the process if the build fails.
The files in step 1 get here from a content managment system and may vary
by the user as to where this "working folder" is located.
ACL
function buildNSIV() {
caret first,first
caret 0,"<dmc>" -t
mark begin
caret 0,"</dmc>" -t
mark end
$title = $selection
java_static('NSIVbuild', 'genBuildProps');
java_static('NSIVbuild', 'genPubModule', $title)
response("Starting build, this takes a minute or two")
java_static('NSIVbuild', 'remove');
java_static('NSIVbuild', 'build');
response("Completed, now launching NSIV")
java_static('NSIVbuild', 'display');
# java_static('NSIVbuild', 'cleanup');
}
JAVA program
// Created by DevDaily.com
import java.io.*;
import java.util.Calendar;
public class NSIVbuild {
public static void genPubModule(String DMC) {
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
try{
// Create file
FileWriter fstream = new
FileWriter("PMC-test-78022-00000-00_000-00_en-US.xml");
BufferedWriter out = new BufferedWriter(fstream);
out.write("\n");
out.write(" out.write("ISO Character Entities 20030531//EN//XML\"
\"
out.write("%ISOEntities;\n");
out.write("]>\n");
out.write("<pm<br/>xmlns:xsi=\"
out.write("xsi:noNamespaceSchemaLocation=\"
out.write("xmlns:rdf=\"
out.write("xmlns:dc=\"
out.write("xmlns:xlink=\"
out.write("<idstatus>\n");
out.write("<pmaddres><pmc><modelic>test</modelic><pmissuer>78022</pmissuer>\n");
out.write("<pmnumber>00000</pmnumber><pmvolume>00</pmvolume></pmc>\n");
out.write("<pmtitle>Review Publish TEST " + month + "/" + day + "/" +
year + "</pmtitle>\n");
out.write("<issno issno="000"/>\n");
out.write("<issdate day="01" month="01" year="2000"/></pmaddres>\n");
// out.write("<issdate day=" + day + " month=" + month + " <br="/>year=" + year + "/></pmaddres>\n");
out.write("<pmstatus>\n");
out.write("<security class="01"/>\n");
out.write("<rpc></rpc>\n");
out.write("<actref><refdm></refdm></actref><applic><displaytext></displaytext>\n");
out.write("</applic>\n");
out.write("<qa>\n");
out.write("<unverif/></qa></pmstatus>\n");
out.write("</idstatus>\n");
out.write("<content>\n");
out.write("<pmentry>\n");
out.write("<title>Review Publish Results " + cal.getTime() +
"</title>\n");
out.write("<refdm>\n");
out.write(DMC);
out.write("</refdm>\n</pmentry>\n</content>\n</pm>\n");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
public static void genBuildProps() {
try{
// Create file
FileWriter fstream = new FileWriter("build.properties");
BufferedWriter out = new BufferedWriter(fstream);
out.write("ietp.pm.main=PMC-test-78022-00000-00_000-00_en-US.xml\n");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
public static void build() {
String s = null;
try {
String[] commands = new String[]{ "C:\\Program
Files\\nsiv3.1.13\\bin\\makedoc.bat", "deploy"};
Process p = Runtime.getRuntime().exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("BUILD PROCESSING:\n");
System.out.println("Here is the standard output of the
command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command
(if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
public static void remove() {
String s = null;
try {
String[] commands = new String[]{ "C:\\Program
Files\\nsiv3.1.13\\bin\\nsiv.bat",
"-Dnsiv.ietp=test-78022-00000-00_000-00_en-US", "remove"};
Process p = Runtime.getRuntime().exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("REMOVE PROCESSING\n");
System.out.println("Here is the standard output of the
command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command
(if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
public static void display() {
String s = null;
try {
String[] commands = new String[]{ "C:\\Program
Files\\nsiv3.1.13\\bin\\nsiv-browse.bat"};
Process p = Runtime.getRuntime().exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("DISPLAY PROCESSING\n");
System.out.println("Here is the standard output of the
command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command
(if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
public static void cleanup() {
String s = null;
try {
String[] commands = new String[]{ "del", "build.properties"};
Process p = Runtime.getRuntime().exec(commands);
System.out.println("DISPLAY PROCESSING\n");
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
try {
String[] commands = new String[]{ "del",
"test-78022-00000-00_000-00_en-US.nci"};
Process p = Runtime.getRuntime().exec(commands);
System.out.println("DISPLAY PROCESSING\n");
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
try {
String[] commands = new String[]{ "del",
"PMC-test-78022-00000-00_000-00_en-US.xml"};
Process p = Runtime.getRuntime().exec(commands);
System.out.println("DISPLAY PROCESSING\n");
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
try {
String[] commands = new String[]{ "del", "/Q", ".nsiv"};
Process p = Runtime.getRuntime().exec(commands);
System.out.println("DISPLAY PROCESSING\n");
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}