Commit 1fa87965 authored by Matija Obreza's avatar Matija Obreza
Browse files

Require ADMINISTRATOR role to clear caches

parent bf8ce944
......@@ -16,11 +16,11 @@
package org.genesys2.server.servlet.controller.rest;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.monitor.LocalMapStats;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.genesys2.server.service.MappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
......@@ -32,11 +32,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.monitor.LocalMapStats;
@Controller("restCacheController")
@PreAuthorize("isAuthenticated()")
......@@ -64,7 +64,8 @@ public class CacheController extends RestController {
IMap imap = (IMap) o;
cacheMaps.add(new CacheStats(imap));
} else {
// cacheOther.add(o); //todo, error when transforming to json
// cacheOther.add(o); //todo, error when transforming to
// json
LOG.info(o.getClass() + " " + o);
}
}
......@@ -76,7 +77,8 @@ public class CacheController extends RestController {
return response;
}
@RequestMapping( value = "/clearTilesCache", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/clearTilesCache", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
@PreAuthorize("hasRole('ADMINISTRATOR')")
public @ResponseBody Object clearTilesCache() {
final Cache tileServerCache = cacheManager.getCache("tileserver");
System.err.println("tileServerCache=" + tileServerCache.getNativeCache());
......@@ -99,6 +101,7 @@ public class CacheController extends RestController {
}
@RequestMapping(method = RequestMethod.POST, value = "/clearCaches")
@PreAuthorize("hasRole('ADMINISTRATOR')")
public @ResponseBody Object clearCaches() {
for (String cacheName : cacheManager.getCacheNames()) {
final Cache cache = cacheManager.getCache(cacheName);
......@@ -108,7 +111,6 @@ public class CacheController extends RestController {
return JSON_OK;
}
public static final class CacheStats {
private String serviceName;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment