mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -3427,34 +3427,27 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (value == null)
|
// overflow check
|
||||||
{
|
if (propDef.getPropertyDefinition().getPropertyType() == PropertyType.INTEGER && value instanceof BigInteger)
|
||||||
nodeService.removeProperty(nodeRef, propertyQName);
|
{
|
||||||
}
|
org.alfresco.service.cmr.dictionary.PropertyDefinition def = dictionaryService.getProperty(propertyQName);
|
||||||
else
|
QName dataDef = def.getDataType().getName();
|
||||||
{
|
BigInteger bigValue = (BigInteger) value;
|
||||||
// overflow check
|
|
||||||
if(propDef.getPropertyDefinition().getPropertyType() == PropertyType.INTEGER && value instanceof BigInteger)
|
if ((bigValue.compareTo(maxInt) > 0 || bigValue.compareTo(minInt) < 0) && dataDef.equals(DataTypeDefinition.INT))
|
||||||
{
|
{
|
||||||
org.alfresco.service.cmr.dictionary.PropertyDefinition def = dictionaryService.getProperty(propertyQName);
|
throw new CmisConstraintException("Value is out of range for property " + propertyQName.getLocalName());
|
||||||
QName dataDef = def.getDataType().getName();
|
}
|
||||||
BigInteger bigValue = (BigInteger)value;
|
|
||||||
|
if ((bigValue.compareTo(maxLong) > 0 || bigValue.compareTo(minLong) < 0) && dataDef.equals(DataTypeDefinition.LONG))
|
||||||
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());
|
||||||
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))
|
nodeService.setProperty(nodeRef, propertyQName, value);
|
||||||
{
|
}
|
||||||
throw new CmisConstraintException("Value is out of range for property " + propertyQName.getLocalName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeService.setProperty(nodeRef, propertyQName, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -276,7 +276,96 @@ public class CMISTest
|
|||||||
this.factory = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory");
|
this.factory = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory");
|
||||||
this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
|
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)
|
private FileInfo createContent(final String folderName, final String docName, final boolean isRule)
|
||||||
{
|
{
|
||||||
final FileInfo folderInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
|
final FileInfo folderInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
<property name="models">
|
<property name="models">
|
||||||
<list>
|
<list>
|
||||||
<value>opencmis/testcmisinteger_model.xml</value>
|
<value>opencmis/testcmisinteger_model.xml</value>
|
||||||
|
<value>tenant/exampleModel.xml</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
Reference in New Issue
Block a user