1
2
3
4
5
6
7 package ch.colabproject.colab.api.rest.team;
8
9 import ch.colabproject.colab.api.controller.team.InstanceMakerManager;
10 import ch.colabproject.colab.api.model.project.InstanceMaker;
11 import ch.colabproject.colab.api.persistence.jpa.project.InstanceMakerDao;
12 import ch.colabproject.colab.generator.model.annotations.AuthenticationRequired;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 import javax.inject.Inject;
17 import javax.ws.rs.*;
18 import javax.ws.rs.core.MediaType;
19 import java.util.List;
20
21
22
23
24
25
26 @Path("instanceMaker")
27 @Consumes(MediaType.APPLICATION_JSON)
28 @Produces(MediaType.APPLICATION_JSON)
29 @AuthenticationRequired
30 public class InstanceMakerRestEndpoint {
31
32
33
34
35 private static final Logger logger = LoggerFactory.getLogger(InstanceMakerRestEndpoint.class);
36
37
38
39
40 @Inject
41 private InstanceMakerManager instanceMakerManager;
42
43
44
45
46 @Inject
47 private InstanceMakerDao instanceMakerDao;
48
49
50
51
52
53
54
55
56
57
58
59
60 @GET
61 @Path("byproject/{projectId: [0-9]+}")
62 public List<InstanceMaker> getInstanceMakersForProject(@PathParam("projectId") Long projectId) {
63 logger.debug("Get project #{} instanceMakers", projectId);
64 return instanceMakerManager.getInstanceMakersForProject(projectId);
65 }
66
67
68
69
70
71
72
73
74
75 @GET
76 @Path("get/{instanceMakerId: [0-9]+}")
77 public InstanceMaker getInstanceMaker(@PathParam("instanceMakerId") Long instanceMakerId) {
78 logger.debug("Get instanceMaker #{}", instanceMakerId);
79 return instanceMakerDao.findInstanceMaker(instanceMakerId);
80 }
81
82
83
84
85
86
87 @DELETE
88 @Path("delete/{instanceMakerId: [0-9]+}")
89 public void deleteInstanceMaker(@PathParam("instanceMakerId") Long instanceMakerId) {
90 logger.debug("Delete instanceMaker #{}", instanceMakerId);
91 instanceMakerManager.deleteInstanceMaker(instanceMakerId);
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108 @POST
109 @Path("shareModel/{id: [0-9]+}/{email}")
110 public InstanceMaker shareModel(@PathParam("id") Long modelId, @PathParam("email") String email) {
111 logger.debug("Share model #{} to {}", modelId, email);
112 return instanceMakerManager.shareModel(modelId, email);
113 }
114 }