mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
remove lastLogin attribute to improve svn and bzr performance
This commit is contained in:
@@ -131,15 +131,64 @@ public class User
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public void copyProperties(User user)
|
public boolean copyProperties(User user)
|
||||||
{
|
{
|
||||||
user.setAdmin(admin);
|
return copyProperties(user, true);
|
||||||
user.setDisplayName(displayName);
|
}
|
||||||
user.setMail(mail);
|
|
||||||
user.setName(name);
|
/**
|
||||||
user.setPassword(password);
|
* Method description
|
||||||
user.setType(type);
|
*
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param copyPassword
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean copyProperties(User user, boolean copyPassword)
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
if (user.isAdmin() != admin)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setAdmin(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Util.isNotEquals(user.getDisplayName(), displayName))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setDisplayName(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Util.isNotEquals(user.getMail(), mail))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setMail(mail);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Util.isNotEquals(user.getName(), name))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copyPassword && Util.isNotEquals(user.getPassword(), password))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setPassword(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Util.isNotEquals(user.getType(), type))
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
user.setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,9 +312,9 @@ public class User
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public long getLastLogin()
|
public Long getLastModified()
|
||||||
{
|
{
|
||||||
return lastLogin;
|
return lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -378,11 +427,11 @@ public class User
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param lastLogin
|
* @param lastModified
|
||||||
*/
|
*/
|
||||||
public void setLastLogin(long lastLogin)
|
public void setLastModified(long lastModified)
|
||||||
{
|
{
|
||||||
this.lastLogin = lastLogin;
|
this.lastModified = lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,7 +493,7 @@ public class User
|
|||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
|
@XmlJavaTypeAdapter(XmlTimestampDateAdapter.class)
|
||||||
private Long lastLogin;
|
private Long lastModified;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String mail;
|
private String mail;
|
||||||
|
|||||||
@@ -142,6 +142,33 @@ public class Util
|
|||||||
return parseDate(dateString, null);
|
return parseDate(dateString, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param byteValue
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String toString(byte[] byteValue)
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < byteValue.length; i++)
|
||||||
|
{
|
||||||
|
int x = byteValue[i] & 0xff;
|
||||||
|
|
||||||
|
if (x < 16)
|
||||||
|
{
|
||||||
|
buffer.append('0');
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.append(Integer.toString(x, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,6 +210,22 @@ public class Util
|
|||||||
return (array == null) || (array.length == 0);
|
return (array == null) || (array.length == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param object
|
||||||
|
* @param other
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isEquals(Object object, Object other)
|
||||||
|
{
|
||||||
|
return (object == null)
|
||||||
|
? other == null
|
||||||
|
: object.equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -222,32 +265,17 @@ public class Util
|
|||||||
return (array != null) && (array.length > 0);
|
return (array != null) && (array.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param byteValue
|
* @param object
|
||||||
|
* @param other
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String toString(byte[] byteValue)
|
public static boolean isNotEquals(Object object, Object other)
|
||||||
{
|
{
|
||||||
StringBuilder buffer = new StringBuilder();
|
return !isEquals(object, other);
|
||||||
|
|
||||||
for (int i = 0; i < byteValue.length; i++)
|
|
||||||
{
|
|
||||||
int x = byteValue[i] & 0xff;
|
|
||||||
|
|
||||||
if (x < 16)
|
|
||||||
{
|
|
||||||
buffer.append('0');
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.append(Integer.toString(x, 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
if (userDB.contains(name))
|
if (userDB.contains(name))
|
||||||
{
|
{
|
||||||
AssertUtil.assertIsValid(user);
|
AssertUtil.assertIsValid(user);
|
||||||
|
user.setLastModified(System.currentTimeMillis());
|
||||||
|
|
||||||
synchronized (XmlUserManager.class)
|
synchronized (XmlUserManager.class)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -124,21 +124,13 @@ public class BasicSecurityContext implements WebSecurityContext
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
user.setLastLogin(System.currentTimeMillis());
|
|
||||||
|
|
||||||
User dbUser = userManager.get(username);
|
User dbUser = userManager.get(username);
|
||||||
|
|
||||||
if (dbUser != null)
|
if ((dbUser != null) && dbUser.copyProperties(user, false))
|
||||||
{
|
{
|
||||||
|
|
||||||
// update properties
|
|
||||||
dbUser.setDisplayName(user.getDisplayName());
|
|
||||||
dbUser.setLastLogin(user.getLastLogin());
|
|
||||||
dbUser.setMail(user.getMail());
|
|
||||||
dbUser.setType(user.getType());
|
|
||||||
userManager.modify(dbUser);
|
userManager.modify(dbUser);
|
||||||
}
|
}
|
||||||
else
|
else if (dbUser == null)
|
||||||
{
|
{
|
||||||
userManager.create(user);
|
userManager.create(user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
|
|
||||||
var userStore = new Sonia.rest.JsonStore({
|
var userStore = new Sonia.rest.JsonStore({
|
||||||
url: restUrl + 'users.json',
|
url: restUrl + 'users.json',
|
||||||
fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastLogin', 'type'],
|
fields: [ 'name', 'displayName', 'mail', 'admin', 'creationDate', 'lastModified', 'type'],
|
||||||
sortInfo: {
|
sortInfo: {
|
||||||
field: 'name'
|
field: 'name'
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
|||||||
{id: 'mail', header: 'Mail', dataIndex: 'mail', renderer: this.renderMailto, width: 200},
|
{id: 'mail', header: 'Mail', dataIndex: 'mail', renderer: this.renderMailto, width: 200},
|
||||||
{id: 'admin', header: 'Admin', dataIndex: 'admin', renderer: this.renderCheckbox, width: 50},
|
{id: 'admin', header: 'Admin', dataIndex: 'admin', renderer: this.renderCheckbox, width: 50},
|
||||||
{id: 'creationDate', header: 'Creation date', dataIndex: 'creationDate'},
|
{id: 'creationDate', header: 'Creation date', dataIndex: 'creationDate'},
|
||||||
{id: 'lastLogin', header: 'Last login', dataIndex: 'lastLogin'},
|
{id: 'lastLogin', header: 'Last modified', dataIndex: 'lastModified'},
|
||||||
{id: 'type', header: 'Type', dataIndex: 'type', width: 80}
|
{id: 'type', header: 'Type', dataIndex: 'type', width: 80}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user