Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

89755: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      89709: Merged DEV to V4.2-BUG-FIX
       88701 : MNT-11809 : Activiti losses data with large Aspect or Type property values
        Configured client-side validation, added server-side validation via task and workflow filters. Added unit test.
       88897 : MNT-11809 : Activiti losses data with large Aspect or Type property values 
        Update some config and unit test. 
       89616 : MNT-11809 : Activiti losses data with large Aspect or Type property values 
        Added and updated some tests. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94637 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 10:42:34 +00:00
parent 79436c9bb4
commit 3b8bee75b0
8 changed files with 485 additions and 313 deletions

View File

@@ -0,0 +1,80 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.forms.processor.workflow;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.forms.Form;
import org.alfresco.repo.forms.FormData;
import org.alfresco.repo.forms.FormData.FieldData;
import org.alfresco.repo.forms.processor.AbstractFilter;
import org.alfresco.repo.workflow.PropertyValueSizeIsMoreMaxLengthException;
public class WorkflowFormFilter<ItemType, PersistType> extends AbstractFilter<ItemType, PersistType>
{
private static final String PROP_BPM_COMMENT = "prop_bpm_comment";
private int maxLengthBpmCommentProperty = 4000;
public void setMaxLengthBpmCommentProperty(int maxLengthBpmCommentProperty)
{
this.maxLengthBpmCommentProperty = maxLengthBpmCommentProperty;
}
@Override
public void beforeGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context)
{
// TODO Auto-generated method stub
}
@Override
public void afterGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context)
{
// TODO Auto-generated method stub
}
@Override
public void beforePersist(ItemType item, FormData data)
{
FieldData bpmComment = data.getFieldData(PROP_BPM_COMMENT);
if (bpmComment != null)
{
int value = ((String) bpmComment.getValue()).getBytes().length;
if (maxLengthBpmCommentProperty < value)
{
throw new PropertyValueSizeIsMoreMaxLengthException(PROP_BPM_COMMENT);
}
}
}
@Override
public void afterPersist(ItemType item, FormData data, PersistType persistedObject)
{
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.workflow;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.namespace.QName;
public class PropertyValueSizeIsMoreMaxLengthException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 5722742734237891185L;
public PropertyValueSizeIsMoreMaxLengthException(QName name)
{
super("Property '" + name.getLocalName() + "' has size more than max value.");
}
public PropertyValueSizeIsMoreMaxLengthException(String name)
{
super("Property '" + name + "' has size more than max value.");
}
}