@@ -0,0 +1,2920 @@
+/***************************************************************************%0A *   Copyright (C) 2008 by Fabrizio Montesi                                *%0A *                                                                         *%0A *   This program is free software; you can redistribute it and/or modify  *%0A *   it under the terms of the GNU Library General Public License as       *%0A *   published by the Free Software Foundation; either version 2 of the    *%0A *   License, or (at your option) any later version.                       *%0A *                                                                         *%0A *   This program is distributed in the hope that it will be useful,       *%0A *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *%0A *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *%0A *   GNU General Public License for more details.                          *%0A *                                                                         *%0A *   You should have received a copy of the GNU Library General Public     *%0A *   License along with this program; if not, write to the                 *%0A *   Free Software Foundation, Inc.,                                       *%0A *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *%0A *                                                                         *%0A *   For details about the authors of this software, see the AUTHORS file. *%0A ***************************************************************************/%0A%0Apackage joliex.util;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipFile;%0Aimport jolie.net.CommMessage;%0Aimport jolie.runtime.ByteArray;%0Aimport jolie.runtime.FaultException;%0Aimport jolie.runtime.JavaService;%0Aimport jolie.runtime.Value;%0A%0A/**%0A *%0A * @author fmontesi%0A */%0Apublic class ZipUtils extends JavaService%0A%7B%0A%09static private int BUFFER_SIZE = 1024;%0A%0A%09static private ByteArray inputStreamToByteArray( InputStream istream )%0A%09%09throws IOException%0A%09%7B%0A%09%09ByteArrayOutputStream ostream = new ByteArrayOutputStream();%0A%09%09byte buffer%5B%5D = new byte%5B BUFFER_SIZE %5D;%0A%09%09int read;%0A%09%09while( (read=istream.read( buffer )) %3E= 0 ) %7B%0A%09%09%09ostream.write( buffer, 0, read );%0A%09%09%7D%0A%09%09return new ByteArray( ostream.toByteArray() );%0A%09%7D%0A%0A%09public CommMessage readEntry( CommMessage request )%0A%09%09throws FaultException%0A%09%7B%0A%09%09Value response = Value.create();%0A%09%09try %7B%0A%09%09%09ZipFile file = new ZipFile(%0A%09%09%09%09request.value().getFirstChild( %22filename%22 ).strValue()%0A%09%09%09);%0A%09%09%09ZipEntry entry = file.getEntry(%0A%09%09%09%09request.value().getFirstChild( %22entry%22 ).strValue()%0A%09%09%09);%0A%09%09%09if ( entry != null ) %7B%0A%09%09%09%09response.setValue(%0A%09%09%09%09%09inputStreamToByteArray( file.getInputStream( entry ) )%0A%09%09%09%09);%0A%09%09%09%7D%0A%09%09%7D catch( IOException e ) %7B%0A%09%09%09throw new FaultException( e );%0A%09%09%7D%0A%09%09return CommMessage.createResponse( request, response );%0A%09%7D%0A%7D%0A

Support for reading ZIP file entries.