Ejemplo n.º 1
0
  @Override
  @GET
  @Path("/pets/{petId}")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  public Response findPetById(@PathParam("petId") long petId) {
    try {
      Result<Pet> response = petClinicMgr.findPetById(petId);
      ServiceResponse<PetSrvMdl> responseMessage = ResponseTranslator.toServiceResponse(response);
      if (response.isSuccess()) {
        PetSrvMdl petSrvMdl = ResponseTranslator.transform(response.getResult());
        responseMessage.setResult(petSrvMdl);
      }
      return Response.ok(responseMessage).build();
    } catch (Exception ex) {

    }
    return Response.ok(ServiceResponse.failure()).build();
  }
Ejemplo n.º 2
0
  @Override
  @GET
  @Path("/owners/{ownerId}")
  @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  public Response findOwnerById(@PathParam("ownerId") long ownerId) {
    try {
      Result<Owner> bussniesResponse = petClinicMgr.findOwnerById(ownerId);
      ServiceResponse<OwnerSrvMdl> responseMessage =
          ResponseTranslator.toServiceResponse(bussniesResponse);

      if (bussniesResponse.isSuccess()) {
        OwnerSrvMdl ownerSrvMdl = ResponseTranslator.transform(bussniesResponse.getResult());
        responseMessage.setResult(ownerSrvMdl);
      }
      return Response.ok(responseMessage).build();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return Response.ok(ServiceResponse.failure()).build();
  }