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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteArchive(MArchive archive, MStorageProvider prov) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ public class ArchiveFileSystem implements IArchiveStore {
|
|||
BufferedOutputStream out = null;
|
||||
try {
|
||||
// create destination folder
|
||||
StringBuilder msgfile = new StringBuilder().append(archivePathRoot).append(File.separator)
|
||||
StringBuilder msgfile = new StringBuilder().append(archivePathRoot)
|
||||
.append(archive.getArchivePathSnippet());
|
||||
final File destFolder = new File(msgfile.toString());
|
||||
if (!destFolder.exists()) {
|
||||
|
@ -226,4 +226,23 @@ public class ArchiveFileSystem implements IArchiveStore {
|
|||
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 boolean deleteArchive(MArchive archive, MStorageProvider prov);
|
||||
|
||||
}
|
||||
|
|
|
@ -275,5 +275,14 @@ public class MArchive extends X_AD_Archive {
|
|||
log.fine(toString());
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
protected boolean beforeDelete ()
|
||||
{
|
||||
IArchiveStore prov = provider.getArchiveStore();
|
||||
if (prov != null)
|
||||
return prov.deleteArchive(this,provider);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
} // MArchive
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.sql.Timestamp;
|
|||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
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.IFormController;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.apps.form.Archive;
|
||||
import org.compiere.model.MArchive;
|
||||
import org.compiere.model.MLookup;
|
||||
|
@ -111,6 +113,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
|||
private Textbox helpField = new Textbox();
|
||||
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
|
||||
private Button updateArchive = new Button();
|
||||
private Button deleteArchive = new Button();
|
||||
|
||||
private Tabbox tabbox = new Tabbox();
|
||||
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.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.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh"));
|
||||
bRefresh.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
bBack.setImage("/images/Parent24.png");
|
||||
bBack.setImage("/images/wfBack24.png");
|
||||
bBack.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
|
||||
bBack.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
bNext.setImage("/images/Detail24.png");
|
||||
bNext.setImage("/images/wfNext24.png");
|
||||
bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
|
||||
bNext.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
|
@ -405,8 +412,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
|||
row.setSpans("4");
|
||||
div = new Div();
|
||||
div.setAlign("right");
|
||||
div.appendChild(deleteArchive);
|
||||
div.appendChild(bRefresh);
|
||||
div.appendChild(updateArchive);
|
||||
div.appendChild(updateArchive);
|
||||
row.appendChild(div);
|
||||
|
||||
createdByField.setReadonly(true);
|
||||
|
@ -449,6 +457,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
|
|||
|
||||
if (e.getTarget() == updateArchive)
|
||||
cmd_updateArchive();
|
||||
else if(e.getTarget() == deleteArchive)
|
||||
cmd_deleteArchive();
|
||||
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
|
||||
SessionManager.getAppDesktop().closeActiveWindow();
|
||||
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)
|
||||
{
|
||||
if (m_archives.length > 0)
|
||||
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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue