package org.gbif.checklistbank.ws.nub;

import com.google.common.base.Strings;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.gbif.api.model.checklistbank.NameUsageMatch;
import org.gbif.api.model.common.LinneanClassification;
import org.gbif.api.util.VocabularyUtils;
import org.gbif.api.vocabulary.Rank;
import org.gbif.nub.lookup.NameUsageMatch2;
import org.gbif.nub.lookup.NameUsageMatchingService2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

@Path("/species")
@Singleton
public class NubResource {

  private static final Logger LOG = LoggerFactory.getLogger(NubResource.class);

  private final NameUsageMatchingService2 matchingService;

  @Inject
  public NubResource(NameUsageMatchingService2 matchingService) {
    this.matchingService = matchingService;
  }

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("match")
  public NameUsageMatch match(@QueryParam("name") String scientificName, @QueryParam("rank") String rank,
                              LinneanClassification classification,
                              @QueryParam("strict") Boolean strict, @QueryParam("verbose") Boolean verbose) {
    Rank r = parse(Rank.class, rank);
    return matchingService.match(scientificName, r, classification, bool(strict), bool(verbose));
  }

  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("match2")
  public NameUsageMatch2 match2(@QueryParam("name") String scientificName, @QueryParam("rank") String rank,
                                LinneanClassification classification,
                                @QueryParam("strict") Boolean strict, @QueryParam("verbose") Boolean verbose) {
    Rank r = parse(Rank.class, rank);
    return matchingService.v2(matchingService.match(scientificName, r, classification, bool(strict), bool(verbose)));
  }

  private <T extends Enum> T parse(Class<T> clazz, String value) throws IllegalArgumentException {
    if (!Strings.isNullOrEmpty(value)) {
      return VocabularyUtils.lookupEnum(value, clazz);
    }
    return null;
  }

  private boolean bool(Boolean bool) {
    return bool == null ? false : bool;
  }

}

@@ -597,16 +597,49 @@
 yParam;%0A
+import javax.ws.rs.core.Context;%0A
 import j
@@ -665,16 +665,16 @@
 iaType;%0A
-
 %0A@Path(%22
@@ -1181,32 +1181,41 @@
                 
+@Context 
 LinneanClassific
@@ -1652,32 +1652,32 @@
 %22) String rank,%0A
-
                 
@@ -1692,16 +1692,25 @@
         
+@Context 
 LinneanC

Add missing @Context