All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.marketcetera.admin.user.SimpleUserInitializer Maven / Gradle / Ivy

The newest version!
package org.marketcetera.admin.user;

import java.util.List;

import org.marketcetera.admin.service.UserService;
import org.marketcetera.core.ClassVersion;
import org.marketcetera.util.log.SLF4JLoggerProxy;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

/* $License$ */

/**
 * Creates {@link PersistentUser} objects as specified.
 *
 * @author Colin DuPlantis
 * @version $Id$
 * @since 2.4.2
 */
@ClassVersion("$Id$")
public class SimpleUserInitializer
        implements InitializingBean
{
    /* (non-Javadoc)
     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
     */
    @Override
    public void afterPropertiesSet()
            throws Exception
    {
        if(users != null) {
            for(PersistentUser user : users) {
                try {
                    userService.save(user);
                } catch (Exception e) {
                    SLF4JLoggerProxy.warn(this,
                                         "Not adding user: {} because {}",
                                         user,
                                         e.getMessage());
                }
            }
        }
    }
    /**
     * Get the users value.
     *
     * @return a List<SimpleUser> value
     */
    public List getUsers()
    {
        return users;
    }
    /**
     * Sets the users value.
     *
     * @param inUsers a List<SimpleUser> value
     */
    public void setUsers(List inUsers)
    {
        users = inUsers;
    }
    /**
     * Get the userService value.
     *
     * @return a UserService value
     */
    public UserService getUserService()
    {
        return userService;
    }
    /**
     * Sets the userService value.
     *
     * @param inUserService a UserService value
     */
    public void setUserService(UserService inUserService)
    {
        userService = inUserService;
    }
    /**
     * list of users to add, may be null
     */
    private List users;
    /**
     * provides access to user objects and services
     */
    @Autowired
    private UserService userService;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy