2 Dec 13:27
Re: Creating site archive
Le mardi 02 décembre 2008 à 12:14 +0100, Julien CARSIQUE a écrit :
> Hello,
>
> We're used to archive Nuxeo without any problem. I'm not sure to
> understand yours.
> How do you do this ? On which OS ? With witch software ?
I am using standard maven-assembly-plugin, maven 2.0.9, linux, java 1.5.
I did the following:
- export a site to zip using the following script (see at end)
- unzip the produced archive
- zip the produced archive with maven
- import the site using the import script below
This does not work.
However, If I remove step 2 and 3, it works. Doing a unzip -l in the
console shows that a banner is added by nuxeo which obviously is not by
maven. I am wondering why this is so ? I can of course look at
NuxeoArchiveWriter and try to reproduce what this does, but this seems
to me a bit complex.
Regards,
aRnaud Bailly
the import script:
import org.nuxeo.ecm.core.io.impl.plugins.ZipReader
import org.nuxeo.ecm.core.io.impl.plugins.DocumentModelWriter
import org.nuxeo.ecm.core.io.impl.DocumentPipeImpl
def main(){
file = Request.getParameter("file")
if (file == null){
// Context.render('import.ftl')
}
else{
try {
reader = new ZipReader(new File(file))
writer = new DocumentModelWriter(Session, "/")
// creating a pipe
pipe = new DocumentPipeImpl()
pipe.setReader(reader)
pipe.setWriter(writer)
pipe.run()
} finally {
if (reader != null) {
reader.close()
}
if (writer != null) {
writer.close()
}
}
}
}
main()
the export script:
import org.nuxeo.ecm.core.io.impl.plugins.DocumentTreeReader
import org.nuxeo.ecm.core.io.impl.plugins.NuxeoArchiveWriter
import org.nuxeo.ecm.core.io.impl.DocumentPipeImpl
import java.text.SimpleDateFormat
import java.util.Date
import java.util.zip.ZipInputStream
import java.io.FileInputStream
def getExportData(destination){
fin = new FileInputStream(destination)
fos = Response.getOutputStream()
buffer = new byte[1024*10]
Response.setContentType( "application/zip" )
Response.setHeader("Content-Disposition", "inline;
filename=export.zip;")
while(fin.read(buffer) != -1) {
fos.write(buffer)
}
fin.close()
fos.flush()
}
def main(){
target = Request.getParameter("target")
if(target == null)
target = "./"
if(!new File(target).exists() || !new File(target).isDirectory()
|| !new File(target).canWrite() ) {
throw new RuntimeException(target + " does not exist, is not a
directory or is not writable")
}
try {
reader = new DocumentTreeReader(Session, Session.getRootDocument())
formatter = new SimpleDateFormat("yyyyMMdd-HHmmss")
destination = new File(target + "/data-" + formatter.format(new
Date()) + ".zip")
writer = new NuxeoArchiveWriter(destination)
// creating a pipe
pipe = new DocumentPipeImpl()
pipe.setReader(reader)
pipe.setWriter(writer)
pipe.run()
//getExportData(destination)
} finally {
if (reader != null) {
reader.close()
}
if (writer != null) {
writer.close()
}
}
}
main()
Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires et
sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir
immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce message, le
contenu de ce message ne représente en aucun cas un engagement de la part de Leroy Merlin.
_______________________________________________
ECM mailing list
ECM <at> lists.nuxeo.com
http://lists.nuxeo.com/mailman/listinfo/ecm
RSS Feed