/**
   * Get Web Service for getting adverts that a member has searched for using words or phrases.
   *
   * @param tags - String representing the words or phrases entered into search.
   * @return - Server response indicating success or failure with a message.
   */
  @GET
  @Path("{tags}")
  public Response getSearchedAdverts(@PathParam("tags") String tags) {
    if (tags == null) {
      return Response.serverError().entity("Tags cannot be blank").build();
    }
    List<Advert> adsList = new ArrayList<>();
    DBConnector db = new DBConnector();
    try {
      db.createConnection();
      adsList = db.getSearchedForAdverts(URLDecoder.decode(tags, "UTF-8"));
      db.closeConnection();
    } catch (SQLException | ClassNotFoundException | UnsupportedEncodingException ex) {
      Logger.getLogger(GetSearchAdvertsREST.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (adsList.isEmpty()) {
      return Response.status(Response.Status.NOT_FOUND)
          .entity("No adverts found with search terms: " + tags)
          .build();
    }
    String json = new Gson().toJson(adsList);

    return Response.ok(json, MediaType.APPLICATION_JSON).build();
  }