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

Merge branch 'development'

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