Search in sources :

Example 11 with DELETE

use of javax.ws.rs.DELETE in project neo4j-clean-remote-db-addon by jexp.

the class DeleteDatabaseResource method cleanDb.

@DELETE
@Path("/{key}")
@Produces(MediaType.APPLICATION_JSON)
public Response cleanDb(@PathParam("key") String deleteKey) {
    GraphDatabaseAPI graph = database.getGraph();
    String configKey = config.getString(CONFIG_DELETE_AUTH_KEY);
    if (deleteKey == null || configKey == null || !deleteKey.equals(configKey)) {
        return Response.status(Status.UNAUTHORIZED).build();
    }
    try {
        Map<String, Object> result = new Neo4jDatabaseCleaner(graph).cleanDb(MAX_NODES_TO_DELETE);
        if ((Long) result.get("nodes") >= MAX_NODES_TO_DELETE) {
            result.putAll(cleanDbDirectory(database));
        }
        log.warning("Deleted Database: " + result);
        return Response.status(Status.OK).entity(JsonHelper.createJsonFrom(result)).build();
    } catch (Throwable e) {
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(JsonHelper.createJsonFrom(e.getMessage())).build();
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.GraphDatabaseAPI) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 12 with DELETE

use of javax.ws.rs.DELETE in project pinot by linkedin.

the class OverrideConfigResource method deleteOverrideConfig.

@DELETE
@Path("/override-config/delete")
public Response deleteOverrideConfig(@NotNull @QueryParam("id") long id) {
    OverrideConfigManager overrideConfigDAO = DAO_REGISTRY.getOverrideConfigDAO();
    overrideConfigDAO.deleteById(id);
    return Response.ok().build();
}
Also used : OverrideConfigManager(com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 13 with DELETE

use of javax.ws.rs.DELETE in project killbill by killbill.

the class AdminResource method invalidatesCacheByTenant.

@DELETE
@Path("/" + CACHE + "/" + TENANTS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Invalidates Caches per tenant level")
@ApiResponses(value = {})
public Response invalidatesCacheByTenant(@QueryParam("tenantApiKey") final String tenantApiKey, @javax.ws.rs.core.Context final HttpServletRequest request) throws TenantApiException {
    // creating Tenant Context from Request
    TenantContext tenantContext = context.createContext(request);
    Tenant currentTenant = tenantApi.getTenantById(tenantContext.getTenantId());
    // getting Tenant Record Id
    Long tenantRecordId = recordIdApi.getRecordId(tenantContext.getTenantId(), ObjectType.TENANT, tenantContext);
    // clear tenant-record-id cache by tenantId
    final Ehcache tenantRecordIdCache = cacheManager.getEhcache(CacheType.TENANT_RECORD_ID.getCacheName());
    tenantRecordIdCache.remove(currentTenant.getId().toString());
    // clear tenant-payment-state-machine-config cache by tenantRecordId
    final Ehcache tenantPaymentStateMachineConfigCache = cacheManager.getEhcache(CacheType.TENANT_PAYMENT_STATE_MACHINE_CONFIG.getCacheName());
    removeCacheByKey(tenantPaymentStateMachineConfigCache, tenantRecordId.toString());
    // clear tenant cache by tenantApiKey
    final Ehcache tenantCache = cacheManager.getEhcache(CacheType.TENANT.getCacheName());
    tenantCache.remove(currentTenant.getApiKey());
    // clear tenant-kv cache by tenantRecordId
    final Ehcache tenantKvCache = cacheManager.getEhcache(CacheType.TENANT_KV.getCacheName());
    removeCacheByKey(tenantKvCache, tenantRecordId.toString());
    // clear tenant-config cache by tenantRecordId
    final Ehcache tenantConfigCache = cacheManager.getEhcache(CacheType.TENANT_CONFIG.getCacheName());
    tenantConfigCache.remove(tenantRecordId);
    // clear tenant-overdue-config cache by tenantRecordId
    final Ehcache tenantOverdueConfigCache = cacheManager.getEhcache(CacheType.TENANT_OVERDUE_CONFIG.getCacheName());
    tenantOverdueConfigCache.remove(tenantRecordId);
    // clear tenant-catalog cache by tenantRecordId
    final Ehcache tenantCatalogCache = cacheManager.getEhcache(CacheType.TENANT_CATALOG.getCacheName());
    tenantCatalogCache.remove(tenantRecordId);
    return Response.status(Status.OK).build();
}
Also used : Tenant(org.killbill.billing.tenant.api.Tenant) TenantContext(org.killbill.billing.util.callcontext.TenantContext) Ehcache(net.sf.ehcache.Ehcache) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with DELETE

use of javax.ws.rs.DELETE in project killbill by killbill.

the class AdminResource method invalidatesCache.

@DELETE
@Path("/" + CACHE)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Invalidates the given Cache if specified, otherwise invalidates all caches")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Cache name does not exist or is not alive") })
public Response invalidatesCache(@QueryParam("cacheName") final String cacheName, @javax.ws.rs.core.Context final HttpServletRequest request) {
    if (null != cacheName && !cacheName.isEmpty()) {
        final Ehcache cache = cacheManager.getEhcache(cacheName);
        // check if cache is null
        if (cache == null) {
            log.warn("Cache for specified cacheName='{}' does not exist or is not alive", cacheName);
            return Response.status(Status.BAD_REQUEST).build();
        }
        // Clear given cache
        cache.removeAll();
    } else {
        // if not given a specific cacheName, clear all
        cacheManager.clearAll();
    }
    return Response.status(Status.OK).build();
}
Also used : Ehcache(net.sf.ehcache.Ehcache) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 15 with DELETE

