55 lines
2.5 KiB
Java
55 lines
2.5 KiB
Java
package eu.eudat.controllers;
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
|
import eu.eudat.models.old.helpers.responses.ResponseItem;
|
|
import eu.eudat.types.ApiMessageCode;
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
import jakarta.transaction.Transactional;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@CrossOrigin
|
|
@RequestMapping(value = {"/api/management/"})
|
|
public class ManagementController{
|
|
|
|
private final DatasetProfileManager datasetProfileManager;
|
|
private final AuthorizationService authorizationService;
|
|
|
|
@Autowired
|
|
public ManagementController(DatasetProfileManager datasetProfileManager, AuthorizationService authorizationService){
|
|
this.datasetProfileManager = datasetProfileManager;
|
|
this.authorizationService = authorizationService;
|
|
}
|
|
|
|
@Transactional
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/addSemantics"})
|
|
public ResponseEntity addSemanticsInDatasetProfiles() throws Exception {
|
|
this.authorizationService.authorizeForce(Permission.AdminRole);
|
|
try {
|
|
this.datasetProfileManager.addSemanticsInDatasetProfiles();
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
} catch (Exception exception) {
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
|
}
|
|
}
|
|
|
|
@Transactional
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSemantics"})
|
|
public ResponseEntity addRdaInSemanticsInDatasetProfiles() throws Exception {
|
|
this.authorizationService.authorizeForce(Permission.AdminRole);
|
|
try {
|
|
this.datasetProfileManager.addRdaInSemanticsInDatasetProfiles();
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
} catch (Exception exception) {
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
|
}
|
|
}
|
|
}
|