Commit aa028fa8 authored by Peter Harrison's avatar Peter Harrison

[#52] Resolving issue with cached lists not updating.

Also enabled deleting boards if you are admin for the board.
parent 6593c98a
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -57,7 +58,7 @@ public class CacheManager implements MessageListener, CacheInvalidationInterface
CacheInvalidationInstruction instruction = (CacheInvalidationInstruction) objectMessage.getObject();
if( logger.isDebugEnabled()){
logger.debug( "Cache Invalidation Instruction: "
logger.debug( "Cache Invalidation Instruction Received: "
+ instruction.getCacheType() + " " + instruction.getId());
}
......@@ -78,6 +79,9 @@ public class CacheManager implements MessageListener, CacheInvalidationInterface
CacheInvalidationInstruction instruction =
new CacheInvalidationInstruction(type,id);
this.jmsTemplate.convertAndSend(instruction);
if( logger.isDebugEnabled()){
logger.debug("Invalidation Message Sent to Queue: " + type + " - " + id);
}
}
public void setTimerManager(TimerManager timerManager) {
......
......@@ -47,6 +47,7 @@ import nz.net.orcon.kanban.tools.IdentifierTools;
import nz.net.orcon.kanban.tools.ListTools;
import nz.net.orcon.kanban.tools.OcmMapperFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
import org.apache.jackrabbit.ocm.query.Query;
import org.apache.jackrabbit.ocm.query.QueryManager;
......@@ -62,8 +63,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.amazonaws.util.StringUtils;
/**
*
*/
......@@ -284,15 +283,12 @@ public class BoardController {
@RequestMapping(value = "/{boardId}", method=RequestMethod.DELETE)
public @ResponseBody void deleteBoard(@PathVariable String boardId) throws Exception {
throw new Exception("Method Unavailable!");
/*
if( StringUtils.isBlank(boardId)){
if( StringUtils.isEmpty(boardId)){
return;
}
ObjectContentManager ocm = ocmFactory.getOcm();
Node node = ocm.getSession().getNode(String.format(boardUri, boardId));
Node node = ocm.getSession().getNode(String.format(URI.BOARD_URI, boardId));
if(node==null){
ocm.logout();
......@@ -302,8 +298,7 @@ public class BoardController {
node.remove();
ocm.save();
ocm.logout();
this.cacheInvalidationManager.invalidate(CacheType.BOARD, boardId);
*/
this.cacheInvalidationManager.invalidate(BOARD, boardId);
}
......@@ -409,11 +404,11 @@ public class BoardController {
detailFilter = "(jcr:contains(@detail,'${detail}'))".replaceAll("\\$\\{detail\\}", detail);
}
if( !StringUtils.isNullOrEmpty(categoryFilter) && !StringUtils.isNullOrEmpty(detailFilter)){
if( !StringUtils.isEmpty(categoryFilter) && !StringUtils.isEmpty(detailFilter)){
qmFilter.addJCRExpression( categoryFilter + " or " + detailFilter);
} else if ( !StringUtils.isNullOrEmpty(categoryFilter) && StringUtils.isNullOrEmpty(detailFilter)) {
} else if ( !StringUtils.isEmpty(categoryFilter) && StringUtils.isEmpty(detailFilter)) {
qmFilter.addJCRExpression( categoryFilter );
} else if (StringUtils.isNullOrEmpty(categoryFilter) && !StringUtils.isNullOrEmpty(detailFilter)) {
} else if (StringUtils.isEmpty(categoryFilter) && !StringUtils.isEmpty(detailFilter)) {
qmFilter.addJCRExpression( detailFilter );
}
......@@ -468,8 +463,8 @@ public class BoardController {
detailFilter = "(jcr:contains(@detail,'${detail}'))".replaceAll("\\$\\{detail\\}", detail);
}
boolean categoryPresent = !StringUtils.isNullOrEmpty(categoryFilter);
boolean detailPresent = !StringUtils.isNullOrEmpty(detailFilter);
boolean categoryPresent = !StringUtils.isEmpty(categoryFilter);
boolean detailPresent = !StringUtils.isEmpty(detailFilter);
if(categoryPresent && detailPresent){
qmFilter.addJCRExpression( categoryFilter + " or " + detailFilter);
......
......@@ -26,9 +26,15 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
abstract public class CacheImpl<T> implements Cache<T> {
private static final Logger logger = LoggerFactory.getLogger(CacheImpl.class);
private static String DEFAULT_LIST_NAME = "default";
private Map<String, T> cacheMap = new ConcurrentHashMap<String,T>();
......@@ -44,7 +50,18 @@ abstract public class CacheImpl<T> implements Cache<T> {
for( int a=0; a<itemIds.length-1; a++){
listId[a] = itemIds[a];
}
this.cacheList.remove(getCacheId(listId));
String cacheListId = getCacheId(listId);
this.cacheList.remove(cacheListId);
if(logger.isDebugEnabled()){
logger.debug("Clearing List: " + cacheListId);
}
} else if(itemIds.length==1){
this.cacheList.remove(DEFAULT_LIST_NAME);
if(logger.isDebugEnabled()){
logger.debug("Clearing Root List: " + itemIds[0]);
}
}
}
......@@ -68,7 +85,7 @@ abstract public class CacheImpl<T> implements Cache<T> {
}
public Map<String,String> list(String... prefixs) throws Exception{
String cacheId = "default";
String cacheId = DEFAULT_LIST_NAME;
if(prefixs.length>0){
cacheId = this.getCacheId(prefixs);
}
......@@ -83,20 +100,6 @@ abstract public class CacheImpl<T> implements Cache<T> {
}
return new HashMap<String,String>(this.cacheList.get(cacheId));
/*
if( this.cacheList == null){
if( prefixs.length>0){
cacheId = this.getCacheId(prefixs);
Map<String,String> list = this.getListFromStore(prefixs);
this.cacheList.put(cacheId, list);
} else {
Map<String,String> list = this.getListFromStore("");
this.cacheList.put(cacheId, list);
}
}
return new HashMap<String,String>(this.cacheList.get(cacheId));
*/
}
@Override
......
......@@ -95,7 +95,7 @@ public class TeamController {
return team;
}
@PreAuthorize("hasPermission(#teamId, 'TEAM', 'READ,WRITE,ADMIN')")
//@PreAuthorize("hasPermission(#teamId, 'TEAM', 'READ,WRITE,ADMIN')")
@RequestMapping(value = "/{teamId}", method=RequestMethod.GET)
public @ResponseBody Team getTeam(@PathVariable String teamId) throws Exception {
return teamCache.getItem(teamId);
......
......@@ -13,8 +13,8 @@
</appender>
<!-- Application Loggers -->
<logger name="nz.net.orcon.gravity">
<level value="info" />
<logger name="nz.net.orcon.kanban">
<level value="debug" />
</logger>
<!-- 3rdparty Loggers -->
......
Markdown is supported
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