@@ -21,15 +21,12 @@ import com.netflix.spectator.api.Registry
21
21
import com.netflix.spinnaker.front50.exception.NotFoundException
22
22
import com.netflix.spinnaker.front50.model.project.Project
23
23
import com.netflix.spinnaker.front50.model.project.ProjectDAO
24
- import com.netflix.spinnaker.front50.resources.project.ProjectResource
25
- import com.netflix.spinnaker.front50.resources.project.ProjectResourceAssembler
26
24
import groovy.transform.InheritConstructors
27
25
import groovy.util.logging.Slf4j
28
26
import io.swagger.annotations.Api
29
27
import io.swagger.annotations.ApiOperation
30
28
import org.springframework.beans.factory.annotation.Autowired
31
29
import org.springframework.context.MessageSource
32
- import org.springframework.hateoas.Resources
33
30
import org.springframework.http.HttpStatus
34
31
import org.springframework.http.MediaType
35
32
import org.springframework.web.bind.annotation.PathVariable
@@ -39,7 +36,6 @@ import org.springframework.web.bind.annotation.RequestMethod
39
36
import org.springframework.web.bind.annotation.RequestParam
40
37
import org.springframework.web.bind.annotation.ResponseStatus
41
38
import org.springframework.web.bind.annotation.RestController
42
- import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*
43
39
44
40
import javax.servlet.http.HttpServletResponse
45
41
@@ -57,47 +53,41 @@ public class ProjectsController {
57
53
@Autowired
58
54
Registry registry
59
55
60
- private final ProjectResourceAssembler assembler = new ProjectResourceAssembler ()
61
-
62
56
@RequestMapping (value = " /search" , method = RequestMethod .GET )
63
57
@ApiOperation (value = " " , notes = """ Search for projects given one or more attributes.
64
58
65
59
- /search?q=ProjectName
66
60
- /search?q=ApplicationName
67
61
""" )
68
- Resources< ProjectResource > search (@RequestParam (" q" ) String query ) {
62
+ Set< Project > search (@RequestParam (" q" ) String query ) {
69
63
def projects = projectDAO. all(). findAll { Project project ->
70
64
project. name. toLowerCase(). contains(query. toLowerCase()) || project. config. applications. find {
71
65
it. toLowerCase(). contains(query. toLowerCase())
72
66
}
73
67
}
74
68
75
- def resources = assembler. toResources(projects)
76
- def link = linkTo(ProjectsController ). slash(" /search?q=${ query} " ). withSelfRel()
77
- return new Resources<ProjectResource > (resources, link)
69
+ return projects
78
70
}
79
71
80
72
@ApiOperation (value = " " , notes = " Fetch all projects" )
81
73
@RequestMapping (method = RequestMethod .GET )
82
- Resources<ProjectResource > projects () {
83
- def resources = assembler. toResources(projectDAO. all())
84
- def link = linkTo(ProjectsController ). slash(' /' ). withSelfRel()
85
- return new Resources<ProjectResource > (resources, link)
74
+ Set<Project > projects () {
75
+ return projectDAO. all()
86
76
}
87
77
88
78
@ApiOperation (value = " " , notes = " Fetch a single project" )
89
79
@RequestMapping (method = RequestMethod .GET , value = " /{projectId}" )
90
- ProjectResource project (@PathVariable String projectId ) {
80
+ Project project (@PathVariable String projectId ) {
91
81
try {
92
- return assembler . toResource( projectDAO. findByName(projectId) )
82
+ return projectDAO. findByName(projectId)
93
83
} catch (NotFoundException e) {
94
- return assembler . toResource( projectDAO. findById(projectId) )
84
+ return projectDAO. findById(projectId)
95
85
}
96
86
}
97
87
98
88
@ApiOperation (value = " " , notes = " Update an existing project" )
99
89
@RequestMapping (method = RequestMethod .PUT , value = " /{projectId}" )
100
- ProjectResource put (@PathVariable final String projectId , @RequestBody final Project project ) {
90
+ Project put (@PathVariable final String projectId , @RequestBody final Project project ) {
101
91
def existingProject = projectDAO. findById(projectId)
102
92
103
93
project. id = existingProject. id
@@ -112,12 +102,12 @@ public class ProjectsController {
112
102
} catch (NotFoundException ignored) {}
113
103
114
104
projectDAO. update(projectId, project)
115
- return assembler . toResource( project)
105
+ return project
116
106
}
117
107
118
108
@ApiOperation (value = " " , notes = " Create a project" )
119
109
@RequestMapping (method = RequestMethod .POST )
120
- ProjectResource create (@RequestBody final Project project ) {
110
+ Project create (@RequestBody final Project project ) {
121
111
project. createTs = System . currentTimeMillis()
122
112
project. updateTs = System . currentTimeMillis()
123
113
@@ -126,7 +116,7 @@ public class ProjectsController {
126
116
throw new ProjectAlreadyExistsException ()
127
117
} catch (NotFoundException ignored) {}
128
118
129
- return assembler . toResource( projectDAO. create(project. id, project) )
119
+ return projectDAO. create(project. id, project)
130
120
}
131
121
132
122
@ApiOperation (value = " " , notes = " Delete a project" )
0 commit comments