- Fixed unreported bug where boolean deafult values where not set correctly

- Fixed AR-314, category rule was not appending additional categories
- Fixed spelling mistake and moved lock messages into properties file while I was there (AWC-350)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2039 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2005-12-13 17:21:33 +00:00
parent 3f047e8aed
commit 366873440c
8 changed files with 59 additions and 15 deletions

View File

@@ -17,6 +17,7 @@
package org.alfresco.repo.action.executer;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -30,6 +31,7 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.namespace.QName;
/**
@@ -117,10 +119,21 @@ public class LinkCategoryActionExecuter extends ActionExecuterAbstractBase
if (categoryAspect != null)
{
// Add the aspect setting the category property to the approptiate values
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(categoryProperty, categoryValue);
this.nodeService.addAspect(actionedUponNodeRef, categoryAspect, properties);
if (this.nodeService.hasAspect(actionedUponNodeRef, categoryAspect) == false)
{
// Add the aspect and set the category property value
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(categoryProperty, categoryValue);
this.nodeService.addAspect(actionedUponNodeRef, categoryAspect, properties);
}
else
{
// Append the category value to the existing values
Serializable value = this.nodeService.getProperty(actionedUponNodeRef, categoryProperty);
Collection<NodeRef> categories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, value);
categories.add(categoryValue);
this.nodeService.setProperty(actionedUponNodeRef, categoryProperty, (Serializable)categories);
}
}
}
}

View File

@@ -165,6 +165,7 @@ public class LockServiceImplTest extends BaseSpringTest
}
catch (UnableToAquireLockException exception)
{
System.out.println(exception.getMessage());
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
@@ -220,6 +221,7 @@ public class LockServiceImplTest extends BaseSpringTest
}
catch (UnableToReleaseLockException exception)
{
System.out.println(exception.getMessage());
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);

View File

@@ -40,6 +40,7 @@ import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
@@ -334,8 +335,32 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
{
if (properties.containsKey(entry.getKey()) == false)
{
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)
{
if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == 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;
}
}
}
}
// Set the default value of the property
properties.put(entry.getKey(), entry.getValue());
properties.put(entry.getKey(), value);
}
}
}

View File

@@ -19,6 +19,7 @@ package org.alfresco.service.cmr.lock;
import java.text.MessageFormat;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -36,10 +37,8 @@ public class NodeLockedException extends AlfrescoRuntimeException
/**
* Error message
*/
private static final String ERROR_MESSAGE = "Can not perform operation since " +
"the node (id:{0}) is locked by another user.";
private static final String ERROR_MESSAGE_2 = "Can not perform operation {0} since " +
"the node (id:{1}) is locked by another user.";
private static final String ERROR_MESSAGE = I18NUtil.getMessage("lock_service.no_op");
private static final String ERROR_MESSAGE_2 = I18NUtil.getMessage("lock_service.no_op2");
/**
* @param message

View File

@@ -18,6 +18,7 @@ package org.alfresco.service.cmr.lock;
import java.text.MessageFormat;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -33,8 +34,7 @@ public class UnableToAquireLockException extends RuntimeException
/**
* Error message
*/
private final static String ERROR_MESSAGE = "The node (id: {0})could not be locked since it" +
" is already locked by antoher user.";
private final static String ERROR_MESSAGE = I18NUtil.getMessage("lock_service.node_locked");
/**
* Constructor

View File

@@ -18,6 +18,7 @@ package org.alfresco.service.cmr.lock;
import java.text.MessageFormat;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -35,10 +36,7 @@ public class UnableToReleaseLockException extends RuntimeException
/**
* Error message
*/
private static final String ERROR_MESSAGE =
"You have insufficent priveleges to realese the " +
"lock on the node (id: {0}). The node is locked by " +
"another user.";
private static final String ERROR_MESSAGE = I18NUtil.getMessage("lock_service.insufficent_preveleges");
/**
* Constructor