57 lines
2.5 KiB
Java
57 lines
2.5 KiB
Java
package eu.eudat.controllers;
|
|
|
|
import eu.eudat.authorization.Permission;
|
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
|
import eu.eudat.logic.services.ApiContext;
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
import eu.eudat.types.ApiMessageCode;
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import jakarta.transaction.Transactional;
|
|
|
|
import static eu.eudat.types.Authorities.ADMIN;
|
|
|
|
@RestController
|
|
@CrossOrigin
|
|
@RequestMapping(value = {"/api/management/"})
|
|
public class ManagementController extends BaseController {
|
|
|
|
private final DatasetProfileManager datasetProfileManager;
|
|
private final AuthorizationService authorizationService;
|
|
|
|
@Autowired
|
|
public ManagementController(ApiContext apiContext, DatasetProfileManager datasetProfileManager, AuthorizationService authorizationService){
|
|
super(apiContext);
|
|
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()));
|
|
}
|
|
}
|
|
}
|