@Override public void run(ApplicationConfiguration configuration, Environment environment) throws Exception { environment.jersey().register(new UriConnegFilter(new MediaTypeMappings(), Collections.<String, String>emptyMap())); Map<String, Object> props = new HashMap<>(); props.put(MessageProperties.LEGACY_WORKERS_ORDERING, true); environment.jersey().getResourceConfig().addProperties(props); addWriters(environment.jersey()); configureCors(environment); //TODO: This path should not be hard coded. configureSwagger(environment, "scigraph"); environment.servlets(). addFilter("Swagger Filter", factory.getInjector().getInstance(SwaggerFilter.class)) .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/swagger.json", "/swagger"); environment.servlets().addFilter("swaggerDocResolver", new SwaggerDocUrlFilter()) .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); DynamicCypherResourceFactory cypherFactory = factory.getInjector().getInstance(DynamicCypherResourceFactory.class); for (Map.Entry<String,Path> config: configuration.getCypherResources().entrySet()) { environment.jersey().getResourceConfig().registerResources(cypherFactory.create(config.getKey(), config.getValue()).getBuilder().build()); } }
/** * {@inheritDoc} */ @Override public boolean configure(FeatureContext context) { Configuration configuration = context.getConfiguration(); if (!configuration.isRegistered(UriConnegFilter.class)) { context.register(UriConnegFilter.class, Priorities.AUTHENTICATION - 100); } if (!context.getConfiguration().isRegistered(DownloadEntityFilter.class)) { context.register(DownloadEntityFilter.class); } if (!configuration.isRegistered(LoadBalancerRequestFilter.class)) { context.register(LoadBalancerRequestFilter.class); } return true; }
private UriConnegFilter uriConnegFilter() { Map<String, MediaType> mediaTypeMappings = new HashMap<>(); mediaTypeMappings.put("xml", MediaType.APPLICATION_XML_TYPE); mediaTypeMappings.put("json", MediaType.APPLICATION_JSON_TYPE); return new UriConnegFilter(mediaTypeMappings, null); }
public UriDataFormatFilter(Map<String, MediaType> mediaTypeMappings) { uriConnegFilter = new UriConnegFilter(mediaTypeMappings, null); }