Methods Summary |
---|
protected void | addPart(java.lang.String contentId, java.lang.String locationId, AttachmentPart ap)
//For DIME streams Content-Location is ignored.
if (contentId != null && contentId.trim().length() != 0)
parts.put(contentId, ap);
orderedParts.add(ap);
|
public void | close()
closed = true;
soapStream.close();
|
public org.apache.axis.Part | getAttachmentByReference(java.lang.String[] id)
//First see if we have read it in yet.
Part ret = null;
try {
for (int i = id.length - 1; ret == null && i > -1; --i) {
ret = (AttachmentPart) parts.get(id[i]);
}
if (null == ret) {
ret = readTillFound(id);
}
log.debug(Messages.getMessage("return02",
"getAttachmentByReference(\"" + id + "\"",
(ret == null ? "null" : ret.toString())));
} catch (java.io.IOException e) {
throw new org.apache.axis.AxisFault(e.getClass().getName()
+ e.getMessage());
}
return ret;
|
public java.util.Collection | getAttachments()
readAll();
return new java.util.LinkedList(orderedParts);
|
public java.lang.String | getContentId()Return the content id of the stream.
return contentId;
|
public java.lang.String | getContentLocation()Return the content location.
return null;
|
public int | read(byte[] b)
return read(b, 0, b.length);
|
public int | read()
if (closed) {
throw new java.io.IOException(Messages.getMessage(
"streamClosed"));
}
if (eos) {
return -1;
}
int ret = soapStream.read();
if (ret < 0) {
eos = true;
}
return ret;
|
public int | read(byte[] b, int off, int len)
if (closed) {
throw new java.io.IOException(Messages.getMessage(
"streamClosed"));
}
if (eos) {
return -1;
}
int read = soapStream.read(b, off, len);
if (read < 0) {
eos = true;
}
return read;
|
protected void | readAll()
try {
readTillFound(READ_ALL);
} catch (Exception e) {
throw org.apache.axis.AxisFault.makeFault(e);
}
|
protected org.apache.axis.Part | readTillFound(java.lang.String[] id)This will read streams in till the one that is needed is found.
if (dimeDelimitedStream == null) {
//The whole stream has been consumed already
return null;
}
Part ret = null;
try {
if (soapStream != null) { //Still on the SOAP stream.
if (!eos) { //The SOAP packet has not been fully read yet. Need to store it away.
java.io.ByteArrayOutputStream soapdata =
new java.io.ByteArrayOutputStream(1024 * 8);
byte[] buf = new byte[1024 * 16];
int byteread = 0;
do {
byteread = soapStream.read(buf);
if (byteread > 0) {
soapdata.write(buf, 0, byteread);
}
} while (byteread > -1);
soapdata.close();
soapStream.close();
soapStream = new java.io.ByteArrayInputStream(
soapdata.toByteArray());
}
dimeDelimitedStream = dimeDelimitedStream.getNextStream();
}
//Now start searching for the data.
if (null != dimeDelimitedStream) {
do {
String contentId = dimeDelimitedStream.getContentId();
String type = dimeDelimitedStream.getType();
if (type != null && !dimeDelimitedStream.getDimeTypeNameFormat().equals(DimeTypeNameFormat.MIME)) {
type = "application/uri; uri=\"" + type + "\"";
}
ManagedMemoryDataSource source = new ManagedMemoryDataSource(dimeDelimitedStream,
ManagedMemoryDataSource.MAX_MEMORY_DISK_CACHED, type, true);
DataHandler dh = new DataHandler(source);
AttachmentPart ap = new AttachmentPart(dh);
if (contentId != null) {
ap.setMimeHeader(HTTPConstants.HEADER_CONTENT_ID, contentId);
}
addPart(contentId, "", ap);
for (int i = id.length - 1; ret == null && i > -1; --i) {
if (contentId != null && id[i].equals(contentId)) { //This is the part being sought
ret = ap;
}
}
dimeDelimitedStream =
dimeDelimitedStream.getNextStream();
}
while (null == ret && null != dimeDelimitedStream);
}
} catch (Exception e) {
throw org.apache.axis.AxisFault.makeFault(e);
}
return ret;
|