mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge pull request #15 from Alfresco/fix/REPO-2705_createDocVersNone
Fix/repo 2705 create doc vers none
This commit is contained in:
@@ -1283,11 +1283,6 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
throw new CmisConstraintException("This document type does requires content!");
|
||||
}
|
||||
|
||||
if (docType.isVersionable() && (versioningState == VersioningState.NONE))
|
||||
{
|
||||
throw new CmisConstraintException("This document type is versionable!");
|
||||
}
|
||||
|
||||
if (!docType.isVersionable() && (versioningState != VersioningState.NONE))
|
||||
{
|
||||
throw new CmisConstraintException("This document type is not versionable!");
|
||||
|
@@ -3669,6 +3669,64 @@ public class CMISTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDocWithVersioningStateNone() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
try
|
||||
{
|
||||
// get repository id
|
||||
final String repositoryId = withCmisService(new CmisServiceCallback<String>()
|
||||
{
|
||||
@Override
|
||||
public String execute(CmisService cmisService)
|
||||
{
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
final String repositoryId = repo.getId();
|
||||
return repositoryId;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
final NodeRef documentNodeRef = withCmisService(new CmisServiceCallback<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef execute(CmisService cmisService)
|
||||
{
|
||||
final PropertiesImpl properties = new PropertiesImpl();
|
||||
String objectTypeId = "cmis:document";
|
||||
properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, objectTypeId));
|
||||
String fileName = "textFile" + GUID.generate();
|
||||
properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, fileName));
|
||||
final ContentStreamImpl contentStream = new ContentStreamImpl(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Simple text plain document");
|
||||
|
||||
String nodeId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.NONE, null, null);
|
||||
return new NodeRef(nodeId.substring(0, nodeId.indexOf(';')));
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
// check versioning properties
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<Void>>()
|
||||
{
|
||||
@Override
|
||||
public List<Void> execute() throws Throwable
|
||||
{
|
||||
assertTrue(nodeService.exists(documentNodeRef));
|
||||
assertFalse(nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-14951: Test that the list of parents can be retrieved for a folder.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user