Search in sources :

Example 1 with SegmentationList

use of annis.service.objects.SegmentationList in project ANNIS by korpling.

the class SearchOptionsPanel method getSegmentationNamesFromService.

private static List<String> getSegmentationNamesFromService(Set<String> corpora) {
    List<String> segNames = new ArrayList<>();
    WebResource service = Helper.getAnnisWebResource();
    if (service != null) {
        for (String corpus : corpora) {
            try {
                SegmentationList segList = service.path("query").path("corpora").path(Helper.encodeJersey(corpus)).path("segmentation-names").get(SegmentationList.class);
                segNames.addAll(segList.getSegmentatioNames());
            } catch (UniformInterfaceException ex) {
                if (ex.getResponse().getStatus() == 403) {
                    log.debug("Did not have access rights to query segmentation names for corpus", ex);
                } else {
                    log.warn("Could not query segmentation names for corpus", ex);
                }
            }
        }
    }
    return segNames;
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SegmentationList(annis.service.objects.SegmentationList) ArrayList(java.util.ArrayList) WebResource(com.sun.jersey.api.client.WebResource)

Example 2 with SegmentationList

use of annis.service.objects.SegmentationList in project ANNIS by korpling.

the class QueryServiceImpl method segmentationNames.

@GET
@Path("corpora/{top}/segmentation-names")
@Produces("application/xml")
public SegmentationList segmentationNames(@PathParam("top") String toplevelCorpus) throws WebApplicationException {
    Subject user = SecurityUtils.getSubject();
    user.checkPermission("query:annotations:" + toplevelCorpus);
    List<Long> corpusList = new ArrayList<>();
    corpusList.add(queryDao.mapCorpusNameToId(toplevelCorpus));
    return new SegmentationList(queryDao.listSegmentationNames(corpusList));
}
Also used : SegmentationList(annis.service.objects.SegmentationList) ArrayList(java.util.ArrayList) Subject(org.apache.shiro.subject.Subject) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SegmentationList (annis.service.objects.SegmentationList)2 ArrayList (java.util.ArrayList)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 WebResource (com.sun.jersey.api.client.WebResource)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Subject (org.apache.shiro.subject.Subject)1