org.glassfish.jersey.server.filter.UriConnegFilter Java Examples

The following examples show how to use org.glassfish.jersey.server.filter.UriConnegFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainApplication.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
@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());
  }
}
 
Example #2
Source File: SysFilteringFeature.java    From ameba with MIT License 6 votes vote down vote up
/**
 * {@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;
}