Revision 57350
Added by Ioannis Diplas over 4 years ago
PiWikController.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.repo.manager.domain.OrderByType; |
6 | 6 |
import eu.dnetlib.repo.manager.domain.Paging; |
7 | 7 |
import eu.dnetlib.repo.manager.service.PiWikServiceImpl; |
8 |
import eu.dnetlib.repo.manager.service.RepositoryService; |
|
8 | 9 |
import eu.dnetlib.repo.manager.shared.RepositoryServiceException; |
9 | 10 |
import io.swagger.annotations.Api; |
10 | 11 |
import io.swagger.annotations.ApiImplicitParam; |
... | ... | |
14 | 15 |
import org.springframework.core.io.FileSystemResource; |
15 | 16 |
import org.springframework.http.MediaType; |
16 | 17 |
import org.springframework.http.ResponseEntity; |
18 |
import org.springframework.security.access.prepost.PostAuthorize; |
|
17 | 19 |
import org.springframework.security.access.prepost.PreAuthorize; |
18 | 20 |
import org.springframework.web.bind.annotation.*; |
19 | 21 |
|
... | ... | |
40 | 42 |
@Autowired |
41 | 43 |
private PiWikServiceImpl piWikService; |
42 | 44 |
|
45 |
@Autowired |
|
46 |
private RepositoryService repositoryService; |
|
43 | 47 |
|
48 |
|
|
44 | 49 |
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
45 | 50 |
@ResponseBody |
51 |
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (@repositoryService.getRepositoryById(#repositoryId).registeredBy==authentication.userInfo.email and hasRole('ROLE_USER'))") |
|
46 | 52 |
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) { |
47 | 53 |
return piWikService.getPiwikSiteForRepo(repositoryId); |
48 | 54 |
} |
49 | 55 |
|
50 | 56 |
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) |
51 |
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') " + |
|
52 |
"and #piwikInfo.requestorEmail == authentication.userInfo.email)") |
|
57 |
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==authentication.userInfo.email and hasRole('ROLE_USER'))") |
|
53 | 58 |
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) { |
54 | 59 |
return piWikService.savePiwikInfo(piwikInfo); |
55 | 60 |
} |
... | ... | |
158 | 163 |
|
159 | 164 |
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) |
160 | 165 |
@ResponseBody |
166 |
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") |
|
161 | 167 |
public String getOpenaireId(String repositoryid){ |
162 | 168 |
return piWikService.getOpenaireId(repositoryid); |
163 | 169 |
} |
Also available in: Unified diff
Moved permissions at the controller level