Commit 11d3c04e authored by Peter Harrison's avatar Peter Harrison

Resolving issues found in FindBugs.

Added project metadata to pom.
parent 6b4709c4
......@@ -11,12 +11,47 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>6.1.4</jetty.version>
<spring.version>3.1.1.RELEASE</spring.version>
<slf4j.version>1.5.10</slf4j.version>
<slf4j.version>1.7.21</slf4j.version>
<java.version>1.6</java.version>
<junit.version>4.8.2</junit.version>
<jackson.version>1.9.10</jackson.version>
</properties>
<licenses>
<license>
<name>GPL, Version 3.0</name>
<url>http://www.gnu.org/licenses/gpl-3.0.en.html</url>
<distribution>repo</distribution>
<comments></comments>
</license>
</licenses>
<organization>
<name>Devcentre Limited</name>
<url>http://devcentre.org</url>
</organization>
<developers>
<developer>
<id>cheetah100</id>
<name>Peter Harrison</name>
<email>cheetah100@gmail.com</email>
<organization>Devcentre Limited</organization>
<organizationUrl>http://devcentre.org</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>New Zealand/Auckland</timezone>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/cheetah100/gravity.git</connection>
<tag>HEAD</tag>
<url>https://github.com/cheetah100/gravity</url>
</scm>
<dependencies>
......@@ -160,6 +195,10 @@
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
......@@ -263,10 +302,9 @@
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
<scope>provided</scope>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
......
......@@ -833,7 +833,7 @@ public class AutomationEngine {
Collections.sort(list, new Comparator<Action>() {
@Override
public int compare(Action action1, Action action2) {
return action1.compareTo(action2);
return action1.getOrder() - action2.getOrder();
}
});
}
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright Peter Harrison 2016
*
* This file is part of Gravity Workflow Automation.
*
......@@ -37,7 +38,7 @@ public class ExtractPlugin implements Plugin {
private static final Logger logger = LoggerFactory.getLogger(ExtractPlugin.class);
@Override
public Map<String,Object> process( Action action, Map<String,Object> context ){
public Map<String,Object> process( Action action, Map<String,Object> context ) throws Exception{
Object target = context.get(action.getResource());
......@@ -60,21 +61,16 @@ public class ExtractPlugin implements Plugin {
}
}
}
try {
// Call the Method.
// If there is an exception we stop processing.
Object response = method.invoke(target,parameterValueArray);
if (response != null) {
context.put(action.getResponse(), response);
logger.info("Recevied response is " + response);
}
} catch (Exception e) {
logger.error("Exception Processing :" + action.getName(), e);
// TO DO:
// add comment and change card color to red..
if(method==null){
throw new Exception("Method Not Found: " + target);
}
Object response = method.invoke(target,parameterValueArray);
if (response != null) {
context.put(action.getResponse(), response);
logger.info("Recevied response is " + response);
}
return context;
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -81,12 +82,11 @@ public class ScriptPlugin implements Plugin{
engine.eval(script);
Bindings resultBindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
for( String key : resultBindings.keySet() ){
if( key.equals("context") || key.equals("print") || key.equals("println")){
for( Entry<String, Object> entry : resultBindings.entrySet() ){
if( entry.getKey().equals("context") || entry.getKey().equals("print") || entry.getKey().equals("println")){
continue;
}
Object value = resultBindings.get(key);
context.put(key, value);
context.put(entry.getKey(), entry.getValue());
}
return context;
}
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -22,6 +23,7 @@
package nz.net.orcon.kanban.automation.plugin;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -48,11 +50,10 @@ public class TemplatePlugin implements Plugin {
StringBuilder builder = new StringBuilder(resource);
for( String field : context.keySet()){
Object value = context.get(field);
if( value!=null){
String valueString = value.toString();
replaceAll( field, valueString, builder);
for( Entry<String,Object> entry : context.entrySet()){
if( entry.getValue()!=null){
String valueString = entry.getValue().toString();
replaceAll( entry.getKey(), valueString, builder);
}
}
......
......@@ -467,12 +467,15 @@ public class BoardController {
if(detail!=null){
detailFilter = "(jcr:contains(@detail,'${detail}'))".replaceAll("\\$\\{detail\\}", detail);
}
boolean categoryPresent = !StringUtils.isNullOrEmpty(categoryFilter);
boolean detailPresent = !StringUtils.isNullOrEmpty(detailFilter);
if(categoryFilter!="" && detailFilter!=""){
if(categoryPresent && detailPresent){
qmFilter.addJCRExpression( categoryFilter + " or " + detailFilter);
} else if (categoryFilter!="" && detailFilter=="") {
} else if (categoryPresent && !detailPresent) {
qmFilter.addJCRExpression( categoryFilter );
} else if (categoryFilter=="" && detailFilter!="") {
} else if (!categoryPresent && detailPresent) {
qmFilter.addJCRExpression( detailFilter );
}
......
......@@ -950,11 +950,6 @@ public class CardController {
Rule rule = ruleCache.getItem(boardId,taskId);
if(rule==null){
logger.warn("Rule Not Found: " + boardId + "." + taskId);
throw new ResourceNotFoundException();
}
CardTask cardTask = new CardTask();
cardTask.setTaskid(rule.getId());
cardTask.setDetail(rule.getName());
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -161,7 +162,7 @@ public class FormController {
try{
listTools.ensurePresence(String.format( URI.FORM_URI, formId), "roles", ocm.getSession());
Node node = ocm.getSession().getNode(String.format(URI.FORM_ROLES_URI, formId, ""));
Node node = ocm.getSession().getNode(String.format(URI.FORM_ROLES_URI, formId));
if( node==null){
throw new ResourceNotFoundException();
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -184,11 +185,14 @@ public class TemplateCache extends CacheImpl<Template>{
protected Template getFromStore(String... itemIds) throws Exception {
ObjectContentManager ocm = ocmFactory.getOcm();
String pre = Integer.toString(itemIds.length) + " - ";
StringBuffer buffer = new StringBuffer();
buffer.append(itemIds.length);
buffer.append(" - ");
for( int x=0; x < itemIds.length; x++){
pre = pre + itemIds[x] + ", ";
buffer.append(itemIds[x]);
buffer.append(", ");
}
logger.info("Prefixs: " + pre);
logger.info("Prefixs: " + buffer.toString());
String path = String.format(URI.TEMPLATE_URI,(Object[])itemIds);
logger.info( "Getting Template At: " + path);
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -31,7 +32,6 @@ import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import nz.net.orcon.kanban.model.Board;
import nz.net.orcon.kanban.model.Card;
import nz.net.orcon.kanban.tools.CardConverter;
import nz.net.orcon.kanban.tools.CardTools;
......@@ -70,23 +70,17 @@ public class XmlFileController {
XStreamMarshaller xstreamMarshaller;
@RequestMapping(value = "/{boardId}", method=RequestMethod.GET)
public @ResponseBody void getXmlFile(@PathVariable String boardId,@RequestParam(required=false) boolean includeArchive, HttpServletResponse response) throws Exception{
Board board = boardsCache.getItem(boardId);
public @ResponseBody void getXmlFile(@PathVariable String boardId,@RequestParam(required=false) boolean includeArchive, HttpServletResponse response) throws Exception{
ObjectContentManager ocm = null;
Collection<Card> cardList = null;
try{
ocm = ocmFactory.getOcm();
cardList = cardTools.getCardList(boardId,includeArchive, ocm);
cardList = cardTools.getCardList(boardId,includeArchive,ocm);
} finally {
ocm.logout();
}
if(cardList.size() == 0){
logger.warn("No such board: "+ boardId + " exists");
response.setStatus(404);
return;
}
generateXml(response, boardId, cardList);
}
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -32,7 +33,7 @@ import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@Node
public class Action extends AbstractNamedModelClass implements Comparable<Action>, Serializable{
public class Action extends AbstractNamedModelClass implements Serializable{
private static final long serialVersionUID = -787744857412601170L;
......@@ -112,9 +113,4 @@ public class Action extends AbstractNamedModelClass implements Comparable<Action
return type;
}
@Override
public int compareTo(Action action) {
return this.getOrder() - action.getOrder();
}
}
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -24,6 +25,7 @@ package nz.net.orcon.kanban.model;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;
......@@ -57,12 +59,11 @@ public class TemplateGroup extends AbstractNamedModelClass implements Serializab
public void setFields(Map<String,TemplateField> newFields) {
SortedMap< Integer, TemplateField> sorted = new TreeMap< Integer, TemplateField>();
for( String key: newFields.keySet()){
TemplateField field = newFields.get(key);
if( field.getPath()==null){
field.setPath(key);
for( Entry<String,TemplateField>entry: newFields.entrySet()){
if( entry.getValue().getPath()==null){
entry.getValue().setPath(entry.getKey());
}
sorted.put(field.getIndex(), field);
sorted.put(entry.getValue().getIndex(), entry.getValue());
}
this.fields = new LinkedHashMap<String,TemplateField>();
for( Integer key: sorted.keySet()){
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -27,6 +28,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import nz.net.orcon.kanban.automation.CacheManager;
......@@ -107,12 +109,12 @@ public class GravityPermissionEvaluator implements PermissionEvaluator {
teams.add(authority.getAuthority());
}
for( String authorised : roles.keySet()){
if(filter==null || filter.contains(roles.get(authorised))){
if(username.equals(authorised)){
for( Entry<String,String> entry : roles.entrySet()){
if(filter==null || filter.contains(entry.getValue())){
if(username.equals(entry.getKey())){
return true;
}
if(teams.contains(authorised)){
if(teams.contains(entry.getKey())){
return true;
}
}
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -28,6 +29,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import nz.net.orcon.kanban.controllers.TeamCache;
......@@ -103,12 +105,12 @@ public class SecurityToolImpl implements SecurityTool {
teams.add(authority.getAuthority());
}
for( String authorised : roles.keySet()){
if(filter==null || filter.contains(( roles.get(authorised)))){
if(username.equals(authorised)){
for( Entry<String,String> entry : roles.entrySet()){
if(filter==null || filter.contains(( entry.getValue() ))){
if(username.equals(entry.getKey())){
return true;
}
if(teams.contains(authorised)){
if(teams.contains(entry.getKey())){
return true;
}
}
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -131,7 +132,7 @@ public class CardConverter implements Converter{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if("id".equalsIgnoreCase(reader.getNodeName())){
card.setId(new Long(reader.getValue()));
card.setId(Long.getLong(reader.getValue()));
}
if("template".equalsIgnoreCase(reader.getNodeName())){
card.setTemplate(reader.getValue());
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -23,11 +24,10 @@ package nz.net.orcon.kanban.tools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
......@@ -235,6 +235,8 @@ public class CardToolsImpl implements CardTools{
case PropertyType.DECIMAL:
value = property.getDecimal();
break;
default:
value = null;
}
return value;
}
......@@ -263,12 +265,10 @@ public class CardToolsImpl implements CardTools{
Set<String> keySet = phases.keySet();
for (Iterator<String> iterator = keySet.iterator(); iterator.hasNext();) {
String phaseId = (String) iterator.next();
Phase phase = phases.get(phaseId);
phaseIndexMap.put(phase.getIndex(),phaseId);
for( Entry<String,Phase> entry : phases.entrySet()){
phaseIndexMap.put(entry.getValue().getIndex(),entry.getKey());
}
// remove last phase from map which is believed to be archieve
if(!includeArchive){
phaseIndexMap.remove(phaseIndexMap.size());
......
/**
* GRAVITY WORKFLOW AUTOMATION
* (C) Copyright 2015 Orcon Limited
* (C) Copyright 2016 Peter Harrison
*
* This file is part of Gravity Workflow Automation.
*
......@@ -25,7 +26,7 @@ import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.TimeZone;
import org.codehaus.jackson.JsonGenerator;
......@@ -42,17 +43,16 @@ public class MapJsonSerializer extends JsonSerializer<Map<String, Object>> {
SerializerProvider provider) throws IOException,
JsonProcessingException {
jgen.writeStartObject();
Set<String> keySet = fields.keySet();
for (String key : keySet) {
Object objectValue = fields.get(key);
for (Entry<String, Object> entry : fields.entrySet()) {
Object objectValue = entry.getValue();
if (objectValue instanceof Date) {
Date date = (Date) objectValue;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland"));
String formattedDate = simpleDateFormat.format(date);
jgen.writeObjectField(key, formattedDate);
jgen.writeObjectField(entry.getKey().toString(), formattedDate);
} else {
jgen.writeObjectField(key, objectValue);
jgen.writeObjectField(entry.getKey().toString(), objectValue);
}
}
jgen.writeEndObject();
......
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