use of org.apache.archiva.rest.api.v2.model.CacheConfiguration in project archiva by apache.
the class DefaultSecurityConfigurationService method getCacheConfiguration.
@Override
public CacheConfiguration getCacheConfiguration() throws ArchivaRestServiceException {
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
log.debug("getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration);
return CacheConfiguration.of(redbackRuntimeConfiguration.getUsersCacheConfiguration());
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(ErrorMessage.of(REPOSITORY_ADMIN_ERROR));
}
}
use of org.apache.archiva.rest.api.v2.model.CacheConfiguration in project archiva by apache.
the class DefaultSecurityConfigurationService method updateCacheConfiguration.
@Override
public CacheConfiguration updateCacheConfiguration(CacheConfiguration cacheConfiguration) throws ArchivaRestServiceException {
if (cacheConfiguration == null) {
throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.MISSING_DATA), 400);
}
try {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
log.debug("getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration);
updateConfig(cacheConfiguration, redbackRuntimeConfiguration);
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
return getCacheConfiguration();
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(ErrorMessage.of(REPOSITORY_ADMIN_ERROR));
}
}
use of org.apache.archiva.rest.api.v2.model.CacheConfiguration in project archiva by apache.
the class NativeSecurityConfigurationServiceTest method testUpdateCacheConfiguration.
@Test
void testUpdateCacheConfiguration() {
String token = getAdminToken();
try {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("time_to_idle_seconds", 1600);
jsonMap.put("time_to_live_seconds", 12000);
jsonMap.put("max_entries_in_memory", 500);
jsonMap.put("max_entries_on_disk", 400);
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonMap).put("config/cache").then().statusCode(200).extract().response();
assertNotNull(response);
response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("config/cache").then().statusCode(200).extract().response();
assertNotNull(response);
CacheConfiguration config = response.getBody().jsonPath().getObject("", CacheConfiguration.class);
assertEquals(1600, config.getTimeToIdleSeconds());
assertEquals(12000, config.getTimeToLiveSeconds());
assertEquals(500, config.getMaxEntriesInMemory());
assertEquals(400, config.getMaxEntriesOnDisk());
} finally {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("time_to_idle_seconds", 1800);
jsonMap.put("time_to_live_seconds", 14400);
jsonMap.put("max_entries_in_memory", 1000);
jsonMap.put("max_entries_on_disk", 0);
given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonMap).put("config/cache").then().statusCode(200);
}
}
Aggregations