IDEMPIERE-2767 Web Services not working with UUID / peer review - implement the same for ModelGetList AD_Reference_ID

This commit is contained in:
Carlos Ruiz 2020-04-22 23:32:50 +02:00
parent 7e91d03ac0
commit 281912af45
3 changed files with 30 additions and 7 deletions

View File

@ -743,6 +743,9 @@ public final class MRole extends X_AD_Role
*/
private void loadOrgAccessUser(ArrayList<OrgAccess> list)
{
if (getAD_User_ID() == -1) {
log.severe("Trying to load Org Access from User but user has not been set");
}
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM AD_User_OrgAccess "
@ -2784,6 +2787,7 @@ public final class MRole extends X_AD_Role
final int AD_User_ID = getAD_User_ID();
if (AD_User_ID < 0)
{
log.severe("Trying to load Child Roles but user has not been set");
//throw new IllegalStateException("AD_User_ID is not set");
return ;
}
@ -2819,6 +2823,7 @@ public final class MRole extends X_AD_Role
final int AD_User_ID = getAD_User_ID();
if (AD_User_ID < 0)
{
log.severe("Trying to load Substituted Roles but user has not been set");
//throw new IllegalStateException("AD_User_ID is not set");
return;
}

View File

@ -358,8 +358,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
String tableName = parameterName.substring(0, parameterName.length()-3);
StringBuilder sql = new StringBuilder("SELECT ");
sql.append(parameterName).append(" FROM ").append(tableName)
.append(" WHERE ").append(tableName).append("_UU=").append(DB.TO_STRING(string));
return DB.getSQLValue(null, sql.toString());
.append(" WHERE ").append(tableName).append("_UU=?");
return DB.getSQLValue(null, sql.toString(), string);
}
Map<String, Object> requestCtx = getRequestCtx();
@ -412,7 +412,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
// Validate parameters
try {
modelRunProcess.setADMenuID(validateParameter("AD_Menu_ID", modelRunProcess.getADMenuID()));
} catch(XmlValueOutOfRangeException e) { // Catch the exception when the Process ID is not an Integer
} catch(XmlValueOutOfRangeException e) { // Catch the exception when the Menu ID is not an Integer
String menuUU = getUUIDValue(modelRunProcess.xgetADMenuID());
if (menuUU == null) {
throw e;
@ -484,7 +484,15 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
int roleid = reqlogin.getRoleID();
// Validate parameters
modelGetList.setADReferenceID(validateParameter("AD_Reference_ID", modelGetList.getADReferenceID()));
try {
modelGetList.setADReferenceID(validateParameter("AD_Reference_ID", modelGetList.getADReferenceID()));
} catch(XmlValueOutOfRangeException e) { // Catch the exception when the Reference ID is not an Integer
String refUU = getUUIDValue(modelGetList.xgetADReferenceID());
if (refUU == null) {
throw e;
}
modelGetList.setADReferenceID(validateParameter("AD_Reference_ID", 0, refUU));
}
modelGetList.setFilter(validateParameter("Filter", modelGetList.getFilter()));
int ref_id = modelGetList.getADReferenceID();
@ -543,7 +551,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
} else if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
// Fill values from a reference table
MRole role = new MRole(ctx, roleid, null);
MRole role = MRole.get(ctx, roleid);
MRefTable rt = MRefTable.get(ctx, ref_id);
if (rt == null || rt.get_ID() == 0)
throw new IdempiereServiceFault("Web service type "

View File

@ -74,6 +74,12 @@ public class Process {
private static final CLogger log = CLogger.getCLogger(Process.class);
/**
* @param cs
* @param req
* @return
* @deprecated - method not used - will be deleted in future versions
*/
public static ProcessParamsDocument getProcessParams( CompiereService cs, GetProcessParamsDocument req )
{
ProcessParamsDocument res = ProcessParamsDocument.Factory.newInstance();
@ -193,11 +199,15 @@ public class Process {
RunProcessResponse r= res.addNewRunProcessResponse();
RunProcess rp = req.getRunProcess();
int AD_Menu_ID = rp.getADMenuID();
int AD_Process_ID = rp.getADProcessID();
int m_record_id = rp.getADRecordID();
MProcess process = MProcess.get (m_cs.getCtx() , AD_Process_ID);
// need to check if Role can access
MProcess process = null;
if (AD_Menu_ID <= 0 && AD_Process_ID > 0)
process = MProcess.get(m_cs.getCtx(), AD_Process_ID);
else if (AD_Menu_ID > 0 && AD_Process_ID <= 0)
process = MProcess.getFromMenu(m_cs.getCtx(), AD_Menu_ID);
if (process == null)
{
r.setError("Process not found");