Commit 31b4bb06 authored by Peter Harrison's avatar Peter Harrison

Merge branch 'development'

parents 1a9acc30 1a624744
......@@ -4,7 +4,7 @@
<groupId>nz.net.gravity</groupId>
<artifactId>gravity</artifactId>
<packaging>war</packaging>
<version>3.0.2</version>
<version>3.0.3-SNAPSHOT</version>
<name>Gravity Workflow Automation</name>
<properties>
......
......@@ -23,6 +23,6 @@ package nz.net.orcon.kanban.automation;
public interface CacheInvalidationInterface {
public void invalidate(String type, String id);
public void invalidate(String type, String... ids);
}
......@@ -59,14 +59,14 @@ public class CacheManager implements MessageListener, CacheInvalidationInterface
if( logger.isDebugEnabled()){
logger.debug( "Cache Invalidation Instruction Received: "
+ instruction.getCacheType() + " " + instruction.getId());
+ instruction.getCacheType() + " " + instruction.getIds().toString());
}
Cache<?> cache = cacheList.get(instruction.getCacheType().toString());
cache.invalidate(instruction.getId());
cache.invalidate(instruction.getIds());
if(instruction.getCacheType().equals("BOARD")){
timerManager.loadTimersForBoard(instruction.getId());
timerManager.loadTimersForBoard(instruction.getIds()[0]);
}
} catch (Exception e) {
logger.error("JMS Exception on Cache Invalidation Reception ",e);
......@@ -75,12 +75,12 @@ public class CacheManager implements MessageListener, CacheInvalidationInterface
}
@Override
public void invalidate( String type, String id){
public void invalidate( String type, String... ids){
CacheInvalidationInstruction instruction =
new CacheInvalidationInstruction(type,id);
new CacheInvalidationInstruction(type, ids);
this.jmsTemplate.convertAndSend(instruction);
if( logger.isDebugEnabled()){
logger.debug("Invalidation Message Sent to Queue: " + type + " - " + id);
logger.debug("Invalidation Message Sent to Queue: " + type);
}
}
......
......@@ -299,7 +299,6 @@ public class BoardController {
ocm.save();
ocm.logout();
this.cacheInvalidationManager.invalidate(BOARD, boardId);
}
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'READ,WRITE,ADMIN')")
......
......@@ -89,8 +89,18 @@ abstract public class CacheImpl<T> implements Cache<T> {
if(prefixs.length>0){
cacheId = this.getCacheId(prefixs);
}
if(logger.isDebugEnabled()){
logger.debug("Getting List from Cache: " + cacheId);
}
Map<String, String> list = this.cacheList.get(cacheId);
if(list==null){
if(logger.isDebugEnabled()){
logger.debug("Cache Empty, Getting List from Data Store: " + cacheId);
}
if(prefixs.length>0){
list = this.getListFromStore(prefixs);
} else {
......
......@@ -94,6 +94,7 @@ public class ListController {
list.setPath(String.format(URI.LIST_URI, boardId, newId.toString()));
ocm.insert(list);
ocm.save();
this.cacheInvalidationManager.invalidate(LIST, boardId,newId);
} finally {
ocm.logout();
}
......@@ -223,7 +224,7 @@ public class ListController {
node.remove();
ocm.save();
this.cacheInvalidationManager.invalidate(LIST, listCache.getCacheId(boardId,listId));
this.cacheInvalidationManager.invalidate(LIST, boardId, listId);
} finally {
ocm.logout();
}
......
......@@ -110,6 +110,7 @@ public class ResourceController {
addNode.setProperty("resource",value);
addNode.setProperty("name",resourceId);
ocm.getSession().save();
this.cacheInvalidationManager.invalidate(RESOURCE, boardId,resourceId);
} finally {
ocm.logout();
}
......@@ -132,7 +133,7 @@ public class ResourceController {
}
node.remove();
ocm.save();
this.cacheInvalidationManager.invalidate(RESOURCE, resourceCache.getCacheId(boardId,resourceId));
this.cacheInvalidationManager.invalidate(RESOURCE, boardId,resourceId);
} finally {
ocm.logout();
}
......
......@@ -97,6 +97,7 @@ public class RuleController {
rule.setPath(String.format(URI.RULE_URI, boardId, IdentifierTools.getIdFromNamedModelClass(rule)));
ocm.insert(rule);
ocm.save();
this.cacheInvalidationManager.invalidate(RULE, boardId, rule.getId());
} finally {
ocm.logout();
}
......@@ -114,15 +115,7 @@ public class RuleController {
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
@RequestMapping(value = "", method=RequestMethod.GET)
public @ResponseBody Map<String,String> listRules(@PathVariable String boardId) throws Exception {
Map<String, String> ruleList = ruleCache.list(boardId,"");
//ruleCache.list(boardId);
//Session session = ocmFactory.getOcm().getSession();
//Map<String,String> result = listTools.list(String.format(URI.RULE_URI, boardId,""), "name", session);
//session.logout();
return ruleList;
return ruleCache.list(boardId,"");
}
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
......@@ -144,7 +137,7 @@ public class RuleController {
node.remove();
ocm.save();
this.cacheInvalidationManager.invalidate(RULE, ruleCache.getCacheId(boardId,ruleId));
this.cacheInvalidationManager.invalidate(RULE, boardId, ruleId);
} finally {
ocm.logout();
}
......
......@@ -81,7 +81,7 @@ public class TemplateController {
node.remove();
ocm.save();
this.cacheInvalidationManager.invalidate(TEMPLATE, templateCache.getCacheId(boardId,templateId));
this.cacheInvalidationManager.invalidate(TEMPLATE, boardId,templateId);
} finally {
ocm.logout();
}
......@@ -107,7 +107,7 @@ public class TemplateController {
ocm.insert(template);
ocm.save();
this.cacheInvalidationManager.invalidate(TEMPLATE, templateId);
this.cacheInvalidationManager.invalidate(TEMPLATE, boardId, templateId);
} finally {
ocm.logout();
}
......@@ -127,7 +127,7 @@ public class TemplateController {
try {
ocm.update(template);
ocm.save();
this.cacheInvalidationManager.invalidate(TEMPLATE, templateId);
this.cacheInvalidationManager.invalidate(TEMPLATE, boardId,templateId);
} finally {
ocm.logout();
}
......
......@@ -29,14 +29,14 @@ public class CacheInvalidationInstruction implements Serializable{
private String cacheType;
private String id;
private String[] ids;
public CacheInvalidationInstruction(){
}
public CacheInvalidationInstruction( String cacheType, String id){
public CacheInvalidationInstruction( String cacheType, String... ids){
this.cacheType = cacheType;
this.id = id;
this.ids = ids;
}
public void setCacheType(String cacheType) {
......@@ -47,11 +47,11 @@ public class CacheInvalidationInstruction implements Serializable{
return cacheType;
}
public void setId(String id) {
this.id = id;
public void setIds(String[] ids) {
this.ids = ids;
}
public String getId() {
return id;
public String[] getIds() {
return ids;
}
}
......@@ -78,6 +78,7 @@ public class GravityPermissionEvaluator implements PermissionEvaluator {
List<String> permissions = new ArrayList<String>(Arrays.asList(permission.toString().split(",")));
return isAuthorised(authentication, roles, permissions);
} catch (Exception e){
LOG.warn("Exception running auth: " + e.getMessage());
return false;
}
}
......
......@@ -155,6 +155,10 @@ public class SecurityToolImpl implements SecurityTool {
roles.put("administrators", "ADMIN");
}
if( roles.get("system")==null){
roles.put("system", "WRITE");
}
String username = getCurrentUser();
if( roles.get(username)==null){
roles.put(username, "ADMIN");
......
......@@ -24,7 +24,7 @@ package nz.net.orcon.kanban.automation;
public class MockCacheManager implements CacheInvalidationInterface {
@Override
public void invalidate(String type, String id) {
public void invalidate(String type, String[] ids) {
// Mock Only
}
}
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