IDEMPIERE-4386 setAD_User_ID() breaks when logged in as System user (#188)
* IDEMPIERE-4386 setAD_User_ID() breaks when logged in as System user Allow saving Tab Customization for System user * IDEMPIERE-4386 setAD_User_ID() breaks when logged in as System user Fix copy/paste error * IDEMPIERE-4386 setAD_User_ID() breaks when logged in as System user Implement same suggestion on all the classes where setAD_User_ID must be allowed to explicitly set to System There were already two classes with the Override approach: MUserPreference and MUserRoles, so this commit is to apply the same approach to all the classes with same approach
This commit is contained in:
parent
24e9fe8402
commit
7892c54aa1
|
@ -11,7 +11,7 @@ public class MTabCustomization extends X_AD_Tab_Customization {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 786885789239156678L;
|
private static final long serialVersionUID = -4986336833193761507L;
|
||||||
|
|
||||||
public MTabCustomization(Properties ctx, int AD_Tab_Customization_ID, String trxName) {
|
public MTabCustomization(Properties ctx, int AD_Tab_Customization_ID, String trxName) {
|
||||||
super(ctx, AD_Tab_Customization_ID, trxName);
|
super(ctx, AD_Tab_Customization_ID, trxName);
|
||||||
|
@ -85,4 +85,18 @@ public class MTabCustomization extends X_AD_Tab_Customization {
|
||||||
return tabCust.save();
|
return tabCust.save();
|
||||||
} // saveTabCustomization
|
} // saveTabCustomization
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
|
{
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 7568476952229922042L;
|
private static final long serialVersionUID = -3887344231734476767L;
|
||||||
|
|
||||||
public static int getForSessionColumnCount(boolean isShowInDashboard, int AD_User_ID, int AD_Role_ID)
|
public static int getForSessionColumnCount(boolean isShowInDashboard, int AD_User_ID, int AD_Role_ID)
|
||||||
{
|
{
|
||||||
|
@ -104,4 +104,19 @@ public class MDashboardPreference extends X_PA_DashboardPreference
|
||||||
{
|
{
|
||||||
super (ctx, rs, trxName);
|
super (ctx, rs, trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
|
{
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class MPasswordHistory extends X_AD_Password_History {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 8602148028134601856L;
|
private static final long serialVersionUID = -571685945938727000L;
|
||||||
|
|
||||||
public MPasswordHistory(Properties ctx, int AD_Password_History_ID,
|
public MPasswordHistory(Properties ctx, int AD_Password_History_ID,
|
||||||
String trxName) {
|
String trxName) {
|
||||||
|
@ -49,4 +49,20 @@ public class MPasswordHistory extends X_AD_Password_History {
|
||||||
|
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
http://wiki.idempiere.org/en/System_user
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
|
{
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ public class MPreference extends X_AD_Preference
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5098559160325123593L;
|
private static final long serialVersionUID = -8935876328996934527L;
|
||||||
|
|
||||||
/** Null Indicator */
|
/** Null Indicator */
|
||||||
public static String NULL = "null";
|
public static String NULL = "null";
|
||||||
|
|
||||||
|
@ -103,5 +104,19 @@ public class MPreference extends X_AD_Preference
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
|
{
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
} // MPreference
|
} // MPreference
|
||||||
|
|
|
@ -1092,12 +1092,7 @@ public class MUser extends X_AD_User
|
||||||
MPasswordHistory passwordHistory = new MPasswordHistory(this.getCtx(), 0, this.get_TrxName());
|
MPasswordHistory passwordHistory = new MPasswordHistory(this.getCtx(), 0, this.get_TrxName());
|
||||||
passwordHistory.setSalt(this.getSalt());
|
passwordHistory.setSalt(this.getSalt());
|
||||||
passwordHistory.setPassword(this.getPassword());
|
passwordHistory.setPassword(this.getPassword());
|
||||||
// http://wiki.idempiere.org/en/System_user
|
passwordHistory.setAD_User_ID(this.getAD_User_ID());
|
||||||
if (!this.is_new() && this.getAD_User_ID() == 0){
|
|
||||||
passwordHistory.set_Value(MPasswordHistory.COLUMNNAME_AD_User_ID, 0);
|
|
||||||
}else{
|
|
||||||
passwordHistory.setAD_User_ID(this.getAD_User_ID());
|
|
||||||
}
|
|
||||||
passwordHistory.setDatePasswordChanged(this.getUpdated());
|
passwordHistory.setDatePasswordChanged(this.getUpdated());
|
||||||
passwordHistory.saveEx();
|
passwordHistory.saveEx();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,13 @@ public class MUserPreference extends X_AD_UserPreference{
|
||||||
{
|
{
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} //MUserPreference
|
} //MUserPreference
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void setAD_User_ID (int AD_User_ID)
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
{
|
{
|
||||||
if (AD_User_ID == 0)
|
if (AD_User_ID == 0)
|
||||||
|
@ -54,7 +60,7 @@ public class MUserPreference extends X_AD_UserPreference{
|
||||||
else
|
else
|
||||||
super.setAD_User_ID(AD_User_ID);
|
super.setAD_User_ID(AD_User_ID);
|
||||||
} //setAD_User_ID
|
} //setAD_User_ID
|
||||||
|
|
||||||
private static MUserPreference createUserPreferences(int AD_User_ID, int AD_Client_ID, String trxName){
|
private static MUserPreference createUserPreferences(int AD_User_ID, int AD_Client_ID, String trxName){
|
||||||
MUserPreference preferences = new MUserPreference(Env.getCtx(), 0, trxName);
|
MUserPreference preferences = new MUserPreference(Env.getCtx(), 0, trxName);
|
||||||
preferences.setAD_User_ID(AD_User_ID);
|
preferences.setAD_User_ID(AD_User_ID);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MUserQuery extends X_AD_UserQuery
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5640578235804864422L;
|
private static final long serialVersionUID = 488522350853249825L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all active queries of client for Tab
|
* Get all active queries of client for Tab
|
||||||
|
@ -336,4 +336,18 @@ public class MUserQuery extends X_AD_UserQuery
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set User/Contact.
|
||||||
|
@param AD_User_ID
|
||||||
|
User within the system - Internal or Business Partner Contact
|
||||||
|
Overridden to allow saving System record (zero ID)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
|
{
|
||||||
|
if (AD_User_ID == 0)
|
||||||
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
} // MUserQuery
|
} // MUserQuery
|
||||||
|
|
|
@ -112,22 +112,27 @@ public class MUserRoles extends X_AD_User_Roles
|
||||||
setAD_User_ID(AD_User_ID);
|
setAD_User_ID(AD_User_ID);
|
||||||
setAD_Role_ID(AD_Role_ID);
|
setAD_Role_ID(AD_Role_ID);
|
||||||
} // MUserRoles
|
} // MUserRoles
|
||||||
|
|
||||||
/**
|
/** Set User/Contact.
|
||||||
* Set User/Contact.
|
@param AD_User_ID
|
||||||
* User within the system - Internal or Business Partner Contact
|
User within the system - Internal or Business Partner Contact
|
||||||
* @param AD_User_ID user
|
Overridden to allow saving System record (zero ID)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setAD_User_ID (int AD_User_ID)
|
public void setAD_User_ID (int AD_User_ID)
|
||||||
{
|
{
|
||||||
set_ValueNoCheck ("AD_User_ID", Integer.valueOf(AD_User_ID));
|
if (AD_User_ID == 0)
|
||||||
} // setAD_User_ID
|
set_ValueNoCheck (COLUMNNAME_AD_User_ID, AD_User_ID);
|
||||||
|
else
|
||||||
|
super.setAD_User_ID(AD_User_ID);
|
||||||
|
} //setAD_User_ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Role.
|
* Set Role.
|
||||||
* Responsibility Role
|
* Responsibility Role
|
||||||
* @param AD_Role_ID role
|
* @param AD_Role_ID role
|
||||||
**/
|
**/
|
||||||
|
@Override
|
||||||
public void setAD_Role_ID (int AD_Role_ID)
|
public void setAD_Role_ID (int AD_Role_ID)
|
||||||
{
|
{
|
||||||
set_ValueNoCheck ("AD_Role_ID", Integer.valueOf(AD_Role_ID));
|
set_ValueNoCheck ("AD_Role_ID", Integer.valueOf(AD_Role_ID));
|
||||||
|
|
|
@ -1276,7 +1276,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
if (preference == null || preference.getAD_Preference_ID() <= 0) {
|
if (preference == null || preference.getAD_Preference_ID() <= 0) {
|
||||||
preference = new MPreference(Env.getCtx(), 0, null);
|
preference = new MPreference(Env.getCtx(), 0, null);
|
||||||
preference.setAD_Window_ID(windowId);
|
preference.setAD_Window_ID(windowId);
|
||||||
preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user
|
preference.setAD_User_ID(userId); // allow System
|
||||||
preference.setAttribute(adTabId+"|DetailPane.IsOpen");
|
preference.setAttribute(adTabId+"|DetailPane.IsOpen");
|
||||||
}
|
}
|
||||||
preference.setValue(value ? "Y" : "N");
|
preference.setValue(value ? "Y" : "N");
|
||||||
|
@ -1971,7 +1971,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
if (preference == null || preference.getAD_Preference_ID() <= 0) {
|
if (preference == null || preference.getAD_Preference_ID() <= 0) {
|
||||||
preference = new MPreference(Env.getCtx(), 0, null);
|
preference = new MPreference(Env.getCtx(), 0, null);
|
||||||
preference.setAD_Window_ID(windowId);
|
preference.setAD_Window_ID(windowId);
|
||||||
preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user
|
preference.setAD_User_ID(userId);
|
||||||
preference.setAttribute(adTabId+"|"+attribute);
|
preference.setAttribute(adTabId+"|"+attribute);
|
||||||
}
|
}
|
||||||
preference.setValue(value);
|
preference.setValue(value);
|
||||||
|
|
|
@ -655,7 +655,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
MDashboardPreference preference = new MDashboardPreference(Env.getCtx(), 0, null);
|
MDashboardPreference preference = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
preference.setAD_Org_ID(0);
|
preference.setAD_Org_ID(0);
|
||||||
preference.setAD_Role_ID(AD_Role_ID);
|
preference.setAD_Role_ID(AD_Role_ID);
|
||||||
preference.set_ValueNoCheck("AD_User_ID", AD_User_ID);
|
preference.setAD_User_ID(AD_User_ID); // allow System
|
||||||
preference.setColumnNo(dc.getColumnNo());
|
preference.setColumnNo(dc.getColumnNo());
|
||||||
preference.setIsCollapsedByDefault(dc.isCollapsedByDefault());
|
preference.setIsCollapsedByDefault(dc.isCollapsedByDefault());
|
||||||
preference.setIsShowInDashboard(dc.isShowInDashboard());
|
preference.setIsShowInDashboard(dc.isShowInDashboard());
|
||||||
|
@ -682,7 +682,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
MDashboardPreference preference = new MDashboardPreference(ctx,0, null);
|
MDashboardPreference preference = new MDashboardPreference(ctx,0, null);
|
||||||
preference.setAD_Org_ID(0);
|
preference.setAD_Org_ID(0);
|
||||||
preference.setAD_Role_ID(Env.getAD_Role_ID(ctx));
|
preference.setAD_Role_ID(Env.getAD_Role_ID(ctx));
|
||||||
preference.set_ValueNoCheck("AD_User_ID",Env.getAD_User_ID(ctx));
|
preference.setAD_User_ID(Env.getAD_User_ID(ctx)); // allow System
|
||||||
preference.setColumnNo(dcs[i].getColumnNo());
|
preference.setColumnNo(dcs[i].getColumnNo());
|
||||||
preference.setIsCollapsedByDefault(dcs[i].isCollapsedByDefault());
|
preference.setIsCollapsedByDefault(dcs[i].isCollapsedByDefault());
|
||||||
preference.setIsShowInDashboard(dcs[i].isShowInDashboard());
|
preference.setIsShowInDashboard(dcs[i].isShowInDashboard());
|
||||||
|
|
|
@ -469,7 +469,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
if ( preference == null || preference.getAD_Preference_ID() <= 0 ) {
|
if ( preference == null || preference.getAD_Preference_ID() <= 0 ) {
|
||||||
|
|
||||||
preference = new MPreference(Env.getCtx(), 0, null);
|
preference = new MPreference(Env.getCtx(), 0, null);
|
||||||
preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user
|
preference.setAD_User_ID(userId); // allow System
|
||||||
preference.setAttribute("SideController.Width");
|
preference.setAttribute("SideController.Width");
|
||||||
}
|
}
|
||||||
preference.setValue(width);
|
preference.setValue(width);
|
||||||
|
@ -512,7 +512,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
if ( preference == null || preference.getAD_Preference_ID() <= 0 ) {
|
if ( preference == null || preference.getAD_Preference_ID() <= 0 ) {
|
||||||
|
|
||||||
preference = new MPreference(Env.getCtx(), 0, null);
|
preference = new MPreference(Env.getCtx(), 0, null);
|
||||||
preference.set_ValueOfColumn("AD_User_ID", userId); // required set_Value for System=0 user
|
preference.setAD_User_ID(userId); // allow System
|
||||||
preference.setAttribute("HelpController.Width");
|
preference.setAttribute("HelpController.Width");
|
||||||
}
|
}
|
||||||
preference.setValue(width);
|
preference.setValue(width);
|
||||||
|
|
|
@ -1832,10 +1832,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
uq = new MUserQuery (Env.getCtx(), 0, null);
|
uq = new MUserQuery (Env.getCtx(), 0, null);
|
||||||
uq.setName (name);
|
uq.setName (name);
|
||||||
uq.setAD_Tab_ID(m_AD_Tab_ID); //red1 UserQuery [ 1798539 ] taking in new field from Compiere
|
uq.setAD_Tab_ID(m_AD_Tab_ID); //red1 UserQuery [ 1798539 ] taking in new field from Compiere
|
||||||
uq.set_ValueOfColumn("AD_User_ID", Env.getAD_User_ID(Env.getCtx())); // required set_Value for System=0 user
|
uq.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); // allow System
|
||||||
}
|
}
|
||||||
if (shareAllUsers)
|
if (shareAllUsers)
|
||||||
uq.set_ValueOfColumn("AD_User_ID", null);
|
uq.setAD_User_ID(-1); // set to null
|
||||||
|
|
||||||
} else if (code.length() <= 0){ // Delete the query
|
} else if (code.length() <= 0){ // Delete the query
|
||||||
if (uq == null)
|
if (uq == null)
|
||||||
|
|
|
@ -395,7 +395,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
pre.setAD_Org_ID(0);
|
pre.setAD_Org_ID(0);
|
||||||
pre.setAD_Role_ID(AD_Role_ID);
|
pre.setAD_Role_ID(AD_Role_ID);
|
||||||
pre.set_ValueNoCheck("AD_User_ID",AD_User_ID);
|
pre.setAD_User_ID(AD_User_ID); // allow System
|
||||||
pre.setColumnNo(content.getColumnNo());
|
pre.setColumnNo(content.getColumnNo());
|
||||||
pre.setIsCollapsedByDefault(content.isCollapsedByDefault());
|
pre.setIsCollapsedByDefault(content.isCollapsedByDefault());
|
||||||
pre.setIsShowInDashboard(content.isShowInDashboard());
|
pre.setIsShowInDashboard(content.isShowInDashboard());
|
||||||
|
@ -410,7 +410,7 @@ public class WGadgets extends Window implements EventListener<Event>{
|
||||||
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
pre = new MDashboardPreference(Env.getCtx(), 0, null);
|
||||||
pre.setAD_Org_ID(0);
|
pre.setAD_Org_ID(0);
|
||||||
pre.setAD_Role_ID(AD_Role_ID);
|
pre.setAD_Role_ID(AD_Role_ID);
|
||||||
pre.set_ValueNoCheck("AD_User_ID",AD_User_ID);
|
pre.setAD_User_ID(AD_User_ID); // allow System
|
||||||
pre.setColumnNo(content.getColumnNo());
|
pre.setColumnNo(content.getColumnNo());
|
||||||
pre.setIsCollapsedByDefault(content.isCollapsedByDefault());
|
pre.setIsCollapsedByDefault(content.isCollapsedByDefault());
|
||||||
pre.setIsShowInDashboard(content.isShowInDashboard());
|
pre.setIsShowInDashboard(content.isShowInDashboard());
|
||||||
|
|
Loading…
Reference in New Issue