if (log.isDebugEnabled()) {
log.debug("Entering deleteAttachments()");
}
Attachments attachments = msgContext.getAttachmentMap();
LifecycleManager lcm = (LifecycleManager)msgContext.getRootContext().getAxisConfiguration().getParameterValue(DeploymentConstants.ATTACHMENTS_LIFECYCLE_MANAGER);
if (attachments != null) {
String [] keys = attachments.getAllContentIDs();
if (keys != null) {
String key = null;
File file = null;
DataSource dataSource = null;
for (int i = 0; i < keys.length; i++) {
try {
key = keys[i];
dataSource = attachments.getDataHandler(key).getDataSource();
if(dataSource instanceof CachedFileDataSource){
file = ((CachedFileDataSource)dataSource).getFile();
if (log.isDebugEnabled()) {
log.debug("Delete cache attachment file: "+file.getName());
}
if(lcm!=null){
if(log.isDebugEnabled()){
log.debug("deleting file using lifecyclemanager");
}
lcm.delete(file);
}else{
file.delete();
}
}
}
catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Delete cache attachment file failed"+ e.getMessage());
}
if (file != null) {
if(lcm!=null){
try{
lcm.deleteOnExit(file);
}catch(Exception ex){
file.deleteOnExit();
}
}
else{