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();
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations