use of annis.gui.ServiceQueryException in project ANNIS by korpling.
the class CorpusManagement method fetchFromService.
public void fetchFromService() throws CriticalServiceQueryException, ServiceQueryException {
if (webResourceProvider != null) {
corpora.clear();
try {
WebResource rootRes = webResourceProvider.getWebResource();
List<AnnisCorpus> corporaList = rootRes.path("query").path("corpora").get(new GenericType<List<AnnisCorpus>>() {
});
for (AnnisCorpus c : corporaList) {
corpora.put(c.getName(), c);
}
} catch (ClientHandlerException ex) {
log.error(null, ex);
throw new ServiceQueryException("Service not available: " + ex.getLocalizedMessage());
} catch (UniformInterfaceException ex) {
if (ex.getResponse().getStatus() == Response.Status.UNAUTHORIZED.getStatusCode()) {
throw new CriticalServiceQueryException("You are not authorized to get the corpus list.");
} else {
log.error(null, ex);
throw new ServiceQueryException("Remote exception: " + ex.getLocalizedMessage());
}
}
}
}
use of annis.gui.ServiceQueryException in project ANNIS by korpling.
the class CorpusManagement method delete.
public void delete(String corpusName) throws CriticalServiceQueryException, ServiceQueryException {
if (webResourceProvider != null) {
try {
WebResource rootRes = webResourceProvider.getWebResource();
rootRes.path("admin").path("corpora").path(corpusName).delete();
corpora.remove(corpusName);
} catch (ClientHandlerException ex) {
log.error(null, ex);
throw new ServiceQueryException("Service not available: " + ex.getLocalizedMessage());
} catch (UniformInterfaceException ex) {
if (ex.getResponse().getStatus() == Response.Status.UNAUTHORIZED.getStatusCode()) {
throw new CriticalServiceQueryException("You are not authorized to delete a corpus");
} else if (ex.getResponse().getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {
throw new ServiceQueryException("Corpus with name " + corpusName + " not found");
} else {
log.error(null, ex);
throw new ServiceQueryException("Remote exception: " + ex.getLocalizedMessage());
}
}
}
}
Aggregations