class ModelBean {

    @GET
    @Produces({"application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "application/x-protobuf",
            "application/x-protostuff", "text/html"})
    @Path("/{name}")
    @GZIP
    @Interceptors({RequiredInterceptor.class, ResponseInterceptor.class})
    public datawave.webservice.model.Model getModel(@Required("name") @PathParam("name") String name, @QueryParam("modelTableName") String modelTableName) {
        
        if (modelTableName == null) {
            modelTableName = defaultModelTableName;
        }
        
        datawave.webservice.model.Model response = new datawave.webservice.model.Model(jqueryUri, dataTablesUri);
        
        // Find out who/what called this method
        Principal p = ctx.getCallerPrincipal();
        String user = p.getName();
        Set<Authorizations> cbAuths = new HashSet<>();
        if (p instanceof DatawavePrincipal) {
            DatawavePrincipal cp = (DatawavePrincipal) p;
            user = cp.getShortName();
            for (Collection<String> auths : cp.getAuthorizations()) {
                cbAuths.add(new Authorizations(auths.toArray(new String[auths.size()])));
            }
        }
        log.trace(user + " has authorizations " + cbAuths);
        
        Connector connector = null;
        try {
            Map<String,String> trackingMap = connectionFactory.getTrackingMap(Thread.currentThread().getStackTrace());
            connector = connectionFactory.getConnection(AccumuloConnectionFactory.Priority.LOW, trackingMap);
            try (Scanner scanner = ScannerHelper.createScanner(connector, this.checkModelTableName(modelTableName), cbAuths)) {
                IteratorSetting cfg = new IteratorSetting(21, "colfRegex", RegExFilter.class.getName());
                cfg.addOption(RegExFilter.COLF_REGEX, "^" + name + "(\\x00.*)?");
                scanner.addScanIterator(cfg);
                for (Entry<Key,Value> entry : scanner) {
                    FieldMapping mapping = ModelKeyParser.parseKey(entry.getKey(), cbAuths);
                    response.getFields().add(mapping);
                }
            }
        } catch (Exception e) {
            QueryException qe = new QueryException(DatawaveErrorCode.MODEL_FETCH_ERROR, e);
            log.error(qe);
            response.addException(qe.getBottomQueryException());
            throw new DatawaveWebApplicationException(qe, response);
        } finally {
            if (null != connector) {
                try {
                    connectionFactory.returnConnection(connector);
                } catch (Exception e) {
                    log.error("Error returning connection to factory", e);
                }
            }
        }
        
        // return 404 if model not found
        if (response.getFields().isEmpty()) {
            throw new NotFoundException(null, response);
        }
        
        response.setName(name);
        return response;
    }

}