1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.controllers;
|
2 |
49236
|
panagiotis
|
|
3 |
50051
|
panagiotis
|
import eu.dnetlib.domain.data.Repository;
|
4 |
|
|
import eu.dnetlib.domain.data.RepositoryInterface;
|
5 |
54525
|
panagiotis
|
import eu.dnetlib.repo.manager.domain.RepositorySnippet;
|
6 |
|
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
7 |
|
|
import eu.dnetlib.repo.manager.service.RepositoryApiImpl;
|
8 |
50570
|
panagiotis
|
import eu.dnetlib.repo.manager.shared.*;
|
9 |
54525
|
panagiotis
|
import io.swagger.annotations.Api;
|
10 |
49362
|
panagiotis
|
import org.json.JSONException;
|
11 |
49450
|
panagiotis
|
import org.springframework.beans.factory.annotation.Autowired;
|
12 |
54525
|
panagiotis
|
import org.springframework.http.MediaType;
|
13 |
51656
|
panagiotis
|
import org.springframework.security.access.prepost.PreAuthorize;
|
14 |
53933
|
panagiotis
|
import org.springframework.security.core.Authentication;
|
15 |
54525
|
panagiotis
|
import org.springframework.web.bind.annotation.*;
|
16 |
50051
|
panagiotis
|
|
17 |
53113
|
panagiotis
|
import java.io.IOException;
|
18 |
54525
|
panagiotis
|
import java.util.List;
|
19 |
|
|
import java.util.Map;
|
20 |
49236
|
panagiotis
|
|
21 |
54525
|
panagiotis
|
@RestController
|
22 |
|
|
@RequestMapping(value = "/repository")
|
23 |
|
|
@Api(description = "Repository API", tags = {"repository"})
|
24 |
|
|
public class RepositoryController {
|
25 |
49236
|
panagiotis
|
|
26 |
49450
|
panagiotis
|
@Autowired
|
27 |
54525
|
panagiotis
|
RepositoryApiImpl repositoryApi;
|
28 |
49450
|
panagiotis
|
|
29 |
54525
|
panagiotis
|
@RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
30 |
|
|
@ResponseBody
|
31 |
49960
|
panagiotis
|
public Country[] getCountries() {
|
32 |
54525
|
panagiotis
|
return repositoryApi.getCountries();
|
33 |
49236
|
panagiotis
|
}
|
34 |
|
|
|
35 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoriesByCountry/{country}/{mode}", method = RequestMethod.GET,
|
36 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
37 |
|
|
@ResponseBody
|
38 |
53113
|
panagiotis
|
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
39 |
|
|
@PathVariable("mode") String mode,
|
40 |
|
|
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
41 |
54525
|
panagiotis
|
return repositoryApi.getRepositoriesByCountry(country, mode, managed);
|
42 |
49236
|
panagiotis
|
}
|
43 |
|
|
|
44 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET,
|
45 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
46 |
|
|
@ResponseBody
|
47 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
48 |
49236
|
panagiotis
|
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
49 |
|
|
@PathVariable("page") String page,
|
50 |
49362
|
panagiotis
|
@PathVariable("size") String size) throws JSONException {
|
51 |
54525
|
panagiotis
|
return repositoryApi.getRepositoriesOfUser(userEmail, page, size);
|
52 |
49236
|
panagiotis
|
}
|
53 |
|
|
|
54 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
55 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
56 |
|
|
@ResponseBody
|
57 |
52781
|
panagiotis
|
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
58 |
54525
|
panagiotis
|
return repositoryApi.getRepositoryById(id);
|
59 |
49236
|
panagiotis
|
}
|
60 |
|
|
|
61 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
62 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
63 |
|
|
@ResponseBody
|
64 |
52781
|
panagiotis
|
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
65 |
54525
|
panagiotis
|
return repositoryApi.getRepositoryAggregations(id);
|
66 |
52781
|
panagiotis
|
}
|
67 |
|
|
|
68 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
|
69 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
70 |
|
|
@ResponseBody
|
71 |
52781
|
panagiotis
|
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
72 |
54525
|
panagiotis
|
return repositoryApi.getRepositoryAggregationsByYear(id);
|
73 |
52781
|
panagiotis
|
}
|
74 |
49935
|
panagiotis
|
|
75 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
|
76 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
77 |
|
|
@ResponseBody
|
78 |
49236
|
panagiotis
|
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
79 |
|
|
@PathVariable("page") String page,
|
80 |
49362
|
panagiotis
|
@PathVariable("size") String size) throws JSONException {
|
81 |
54525
|
panagiotis
|
return repositoryApi.getRepositoriesByName(name, page, size);
|
82 |
49236
|
panagiotis
|
}
|
83 |
|
|
|
84 |
54525
|
panagiotis
|
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
85 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
86 |
|
|
@ResponseBody
|
87 |
49988
|
panagiotis
|
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
88 |
54525
|
panagiotis
|
return repositoryApi.getRepositoryInterface(id);
|
89 |
49236
|
panagiotis
|
}
|
90 |
|
|
|
91 |
54525
|
panagiotis
|
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
92 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
93 |
|
|
@ResponseBody
|
94 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
95 |
50945
|
panagiotis
|
public Repository addRepository(@RequestParam("datatype") String datatype,
|
96 |
|
|
@RequestBody Repository repository) throws Exception {
|
97 |
49898
|
panagiotis
|
|
98 |
54525
|
panagiotis
|
return repositoryApi.addRepository(datatype, repository);
|
99 |
49963
|
panagiotis
|
}
|
100 |
49960
|
panagiotis
|
|
101 |
54525
|
panagiotis
|
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
|
102 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
103 |
|
|
@ResponseBody
|
104 |
|
|
List<String> getDnetCountries(){
|
105 |
|
|
return repositoryApi.getDnetCountries();
|
106 |
50075
|
panagiotis
|
}
|
107 |
|
|
|
108 |
54525
|
panagiotis
|
@RequestMapping(value = "/getTypologies", method = RequestMethod.GET,
|
109 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
110 |
|
|
@ResponseBody
|
111 |
|
|
List<String> getTypologies(){
|
112 |
|
|
return repositoryApi.getTypologies();
|
113 |
49960
|
panagiotis
|
}
|
114 |
|
|
|
115 |
54525
|
panagiotis
|
@RequestMapping(value = "/getTimezones", method = RequestMethod.GET,
|
116 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
117 |
|
|
@ResponseBody
|
118 |
|
|
List<Timezone> getTimezones(){
|
119 |
|
|
return repositoryApi.getTimezones();
|
120 |
49963
|
panagiotis
|
}
|
121 |
|
|
|
122 |
54525
|
panagiotis
|
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
123 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
124 |
|
|
@ResponseBody
|
125 |
|
|
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
126 |
|
|
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
127 |
|
|
return repositoryApi.updateRepository(repository, authentication);
|
128 |
49236
|
panagiotis
|
}
|
129 |
|
|
|
130 |
54525
|
panagiotis
|
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
|
131 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
132 |
|
|
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
133 |
|
|
@RequestParam("registeredBy") String registeredBy){
|
134 |
54525
|
panagiotis
|
repositoryApi.deleteRepositoryInterface(id, registeredBy);
|
135 |
49813
|
panagiotis
|
}
|
136 |
|
|
|
137 |
54525
|
panagiotis
|
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
138 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
139 |
|
|
@ResponseBody
|
140 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
141 |
50075
|
panagiotis
|
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
142 |
|
|
@RequestParam("repoId") String repoId,
|
143 |
52781
|
panagiotis
|
@RequestParam("registeredBy") String registeredBy,
|
144 |
|
|
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
145 |
54525
|
panagiotis
|
return repositoryApi.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface);
|
146 |
49963
|
panagiotis
|
}
|
147 |
|
|
|
148 |
54525
|
panagiotis
|
@RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET,
|
149 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
150 |
|
|
@ResponseBody
|
151 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
152 |
50614
|
panagiotis
|
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
153 |
49763
|
panagiotis
|
@PathVariable("page") String page,
|
154 |
|
|
@PathVariable("size") String size) throws JSONException {
|
155 |
54525
|
panagiotis
|
return repositoryApi.getUrlsOfUserRepos(userEmail, page, size);
|
156 |
49236
|
panagiotis
|
}
|
157 |
|
|
|
158 |
54525
|
panagiotis
|
@RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET,
|
159 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
160 |
|
|
@ResponseBody
|
161 |
49450
|
panagiotis
|
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
162 |
54525
|
panagiotis
|
return repositoryApi.getDatasourceVocabularies(mode);
|
163 |
49450
|
panagiotis
|
}
|
164 |
|
|
|
165 |
54525
|
panagiotis
|
@RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET,
|
166 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
167 |
|
|
@ResponseBody
|
168 |
49790
|
panagiotis
|
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
|
169 |
|
|
|
170 |
54525
|
panagiotis
|
return repositoryApi.getCompatibilityClasses(mode);
|
171 |
49790
|
panagiotis
|
}
|
172 |
|
|
|
173 |
54525
|
panagiotis
|
@RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET,
|
174 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
175 |
|
|
@ResponseBody
|
176 |
49790
|
panagiotis
|
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
|
177 |
54525
|
panagiotis
|
return repositoryApi.getDatasourceClasses(mode);
|
178 |
49790
|
panagiotis
|
}
|
179 |
|
|
|
180 |
54525
|
panagiotis
|
@RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET,
|
181 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
182 |
|
|
@ResponseBody
|
183 |
50570
|
panagiotis
|
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
184 |
54525
|
panagiotis
|
return repositoryApi.getMetricsInfoForRepository(repoId);
|
185 |
50570
|
panagiotis
|
}
|
186 |
|
|
|
187 |
54525
|
panagiotis
|
@RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET,
|
188 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
189 |
|
|
@ResponseBody
|
190 |
51330
|
panagiotis
|
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
191 |
54525
|
panagiotis
|
return repositoryApi.getListLatestUpdate(mode);
|
192 |
51330
|
panagiotis
|
}
|
193 |
|
|
|
194 |
54525
|
panagiotis
|
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
195 |
|
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
196 |
|
|
@ResponseBody
|
197 |
52781
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
|
198 |
51525
|
panagiotis
|
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
199 |
52781
|
panagiotis
|
@RequestParam("registeredBy") String registeredBy,
|
200 |
51525
|
panagiotis
|
@RequestBody RepositoryInterface repositoryInterface) throws JSONException {
|
201 |
54525
|
panagiotis
|
return repositoryApi.updateRepositoryInterface(repoId, registeredBy, repositoryInterface);
|
202 |
51525
|
panagiotis
|
}
|
203 |
49236
|
panagiotis
|
}
|