Search in sources :

Example 6 with User

use of com.salesmanager.core.model.user.User in project shopizer by shopizer-ecommerce.

the class UserFacadeImpl method updateEnabled.

@Override
public void updateEnabled(MerchantStore store, PersistableUser user) {
    Validate.notNull(user, "User cannot be null");
    Validate.notNull(store, "MerchantStore cannot be null");
    Validate.notNull(user.getId(), "User.id cannot be null");
    try {
        User modelUser = userService.findByStore(user.getId(), store.getCode());
        if (modelUser == null) {
            throw new ResourceNotFoundException("User with id [" + user.getId() + "] not found for store [" + store.getCode() + "]");
        }
        modelUser.setActive(user.isActive());
        userService.saveOrUpdate(modelUser);
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while updating user enable flag", e);
    }
}
Also used : ReadableUser(com.salesmanager.shop.model.user.ReadableUser) User(com.salesmanager.core.model.user.User) PersistableUser(com.salesmanager.shop.model.user.PersistableUser) ServiceException(com.salesmanager.core.business.exception.ServiceException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 7 with User

use of com.salesmanager.core.model.user.User in project shopizer by shopizer-ecommerce.

the class UserFacadeImpl method resetPassword.

@Override
public void resetPassword(String password, String token, String store) {
    Validate.notNull(token, "ResetPassword token cannot be null");
    Validate.notNull(store, "Store code cannot be null");
    Validate.notNull(password, "New password cannot be null");
    // reverify
    User user = verifyUserLink(token, store);
    user.setAdminPassword(passwordEncoder.encode(password));
    try {
        userService.save(user);
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while saving user", e);
    }
}
Also used : ReadableUser(com.salesmanager.shop.model.user.ReadableUser) User(com.salesmanager.core.model.user.User) PersistableUser(com.salesmanager.shop.model.user.PersistableUser) ServiceException(com.salesmanager.core.business.exception.ServiceException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 8 with User

use of com.salesmanager.core.model.user.User in project shopizer by shopizer-ecommerce.

the class UserFacadeImpl method findByUserName.

@Override
public ReadableUser findByUserName(String userName) {
    Validate.notNull(userName, "userName cannot be null");
    User user;
    try {
        user = userService.getByUserName(userName);
        if (user == null) {
            throw new ResourceNotFoundException("User [" + userName + "] not found");
        }
        return this.convertUserToReadableUser(user.getDefaultLanguage(), user);
    } catch (ServiceException e) {
        throw new ServiceRuntimeException("Error while getting user [" + userName + "]", e);
    }
}
Also used : ReadableUser(com.salesmanager.shop.model.user.ReadableUser) User(com.salesmanager.core.model.user.User) PersistableUser(com.salesmanager.shop.model.user.PersistableUser) ServiceException(com.salesmanager.core.business.exception.ServiceException) ResourceNotFoundException(com.salesmanager.shop.store.api.exception.ResourceNotFoundException) ServiceRuntimeException(com.salesmanager.shop.store.api.exception.ServiceRuntimeException)

Example 9 with User

use of com.salesmanager.core.model.user.User in project shopizer by shopizer-ecommerce.

the class UserServiceImpl method findByStore.

@Override
public User findByStore(Long userId, String storeCode) throws ServiceException {
    User user = userRepository.findOne(userId);
    // store must be in lineage
    boolean isFound = merchantStoreService.isStoreInGroup(storeCode);
    if (isFound)
        return user;
    return null;
}
Also used : User(com.salesmanager.core.model.user.User)

Example 10 with User

use of com.salesmanager.core.model.user.User in project shopizer by shopizer-ecommerce.

the class UserServiceImpl method delete.

@Override
public void delete(User user) throws ServiceException {
    User u = this.getById(user.getId());
    super.delete(u);
}
Also used : User(com.salesmanager.core.model.user.User)

Aggregations

User (com.salesmanager.core.model.user.User)21 ServiceException (com.salesmanager.core.business.exception.ServiceException)16 PersistableUser (com.salesmanager.shop.model.user.PersistableUser)15 ReadableUser (com.salesmanager.shop.model.user.ReadableUser)14 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)13 ResourceNotFoundException (com.salesmanager.shop.store.api.exception.ResourceNotFoundException)7 Group (com.salesmanager.core.model.user.Group)6 ConversionException (com.salesmanager.core.business.exception.ConversionException)5 PersistableGroup (com.salesmanager.shop.model.security.PersistableGroup)5 OperationNotAllowedException (com.salesmanager.shop.store.api.exception.OperationNotAllowedException)5 UnauthorizedException (com.salesmanager.shop.store.api.exception.UnauthorizedException)5 ReadableGroup (com.salesmanager.shop.model.security.ReadableGroup)4 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)4 GenericRuntimeException (com.salesmanager.shop.store.api.exception.GenericRuntimeException)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 CredentialsReset (com.salesmanager.core.model.common.CredentialsReset)3 GenericEntityList (com.salesmanager.core.model.common.GenericEntityList)3 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)3 Language (com.salesmanager.core.model.reference.language.Language)3