Thanks for replying. Here is a snippet of the function creating the change. I've removed the multiple lines that are setting different fields to conserve space.
Code:
private ChangeInstanceType createChangeInstance(Map arguments)
{
*SNIP REMOVED CODE THAT DOESN'T REALLY MATTER*
ChangeInstanceType instance = new ChangeInstanceType();
assets = new Assets_type1();
value = (String) arguments.get(ARGUMENT_ASSETS);
assets.addAssets(ChangeManagementServiceUtility.GetStringType(value));
assets.setType("ArrayType");
middle = new Middle_type2();
middle.setType("StringType");
middle.setAssets(assets);
instance.setMiddle(middle);
description = new Description_type2();
value = (String) arguments.get(ARGUMENT_DESCRIPTION);
description.addDescription(ChangeManagementServiceUtility.GetStringType(value));
description.setType("ArrayType");
structure = new DescriptionStructure_type2();
structure.setType("StructureType");
structure.setDescription(description);
instance.setDescriptionStructure(structure);
ArrayList files =
ChangeManagementServiceUtility.ParseList((String) arguments.get(ARGUMENT_ATTACHMENT));
if (files != null && files.size() > 0) {
AttachmentsType attachments = new AttachmentsType();
for (int i = 0; i < files.size(); i++) {
File file =
new File("." + File.separator + ChangeManagementServiceUtility.RESOURCES
+ File.separator + files.get(i));
// new File((String) files.get(i));
System.out.println(file.getAbsolutePath());
if (file.exists()) {
System.out.println("File exists, adding attachment to attachments");
System.out.println(file.toURI());
attachments.addAttachment(ChangeManagementServiceUtility.GetAttachmentType(file));
}
}
if (attachments.getAttachment() != null && attachments.getAttachment().length > 0) {
System.out.println("Attachments exist, adding to instance");
instance.setAttachments(attachments);
}
}
close = new Close_type2();
close.setType("StringType");
instance.setClose(close);
return instance;
}
And here is my GetAttachmentType function, which should be pretty much the same as the previous one I posted.
Code:
public static AttachmentType GetAttachmentType(File file)
{
// Creating a javax.activation.FileDataSource from the input file.
//File file = new File("c:\\LOGF56D.log");
// File file = new File("//devapps017.devdomau.local/Temp/Test.txt");
FileDataSource fileDataSource = new FileDataSource(file);
DataHandler dataHandler = new DataHandler(fileDataSource);
AttachmentType attachmentType = new AttachmentType();
attachmentType.setLen(Integer.valueOf((int) file.length()));
attachmentType.setName(file.getName());
attachmentType.setAction("add");
ContentType_type0 contentType = new ContentType_type0();
System.out.println(fileDataSource.getContentType());
contentType.setContentType_type0(fileDataSource.getContentType());
attachmentType.setContentType(contentType);
attachmentType.setType(fileDataSource.getContentType());
attachmentType.setBase64Binary(dataHandler);
//System.out.println(attachmentType.getContentId());
return attachmentType;
}
Bookmarks