You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ma...@apache.org on 2008/06/18 08:24:49 UTC
svn commit: r669094 - in
/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src:
attachments/axiom_mime_body_part.h attachments/axiom_mime_output.h
attachments/data_handler.c attachments/mime_body_part.c
attachments/mime_output.c om/om_output.c
Author: manjula
Date: Tue Jun 17 23:24:48 2008
New Revision: 669094
URL: http://svn.apache.org/viewvc?rev=669094&view=rev
Log:
Remove the whole stream creation code . Instead add exach part
to a list.
Next step is to change the transport accoarding to this change.
Modified:
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h Tue Jun 17 23:24:48 2008
@@ -32,6 +32,8 @@
#include <axutil_string.h>
#include <axutil_array_list.h>
#include <axiom_data_handler.h>
+#include <axiom_text.h>
+#include <axiom_mime_const.h>
#ifdef __cplusplus
extern "C"
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h Tue Jun 17 23:24:48 2008
@@ -53,7 +53,7 @@
AXIOM_MIME_OUTPUT_PART_BUFFER = 0,
/* A file */
- AXIOM_MIME_OUTPUT_PART_FILE;
+ AXIOM_MIME_OUTPUT_PART_FILE,
/* unknown type*/
AXIOM_MIME_OUTPUT_PART_UNKNOWN
@@ -66,20 +66,7 @@
axis2_char_t *file_name;
int part_size;
axiom_mime_output_part_type_t type;
- }
-
- AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
- axiom_mime_output_complete(
- axiom_mime_output_t * mime_output,
- const axutil_env_t * env,
- axis2_byte_t ** output_stream,
- int *output_stream_size,
- axis2_char_t * soap_body_buffer,
- axutil_array_list_t * binary_node_list,
- axis2_char_t * boundary,
- axis2_char_t * content_id,
- axis2_char_t * char_set_encoding,
- const axis2_char_t * soap_content_type);
+ };
AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
axiom_mime_output_get_content_type_for_mime(
@@ -115,6 +102,18 @@
axiom_mime_output_part_create(
const axutil_env_t *env);
+ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+ axiom_mime_output_create_part_list(
+ axiom_mime_output_t *mime_output,
+ const axutil_env_t *env,
+ axis2_char_t *soap_body,
+ axutil_array_list_t *binary_node_list,
+ axis2_char_t *boundary,
+ axis2_char_t *content_id,
+ axis2_char_t *char_set_encoding,
+ const axis2_char_t *soap_content_type);
+
+
/** @} */
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c Tue Jun 17 23:24:48 2008
@@ -411,14 +411,14 @@
if(!binary_part)
{
- return AXIS2_FAILUE;
+ return AXIS2_FAILURE;
}
if (data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_BUFFER)
{
binary_part->part = (axis2_byte_t *)data_handler->buffer;
- binary_part->part_size = (axis2_byte_t *)data_handler->buffer_len;
- binary_part->type = AXIOM_MIME_OUTPUT_PART_TYPE_BUFFER;
+ binary_part->part_size = data_handler->buffer_len;
+ binary_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
}
else if (data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE
@@ -438,7 +438,7 @@
{
binary_part->file_name = data_handler->file_name;
binary_part->part_size = stat_p.st_size;
- binary_part->type = AXIOM_MIME_OUTPUT_PART_TYPE_FILE;
+ binary_part->type = AXIOM_MIME_OUTPUT_PART_FILE;
}
}
else
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c Tue Jun 17 23:24:48 2008
@@ -203,13 +203,8 @@
axis2_char_t *header_str = NULL;
axis2_char_t *temp_header_str = NULL;
int header_str_size = 0;
- axis2_byte_t *data_handler_stream = NULL;
- int data_handler_stream_size = 0;
axis2_status_t status = AXIS2_FAILURE;
- axis2_byte_t *byte_stream = NULL;
- int size = 0;
axiom_mime_output_part_t *mime_header_part = NULL;
- axiom_mime_output_part_t *binary_part = NULL;
/* We have the mime headers in the hash with thier keys
@@ -293,7 +288,7 @@
if (mime_body_part->data_handler)
{
- status = axiom_data_handler_add_binary_data(data_handler, env, list);
+ status = axiom_data_handler_add_binary_data(mime_body_part->data_handler, env, list);
if (status != AXIS2_SUCCESS)
{
return status;
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c Tue Jun 17 23:24:48 2008
@@ -37,11 +37,11 @@
axutil_array_list_t *list,
axis2_char_t *boundary);
-static axis2_status_t axis2_write_finish_writing_mime(
+static axis2_status_t
+axiom_mime_output_finish_adding_parts(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
+ axutil_array_list_t *list,
axis2_char_t *boundary);
@@ -98,224 +98,11 @@
return;
}
-AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
-axiom_mime_output_complete(
- axiom_mime_output_t *mime_output,
- const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
- axis2_char_t *soap_body,
- axutil_array_list_t *binary_node_list,
- axis2_char_t *boundary,
- axis2_char_t *content_id,
- axis2_char_t *char_set_encoding,
- const axis2_char_t *soap_content_type)
-{
- axis2_status_t status = AXIS2_FAILURE;
- axis2_char_t *header_value = NULL;
- axis2_char_t *temp_header_value = NULL;
- axis2_char_t *content_id_string = NULL;
- axis2_char_t *temp_content_id_string = NULL;
- axiom_mime_body_part_t *root_mime_body_part = NULL;
- axis2_byte_t *output_stream_start = NULL;
- int output_stream_start_size = 0;
- axis2_byte_t *output_stream_body = NULL;
- int output_stream_body_size = 0;
- axis2_byte_t *output_stream_body_parts = NULL;
- int output_stream_body_parts_size = 0;
- axis2_byte_t *boundary_stream = NULL;
- int boundary_stream_size = 0;
- axis2_byte_t *stream_buffer = NULL;
- int stream_buffer_size = 0;
- int soap_body_buffer_size = 0;
- axis2_char_t *temp_soap_body_buffer = NULL;
- axis2_char_t *soap_body_buffer = NULL;
-
- status = axis2_start_writing_mime(mime_output, env, &output_stream_start,
- &output_stream_start_size, boundary);
- if (status != AXIS2_SUCCESS)
- {
- return NULL;
- }
-
- root_mime_body_part = axiom_mime_body_part_create(env);
-
- if (!root_mime_body_part)
- {
- return NULL;
- }
-
- /* Adding Content-Type Header */
- header_value = axutil_strdup(env, AXIOM_MIME_TYPE_XOP_XML
- ";" AXIOM_MIME_HEADER_FIELD_CHARSET "=");
- temp_header_value = axutil_stracat(env, header_value, char_set_encoding);
- AXIS2_FREE(env->allocator, header_value);
- header_value = temp_header_value;
- temp_header_value = axutil_stracat(env, header_value, ";"
- AXIOM_MIME_HEADER_FIELD_TYPE "=\"");
- AXIS2_FREE(env->allocator, header_value);
- header_value = temp_header_value;
- temp_header_value = axutil_stracat(env, header_value, soap_content_type);
- AXIS2_FREE(env->allocator, header_value);
- header_value = temp_header_value;
- temp_header_value = axutil_stracat(env, header_value, "\";");
- AXIS2_FREE(env->allocator, header_value);
- header_value = temp_header_value;
- AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
- AXIOM_MIME_HEADER_CONTENT_TYPE, header_value);
-
- /* Adding Content-Transfer Encoding Header */
- AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
- AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING,
- axutil_strdup(env, AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY));
-
- /* Adding Content-ID Header */
- content_id_string = (axis2_char_t *) "<";
- content_id_string = axutil_stracat(env, content_id_string, content_id);
- temp_content_id_string = axutil_stracat(env, content_id_string, ">");
- AXIS2_FREE(env->allocator, content_id_string);
- content_id_string = temp_content_id_string;
- AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
- AXIOM_MIME_HEADER_CONTENT_ID, content_id_string);
-
- axis2_write_body_part(mime_output, env, &output_stream_body,
- &output_stream_body_size, root_mime_body_part, boundary);
-
- AXIOM_MIME_BODY_PART_FREE(root_mime_body_part, env);
- root_mime_body_part = NULL;
-
- if (binary_node_list)
- {
- int j = 0;
- axis2_byte_t *temp_stream = NULL;
- int temp_stream_size = 0;
- axis2_byte_t *temp = NULL;
- int temp_size = 0;
- for (j = 0; j < axutil_array_list_size(binary_node_list, env); j++)
- {
- axiom_text_t *text = (axiom_text_t *)
- axutil_array_list_get(binary_node_list, env, j);
- if (text)
- {
- axiom_mime_body_part_t *mime_body_part = NULL;
- mime_body_part = axis2_create_mime_body_part(text, env);
- axis2_write_body_part(mime_output, env, &temp_stream,
- &temp_stream_size, mime_body_part, boundary);
-
- AXIOM_MIME_BODY_PART_FREE(mime_body_part, env);
- mime_body_part = NULL;
-
- temp = output_stream_body_parts;
- temp_size = output_stream_body_parts_size;
- output_stream_body_parts_size = temp_size +
- output_stream_start_size + temp_stream_size;
- output_stream_body_parts = AXIS2_MALLOC(env->allocator,
- output_stream_body_parts_size * sizeof(axis2_byte_t));
- if (!output_stream_body_parts)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "No memory. Cannot create output stream");
- return NULL;
- }
-
- if (temp)
- {
- memcpy(output_stream_body_parts, temp, temp_size);
- AXIS2_FREE(env->allocator, temp);
- temp = NULL;
- }
-
- if (output_stream_start)
- {
- memcpy(output_stream_body_parts + temp_size,
- output_stream_start, output_stream_start_size);
- }
-
- if (temp_stream)
- {
- memcpy(output_stream_body_parts + temp_size +
- output_stream_start_size, temp_stream,
- temp_stream_size);
- AXIS2_FREE(env->allocator, temp_stream);
- temp_stream = NULL;
- }
-
- temp_size = 0;
- temp_stream_size = 0;
- }
- }
- }
-
- axis2_write_finish_writing_mime(mime_output, env, &boundary_stream,
- &boundary_stream_size, boundary);
-
- if (soap_body)
- {
- temp_soap_body_buffer = axutil_stracat(env, soap_body, AXIS2_CRLF);
- soap_body_buffer = temp_soap_body_buffer;
- soap_body_buffer_size = (int) axutil_strlen(soap_body_buffer);
- }
-
- stream_buffer = AXIS2_MALLOC(env->allocator,
- (output_stream_start_size + output_stream_body_size +
- soap_body_buffer_size + output_stream_body_parts_size +
- boundary_stream_size) * sizeof(axis2_byte_t));
-
- if (output_stream_start)
- {
- memcpy(stream_buffer, output_stream_start, output_stream_start_size);
- AXIS2_FREE(env->allocator, output_stream_start);
- output_stream_start = NULL;
- stream_buffer_size += output_stream_start_size;
- }
-
- if (output_stream_body)
- {
- memcpy(stream_buffer + stream_buffer_size, output_stream_body,
- output_stream_body_size);
- AXIS2_FREE(env->allocator, output_stream_body);
- output_stream_body = NULL;
- stream_buffer_size += output_stream_body_size;
- }
-
- if (soap_body_buffer)
- {
- memcpy(stream_buffer + stream_buffer_size, soap_body_buffer,
- soap_body_buffer_size);
- AXIS2_FREE(env->allocator, soap_body_buffer);
- soap_body_buffer = NULL;
- stream_buffer_size += soap_body_buffer_size;
- }
-
- if (output_stream_body_parts)
- {
- memcpy(stream_buffer + stream_buffer_size, output_stream_body_parts,
- output_stream_body_parts_size);
- AXIS2_FREE(env->allocator, output_stream_body_parts);
- output_stream_body_parts = NULL;
- stream_buffer_size += output_stream_body_parts_size;
- }
-
- if (boundary_stream)
- {
- memcpy(stream_buffer + stream_buffer_size, boundary_stream,
- boundary_stream_size);
- AXIS2_FREE(env->allocator, boundary_stream);
- boundary_stream = NULL;
- stream_buffer_size += boundary_stream_size;
- }
-
- *output_stream = stream_buffer;
- *output_stream_size = stream_buffer_size;
- return stream_buffer;
-}
/* This method will create a mime_boundary buffer
* and based on the buffer creates a mime_output part
* This will be added to the array_list so later in the trasnport
- *this can be put to the wire. */
+ * this can be put to the wire. */
static axis2_status_t
axiom_mime_output_write_mime_boundary(
@@ -347,9 +134,7 @@
byte_stream[1] = AXIOM_MIME_BOUNDARY_BYTE;
memcpy(byte_stream + 2, byte_buffer, size);
- AXIS2_FREE(env->allocator, byte_buffer);
- byte_buffer = NULL;
-
+
boundary_part->part = byte_stream;
boundary_part->part_size = size + 2;
boundary_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
@@ -402,14 +187,17 @@
axiom_mime_output_finish_adding_parts(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axutil_array_list *list,
+ axutil_array_list_t *list,
axis2_char_t *boundary)
{
axis2_byte_t *byte_buffer = NULL;
axis2_byte_t *byte_stream = NULL;
int size = 0;
+ axiom_mime_output_part_t *final_part = NULL;
- axis2_char_2_byte(env, boundary, &byte_buffer, &size);
+ size = axutil_strlen(boundary);
+ byte_buffer = (axis2_byte_t *)boundary;
+
byte_stream =
AXIS2_MALLOC(env->allocator, (size + 4) * sizeof(axis2_byte_t));
if (!byte_stream)
@@ -420,6 +208,8 @@
return AXIS2_FAILURE;
}
+ /* Adding the starting -- */
+
byte_stream[0] = AXIOM_MIME_BOUNDARY_BYTE;
byte_stream[1] = AXIOM_MIME_BOUNDARY_BYTE;
if (byte_buffer)
@@ -434,16 +224,35 @@
"Byte buffer not available for writing");
}
+ /* Adding the final -- */
+
byte_stream[size + 2] = AXIOM_MIME_BOUNDARY_BYTE;
byte_stream[size + 3] = AXIOM_MIME_BOUNDARY_BYTE;
+
+ /* Now we add this as an mime_output part to
+ * the list. */
+
+ final_part = axiom_mime_output_part_create(env);
+
+ if(!final_part)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "No memory. Cannot create final_part");
+ return AXIS2_FAILURE;
+ }
+
+ final_part->part = byte_stream;
+ final_part->part_size = size + 4;
+ final_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+
+ axutil_array_list_add(list, env, final_part);
- *output_stream = byte_stream;
- *output_stream_size = size + 4;
-
+
return AXIS2_SUCCESS;
-
}
+
AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
axiom_mime_output_get_content_type_for_mime(
axiom_mime_output_t *mime_output,
@@ -547,7 +356,14 @@
return content_type_string;
}
-AXIS2_EXTERN axutil_arraylist_t *AXIS2_CALL
+
+/* This method is the core of attachment sending
+ * part. It will build each and every part and put them in
+ * a array_list. Instead of a big buffer we pass the array_list
+ * with small buffers and attachment locations . */
+
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
axiom_mime_output_create_part_list(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
@@ -564,18 +380,6 @@
axis2_char_t *content_id_string = NULL;
axis2_char_t *temp_content_id_string = NULL;
axiom_mime_body_part_t *root_mime_body_part = NULL;
- axis2_byte_t *output_stream_start = NULL;
- int output_stream_start_size = 0;
- axis2_byte_t *output_stream_body = NULL;
- int output_stream_body_size = 0;
- axis2_byte_t *output_stream_body_parts = NULL;
- int output_stream_body_parts_size = 0;
- axis2_byte_t *boundary_stream = NULL;
- int boundary_stream_size = 0;
- axis2_byte_t *stream_buffer = NULL;
- int stream_buffer_size = 0;
- int soap_body_buffer_size = 0;
- axis2_char_t *temp_soap_body_buffer = NULL;
axis2_char_t *soap_body_buffer = NULL;
axutil_array_list_t *part_list = NULL;
axiom_mime_output_part_t *soap_part = NULL;
@@ -584,7 +388,9 @@
if(!part_list)
{
- AXIS2_LOG_ERROR(env->log, "No memory");
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "No memory. Cannot create part list array");
return NULL;
}
@@ -671,10 +477,6 @@
if (binary_node_list)
{
int j = 0;
- axis2_byte_t *temp_stream = NULL;
- int temp_stream_size = 0;
- axis2_byte_t *temp = NULL;
- int temp_size = 0;
for (j = 0; j < axutil_array_list_size(binary_node_list, env); j++)
{
/* Getting each attachment text node from the node list */
@@ -704,7 +506,7 @@
mime_body_part = NULL;
/* Then we need to add a mime_boundary */
- staus = axiom_mime_output_write_mime_boundary(env, part_list, boundary);
+ status = axiom_mime_output_write_mime_boundary(mime_output, env, part_list, boundary);
if(status == AXIS2_FAILURE)
{
@@ -714,12 +516,12 @@
}
}
+ /* Now all the attachments and headers are added to the list.
+ * So let's add the final mime_boundary with -- at the end */
+ axiom_mime_output_finish_adding_parts(mime_output, env, part_list, boundary);
- axis2_write_finish_writing_mime(mime_output, env, &boundary_stream,
- &boundary_stream_size, boundary);
-
-
+ return part_list;
}
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c?rev=669094&r1=669093&r2=669094&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c Tue Jun 17 23:24:48 2008
@@ -646,8 +646,9 @@
{
axis2_byte_t *byte_stream = NULL;
axis2_char_t *root_content_id = NULL;
- axis2_char_t *buffer =
- (axis2_char_t *) axiom_xml_writer_get_xml(om_output->xml_writer,
+ axis2_char_t *buffer = NULL;
+
+ buffer = axiom_xml_writer_get_xml(om_output->xml_writer,
env);
int stream_size = 0;
if (om_output->is_soap11)
@@ -661,13 +662,13 @@
om_output->mime_output = axiom_mime_output_create(env);
om_output->mime_boundry = axiom_output_get_mime_boundry(om_output, env);
root_content_id = axiom_output_get_root_content_id(om_output, env);
- axiom_mime_output_complete(om_output->mime_output,
+ /*axiom_mime_output_complete(om_output->mime_output,
env, &byte_stream, &stream_size,
buffer, om_output->binary_node_list,
om_output->mime_boundry,
om_output->root_content_id,
om_output->char_set_encoding,
- soap_content_type);
+ soap_content_type);*/
*output_stream = byte_stream;
*output_stream_size = stream_size;