1 |
51088
|
claudio.at
|
package eu.dnetlib.openaire.community;
|
2 |
50853
|
claudio.at
|
|
3 |
|
|
import java.util.List;
|
4 |
|
|
|
5 |
|
|
import io.swagger.annotations.ApiOperation;
|
6 |
|
|
import io.swagger.annotations.ApiResponse;
|
7 |
|
|
import io.swagger.annotations.ApiResponses;
|
8 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
9 |
|
|
import org.springframework.web.bind.annotation.*;
|
10 |
|
|
|
11 |
51088
|
claudio.at
|
import static eu.dnetlib.openaire.common.ExporterConstants.*;
|
12 |
51080
|
claudio.at
|
|
13 |
50853
|
claudio.at
|
@RestController
|
14 |
51019
|
claudio.at
|
@io.swagger.annotations.Api(tags = "OpenAIRE Communities API", description = "the OpenAIRE Community API")
|
15 |
51080
|
claudio.at
|
public class CommunityApiController {
|
16 |
50853
|
claudio.at
|
|
17 |
|
|
@Autowired
|
18 |
|
|
private CommunityApiCore communityApiCore;
|
19 |
|
|
|
20 |
|
|
@RequestMapping(value = "/community/communities", produces = { "application/json" }, method = RequestMethod.GET)
|
21 |
|
|
@ApiOperation(
|
22 |
|
|
value = "get all community profiles",
|
23 |
|
|
notes = "get all community profiles",
|
24 |
|
|
tags = { C, R },
|
25 |
|
|
response = CommunitySummary[].class)
|
26 |
|
|
@ApiResponses(value = {
|
27 |
|
|
@ApiResponse(code = 200, message = "OK", response = CommunitySummary[].class),
|
28 |
50923
|
claudio.at
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
29 |
|
|
public List<CommunitySummary> listCommunities() throws CommunityException {
|
30 |
50853
|
claudio.at
|
return communityApiCore.listCommunities();
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.GET)
|
34 |
|
|
@ApiOperation(
|
35 |
|
|
value = "get community profile",
|
36 |
|
|
notes = "get community profile",
|
37 |
|
|
tags = { C, R },
|
38 |
50923
|
claudio.at
|
response = CommunityDetails.class)
|
39 |
50853
|
claudio.at
|
@ApiResponses(value = {
|
40 |
50923
|
claudio.at
|
@ApiResponse(code = 200, message = "OK", response = CommunityDetails.class),
|
41 |
|
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
42 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
43 |
|
|
public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
|
44 |
50853
|
claudio.at
|
return communityApiCore.getCommunity(id);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
50923
|
claudio.at
|
@RequestMapping(value = "/community/{id}", produces = { "application/json" }, method = RequestMethod.POST)
|
48 |
|
|
@ApiOperation(
|
49 |
|
|
value = "update community details",
|
50 |
|
|
notes = "update community details",
|
51 |
|
|
tags = { C, R })
|
52 |
|
|
@ApiResponses(value = {
|
53 |
|
|
@ApiResponse(code = 200, message = "OK"),
|
54 |
|
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
55 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
56 |
|
|
public void setCommunity(
|
57 |
|
|
@PathVariable final String id,
|
58 |
|
|
@RequestBody CommunityWritableProperties properties) throws CommunityException, CommunityNotFoundException {
|
59 |
|
|
|
60 |
|
|
communityApiCore.setCommunity(id, properties);
|
61 |
|
|
}
|
62 |
|
|
|
63 |
50853
|
claudio.at
|
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.GET)
|
64 |
|
|
@ApiOperation(
|
65 |
|
|
value = "get community projects",
|
66 |
|
|
notes = "get community projects",
|
67 |
51019
|
claudio.at
|
tags = { C_PJ, R },
|
68 |
50853
|
claudio.at
|
response = CommunityProject[].class)
|
69 |
|
|
@ApiResponses(value = {
|
70 |
|
|
@ApiResponse(code = 200, message = "OK", response = CommunityProject[].class),
|
71 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
72 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
73 |
|
|
public List<CommunityProject> getCommunityProjects(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
|
74 |
50853
|
claudio.at
|
return communityApiCore.getCommunityProjects(id);
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.POST)
|
78 |
|
|
@ApiOperation(
|
79 |
|
|
value = "associate a project to the community",
|
80 |
|
|
notes = "associate a project to the community",
|
81 |
51019
|
claudio.at
|
tags = { C_PJ, W })
|
82 |
50853
|
claudio.at
|
@ApiResponses(value = {
|
83 |
|
|
@ApiResponse(code = 200, message = "OK"),
|
84 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
85 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
86 |
50853
|
claudio.at
|
public void addCommunityProject(
|
87 |
|
|
@PathVariable final String id,
|
88 |
50923
|
claudio.at
|
@RequestBody final CommunityProject project) throws CommunityException, CommunityNotFoundException {
|
89 |
50853
|
claudio.at
|
|
90 |
|
|
communityApiCore.addCommunityProject(id, project);
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
@RequestMapping(value = "/community/{id}/projects", produces = { "application/json" }, method = RequestMethod.DELETE)
|
94 |
|
|
@ApiOperation(
|
95 |
|
|
value = "remove a project from the community",
|
96 |
|
|
notes = "remove a project from the community",
|
97 |
51019
|
claudio.at
|
tags = { C_PJ, W })
|
98 |
50853
|
claudio.at
|
@ApiResponses(value = {
|
99 |
|
|
@ApiResponse(code = 200, message = "OK"),
|
100 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
101 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
102 |
50853
|
claudio.at
|
public void deleteCommunityProject(
|
103 |
|
|
@PathVariable final String id,
|
104 |
50923
|
claudio.at
|
@RequestBody final String projectId) throws CommunityException, CommunityNotFoundException {
|
105 |
50853
|
claudio.at
|
|
106 |
|
|
communityApiCore.removeCommunityProject(id, projectId);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
50854
|
claudio.at
|
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.GET)
|
110 |
50853
|
claudio.at
|
@ApiOperation(
|
111 |
50854
|
claudio.at
|
value = "get the list of content providers associated to a given community",
|
112 |
|
|
notes = "get the list of content providers associated to a given community",
|
113 |
51019
|
claudio.at
|
tags = { C_CP, R },
|
114 |
50853
|
claudio.at
|
response = CommunityContentprovider[].class)
|
115 |
|
|
@ApiResponses(value = {
|
116 |
|
|
@ApiResponse(code = 200, message = "OK", response = CommunityContentprovider[].class),
|
117 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
118 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
119 |
|
|
public List<CommunityContentprovider> getCommunityContentproviders(@PathVariable final String id) throws CommunityException, CommunityNotFoundException {
|
120 |
50853
|
claudio.at
|
return communityApiCore.getCommunityContentproviders(id);
|
121 |
|
|
}
|
122 |
|
|
|
123 |
50854
|
claudio.at
|
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.POST)
|
124 |
50853
|
claudio.at
|
@ApiOperation(
|
125 |
|
|
value = "associate a content provider to the community",
|
126 |
|
|
notes = "associate a content provider to the community",
|
127 |
51019
|
claudio.at
|
tags = { C_CP, W })
|
128 |
50853
|
claudio.at
|
@ApiResponses(value = {
|
129 |
|
|
@ApiResponse(code = 200, message = "OK"),
|
130 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
131 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
132 |
50853
|
claudio.at
|
public void addCommunityContentprovider(
|
133 |
|
|
@PathVariable final String id,
|
134 |
50923
|
claudio.at
|
@RequestBody final CommunityContentprovider contentprovider) throws CommunityException, CommunityNotFoundException {
|
135 |
50853
|
claudio.at
|
|
136 |
|
|
communityApiCore.addCommunityContentprovider(id, contentprovider);
|
137 |
|
|
}
|
138 |
|
|
|
139 |
50854
|
claudio.at
|
@RequestMapping(value = "/community/{id}/contentproviders", produces = { "application/json" }, method = RequestMethod.DELETE)
|
140 |
50853
|
claudio.at
|
@ApiOperation(
|
141 |
50854
|
claudio.at
|
value = "remove the association between a content provider and the community",
|
142 |
|
|
notes = "remove the association between a content provider and the community",
|
143 |
51019
|
claudio.at
|
tags = { C_CP, W })
|
144 |
50853
|
claudio.at
|
@ApiResponses(value = {
|
145 |
|
|
@ApiResponse(code = 200, message = "OK"),
|
146 |
50923
|
claudio.at
|
@ApiResponse(code = 404, message = "not found", response = CommunityNotFoundException.class),
|
147 |
|
|
@ApiResponse(code = 500, message = "unexpected error", response = CommunityException.class) })
|
148 |
50853
|
claudio.at
|
public void removeCommunityContentprovider(
|
149 |
|
|
@PathVariable final String id,
|
150 |
50923
|
claudio.at
|
@RequestBody final String contentproviderId) throws CommunityException, CommunityNotFoundException {
|
151 |
50853
|
claudio.at
|
|
152 |
|
|
communityApiCore.removeCommunityContentProvider(id, contentproviderId);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
}
|