From f16b1ac5678581431276c69a9ab9540bb3cdd769 Mon Sep 17 00:00:00 2001 From: Ahmed Owian Date: Thu, 16 Oct 2014 21:50:10 +0000 Subject: [PATCH] ACE-3121: Workflow Admin Console: Cannot change priority for activiti - Removed priority value validation. Just checked the type. - TODO: Determine if DelegateTask also needs similar handling git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@88560 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../ActivitiPriorityPropertyHandler.java | 18 +++---- .../ActivitiPriorityPropertyHandlerTest.java | 47 ++++++++----------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java index 5336e246b7..0a9b43fca3 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java +++ b/source/java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2014 Alfresco Software Limited. * * This file is part of Alfresco * @@ -41,8 +41,8 @@ public class ActivitiPriorityPropertyHandler extends ActivitiTaskPropertyHandler @Override protected Object handleTaskProperty(Task task, TypeDefinition type, QName key, Serializable value) { - int priority = -1; - // ACE-3121: According to bpmModel.xml, priority should be an int with allowed values {1,2,3} + int priority; + // ACE-3121: Workflow Admin Console: Cannot change priority for activiti // It could be a String that converts to an int, like when coming from WorkflowInterpreter.java if (value instanceof String) { @@ -52,7 +52,7 @@ public class ActivitiPriorityPropertyHandler extends ActivitiTaskPropertyHandler } catch (NumberFormatException e) { - return DO_NOT_ADD; + throw getInvalidPropertyValueException(key, value); } } else @@ -61,14 +61,8 @@ public class ActivitiPriorityPropertyHandler extends ActivitiTaskPropertyHandler priority = (Integer) value; } - if (1 <= priority && priority <= 3) - { - task.setPriority(priority); - } - else - { - throw getInvalidPropertyValueException(key, value); - } + // Priority value validation not performed to allow for future model changes + task.setPriority(priority); return DO_NOT_ADD; } diff --git a/source/test-java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandlerTest.java b/source/test-java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandlerTest.java index d2a2db0d14..2b6f979965 100644 --- a/source/test-java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandlerTest.java +++ b/source/test-java/org/alfresco/repo/workflow/activiti/properties/ActivitiPriorityPropertyHandlerTest.java @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ package org.alfresco.repo.workflow.activiti.properties; import static org.junit.Assert.*; @@ -54,33 +72,9 @@ public class ActivitiPriorityPropertyHandlerTest } @Test(expected = org.alfresco.service.cmr.workflow.WorkflowException.class) - public void handleTaskPropertyDoesNotSetInvalidIntPriority0() + public void handleTaskPropertyDoesNotSetInvalidStringPriority() { - int priority = 0; - handler.handleTaskProperty(task, type, key, priority); - fail("The method should throw an exception and not reach here."); - } - - @Test(expected = org.alfresco.service.cmr.workflow.WorkflowException.class) - public void handleTaskPropertyDoesNotSetInvalidIntPriority4() - { - int priority = 4; - handler.handleTaskProperty(task, type, key, priority); - fail("The method should throw an exception and not reach here."); - } - - @Test(expected = org.alfresco.service.cmr.workflow.WorkflowException.class) - public void handleTaskPropertyDoesNotSetInvalidStringPriority0() - { - String priority = "0"; - handler.handleTaskProperty(task, type, key, priority); - fail("The method should throw an exception and not reach here."); - } - - @Test(expected = org.alfresco.service.cmr.workflow.WorkflowException.class) - public void handleTaskPropertyDoesNotSetInvalidStringPriority4() - { - String priority = "4"; + String priority = "Not an integer"; handler.handleTaskProperty(task, type, key, priority); fail("The method should throw an exception and not reach here."); } @@ -92,5 +86,4 @@ public class ActivitiPriorityPropertyHandlerTest handler.handleTaskProperty(task, type, key, priority); fail("The method should throw an exception and not reach here."); } - }