cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Holmes <>
Subject mkdir in flowscript fails
Date Fri, 09 Jan 2009 22:36:08 GMT
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"teiJournal/backups/" + 
styleGuide + "/" +  docId);

      if (!xhtml_folder.exists()){



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] 
http-8081-7/MemberBox: JavaException: 

(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 =["folder"]);
      var styleGuide =["styleGuide"]);
      var qParams =["urlQueryString"]);
      var arrTemp = qParams.split("&");
      var docId = arrTemp[0].split("=")[1];

//Create a directory to dump the files to

      xhtml_folder = new"teiJournal/backups/" + 
styleGuide + "/" +  docId);
      if (!xhtml_folder.exists()){

// Create link to file

      xhtml_file = + "teiJournal/backups/" 
+ styleGuide + "/" + docId + "/" + docId + ".xhtml");

// Create outputstream to dump the results of conversion to the file

      outstreamXHTML = new xhtml_file );

// Call cocoon pipeline and save the results to the outputstream
      var pipePath = styleGuide + "/doc.xhtml?id=" + docId;
      cocoon.processPipelineTo(pipePath, null, outstreamXHTML);


// Bounce back to the backups list page.
      cocoon.redirectTo("../../backups.xhtml?styleGuide=" + styleGuide + 
"#" + docId, true);

    } catch( ex ) {
// Smth. went wrong. Sending a error.txt file to the browser
       cocoon.sendPage("backups/save_file_error.txt", null);

All help appreciated,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message