Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
22be00a799
|
@ -19,6 +19,7 @@ import eu.eudat.validators.DataManagementPlanTableRequestValidator;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -49,38 +50,38 @@ public class DMPs extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = new DataManagementPlanManager().getPaged(this.getApiContext(), dataManagementPlanTableRequest,principal);
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.OK).payload(dataTable));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataManagementPlan> getSingle(@PathVariable String id,Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataManagementPlan>> getSingle(@PathVariable String id,Principal principal) {
|
||||
try {
|
||||
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(this.getApiContext().getDatabaseRepository().getDmpDao(), id,principal);
|
||||
return new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataManagementPlan>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/createOrUpdate" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DMP> createOrUpdate(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan, Principal principal) {
|
||||
try{
|
||||
DataManagementPlanManager.createOrUpdate(this.getApiContext(),dataManagementPlan,principal);
|
||||
return new ResponseItem<DMP>().status(HttpStatus.CREATED);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(HttpStatus.CREATED));
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DMP>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,15 +89,14 @@ public class DMPs extends BaseController {
|
|||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DataManagementPlan>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria,Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<DataManagementPlan>>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria,Principal principal) {
|
||||
try {
|
||||
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(this.getApiContext().getDatabaseRepository().getDmpDao(), dataManagementPlanCriteria);
|
||||
|
||||
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.models.security.Principal;
|
|||
import eu.eudat.services.ApiContext;
|
||||
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;
|
||||
|
@ -26,15 +27,15 @@ public class DashBoardController extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||
public ResponseItem<DashBoardStatistics> getStatistics(Principal principal){
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics(Principal principal){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(this.getApiContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getDatabaseRepository().getProjectDao());
|
||||
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.OK).payload(statistics);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(HttpStatus.OK).payload(statistics));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.INTERNAL_SERVER_ERROR).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DashBoardStatistics>().status(HttpStatus.INTERNAL_SERVER_ERROR).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,16 +48,16 @@ public class DataRepositories extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/datarepos" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<Map<String,String>>> listExternalDataRepositories(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<Map<String,String>>>> listExternalDataRepositories(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getRepositories(query);
|
||||
return new ResponseItem<List<Map<String,String>>>().status(HttpStatus.OK).payload(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Map<String,String>>>().status(HttpStatus.OK).payload(remoteRepos));
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return new ResponseItem<List<Map<String,String>>>().status(HttpStatus.INTERNAL_SERVER_ERROR).payload(null);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String,String>>>().status(HttpStatus.INTERNAL_SERVER_ERROR).payload(null));
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return new ResponseItem<List<Map<String,String>>>().status(HttpStatus.UNPROCESSABLE_ENTITY).payload(null);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<Map<String,String>>>().status(HttpStatus.UNPROCESSABLE_ENTITY).payload(null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.models.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.user.composite.DatasetProfile;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -41,7 +43,7 @@ public class DatasetProfileController extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetwizard/get/{id}" }, produces="application/json")
|
||||
public ResponseEntity<Object> getSingle(@PathVariable String id){
|
||||
public ResponseEntity<ResponseItem<DatasetProfile>> getSingle(@PathVariable String id){
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = this.getApiContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
||||
|
@ -51,11 +53,11 @@ public class DatasetProfileController extends BaseController{
|
|||
Map<String,Object> properties = (Map<String, Object>)jobject.toMap();
|
||||
datasetprofile.fromJsonObject(properties);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(HttpStatus.OK).payload(datasetprofile));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,44 +44,44 @@ import eu.eudat.dao.entities.ServiceDao;
|
|||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DatasetProfiles extends BaseController{
|
||||
public class DatasetProfiles extends BaseController {
|
||||
|
||||
@Autowired
|
||||
public DatasetProfiles(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
@Autowired
|
||||
public DatasetProfiles(ApiContext apiContext) {
|
||||
super(apiContext);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/datasetprofiles/get" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DatasetProfileAutocompleteItem>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
||||
try {
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(),datasetProfileAutocompleteRequest);
|
||||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.OK).payload(datasetProfileAutocompleteItems);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileAutocompleteItem>>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) {
|
||||
try {
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = DatasetProfileManager.getWithCriteria(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileAutocompleteRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.OK).payload(datasetProfileAutocompleteItems));
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.BAD_REQUEST));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/datasetprofiles/getPaged" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetProfileListingModel>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
||||
try {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(),datasetProfileTableRequestItem);
|
||||
return new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData );
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/getPaged"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
||||
try {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileTableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData));
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofiles/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DatasetProfileListingModel>> getAll() {
|
||||
try {
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getAll(this.getApiContext().getDatabaseRepository().getDatasetProfileDao());
|
||||
return new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData );
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll() {
|
||||
try {
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getAll(this.getApiContext().getDatabaseRepository().getDatasetProfileDao());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.OK).payload(datasetProfileTableData));
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DatasetProfileListingModel>>().status(HttpStatus.BAD_REQUEST));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.managers.DatasetManager;
|
||||
import eu.eudat.managers.DatasetWizardManager;
|
||||
import eu.eudat.managers.UserManager;
|
||||
|
@ -19,6 +20,7 @@ import eu.eudat.services.ApiContext;
|
|||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
@ -40,53 +42,49 @@ public class DatasetWizardController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<List<DataManagentPlanListingModel>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<DataManagentPlanListingModel>>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
|
||||
try {
|
||||
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal);
|
||||
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<List<AssociatedProfile>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<AssociatedProfile>>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
|
||||
try {
|
||||
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest);
|
||||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DatasetWizardModel>> getPaged(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Dataset>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = DatasetManager.createOrUpdate(this.getApiContext(), profile);
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,28 +39,27 @@ public class Datasets extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/datasets/makepublic/{id}"}, produces = "application/json")
|
||||
public @ResponseBody ResponseItem<Dataset> makePublic(@PathVariable UUID id, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Dataset>> makePublic(@PathVariable UUID id, Principal principal) {
|
||||
try {
|
||||
DatasetManager.makePublic(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
return new ResponseItem<Dataset>().status(HttpStatus.OK).message("Dataset Has Been Made Public");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(HttpStatus.OK).message("Dataset Has Been Made Public"));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import eu.eudat.models.security.Principal;
|
|||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -34,25 +35,25 @@ public class ExternalDatasets extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<ExternalDatasetListingModel>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<ExternalDatasetListingModel>>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), datasetTableRequest);
|
||||
return new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.OK).payload(dataTable));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/datasets"}, produces = "application/json")
|
||||
public @ResponseBody ResponseItem<List<ExternalDatasetListingModel>> getWithExternal(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
try {
|
||||
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), query, this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<ExternalDatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.security.validators.twitter.TwitterTokenValidator;
|
|||
import eu.eudat.services.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.social.oauth1.OAuthToken;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -38,48 +39,48 @@ public class Login {
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/externallogin" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody LoginInfo credentials) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> googleLogin(@RequestBody LoginInfo credentials) {
|
||||
try {
|
||||
return new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK));
|
||||
}catch (UnauthorisedException ex){
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/twitterRequestToken" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<OAuthToken> twitterRequestToken() {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<OAuthToken>> twitterRequestToken() {
|
||||
try {
|
||||
return new ResponseItem<OAuthToken>().payload(this.twitterTokenValidator.getRequestToken()).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OAuthToken>().payload(this.twitterTokenValidator.getRequestToken()).status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<OAuthToken>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OAuthToken>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/me" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Principal> authMe(Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> authMe(Principal principal) {
|
||||
try {
|
||||
return new ResponseItem<Principal>().payload(this.authenticationService.Touch(principal.getToken())).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(this.authenticationService.Touch(principal.getToken())).status(HttpStatus.OK));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/logout" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Principal> logout(Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Principal>> logout(Principal principal) {
|
||||
try {
|
||||
this.authenticationService.Logout(principal.getToken());
|
||||
return new ResponseItem<Principal>().status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().status(HttpStatus.OK));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,90 +50,21 @@ public class Organisations extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/organisations" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<OrganisationsExternalSourcesModel> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseEntity<ResponseItem<OrganisationsExternalSourcesModel>> listExternalOrganisations(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getOrganisations(query);
|
||||
OrganisationsExternalSourcesModel projectsExternalSourcesModel = new OrganisationsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<OrganisationsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK));
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found"));
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set"));
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<OrganisationsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MANAGE ORGANISATIONS(S)
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/organisations" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listOrganisations(){
|
||||
try {
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getOrganisationDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/organisations/{id}" })
|
||||
public @ResponseBody ResponseEntity<Organisation> getOrganisations(@PathVariable("id") String id) {
|
||||
try {
|
||||
Organisation organisation = this.getApiContext().getDatabaseRepository().getOrganisationDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(organisation);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/organisation/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllOrganisations(){
|
||||
try {
|
||||
List<Organisation> allOrganisations = this.getApiContext().getDatabaseRepository().getOrganisationDao().getAll();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allOrganisations);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/organisation/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Organisation> setOrganisation(@RequestBody Organisation organisation) {
|
||||
try {
|
||||
Organisation createdOrganisation = this.getApiContext().getDatabaseRepository().getOrganisationDao().update(organisation);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdOrganisation);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/organisation/delete" }, consumes = "application/json", produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Organisation> delete(@RequestBody Organisation organisation) {
|
||||
|
||||
Organisation org = new Organisation();
|
||||
org.setId(organisation.getId());
|
||||
try {
|
||||
this.getApiContext().getDatabaseRepository().getOrganisationDao().delete(org);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
|||
import eu.eudat.models.external.RegistriesExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.project.ProjectCriteriaRequest;
|
||||
import eu.eudat.models.project.ProjectListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -66,326 +67,89 @@ public class Projects extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<eu.eudat.models.project.ProjectListingModel> dataTable = new ProjectManager().getPaged(this.getApiContext().getDatabaseRepository().getProjectDao(), projectTableRequest);
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().payload(dataTable).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().payload(dataTable).status(HttpStatus.OK));
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<eu.eudat.models.project.ProjectListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/projects/getSingle/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<eu.eudat.models.project.Project> getSingle(@PathVariable String id, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<eu.eudat.models.project.Project>> getSingle(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(this.getApiContext().getDatabaseRepository().getProjectDao(), id);
|
||||
return new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<eu.eudat.models.project.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.project.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/createOrUpdate"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<eu.eudat.entities.Project> addProject(@Valid @RequestBody eu.eudat.models.project.Project project, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Project>> addProject(@Valid @RequestBody eu.eudat.models.project.Project project, Principal principal) {
|
||||
try {
|
||||
ProjectManager.createOrUpdate(this.getApiContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getDatabaseRepository().getUserInfoDao(), project, principal);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/projects/inactivate/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<eu.eudat.entities.Project> inactivate(@PathVariable String id, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Project>> inactivate(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
Project project = new ProjectManager().inactivate(this.getApiContext().getDatabaseRepository().getProjectDao(), id);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<List<eu.eudat.models.project.Project>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<eu.eudat.models.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<List<eu.eudat.models.project.Project>> get(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<eu.eudat.models.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getRemoteFetcher());
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/projects"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<ProjectsExternalSourcesModel> listExternalProjects(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<ProjectsExternalSourcesModel>> listExternalProjects(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
try {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getRemoteFetcher().getProjects(query);
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ProjectsExternalSourcesModel>().payload(projectsExternalSourcesModel).status(HttpStatus.OK));
|
||||
} catch (NoURLFound ex) {
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found"));
|
||||
} catch (HugeResultSet ex) {
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set"));
|
||||
} catch (Exception ex) {
|
||||
return new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ProjectsExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MANAGE PROJECT(S)
|
||||
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/projects" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<List<UUID>> listProjects(){
|
||||
// try {
|
||||
// List<UUID> allIDs = projectDao.listAllIDs();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/projects/{id}" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Project> getProject(@PathVariable("id") String id) {
|
||||
// try {
|
||||
// Project project = projectDao.read(UUID.fromString(id));
|
||||
//
|
||||
// System.out.println(project.getId().toString());
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(project);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/project/listAllLabelIDs" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
||||
// try {
|
||||
// List<IDLabelPair> allIDs = projectDao.listAllIDsLabels();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/project/getAll" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> getAllProjects(){
|
||||
// try {
|
||||
// List<Project> allProjects = projectDao.getAll();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allProjects);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Project> createProject(@RequestBody Project project) {
|
||||
// Project createdProject = projectDao.update(project);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/update" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Project> updateProject(@RequestBody Project project) {
|
||||
// Project updatedProject = projectDao.update(project);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(updatedProject);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/delete" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Project> delete(@RequestBody Project project) {
|
||||
//
|
||||
// Project p = new Project();
|
||||
// p.setId(project.getId());
|
||||
// try {
|
||||
// projectDao.delete(p);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/softdelete" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Project project) {
|
||||
//
|
||||
// project.setStatus(new Short("-1"));
|
||||
//
|
||||
// try {
|
||||
// projectDao.update(project);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/getdmps" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> getProjectDmps(@RequestBody Project project) {
|
||||
// try {
|
||||
// Set<DMP> dmps = projectDao.read(project.getId()).getDmps();
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(dmps);
|
||||
// } catch (Exception e) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// ////////////////////////////////
|
||||
// //// USER - RELATED ACTIONS ////
|
||||
// ////////////////////////////////
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/project/getofuser" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<Object> getProjectsOfUser(){
|
||||
//
|
||||
// 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.read(UUID.fromString(userID));
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happen
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// List<Project> userProjects = projectDao.getProjectsOfUser(userID);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(userProjects);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * OLD ONE
|
||||
// Map<UUID, Researcher> userProjects = new HashMap<UUID, Researcher>();
|
||||
//
|
||||
// userInfo.getDmps().forEach( dmp -> {
|
||||
// Researcher proj = dmp.getProject();
|
||||
// userProjects.put(proj.getId(), proj);
|
||||
// });
|
||||
//
|
||||
// try {
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(userProjects.values()));
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
// }
|
||||
// */
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/createofuser" }, produces="text/plain", consumes = "application/json")
|
||||
// public @ResponseBody ResponseEntity<Project> createProjectOfUser(@RequestBody Project project){
|
||||
//
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
//
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happer
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// project.setId(null);
|
||||
// project.setStatus(new Short("0"));
|
||||
// project.setCreationUser(userInfo);
|
||||
// project.setCreated(new Date());
|
||||
// project.setModified(new Date());
|
||||
//
|
||||
// Project newproj = projectDao.create(project);
|
||||
//
|
||||
//// DMP newdmp = new DMP();
|
||||
//// newdmp.setId(null);
|
||||
//// newdmp.setLabel("Auto-Generated");
|
||||
//// newdmp.setCreated(new Date());
|
||||
//// newdmp.setVersion(1);
|
||||
//// newdmp.setStatus(new Short("0"));
|
||||
//// newdmp.setProject(newproj);
|
||||
////
|
||||
//// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||
//// users.add(userInfo);
|
||||
//// newdmp.setUsers(users);
|
||||
////
|
||||
//// newdmp = dMPDao.create(newdmp);
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(newproj);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/updateofuser" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<Object> updateProjectOfUser(@RequestBody Researcher project){
|
||||
//
|
||||
// if(project.getId()==null)
|
||||
// return ResponseEntity.status(HttpStatus.NOT_MODIFIED).body("Cannot update, id was null");
|
||||
// return setProject(project);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -51,108 +51,24 @@ public class Registries extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/registries" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<RegistriesExternalSourcesModel> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseEntity<ResponseItem<RegistriesExternalSourcesModel>> listExternalRegistries(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getRegistries(query);
|
||||
RegistriesExternalSourcesModel registriesExternalSourcesModel = new RegistriesExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RegistriesExternalSourcesModel>().payload(registriesExternalSourcesModel).status(HttpStatus.OK));
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found"));
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set"));
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<RegistriesExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MANAGE REGISTRY(IES)
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/registries" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listRegistries(){
|
||||
try {
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getRegistryDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/registries/{id}" })
|
||||
public @ResponseBody ResponseEntity<Registry> getRegistries(@PathVariable("id") String id) {
|
||||
try {
|
||||
Registry registry = this.getApiContext().getDatabaseRepository().getRegistryDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(registry);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/registries/listAllLabelIDs" })
|
||||
public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
||||
try {
|
||||
List<IDLabelPair> allIDs = this.getApiContext().getDatabaseRepository().getRegistryDao().listAllIDsLabels();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/registry/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllRegistries(){
|
||||
try {
|
||||
List<Registry> allRegistries = this.getApiContext().getDatabaseRepository().getRegistryDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allRegistries);
|
||||
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/registry/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Registry> setRegistry(@RequestBody Registry registry) {
|
||||
Registry createdRegistry = this.getApiContext().getDatabaseRepository().getRegistryDao().update(registry);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdRegistry);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/registry/delete" }, consumes = "application/json", produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody Registry registry) {
|
||||
|
||||
Registry r = new Registry();
|
||||
r.setId(registry.getId());
|
||||
try {
|
||||
this.getApiContext().getDatabaseRepository().getRegistryDao().delete(r);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted registry!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete registry!\"}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,103 +50,21 @@ public class Researchers extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/researchers" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ResearchersExternalSourcesModel> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseEntity<ResponseItem<ResearchersExternalSourcesModel>> listExternalResearchers(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getResearchers(query);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(HttpStatus.OK));
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found"));
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set"));
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ResearchersExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MANAGE RESEARCHER(S)
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/researchers" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listResearchers(){
|
||||
try {
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getResearcherDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/researchers/{id}" })
|
||||
public @ResponseBody ResponseEntity<Researcher> getResearchers(@PathVariable("id") String id) {
|
||||
try {
|
||||
Researcher researcher = this.getApiContext().getDatabaseRepository().getResearcherDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(researcher);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getByEmail" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Researcher> getResearcherByEmail(@RequestParam("email") String email){
|
||||
try {
|
||||
Researcher researcher = this.getApiContext().getDatabaseRepository().getResearcherDao().getResearcherByEmail(email);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(researcher);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<List<Researcher>> getAllResearchers(){
|
||||
try {
|
||||
List<Researcher> allResearchers = this.getApiContext().getDatabaseRepository().getResearcherDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allResearchers);
|
||||
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/researcher/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Researcher> setResearcher(@RequestBody Researcher researcher) {
|
||||
Researcher createdResearcher = this.getApiContext().getDatabaseRepository().getResearcherDao().update(researcher);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdResearcher);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/researcher/delete" }, consumes = "application/json", produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody Researcher researcher) {
|
||||
|
||||
Researcher res = new Researcher();
|
||||
res.setId(researcher.getId());
|
||||
try {
|
||||
this.getApiContext().getDatabaseRepository().getResearcherDao().delete(res);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted researcher!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete researcher!\"}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -49,95 +49,21 @@ public class Services extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/services" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<ServiceExternalSourcesModel> listExternalServices(@RequestParam(value="query", required=false) String query ){
|
||||
public @ResponseBody ResponseEntity<ResponseItem<ServiceExternalSourcesModel>> listExternalServices(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
List<Map<String,String>> remoteRepos = this.getApiContext().getRemoteFetcher().getServices(query);
|
||||
ServiceExternalSourcesModel serviceExternalSourcesModel = new ServiceExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(HttpStatus.OK);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ServiceExternalSourcesModel>().payload(serviceExternalSourcesModel).status(HttpStatus.OK));
|
||||
}
|
||||
catch(NoURLFound ex) {
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("External Url Not Found"));
|
||||
}
|
||||
catch(HugeResultSet ex) {
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message("Huge Result Set"));
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<ServiceExternalSourcesModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MANAGE SERVICE(S)
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/services" })
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listServices(){
|
||||
try {
|
||||
List<UUID> allIDs = this.getApiContext().getDatabaseRepository().getServiceDao().listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/services/{id}" })
|
||||
public @ResponseBody ResponseEntity<Service> getServices(@PathVariable("id") String id) {
|
||||
try {
|
||||
Service service = this.getApiContext().getDatabaseRepository().getServiceDao().read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(service);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/service/getAll" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> getAllServices(){
|
||||
try {
|
||||
List<Service> allServices = this.getApiContext().getDatabaseRepository().getServiceDao().getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allServices);
|
||||
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/service/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Service> setService(@RequestBody Service service) {
|
||||
|
||||
Service createdService = this.getApiContext().getDatabaseRepository().getServiceDao().update(service);
|
||||
try {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdService);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/service/delete" }, consumes = "application/json", produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody Service service) {
|
||||
|
||||
System.out.println(service);
|
||||
|
||||
try {
|
||||
this.getApiContext().getDatabaseRepository().getServiceDao().delete(service);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Service entity!\"}");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Service entity!\"}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.models.userinfo.UserInfoRequestItem;
|
|||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -31,40 +32,40 @@ public class UserInvitationController extends BaseController{
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/users" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Invitation> users(@RequestBody Invitation invitation, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<Invitation>> users(@RequestBody Invitation invitation, Principal principal) {
|
||||
try {
|
||||
InvitationsManager.inviteUsers(this.getApiContext(),invitation,principal);
|
||||
return new ResponseItem<Invitation>().status(HttpStatus.OK).message("Users have beeen invited");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Invitation>().status(HttpStatus.OK).message("Users have beeen invited"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<Invitation>().message(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Invitation>().message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/exchange/{invitationID}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<UUID> exchange(@PathVariable UUID invitationID, Principal principal) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<UUID>> exchange(@PathVariable UUID invitationID, Principal principal) {
|
||||
try {
|
||||
UUID dmpId = InvitationsManager.assignUserAcceptedInvitation(this.getApiContext(),invitationID,principal);
|
||||
return new ResponseItem<UUID>().status(HttpStatus.OK).payload(dmpId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(HttpStatus.OK).payload(dmpId));
|
||||
}catch (UnauthorisedException e){
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<UUID>().message(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<UUID>().message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/getUsers" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<UserInfoInvitationModel>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) {
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) {
|
||||
try {
|
||||
List<UserInfoInvitationModel> users = InvitationsManager.getUsers(this.getApiContext(),userInfoRequestItem);
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.OK).payload(users);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.OK).payload(users));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.BAD_REQUEST).message(e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.BAD_REQUEST).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ResponseItem<T> {
|
|||
return payload;
|
||||
}
|
||||
|
||||
public void setpayload(T payload) {
|
||||
public void setPayload(T payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package eu.eudat.models.properties;
|
||||
|
||||
import eu.eudat.models.user.components.datasetprofile.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/19/2018.
|
||||
*/
|
||||
public class DatasetProfilePage {
|
||||
private Integer ordinal;
|
||||
private String title;
|
||||
private List<Section> sections;
|
||||
|
||||
public Integer getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
public void setOrdinal(Integer ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,22 @@
|
|||
package eu.eudat.models.properties;
|
||||
|
||||
import eu.eudat.models.user.composite.DatasetProfilePage;
|
||||
import eu.eudat.models.user.composite.PagedDatasetProfile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PropertiesModel implements PropertiesGenerator{
|
||||
private int status;
|
||||
private List<Section> sections;
|
||||
private List<eu.eudat.models.properties.DatasetProfilePage> pages;
|
||||
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
public List<eu.eudat.models.properties.DatasetProfilePage> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
public void setPages(List<eu.eudat.models.properties.DatasetProfilePage> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
|
@ -26,8 +29,7 @@ public class PropertiesModel implements PropertiesGenerator{
|
|||
|
||||
@Override
|
||||
public void toMap(Map<String, Object> fieldValues) {
|
||||
this.sections.forEach(item->item.toMap(fieldValues));
|
||||
|
||||
this.pages.forEach(item->item.getSections().forEach(sectionItem->sectionItem.toMap(fieldValues)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue