IDEMPIERE-859 NPE on Attachment where is not storage provider configured / Show cause of problems when toolbar buttons cannot action

This commit is contained in:
Carlos Ruiz 2013-04-20 12:24:42 -05:00
parent 268acba0f6
commit 1ab95f22bb
2 changed files with 24 additions and 23 deletions

View File

@ -21,6 +21,7 @@ import java.util.Properties;
import org.adempiere.base.Service; import org.adempiere.base.Service;
import org.adempiere.base.ServiceQuery; import org.adempiere.base.ServiceQuery;
import org.adempiere.exceptions.AdempiereException;
public class MStorageProvider extends X_AD_StorageProvider { public class MStorageProvider extends X_AD_StorageProvider {
/** /**
@ -43,8 +44,8 @@ public class MStorageProvider extends X_AD_StorageProvider {
method = "DB"; method = "DB";
query.put("method", method); query.put("method", method);
IAttachmentStore store = Service.locator().locate(IAttachmentStore.class, query).getService(); IAttachmentStore store = Service.locator().locate(IAttachmentStore.class, query).getService();
if (store == null){ if (store == null) {
log.saveError("Error", "No attachment storage provider found"); throw new AdempiereException("No attachment storage provider found");
} }
return store; return store;
} }
@ -56,8 +57,8 @@ public class MStorageProvider extends X_AD_StorageProvider {
method = "DB"; method = "DB";
query.put("method", method); query.put("method", method);
IArchiveStore store = Service.locator().locate(IArchiveStore.class, query).getService(); IArchiveStore store = Service.locator().locate(IArchiveStore.class, query).getService();
if (store == null){ if (store == null) {
log.saveError("Error", "No archive storage provider found"); throw new AdempiereException("No archive storage provider found");
} }
return store; return store;
} }

View File

@ -17,7 +17,6 @@
package org.adempiere.webui.adwindow; package org.adempiere.webui.adwindow;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -36,6 +35,7 @@ import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MToolBarButton; import org.compiere.model.MToolBarButton;
import org.compiere.model.MToolBarButtonRestrict; import org.compiere.model.MToolBarButtonRestrict;
@ -43,6 +43,7 @@ import org.compiere.model.X_AD_ToolBarButton;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
import org.zkoss.image.AImage; import org.zkoss.image.AImage;
import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
@ -355,25 +356,24 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
Method method = tListener.getClass().getMethod(methodName, (Class[]) null); Method method = tListener.getClass().getMethod(methodName, (Class[]) null);
method.invoke(tListener, (Object[]) null); method.invoke(tListener, (Object[]) null);
} }
catch(SecurityException e) catch (Exception e)
{ {
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e); String msg = null;
} ValueNamePair vp = CLogger.retrieveError();
catch(NoSuchMethodException e) if (vp != null) {
{ msg = vp.getName();
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e); }
} if (msg == null) {
catch(IllegalArgumentException e) Throwable cause = e.getCause();
{ if (cause != null) {
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e); msg = cause.getLocalizedMessage();
} }
catch(IllegalAccessException e) }
{ if (msg == null) {
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e); msg = "Could not invoke Toolbar listener method: " + methodName + "()";
} }
catch(InvocationTargetException e) FDialog.error(windowNo, this, "Error", msg);
{ log.log(Level.SEVERE, msg, e);
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
} }
} }
this.event = null; this.event = null;