IDEMPIERE-3604 improve error messages when process access rights are not set / IDEMPIERE-1920

This commit is contained in:
Carlos Ruiz 2018-01-08 15:24:23 +01:00
parent 80acb075a8
commit 3c10b2c455
2 changed files with 11 additions and 4 deletions

View File

@ -26,7 +26,6 @@ import org.compiere.model.I_AD_Role_Included;
import org.compiere.model.MRole;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
@ -76,7 +75,7 @@ public class CopyRole extends SvrProcess
protected String doIt() throws Exception
{
if (! MRole.getDefault().isAccessAdvanced()) {
throw new AdempiereException(Msg.getMsg(getCtx(), "CannotAccessProcess", new Object[] {getProcessInfo().getAD_Process_ID(), MRole.getDefault().getName()}));
return "@Error@ @Advanced@ @Process@";
}
if (m_AD_Role_ID_From == m_AD_Role_ID_To)

View File

@ -32,6 +32,7 @@ import org.adempiere.base.event.EventManager;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.compiere.util.Msg;
import org.idempiere.distributed.IMessageService;
import org.idempiere.distributed.ITopic;
@ -219,8 +220,15 @@ public class MPInstance extends X_AD_PInstance
{
MRole role = MRole.get(getCtx(), AD_Role_ID);
Boolean access = role.getProcessAccess(AD_Process_ID);
if (access == null || !access.booleanValue())
throw new IllegalStateException(Msg.getMsg(getCtx(), "CannotAccessProcess", new Object[] {AD_Process_ID, role.getName()}));
if (access == null || !access.booleanValue()) {
MProcess proc = MProcess.get(getCtx(), AD_Process_ID);
StringBuilder procMsg = new StringBuilder("[");
if (! Language.isBaseLanguage (Env.getAD_Language(getCtx()))) {
procMsg.append(proc.get_Translation("Name")).append(" / ");
}
procMsg.append(proc.getName()).append("]");
throw new IllegalStateException(Msg.getMsg(getCtx(), "CannotAccessProcess", new Object[] {procMsg.toString(), role.getName()}));
}
}
super.setAD_Process_ID (AD_Process_ID);
} // setAD_Process_ID