BF [2991251] - Attachment handle replacements
https://sourceforge.net/tracker/?func=detail&aid=2991251&group_id=176962&atid=879332
This commit is contained in:
parent
9045226d7b
commit
36fab48e2f
|
@ -111,10 +111,13 @@ public class MAttachment extends X_AD_Attachment
|
|||
*/
|
||||
public MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String trxName)
|
||||
{
|
||||
this (ctx, 0, trxName);
|
||||
this (ctx
|
||||
, MAttachment.get(ctx, AD_Table_ID, Record_ID) == null ? 0 : MAttachment.get(ctx, AD_Table_ID, Record_ID).get_ID()
|
||||
, trxName);
|
||||
if (MAttachment.get(ctx, AD_Table_ID, Record_ID) == null) {
|
||||
setAD_Table_ID (AD_Table_ID);
|
||||
setRecord_ID (Record_ID);
|
||||
initAttachmentStoreDetails(ctx, trxName);
|
||||
}
|
||||
} // MAttachment
|
||||
|
||||
/**
|
||||
|
@ -241,7 +244,7 @@ public class MAttachment extends X_AD_Attachment
|
|||
log.warning("No File");
|
||||
return false;
|
||||
}
|
||||
if (!file.exists() || file.isDirectory())
|
||||
if (!file.exists() || file.isDirectory() || !file.canRead())
|
||||
{
|
||||
log.warning("not added - " + file
|
||||
+ ", Exists=" + file.exists() + ", Directory=" + file.isDirectory());
|
||||
|
@ -290,14 +293,24 @@ public class MAttachment extends X_AD_Attachment
|
|||
*/
|
||||
public boolean addEntry (MAttachmentEntry item)
|
||||
{
|
||||
boolean replaced = false;
|
||||
boolean retValue = false;
|
||||
if (item == null)
|
||||
return false;
|
||||
if (m_items == null)
|
||||
loadLOBData();
|
||||
boolean retValue = m_items.add(item);
|
||||
for (int i = 0; i < m_items.size(); i++) {
|
||||
if (m_items.get(i).getName().equals(item.getName()) ) {
|
||||
m_items.set(i, item);
|
||||
replaced = true;
|
||||
}
|
||||
}
|
||||
if (!replaced) {
|
||||
retValue = m_items.add(item);
|
||||
}
|
||||
log.fine(item.toStringX());
|
||||
addTextMsg(" "); // otherwise not saved
|
||||
return retValue;
|
||||
setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
|
||||
return retValue || replaced;
|
||||
} // addEntry
|
||||
|
||||
/**
|
||||
|
|
|
@ -373,6 +373,7 @@ public final class Attachment extends CDialog
|
|||
{
|
||||
if (m_change)
|
||||
{
|
||||
m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
|
||||
m_attachment.setTextMsg(text.getText());
|
||||
m_attachment.save();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue