use of org.openforis.collect.model.User in project collect by openforis.
the class UserSessionService method changePassword.
public OperationResult changePassword(String oldPassword, String newPassword) throws UserPersistenceException {
SessionState sessionState = sessionManager.getSessionState();
User currentUser = sessionState.getUser();
return userManager.changePassword(currentUser.getUsername(), oldPassword, newPassword);
}
use of org.openforis.collect.model.User in project collect by openforis.
the class BackupRestoreController method createRecordFilter.
private RecordFilter createRecordFilter(CollectSurvey survey, Integer rootEntityId, boolean onlyOwnedRecords, String[] rootEntityKeyValues) {
RecordFilter recordFilter = new RecordFilter(survey, rootEntityId);
// filter by record owner
if (onlyOwnedRecords) {
SessionState sessionState = sessionManager.getSessionState();
User user = sessionState.getUser();
recordFilter.setOwnerId(user.getId());
}
// filter by root entity keys
recordFilter.setKeyValues(rootEntityKeyValues);
return recordFilter;
}
use of org.openforis.collect.model.User in project collect by openforis.
the class RecordGenerator method generate.
@Transactional
public CollectRecord generate(int surveyId, NewRecordParameters parameters, RecordKey recordKey) {
CollectSurvey survey = surveyManager.getById(surveyId);
User user = loadUser(parameters.getUserId(), parameters.getUsername());
CollectRecord record = createRecord(survey, user, recordKey);
if (parameters.isAddSecondLevelEntities()) {
addSecondLevelEntities(record, recordKey);
}
recordManager.save(record);
return record;
}
use of org.openforis.collect.model.User in project collect by openforis.
the class SessionManager method checkIsActiveRecordLocked.
public void checkIsActiveRecordLocked() throws RecordUnlockedException {
SessionState sessionState = getSessionState();
CollectRecord record = sessionState.getActiveRecord();
if (record == null) {
throw new RecordUnlockedException();
} else if (record.getId() != null) {
User user = sessionState.getUser();
String lockId = sessionState.getSessionId();
try {
recordManager.checkIsLocked(record.getId(), user, lockId);
sessionState.keepActiveRecordAlive();
} catch (RecordUnlockedException e) {
clearActiveRecord();
throw e;
}
}
}
use of org.openforis.collect.model.User in project collect by openforis.
the class SessionManager method loadAuthenticatedUser.
private User loadAuthenticatedUser() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
String name = authentication.getName();
User user = userManager.loadByUserName(name);
return user;
} else {
return null;
}
}
Aggregations