Can anyone tell me what I ma doing wrong. Service compiles fine but does not give any result.
IDataCursor pipelineCursor = pipeline.getCursor();
byte[] zippedBytes = null;
ZipInputStream zippedStream = null;
String fname = "super";
ZipEntry ze = null;
IData[] data = new IData[5];
int temp = 0;
if (pipelineCursor.first("zipbytes"))
{
zippedBytes = (byte[])pipelineCursor.getValue();
}
else
throw new ServiceException("Missing required parameter");
if (pipelineCursor.first("zipfilename"))
fname = (String) pipelineCursor.getValue();
ByteArrayInputStream is = new ByteArrayInputStream(zippedBytes);
try{
zippedStream = new ZipInputStream(is);
}
catch (Exception e)
{
throw new ServiceException(e.getMessage());
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
int dataSize = 0;
try
{
while ((ze = zippedStream.getNextEntry()) != null)
{
String strUnzippedFileName = ze.getName();
int numBytesRead = 0;
byte rdata[] = new byte[4096];
Object unZippedBytes;
while ((numBytesRead = zippedStream.read(rdata)) != -1)
{
try
{
numBytesRead = zippedStream.read(rdata);
}
catch (EOFException e)
{
numBytesRead = -1;
}
os.write(rdata, 0, numBytesRead);
}
unZippedBytes = os.toByteArray();
data[dataSize] = IDataFactory.create();
IDataCursor outDataCursor = data[dataSize].getCursor();
Object bytes = unZippedBytes;
String filename = strUnzippedFileName;
IDataUtil.put(outDataCursor, "bytes", bytes);
IDataUtil.put(outDataCursor, "filename", filename);
dataSize++;
outDataCursor.destroy();
}
}
catch (IOException e)
{
throw new ServiceException("Exception occurred while handling ZIP file: " + e);
}
Inputs is: zippedBytes which is an object and filename.
Output is a datalist of the unzipped contents - bytes, filename
regards,
qwerty12