}
@Override
public final ActionForward execute(ActionMapping mapping, DeleteForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
DeletePanel panel = null;
if(Panel.getPanelStack(request).isTypeOnTop(Panel.Type.DELETE)) {
panel = (DeletePanel)Panel.getPanelStack(request).peek();
} else if(Panel.getPanelStack(request).isTypeOnTop(Panel.Type.EDIT)) {
EditPanel editPanel = (EditPanel)Panel.getPanelStack(request).peek();
panel = new DeletePanel();
panel.setTitle((String)editPanel.getAttribute(TEXT_TITLE));
panel.setQuestion((String)editPanel.getAttribute(TEXT_QUESTION));
panel.setEntity(editPanel.getEntity());
panel.setPath(editPanel.getAction(org.opencustomer.framework.webapp.panel.Action.Type.DELETE).getAction());
preparePanel(editPanel, panel);
Panel.getPanelStack(request).push(panel);
} else {
log.error("missing valid panel: "+Panel.getPanelStack(request).peek());
}
Status status = Status.NONE;
if(this.isTokenValid(request) && form.getDoDelete() != null)
{
ActionMessages errors = new ActionMessages();
if (log.isDebugEnabled())
log.debug("delete entity (ID:" + panel.getEntity().getId() + ")");
if (panel.getEntity().getId() != null) {
boolean writeAllowed = true;
if(panel.getEntity() instanceof EntityAccess) {
UserVO user = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
writeAllowed = EntityAccessUtility.isAccessGranted(user, (EntityAccess)panel.getEntity(), EntityAccess.Access.WRITE);
if(log.isDebugEnabled())
log.debug("delete is allowed on entity for user: "+writeAllowed);
}
if(writeAllowed) {
deleteEntity(panel, request, response, errors);
} else if(log.isDebugEnabled()) {
log.debug("user is not allowed to delete entity "+panel.getEntity());
}
} else {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.invalidEntity", panel.getEntity().getId()));
}
if (errors.isEmpty())
status = Status.DELETED;
else