argos/dmp-backend/web/src/main/java/eu/eudat/controllers/old/ManagementController.java

51 lines
1.9 KiB
Java

package eu.eudat.controllers.old;
import eu.eudat.authorization.Permission;
import eu.eudat.logic.managers.DatasetProfileManager;
import gr.cite.commons.web.authz.service.AuthorizationService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
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 boolean addSemanticsInDatasetProfiles() throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole);
try {
this.datasetProfileManager.addSemanticsInDatasetProfiles();
return true;
} catch (Exception exception) {
return false;
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSemantics"})
public boolean addRdaInSemanticsInDatasetProfiles() throws Exception {
this.authorizationService.authorizeForce(Permission.AdminRole);
try {
this.datasetProfileManager.addRdaInSemanticsInDatasetProfiles();
return true;
} catch (Exception exception) {
return false;
}
}
}