use of javax.ws.rs.DELETE in project killbill by killbill.

the class PaymentResource method cancelScheduledPaymentTransactionById.

@TimedResource(name = "cancelScheduledPaymentTransaction")
@DELETE
@Path("/{paymentTransactionId:" + UUID_PATTERN + "}/" + CANCEL_SCHEDULED_PAYMENT_TRANSACTION)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Cancels a scheduled payment attempt retry")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid paymentTransactionId supplied") })
public Response cancelScheduledPaymentTransactionById(@PathParam("paymentTransactionId") final String paymentTransactionId, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final UriInfo uriInfo, @javax.ws.rs.core.Context final HttpServletRequest request) throws PaymentApiException, AccountApiException {
    final CallContext callContext = context.createContext(createdBy, reason, comment, request);
    paymentApi.cancelScheduledPaymentTransaction(UUID.fromString(paymentTransactionId), callContext);
    return Response.status(Status.OK).build();
}
Also used : CallContext(org.killbill.billing.util.callcontext.CallContext) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) TimedResource(org.killbill.commons.metrics.TimedResource) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

DELETE (javax.ws.rs.DELETE)202 Path (javax.ws.rs.Path)186 ApiOperation (io.swagger.annotations.ApiOperation)59 ApiResponses (io.swagger.annotations.ApiResponses)48 Produces (javax.ws.rs.Produces)43 Timed (com.codahale.metrics.annotation.Timed)31 AuditEvent (org.graylog2.audit.jersey.AuditEvent)25 IOException (java.io.IOException)20 Response (javax.ws.rs.core.Response)20 WebApplicationException (javax.ws.rs.WebApplicationException)17 HashMap (java.util.HashMap)15 NotFoundException (javax.ws.rs.NotFoundException)15 RestException (com.yahoo.pulsar.broker.web.RestException)12 Consumes (javax.ws.rs.Consumes)12 KeeperException (org.apache.zookeeper.KeeperException)12 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)11 ApiResponse (io.swagger.annotations.ApiResponse)11 NamespaceId (co.cask.cdap.proto.id.NamespaceId)9 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)9 Event (keywhiz.log.Event)9