mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
added default type to user manager
This commit is contained in:
@@ -129,6 +129,13 @@ public class XmlGroupManager extends AbstractGroupManager
|
|||||||
@Override
|
@Override
|
||||||
public void create(Group group) throws GroupException, IOException
|
public void create(Group group) throws GroupException, IOException
|
||||||
{
|
{
|
||||||
|
String type = group.getType();
|
||||||
|
|
||||||
|
if (Util.isEmpty(type))
|
||||||
|
{
|
||||||
|
group.setType(groupDAO.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
logger.info("create group {} of type {}", group.getName(),
|
logger.info("create group {} of type {}", group.getName(),
|
||||||
@@ -142,13 +149,6 @@ public class XmlGroupManager extends AbstractGroupManager
|
|||||||
throw new GroupAllreadyExistExeption();
|
throw new GroupAllreadyExistExeption();
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = group.getType();
|
|
||||||
|
|
||||||
if (Util.isEmpty(type))
|
|
||||||
{
|
|
||||||
group.setType(groupDAO.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
group.setCreationDate(System.currentTimeMillis());
|
group.setCreationDate(System.currentTimeMillis());
|
||||||
groupDAO.add(group);
|
groupDAO.add(group);
|
||||||
fireEvent(group, HandlerEvent.CREATE);
|
fireEvent(group, HandlerEvent.CREATE);
|
||||||
|
|||||||
@@ -160,6 +160,13 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
@Override
|
@Override
|
||||||
public void create(User user) throws UserException, IOException
|
public void create(User user) throws UserException, IOException
|
||||||
{
|
{
|
||||||
|
String type = user.getType();
|
||||||
|
|
||||||
|
if (Util.isEmpty(type))
|
||||||
|
{
|
||||||
|
user.setType(userDAO.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
logger.info("create user {} of type {}", user.getName(), user.getType());
|
logger.info("create user {} of type {}", user.getName(), user.getType());
|
||||||
@@ -177,13 +184,6 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
throw new UserAllreadyExistException(user.getName());
|
throw new UserAllreadyExistException(user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = user.getType();
|
|
||||||
|
|
||||||
if (Util.isEmpty(type))
|
|
||||||
{
|
|
||||||
user.setType(userDAO.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
AssertUtil.assertIsValid(user);
|
AssertUtil.assertIsValid(user);
|
||||||
user.setCreationDate(System.currentTimeMillis());
|
user.setCreationDate(System.currentTimeMillis());
|
||||||
userDAO.add(user);
|
userDAO.add(user);
|
||||||
@@ -457,6 +457,18 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
return getAll(null, start, limit);
|
return getAll(null, start, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getDefaultType()
|
||||||
|
{
|
||||||
|
return userDAO.getType();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import sonia.scm.Manager;
|
|||||||
import sonia.scm.search.Searchable;
|
import sonia.scm.search.Searchable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The central class for managing {@link User} objects.
|
||||||
|
* This class is a singleton and is available via injection.
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@@ -49,12 +51,23 @@ public interface UserManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Returns true if a user with the specified username exists.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param username
|
* @param username username of the user
|
||||||
*
|
*
|
||||||
* @return
|
* @return true if the user exists
|
||||||
*/
|
*/
|
||||||
public boolean contains(String username);
|
public boolean contains(String username);
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default type for users.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return default user type
|
||||||
|
* @since 1.14
|
||||||
|
*/
|
||||||
|
public String getDefaultType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import sonia.scm.security.EncryptionHandler;
|
|||||||
import sonia.scm.user.User;
|
import sonia.scm.user.User;
|
||||||
import sonia.scm.user.UserException;
|
import sonia.scm.user.UserException;
|
||||||
import sonia.scm.user.UserManager;
|
import sonia.scm.user.UserManager;
|
||||||
import sonia.scm.user.xml.XmlUserManager;
|
|
||||||
import sonia.scm.util.AssertUtil;
|
import sonia.scm.util.AssertUtil;
|
||||||
import sonia.scm.web.security.WebSecurityContext;
|
import sonia.scm.web.security.WebSecurityContext;
|
||||||
|
|
||||||
@@ -64,7 +63,6 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import sonia.scm.user.xml.XmlUserDAO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -145,8 +143,8 @@ public class ChangePasswordResource
|
|||||||
logger.info("password change for user {}", currentUser.getName());
|
logger.info("password change for user {}", currentUser.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove dependency to xml implementation
|
// Only account of the default type can change their password
|
||||||
if (currentUser.getType().equals(XmlUserDAO.TYPE))
|
if (currentUser.getType().equals(userManager.getDefaultType()))
|
||||||
{
|
{
|
||||||
User dbUser = userManager.get(currentUser.getName());
|
User dbUser = userManager.get(currentUser.getName());
|
||||||
|
|
||||||
@@ -163,7 +161,12 @@ public class ChangePasswordResource
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.error("only xml user can change their passwor");
|
//J-
|
||||||
|
logger.error(
|
||||||
|
"Only account of the default type ({}) can change their password",
|
||||||
|
userManager.getDefaultType()
|
||||||
|
);
|
||||||
|
//J+
|
||||||
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ Sonia.group.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug( 'create group: ' + item.name );
|
console.debug( 'create group: ' + item.name );
|
||||||
}
|
}
|
||||||
item.type = 'xml';
|
// item.type = 'xml';
|
||||||
|
|
||||||
var url = restUrl + 'groups.json';
|
var url = restUrl + 'groups.json';
|
||||||
var el = this.el;
|
var el = this.el;
|
||||||
|
|||||||
Reference in New Issue
Block a user