use of org.openforis.collect.model.User in project collect by openforis.
the class LocalUserManager method save.
@Override
@Transactional(readOnly = false, propagation = REQUIRED)
public User save(User user, User createdByUser) {
Integer userId = user.getId();
String rawPassword = user.getRawPassword();
if (StringUtils.isBlank(rawPassword)) {
if (userId == null) {
throw new IllegalArgumentException("Blank password specified for a new user");
} else {
// preserve old password
User oldUser = userDao.loadById(userId);
user.setPassword(oldUser.getPassword());
}
} else {
String encodedPassword = checkAndEncodePassword(rawPassword);
user.setPassword(encodedPassword);
}
if (userId == null) {
userDao.insert(user);
groupManager.createDefaultPrivateUserGroup(user, createdByUser);
groupManager.joinToDefaultPublicGroup(user, UserGroupRole.ADMINISTRATOR);
} else {
userDao.update(user);
}
// do not store raw password in cache
user.setRawPassword(null);
updateCache(user);
return user;
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordManager method loadDistinctOwners.
public Set<User> loadDistinctOwners(RecordFilter recordFilter) {
Set<Integer> ownerIds = recordDao.loadDistinctOwnerIds(recordFilter);
Set<User> owners = new HashSet<User>(ownerIds.size());
for (Integer ownerId : ownerIds) {
User owner = userManager.loadById(ownerId);
owners.add(owner);
}
return owners;
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordManager method save.
@Transactional(readOnly = false, propagation = REQUIRED)
public void save(CollectRecord record, String sessionId) throws RecordPersistenceException {
User lockingUser = record.getModifiedBy();
save(record, lockingUser, sessionId, true);
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordManager method delete.
@Transactional(readOnly = false, propagation = REQUIRED)
public void delete(int recordId) throws RecordPersistenceException {
if (isLockingEnabled() && lockManager.isLocked(recordId)) {
RecordLock lock = lockManager.getLock(recordId);
User lockUser = lock.getUser();
throw new RecordLockedException(lockUser.getUsername());
} else {
recordDao.delete(recordId);
}
}
use of org.openforis.collect.model.User in project collect by openforis.
the class UserDao method loadAll.
@Override
public List<User> loadAll() {
UserDSLContext dsl = dsl();
Result<OfcUserRecord> r = dsl.selectFrom(OFC_USER).orderBy(OFC_USER.USERNAME).fetch();
List<User> users = r != null ? dsl.fromResult(r) : null;
return users;
}
Aggregations