IDEMPIERE-523 can´t delete archive
This commit is contained in:
parent
b29658bb80
commit
17a02687e0
|
@ -107,4 +107,10 @@ public class ArchiveDB implements IArchiveStore {
|
||||||
archive.setByteData(deflatedData);
|
archive.setByteData(deflatedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteArchive(MArchive archive, MStorageProvider prov) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class ArchiveFileSystem implements IArchiveStore {
|
||||||
BufferedOutputStream out = null;
|
BufferedOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
// create destination folder
|
// create destination folder
|
||||||
StringBuilder msgfile = new StringBuilder().append(archivePathRoot).append(File.separator)
|
StringBuilder msgfile = new StringBuilder().append(archivePathRoot)
|
||||||
.append(archive.getArchivePathSnippet());
|
.append(archive.getArchivePathSnippet());
|
||||||
final File destFolder = new File(msgfile.toString());
|
final File destFolder = new File(msgfile.toString());
|
||||||
if (!destFolder.exists()) {
|
if (!destFolder.exists()) {
|
||||||
|
@ -226,4 +226,23 @@ public class ArchiveFileSystem implements IArchiveStore {
|
||||||
return archivePathRoot;
|
return archivePathRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteArchive(MArchive archive, MStorageProvider prov) {
|
||||||
|
String archivePathRoot = getArchivePathRoot(prov);
|
||||||
|
if ("".equals(archivePathRoot)) {
|
||||||
|
throw new IllegalArgumentException("no attachmentPath defined");
|
||||||
|
}
|
||||||
|
StringBuilder msgfile = new StringBuilder().append(archivePathRoot)
|
||||||
|
.append(archive.getArchivePathSnippet()).append(archive.get_ID()).append(".pdf");
|
||||||
|
|
||||||
|
File file=new File(msgfile.toString());
|
||||||
|
if (file !=null && file.exists()) {
|
||||||
|
if (!file.delete()) {
|
||||||
|
log.warning("unable to delete " + file.getAbsolutePath());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,6 @@ public interface IArchiveStore {
|
||||||
|
|
||||||
public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData);
|
public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData);
|
||||||
|
|
||||||
|
public boolean deleteArchive(MArchive archive, MStorageProvider prov);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,4 +276,13 @@ public class MArchive extends X_AD_Archive {
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
protected boolean beforeDelete ()
|
||||||
|
{
|
||||||
|
IArchiveStore prov = provider.getArchiveStore();
|
||||||
|
if (prov != null)
|
||||||
|
return prov.deleteArchive(this,provider);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // MArchive
|
} // MArchive
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.Callback;
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.Checkbox;
|
import org.adempiere.webui.component.Checkbox;
|
||||||
import org.adempiere.webui.component.ConfirmPanel;
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
|
@ -48,6 +49,7 @@ import org.adempiere.webui.panel.ADForm;
|
||||||
import org.adempiere.webui.panel.CustomForm;
|
import org.adempiere.webui.panel.CustomForm;
|
||||||
import org.adempiere.webui.panel.IFormController;
|
import org.adempiere.webui.panel.IFormController;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.apps.form.Archive;
|
import org.compiere.apps.form.Archive;
|
||||||
import org.compiere.model.MArchive;
|
import org.compiere.model.MArchive;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
|
@ -111,6 +113,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
||||||
private Textbox helpField = new Textbox();
|
private Textbox helpField = new Textbox();
|
||||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||||
private Button updateArchive = new Button();
|
private Button updateArchive = new Button();
|
||||||
|
private Button deleteArchive = new Button();
|
||||||
|
|
||||||
private Tabbox tabbox = new Tabbox();
|
private Tabbox tabbox = new Tabbox();
|
||||||
private Tabs tabs = new Tabs();
|
private Tabs tabs = new Tabs();
|
||||||
|
@ -194,15 +197,19 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
||||||
updateArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Update"));
|
updateArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Update"));
|
||||||
updateArchive.addEventListener(Events.ON_CLICK, this);
|
updateArchive.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
|
deleteArchive.setImage("/images/Delete24.png");
|
||||||
|
deleteArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));
|
||||||
|
deleteArchive.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
bRefresh.setImage("/images/Refresh24.png");
|
bRefresh.setImage("/images/Refresh24.png");
|
||||||
bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh"));
|
bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh"));
|
||||||
bRefresh.addEventListener(Events.ON_CLICK, this);
|
bRefresh.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
bBack.setImage("/images/Parent24.png");
|
bBack.setImage("/images/wfBack24.png");
|
||||||
bBack.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
|
bBack.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
|
||||||
bBack.addEventListener(Events.ON_CLICK, this);
|
bBack.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
bNext.setImage("/images/Detail24.png");
|
bNext.setImage("/images/wfNext24.png");
|
||||||
bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
|
bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
|
||||||
bNext.addEventListener(Events.ON_CLICK, this);
|
bNext.addEventListener(Events.ON_CLICK, this);
|
||||||
|
|
||||||
|
@ -405,6 +412,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
||||||
row.setSpans("4");
|
row.setSpans("4");
|
||||||
div = new Div();
|
div = new Div();
|
||||||
div.setAlign("right");
|
div.setAlign("right");
|
||||||
|
div.appendChild(deleteArchive);
|
||||||
div.appendChild(bRefresh);
|
div.appendChild(bRefresh);
|
||||||
div.appendChild(updateArchive);
|
div.appendChild(updateArchive);
|
||||||
row.appendChild(div);
|
row.appendChild(div);
|
||||||
|
@ -449,6 +457,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
||||||
|
|
||||||
if (e.getTarget() == updateArchive)
|
if (e.getTarget() == updateArchive)
|
||||||
cmd_updateArchive();
|
cmd_updateArchive();
|
||||||
|
else if(e.getTarget() == deleteArchive)
|
||||||
|
cmd_deleteArchive();
|
||||||
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
||||||
SessionManager.getAppDesktop().closeActiveWindow();
|
SessionManager.getAppDesktop().closeActiveWindow();
|
||||||
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
|
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
|
||||||
|
@ -479,15 +489,50 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Query Display
|
||||||
|
*/
|
||||||
|
|
||||||
|
private void updateQDisplay()
|
||||||
|
{
|
||||||
|
boolean reports = reportField.isChecked();
|
||||||
|
log.config("Reports=" + reports);
|
||||||
|
|
||||||
|
// Show
|
||||||
|
processLabel.setVisible(reports);
|
||||||
|
processField.setVisible(reports);
|
||||||
|
|
||||||
|
// Hide
|
||||||
|
bPartnerLabel.setVisible(!reports);
|
||||||
|
bPartnerField.setVisible(!reports);
|
||||||
|
} // updateQDisplay
|
||||||
|
|
||||||
|
|
||||||
/* public void valueChange(ValueChangeEvent evt)
|
/* public void valueChange(ValueChangeEvent evt)
|
||||||
{
|
{
|
||||||
if (m_archives.length > 0)
|
if (m_archives.length > 0)
|
||||||
updateArchive.setEnabled(true);
|
updateArchive.setEnabled(true);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public void cmd_deleteArchive(){
|
||||||
|
FDialog.ask(m_WindowNo, this.form, "ArchiveDelete?", new Callback<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCallback(Boolean result)
|
||||||
|
{
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
MArchive ar = m_archives[m_index];
|
||||||
|
ar.delete(true);
|
||||||
|
}
|
||||||
|
tabbox.setSelectedIndex(0);
|
||||||
|
dynInit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Update Query Display
|
* Update Query Display
|
||||||
*/
|
|
||||||
|
|
||||||
private void updateQDisplay()
|
private void updateQDisplay()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue