no message
This commit is contained in:
parent
a70529fb93
commit
2a64608849
|
@ -5,7 +5,10 @@ import java.util.UUID;
|
|||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.managers.DashBoardManager;
|
||||
import eu.eudat.models.dashboard.DashBoardStatistics;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -23,6 +26,8 @@ import eu.eudat.models.admin.composite.DatasetProfile;
|
|||
import javax.transaction.Transactional;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class Admin extends BaseController {
|
||||
|
@ -34,7 +39,7 @@ public class Admin extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile){
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
this.getApiContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
|
@ -47,7 +52,7 @@ public class Admin extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> updateDmp(@PathVariable String id,@RequestBody DatasetProfile profile){
|
||||
public ResponseEntity<Object> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
|
||||
|
@ -63,7 +68,7 @@ public class Admin extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/admin/get/{id}"}, produces = "application/json")
|
||||
public ResponseEntity<Object> get(@PathVariable String id){
|
||||
public ResponseEntity<Object> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile profile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
|
|
|
@ -41,13 +41,13 @@ public class Login {
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/externallogin"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> externallogin(@RequestBody LoginInfo credentials) {
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Principal>> externallogin(@RequestBody LoginInfo credentials) {
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch (UnauthorisedException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
|
@ -55,20 +55,21 @@ public class Login {
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/nativelogin"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> nativelogin(@RequestBody Credentials credentials) {
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Principal>> nativelogin(@RequestBody Credentials credentials) {
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(UserManager.authenticate(this.authenticationService, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch (UnauthorisedException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/twitterRequestToken"}, produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<OAuthToken>> twitterRequestToken() {
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<OAuthToken>> twitterRequestToken() {
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OAuthToken>().payload(this.twitterTokenValidator.getRequestToken()).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
|
@ -78,7 +79,8 @@ public class Login {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/me"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) {
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) {
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(this.authenticationService.Touch(principal.getToken())).status(ApiMessageCode.NO_MESSAGE));
|
||||
|
||||
|
@ -89,7 +91,8 @@ public class Login {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/logout"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
||||
try {
|
||||
this.authenticationService.Logout(principal.getToken());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(ApiMessageCode.NO_MESSAGE));
|
||||
|
|
Loading…
Reference in New Issue