cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: [FYI] www.ormaz.it usecase
Date Tue, 15 Apr 2003 10:20:33 GMT
on 4/15/03 10:45 AM Michael Wechner wrote:

>>5) no database. all information is stored in xml files in a virtual xml
>>repository on disk.
>>
> 
> what do you mean by "virtual xml repository" and how does it work?

It's something like this:

 1) an xml document is really a folder that includes 'document.xml' and
a bunch of binary objects (in this case one or more hi-res images)

 2) a folder is given a unique identifier (an incremental number, in
this case)

 3) when the user starts editing, the folder is copied into a temporary
directory and the editing continues from there. in case, a file 'locked'
could be placed in the original folder to signify that editing is
prohibited but I didn't implement it because there was no such
concurrency problems.

 4) the user can modify the document by uploading different stuff, yet
all the stuff is copied into the temp forder. only when the person
really finishes, the stuff is copied back to the original destination
and it's then visible from the outside (if the document has the 'online'
attribute set in the root element

the code that implements the above is here:

function edit(id,type) {

   var home = cocoon.context.getRealPath("/");
   var repository = home + type + "/";
   var tempId = userid + "-" + java.lang.System.currentTimeMillis();
   var temp = repository + "temp/" + tempId;

   utilities.copy(repository + id, repository + "temp/" + tempId);

   while (true) {
        sendPageAndWait("admin/screen/" + type + "/temp-" + tempId, {
username: username, id: tempId });

        var action = cocoon.request.getParameter("action");

        if (action == "delete") {
        	utilities.remove(repository + id);
        	break;
       	} else {
	        var output = new java.io.FileOutputStream(temp + "/document.xml");
	        process("admin/" + type + "/save",{},output);
	
	        utilities.save(cocoon.request, temp);
			
	    	if (action == "finish") {
	    		if (id == "template") id = utilities.getID(repository);
	    		utilities.copy(temp,repository + id);
	    		break;
	    	}
	 }	   	
   }

   utilities.remove(temp);

   redirect("/admin/" + type);
}



Mime
View raw message