{
attachments = new ArrayList<AttachmentMetaData>();
repositoryMetaData.setAttachments(attachments);
}
// Extract the attachment
AttachmentMetaData attachment = null;
for(AttachmentMetaData a : attachments)
{
if(attachmentName.equals(a.getName()))
attachment = a;
}
// Create a new one
if(attachment == null)
{
// Create attachment meta data
attachment = new AttachmentMetaData();
// Add attachment meta data
attachments.add(attachment);
}
// Is attachmentName the same as the className ?
attachment.setName(attachmentName);
attachment.setClassName(managedObject.getAttachment().getClass().getName());
// Save the attachment
String attachmentPath = deploymentPath + attachment.getName();
// Create the persistence information
PersistenceRoot persistenceRoot = getSerializer().loadAttachment(attachmentPath, PersistenceRoot.class);
//
persistenceRoot = createPersistedMetaData(persistenceRoot, managedObject, component, remove);
// Serialize the attachment
getSerializer().saveAttachment(attachmentPath, persistenceRoot);
// Update the last modified.
long lastModified = System.currentTimeMillis();
attachment.setLastModified(lastModified);
repositoryMetaData.setLastModified(lastModified);
// Save the updated repository meta data
getSerializer().saveAttachment(getMetaDataPathName(deploymentPath), repositoryMetaData);
}