Search in sources :

Example 1 with AuditLogFilter

use of org.apache.helix.rest.server.filters.AuditLogFilter in project helix by apache.

the class AbstractTestClass method configure.

@Override
protected Application configure() {
    // start zk
    try {
        if (_zkServer == null) {
            _zkServer = TestHelper.startZkServer(ZK_ADDR);
            Assert.assertTrue(_zkServer != null);
            ZKClientPool.reset();
        }
        if (_zkServerTestNS == null) {
            _zkServerTestNS = TestHelper.startZkServer(_zkAddrTestNS);
            Assert.assertTrue(_zkServerTestNS != null);
            ZKClientPool.reset();
        }
    } catch (Exception e) {
        Assert.assertTrue(false, String.format("Failed to start ZK server: %s", e.toString()));
    }
    // Configure server context
    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.packages(AbstractResource.class.getPackage().getName());
    ServerContext serverContext = new ServerContext(ZK_ADDR);
    resourceConfig.property(ContextPropertyKeys.SERVER_CONTEXT.name(), serverContext);
    resourceConfig.register(new AuditLogFilter(Arrays.<AuditLogger>asList(new MockAuditLogger())));
    return resourceConfig;
}
Also used : AuditLogger(org.apache.helix.rest.server.auditlog.AuditLogger) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) TestContainerException(org.glassfish.jersey.test.spi.TestContainerException) IOException(java.io.IOException) AuditLogFilter(org.apache.helix.rest.server.filters.AuditLogFilter)

Example 2 with AuditLogFilter

use of org.apache.helix.rest.server.filters.AuditLogFilter in project helix by apache.

the class HelixRestServer method getResourceConfig.

private ResourceConfig getResourceConfig(HelixRestNamespace namespace, ServletType type) {
    ResourceConfig cfg = new ResourceConfig();
    cfg.packages(type.getServletPackageArray());
    cfg.property(ContextPropertyKeys.SERVER_CONTEXT.name(), new ServerContext(namespace.getMetadataStoreAddress()));
    if (type == ServletType.DEFAULT_SERVLET) {
        cfg.property(ContextPropertyKeys.ALL_NAMESPACES.name(), _helixNamespaces);
    } else {
        cfg.property(ContextPropertyKeys.METADATA.name(), namespace);
    }
    cfg.register(new CORSFilter());
    cfg.register(new AuditLogFilter(_auditLoggers));
    return cfg;
}
Also used : ResourceConfig(org.glassfish.jersey.server.ResourceConfig) CORSFilter(org.apache.helix.rest.server.filters.CORSFilter) AuditLogFilter(org.apache.helix.rest.server.filters.AuditLogFilter)

Aggregations

AuditLogFilter (org.apache.helix.rest.server.filters.AuditLogFilter)2 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)2 IOException (java.io.IOException)1 AuditLogger (org.apache.helix.rest.server.auditlog.AuditLogger)1 CORSFilter (org.apache.helix.rest.server.filters.CORSFilter)1 TestContainerException (org.glassfish.jersey.test.spi.TestContainerException)1