From 2ade4922f6ef21e63afae6a98b54ec5cfd9f43df Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 18 Jan 2006 16:28:39 +0000 Subject: [PATCH] Removed deep nesting logic git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/node/db/DbNodeServiceImpl.java | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java index 17d5a1967b..603cf09501 100644 --- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java +++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java @@ -333,35 +333,41 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl { for (Map.Entry entry : classDefinition.getDefaultValues().entrySet()) { - if (properties.containsKey(entry.getKey()) == false) + if (properties.containsKey(entry.getKey())) { - Serializable value = entry.getValue(); - - // TODO what other conversions are nessesary here for other types of default values ? - - // Check the type of the default property - PropertyDefinition prop = this.dictionaryService.getProperty(entry.getKey()); - if (prop != null) + // property is present + continue; + } + Serializable value = entry.getValue(); + + // Check the type of the default property + PropertyDefinition prop = this.dictionaryService.getProperty(entry.getKey()); + if (prop == null) + { + // dictionary doesn't have a default value present + continue; + } + + // TODO what other conversions are nessesary here for other types of default values ? + + // ensure that we deliver the property in the correct form + if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == true) + { + if (value instanceof String) { - if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == true) + if (((String)value).toUpperCase().equals("TRUE") == true) { - if (value instanceof String) - { - if (((String)value).toUpperCase().equals("TRUE") == true) - { - value = Boolean.TRUE; - } - else if (((String)value).toUpperCase().equals("FALSE") == true) - { - value = Boolean.FALSE; - } - } + value = Boolean.TRUE; + } + else if (((String)value).toUpperCase().equals("FALSE") == true) + { + value = Boolean.FALSE; } } - - // Set the default value of the property - properties.put(entry.getKey(), value); } + + // Set the default value of the property + properties.put(entry.getKey(), value); } }