Hi there,
I'm trying to write flowscript which saves the output of a pipeline onto
the file system. I've successfully done this for several pipelines,
following the instructions on the WIKI. Up to now, I've been saving all
the output files in an existing directory. Now I want to save one
pipeline into a subdirectory, which I create on the fly based on the
document id:
var xhtml_folder = new Packages.java.io.File("teiJournal/backups/" +
styleGuide + "/" + docId);
if (!xhtml_folder.exists()){
xhtml_folder.mkdir();
}
The new folder is named with the string in docId, and its parent folder
already exists. The parent folder is writable by the user under which
Cocoon is running (in fact, it's owned by that user), and other
pipelines can already save files into it; however, I just can't get
Cocoon to create the subfolder. This is running on a RedHat server. If I
modify the function to write the file directly to the existing
directory, it works fine.
Does anyone have any idea why this might fail? This is the error,
followed by the complete flowscript function:
ERROR (2009-01-09) 14:30.51:770 [flow]
(/ialltjournal/teiJournal/backups/apa/doc.xhtml?id=iallt_40_01_sawhill)
http-8081-7/MemberBox: JavaException: java.io.FileNotFoundException:
/usr/local/apache-tomcat-dev/webapps/ialltjournal/teiJournal/backups/apa/iallt_40_01_sawhill/iallt_40_01_sawhill.xhtml
(No such file or directory)
(In other words, the output file is not saved, because the new directory
has not been successfully created.)
function makeBackupXHTML() {
var xml_file;
var xhtml_folder;
var xhtml_file;
var outstreamXHTML;
try {
// Get required variables.
var folder = Packages.java.lang.String(cocoon.parameters["folder"]);
var styleGuide =
Packages.java.lang.String(cocoon.parameters["styleGuide"]);
var qParams =
Packages.java.lang.String(cocoon.parameters["urlQueryString"]);
var arrTemp = qParams.split("&");
var docId = arrTemp[0].split("=")[1];
//Create a directory to dump the files to
xhtml_folder = new Packages.java.io.File("teiJournal/backups/" +
styleGuide + "/" + docId);
if (!xhtml_folder.exists()){
xhtml_folder.mkdir();
}
// Create link to file
xhtml_file = Packages.java.io.File(folder + "teiJournal/backups/"
+ styleGuide + "/" + docId + "/" + docId + ".xhtml");
// Create outputstream to dump the results of conversion to the file
outstreamXHTML = new Packages.java.io.FileOutputStream( xhtml_file );
// Call cocoon pipeline and save the results to the outputstream
var pipePath = styleGuide + "/doc.xhtml?id=" + docId;
cocoon.processPipelineTo(pipePath, null, outstreamXHTML);
outstreamXHTML.close();
// Bounce back to the backups list page.
cocoon.redirectTo("../../backups.xhtml?styleGuide=" + styleGuide +
"#" + docId, true);
} catch( ex ) {
cocoon.log.error(ex);
// Smth. went wrong. Sending a error.txt file to the browser
cocoon.sendPage("backups/save_file_error.txt", null);
}
}
All help appreciated,
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]