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

63749: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (4.3.0.BF)
      63717: Merged V4.1-BUG-FIX (4.1.9) to V4.2-BUG-FIX (4.2.2)
         63646:  Merged DEV to V4.1-BUG-FIX (4.1.9)
            55519: MNT-9203: CMIS: Cannot unset (set to null) property during checkin
              - CMISConnector#setProperty method was modified. Now we can set null values according to provided API. Also, testCheckIn unit test was added for this approach.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@64327 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-03-14 17:01:02 +00:00
parent 824391d858
commit a201257a29
3 changed files with 112 additions and 29 deletions

View File

@@ -3427,26 +3427,20 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
else
{
if (value == null)
{
nodeService.removeProperty(nodeRef, propertyQName);
}
else
{
// overflow check
if(propDef.getPropertyDefinition().getPropertyType() == PropertyType.INTEGER && value instanceof BigInteger)
if (propDef.getPropertyDefinition().getPropertyType() == PropertyType.INTEGER && value instanceof BigInteger)
{
org.alfresco.service.cmr.dictionary.PropertyDefinition def = dictionaryService.getProperty(propertyQName);
QName dataDef = def.getDataType().getName();
BigInteger bigValue = (BigInteger)value;
BigInteger bigValue = (BigInteger) value;
if ((bigValue.compareTo(maxInt) > 0 || bigValue.compareTo(minInt) < 0 ) && dataDef.equals(DataTypeDefinition.INT))
if ((bigValue.compareTo(maxInt) > 0 || bigValue.compareTo(minInt) < 0) && dataDef.equals(DataTypeDefinition.INT))
{
throw new CmisConstraintException("Value is out of range for property " + propertyQName.getLocalName());
}
if ((bigValue.compareTo(maxLong) > 0 || bigValue.compareTo(minLong) < 0 ) && dataDef.equals(DataTypeDefinition.LONG))
if ((bigValue.compareTo(maxLong) > 0 || bigValue.compareTo(minLong) < 0) && dataDef.equals(DataTypeDefinition.LONG))
{
throw new CmisConstraintException("Value is out of range for property " + propertyQName.getLocalName());
}
@@ -3456,7 +3450,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
}
}
private Serializable getValue(PropertyData<?> property, boolean isMultiValue)
{

View File

@@ -277,6 +277,95 @@ public class CMISTest
this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
}
/**
* Test for MNT-9203.
*/
@Test
public void testCeheckIn()
{
String repositoryId = null;
ObjectData objectData = null;
Holder<String> objectId = null;
CallContext context = new SimpleCallContext("admin", "admin", CmisVersion.CMIS_1_0);
final String folderName = "testfolder." + GUID.generate();
final String docName = "testdoc.txt." + GUID.generate();
final String customModel = "my.new.model";
final QName testCustomTypeQName = QName.createQName(customModel, "sop");
final QName authorisedByQname = QName.createQName(customModel, "authorisedBy");
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
try
{
final FileInfo fileInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
{
@Override
public FileInfo execute() throws Throwable
{
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
FileInfo fileInfo = fileFolderService.create(folderInfo.getNodeRef(), docName, testCustomTypeQName);
Map<QName, Serializable> customProperties = new HashMap<QName, Serializable>();
customProperties.put(authorisedByQname, "customPropertyString");
customProperties.put(ContentModel.PROP_NAME, docName);
nodeService.setProperties(fileInfo.getNodeRef(), customProperties);
return fileInfo;
}
});
CmisService service = factory.getService(context);
try
{
List<RepositoryInfo> repositories = service.getRepositoryInfos(null);
assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0);
repositoryId = repo.getId();
objectData = service.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true, IncludeRelationships.NONE, null, false, true, null);
// checkout
objectId = new Holder<String>(objectData.getId());
service.checkOut(repositoryId, objectId, null, new Holder<Boolean>(true));
}
finally
{
service.close();
}
try
{
service = factory.getService(context);
PropertyStringImpl prop = new PropertyStringImpl();
prop.setId("my:" + authorisedByQname.toPrefixString());
prop.setValue(null);
Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>();
propsList.add(prop);
Properties properties = new PropertiesImpl(propsList);
// checkIn on pwc
service.checkIn(repositoryId, objectId, false, properties, null, null, null, null, null, null);
}
finally
{
service.close();
}
// check that value is null
assertTrue(nodeService.getProperty(fileInfo.getNodeRef(), authorisedByQname) == null);
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
private FileInfo createContent(final String folderName, final String docName, final boolean isRule)
{
final FileInfo folderInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()

View File

@@ -7,6 +7,7 @@
<property name="models">
<list>
<value>opencmis/testcmisinteger_model.xml</value>
<value>tenant/exampleModel.xml</value>
</list>
</property>
</bean>