| 
					
				 | 
			
			
				@@ -3,7 +3,6 @@ package com.swagger.rest.controllers 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.swagger.rest.models.Project 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.swagger.rest.repositories.PlatformRepository 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.swagger.rest.repositories.ProjectRepository 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.aspectj.asm.internal.ProgramElement.trim 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.http.HttpStatus 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.http.ResponseEntity 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.* 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -20,9 +19,9 @@ class ProjectController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     fun getProject(@RequestParam(required = false) name: String?): Any { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             val projects: List<Project> = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (name == null) projectRepository.findAll() as List<Project> else projectRepository.findByNameContaining( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (name == null) projectRepository.findAll() else projectRepository.findByNameContaining( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) as List<Project> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (projects.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 arrayOf<String>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else ResponseEntity<List<Project>?>(projects, HttpStatus.OK) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -44,7 +43,7 @@ class ProjectController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostMapping("/projects") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     fun addProject(@RequestBody project: Project): ResponseEntity<Project> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            val found = projectRepository.findByNameContaining(project.name)!!.size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            val found = projectRepository.findByNameContaining(project.name).size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (project.name.isNotBlank()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (project.name.length > 100 || project.description!!.length > 255) {//too long 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Project>(HttpStatus.PAYLOAD_TOO_LARGE) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,7 +65,7 @@ class ProjectController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PutMapping("/projects/{id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     fun updateProjectById(@PathVariable("id") id: Long, @RequestBody project: Project): ResponseEntity<out Any?> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         val projectData = projectRepository.findById(id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        val found = projectRepository.findByNameContaining(project.name)!!.size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val found = projectRepository.findByNameContaining(project.name).size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return if (project.name.isNotBlank()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (project.name.length > 100 || project.description!!.length > 255) {//too long 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ResponseEntity<Project>(HttpStatus.PAYLOAD_TOO_LARGE) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -90,7 +89,7 @@ class ProjectController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @DeleteMapping("/projects/{id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     fun deleteProject(@PathVariable("id") id: Long): ResponseEntity<HttpStatus> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         val find = projectRepository.findById(id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        val used = platformRepository.findByProject(id.toString())!!.size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val used = platformRepository.findByProject(id.toString()).size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (used > 0) {//child used in transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ResponseEntity(HttpStatus.RESET_CONTENT) 
			 |