Permalink
Browse files

changes during validation for parameters

  • Loading branch information...
dgkncelik committed May 22, 2018
1 parent ec6f917 commit a4d1e479d8c168213e2c41be967137ae32ace83f
@@ -43,24 +43,18 @@ public Response createComponent(@RequestParam(value = "user_name") String userNa
return new Response(0,"created");
}
@ApiOperation(value = "Get component with id or components owner username = {component_key}")
@ApiOperation(value = "Get component with id or components owner username = {component_id}")
@ApiResponses({
@ApiResponse(code = 200, message = "Successfully get component with id = {component_id}", response = ComponentResponse.class),
@ApiResponse(code = 400, message = "Bad request", response = ErrorResponse.class),
@ApiResponse(code = 401, message = "Unauthorized request", response = ErrorResponse.class),
@ApiResponse(code = 403, message = "Forbidden", response = ErrorResponse.class),
@ApiResponse(code = 404, message = "No component found with id = {component_id}", response = ErrorResponse.class),
})
@GetMapping(value = "/{component_key}", produces = "application/json")
@GetMapping(value = "/{component_id}", produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public ComponentResponse getComponent(@PathVariable(value = "component_key")String componentKey){
Long componentIdLong;
try {
componentIdLong = Long.parseLong(componentKey);
return new ComponentResponse(0,null,calendarManagerService.getComponentById(componentIdLong));
}catch (Exception e){
return new ComponentResponse(0,null,calendarManagerService.getComponentByOwner(calendarManagerService.getParticipantByUserName(componentKey)));
}
public ComponentResponse getComponent(@PathVariable(value = "component_id")Long component_id){
return new ComponentResponse(0,null,calendarManagerService.getComponentById(component_id));
}
@ApiOperation(value = "Update component with id = {component_id}")
@@ -2,6 +2,7 @@
import edu.itu.cavabunga.business.CalendarManagerService;
import edu.itu.cavabunga.core.entity.Participant;
import edu.itu.cavabunga.core.http.ComponentResponse;
import edu.itu.cavabunga.core.http.ErrorResponse;
import edu.itu.cavabunga.core.http.ParticipantResponse;
import edu.itu.cavabunga.core.http.Response;
@@ -96,4 +97,10 @@ public Response updateParticipant(@PathVariable(value = "user_id") Long id, @Req
calendarManagerService.updateParticipant(id, participant);
return new Response(0,"updated");
}
@GetMapping(value="/{user_name}/components", produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public ComponentResponse getPartipantComponents(@PathVariable(value = "user_name")String userName){
return new ComponentResponse(0,null,calendarManagerService.getComponentByOwner(calendarManagerService.getParticipantByUserName(userName)));
}
}

0 comments on commit a4d1e47

Please sign in to comment.