no message
This commit is contained in:
parent
9a724100d0
commit
66447e29e9
|
@ -0,0 +1,114 @@
|
||||||
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import eu.eudat.dao.entities.DMPDao;
|
||||||
|
import eu.eudat.dao.entities.DMPProfileDao;
|
||||||
|
import eu.eudat.dao.entities.DataRepositoryDao;
|
||||||
|
import eu.eudat.dao.entities.DatasetDao;
|
||||||
|
import eu.eudat.dao.entities.DatasetProfileDao;
|
||||||
|
import eu.eudat.dao.entities.DatasetProfileRulesetDao;
|
||||||
|
import eu.eudat.dao.entities.DatasetProfileViewstyleDao;
|
||||||
|
import eu.eudat.dao.entities.OrganisationDao;
|
||||||
|
import eu.eudat.dao.entities.ProjectDao;
|
||||||
|
import eu.eudat.dao.entities.RegistryDao;
|
||||||
|
import eu.eudat.dao.entities.ResearcherDao;
|
||||||
|
import eu.eudat.dao.entities.ServiceDao;
|
||||||
|
import eu.eudat.dao.entities.UserInfoDao;
|
||||||
|
import eu.eudat.entities.DMP;
|
||||||
|
import eu.eudat.entities.DMPProfile;
|
||||||
|
import eu.eudat.entities.DataRepository;
|
||||||
|
import eu.eudat.entities.Dataset;
|
||||||
|
import eu.eudat.entities.DatasetProfile;
|
||||||
|
import eu.eudat.entities.DatasetProfileRuleset;
|
||||||
|
import eu.eudat.entities.Organisation;
|
||||||
|
import eu.eudat.entities.Project;
|
||||||
|
import eu.eudat.entities.Registry;
|
||||||
|
import eu.eudat.entities.Researcher;
|
||||||
|
import eu.eudat.entities.Service;
|
||||||
|
import eu.eudat.entities.UserInfo;
|
||||||
|
import eu.eudat.helpers.Transformers;
|
||||||
|
import eu.eudat.responses.RestResponse;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
public class Users {
|
||||||
|
|
||||||
|
@Autowired private DataRepositoryDao dataRepositoryDao;
|
||||||
|
@Autowired private DatasetDao datasetDao;
|
||||||
|
@Autowired private DatasetProfileDao datasetProfileDao;
|
||||||
|
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
||||||
|
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||||
|
@Autowired private DMPDao dMPDao;
|
||||||
|
@Autowired private DMPProfileDao dMPProfileDao;
|
||||||
|
@Autowired private OrganisationDao organisationDao;
|
||||||
|
@Autowired private ProjectDao projectDao;
|
||||||
|
@Autowired private RegistryDao registryDao;
|
||||||
|
@Autowired private ResearcherDao researcherDao;
|
||||||
|
@Autowired private ServiceDao serviceDao;
|
||||||
|
@Autowired private UserInfoDao userInfoDao;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = { "/user/whoami" }, produces="application/json;charset=UTF-8")
|
||||||
|
public @ResponseBody ResponseEntity<Object> whoami(){
|
||||||
|
|
||||||
|
|
||||||
|
String userID = null;
|
||||||
|
try {
|
||||||
|
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
|
} catch(NullPointerException ex) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here");
|
||||||
|
}
|
||||||
|
|
||||||
|
UserInfo userInfo = userInfoDao.getUserInfo(userID);
|
||||||
|
|
||||||
|
|
||||||
|
if(userInfo==null) //this should normally never happer
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(userInfo);
|
||||||
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ export class RestBase {
|
||||||
protocol: string = "http";
|
protocol: string = "http";
|
||||||
hostname: string ="192.168.32.103"
|
hostname: string ="192.168.32.103"
|
||||||
port: number = 8080;
|
port: number = 8080;
|
||||||
webappname: string = "dmp-backend";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
protocol: string = "http";
|
protocol: string = "http";
|
||||||
|
@ -30,9 +29,9 @@ export class RestBase {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/";
|
proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/proxy/";
|
||||||
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/login/";
|
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/login/";
|
||||||
restPath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/rest/";
|
restPath: string = this.protocol+"://"+this.hostname+":"+this.port;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue