use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class SystemController method getSystemStatus.
@RequestMapping(value = "/systemstatus", method = RequestMethod.POST)
public ResponseEntity<HashMap> getSystemStatus() throws Exception {
ResourceBundleProvider.updateLocale(new Locale("en_US"));
HashMap<String, String> map = new HashMap<>();
map.put("OpenClinica Version", CoreResources.getField("OpenClinica.version"));
map.put("Java Version", System.getProperty("java.version"));
map.put("Java Class Path", System.getProperty("java.class.path"));
map.put("Java Home", System.getProperty("java.home"));
map.put("OS Name", System.getProperty("os.name"));
map.put("OS Version", System.getProperty("os.version"));
map.put("OS Architecture", System.getProperty("os.arch"));
map.put("File Separator", System.getProperty("file.separator"));
map.put("Path Separator", System.getProperty("path.separator"));
map.put("Line Separator", System.getProperty("line.separator"));
map.put("User Home", System.getProperty("user.home"));
map.put("User Directory", System.getProperty("user.dir"));
map.put("User Name", System.getProperty("user.name"));
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format("%s=%s%n", envName, env.get(envName));
}
DatabaseMetaData metaData = dataSource.getConnection().getMetaData();
try {
UserAccountDAO udao = new UserAccountDAO(dataSource);
UserAccountBean uBean = (UserAccountBean) udao.findByPK(1);
if (uBean.getFirstName().equals("Root") && uBean.getLastName().equals("User")) {
map.put("Root User Account First And Last Name", uBean.getFirstName() + " " + uBean.getLastName());
map.put("Database Connection", "PASS");
} else {
map.put("Database Connection", "FAIL");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new ResponseEntity<HashMap>(map, org.springframework.http.HttpStatus.OK);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class UserAccountController method getUserAccountByStudy.
private ArrayList<UserAccountBean> getUserAccountByStudy(String userName, ArrayList allStudies) {
udao = new UserAccountDAO(dataSource);
ArrayList<UserAccountBean> userAccountBeans = udao.findStudyByUser(userName, allStudies);
return userAccountBeans;
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class UserAccountController method getUserAccountByApiKey.
private UserAccountBean getUserAccountByApiKey(String apiKey) {
udao = new UserAccountDAO(dataSource);
UserAccountBean userAccountBean = (UserAccountBean) udao.findByApiKey(apiKey);
return userAccountBean;
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class UserAccountController method createUserAccount.
private void createUserAccount(UserAccountBean userAccountBean) {
udao = new UserAccountDAO(dataSource);
udao.create(userAccountBean);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class UserInfoController method getCrcAccountBySession.
/**
* @api {get} /pages/userinfo/study/:studyOid/crc Retrieve a user account - crc
* @apiName getCrcAccountBySession
* @apiPermission Module participate - enabled & admin
* @apiVersion 3.12.2
* @apiGroup User Account
* @apiDescription Retrieves the crc user account associated with the current session.
* @apiParamExample {json} Request-Example:
* {
* "studyOid": " S_BL101",
* }
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "lName": "Jackson",
* "mobile": "",
* "accessCode": "",
* "apiKey": "6e8b69f6fb774e899f9a6c349c5adace",
* "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
* "email": "abc@yahoo.com",
* "userName": "crc_user",
* "studySubjectId": null,
* "fName": "joe"
* }
*/
@RequestMapping(value = "/study/{studyOid}/crc", method = RequestMethod.GET)
public ResponseEntity<UserDTO> getCrcAccountBySession(@PathVariable("studyOid") String studyOid) throws Exception {
ResourceBundleProvider.updateLocale(new Locale("en_US"));
sdao = new StudyDAO(dataSource);
udao = new UserAccountDAO(dataSource);
boolean isRequestValid = true;
uDTO = null;
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Object principle = null;
if (auth != null)
principle = auth.getPrincipal();
StudyBean currentStudy = sdao.findByOid(studyOid);
UserAccountBean userAccount = (UserAccountBean) udao.findByUserName(((UserDetails) principle).getUsername());
StudyBean parentStudy = getParentStudy(currentStudy.getOid());
Integer pStudyId = parentStudy.getId();
String oid = parentStudy.getOid();
if (isStudyASiteLevelStudy(currentStudy.getOid()))
isRequestValid = false;
else if (!mayProceed(oid))
isRequestValid = false;
else if (isStudyDoesNotExist(oid))
isRequestValid = false;
else if (isCRCUserAccountDoesNotExist(userAccount.getName()))
isRequestValid = false;
else if (doesCRCNotHaveStudyAccessRole(userAccount.getName(), pStudyId))
isRequestValid = false;
if (isRequestValid) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
buildUserDTO(userAccount);
return new ResponseEntity<UserDTO>(uDTO, headers, org.springframework.http.HttpStatus.OK);
} else {
return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
}
Aggregations