Skip to content

Commit 351efda

Browse files
committed
Fix the issue to clear cache via REST
1 parent 47b8d34 commit 351efda

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

core/src/main/java/org/commonjava/indy/core/ctl/IspnCacheController.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.commonjava.indy.IndyWorkflowException;
1919
import org.commonjava.indy.model.core.io.IndyObjectMapper;
20+
import org.commonjava.indy.subsys.infinispan.BasicCacheHandle;
2021
import org.commonjava.indy.subsys.infinispan.CacheProducer;
2122
import org.infinispan.Cache;
2223
import org.infinispan.manager.EmbeddedCacheManager;
@@ -46,14 +47,11 @@ public class IspnCacheController
4647
@Inject
4748
private IndyObjectMapper mapper;
4849

49-
private EmbeddedCacheManager cacheManager;
50-
5150
private Map<String, String> string2keyMapper;
5251

5352
@PostConstruct
5453
private void setUp()
5554
{
56-
cacheManager = cacheProducer.getCacheManager();
5755
string2keyMapper = new HashMap<>();
5856
string2keyMapper.put( "content-index", "org.commonjava.indy.content.index.ISPFieldStringKey2StringMapper" );
5957
string2keyMapper.put( "default", "org.commonjava.indy.pkg.maven.content.StoreKey2StringMapper" );
@@ -66,7 +64,7 @@ public void clean( String name ) throws IndyWorkflowException
6664
throw new IndyWorkflowException( "Can not clean cache, name: " + name );
6765
}
6866

69-
Cache<Object, Object> cache = cacheManager.getCache( name );
67+
BasicCacheHandle cache = cacheProducer.getBasicCache( name );
7068
if ( cache == null )
7169
{
7270
throw new IndyWorkflowException( "Cache not found, name: " + name );
@@ -77,7 +75,7 @@ public void clean( String name ) throws IndyWorkflowException
7775
// only work for some caches for debugging
7876
public String export( String cacheName, String key ) throws Exception
7977
{
80-
Cache<Object, Object> cache = cacheManager.getCache( cacheName );
78+
BasicCacheHandle cache = cacheProducer.getBasicCache( cacheName );
8179
if ( cache == null )
8280
{
8381
throw new IndyWorkflowException( "Cache not found, name: " + cacheName );
@@ -99,7 +97,7 @@ public String export( String cacheName, String key ) throws Exception
9997
}
10098
else
10199
{
102-
return mapper.writeValueAsString( cache.entrySet() );
100+
return mapper.writeValueAsString( cache.getCache().entrySet() );
103101
}
104102
}
105103

0 commit comments

Comments
 (0)