org.apache.chemistry.opencmis.commons.enums.VersioningState Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.enums.VersioningState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Create dispatch for AtomPub
 * 
 * @param context call context
 * @param properties the properties
 * @param folderId identifier of the parent folder
 * @param contentStream stream of the document to create
 * @param versioningState state of the version
 * @param objectInfos informations
 * 
 * @return the newly created object
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
		VersioningState versioningState, ObjectInfoHandler objectInfos) {
	debug("create " + folderId);
	validatePermission(folderId, context, Permission.WRITE);

	String typeId = getTypeId(properties);

	TypeDefinition type = types.getType(typeId);
	if (type == null)
		throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");

	String objectId = null;
	if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
		objectId = createDocument(context, properties, folderId, contentStream, versioningState);
		return compileObjectType(context, getDocument(objectId), null, false, false, objectInfos);
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		objectId = createFolder(context, properties, folderId);
		return compileObjectType(context, getFolder(objectId), null, false, false, objectInfos);
	} else {
		throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
	}
}
 
Example #2
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static Document createDocument(Folder target, String newDocName, Session session)
{
    Map<String, String> props = new HashMap<String, String>();
    props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    props.put(PropertyIds.NAME, newDocName);
    String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
    byte[] buf = null;
    try
    {
        buf = content.getBytes("ISO-8859-1"); // set the encoding here for the content stream
    }
    catch (UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }

    ByteArrayInputStream input = new ByteArrayInputStream(buf);

    ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
            "text/plain; charset=UTF-8", input); // additionally set the charset here
    // NOTE that we intentionally specified the wrong charset here (as UTF-8)
    // because Alfresco does automatic charset detection, so we will ignore this explicit request
    return target.createDocument(props, contentStream, VersioningState.MAJOR);
}
 
Example #3
Source File: CMISDataCreatorTest.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Document createUniqueDocument(Folder newFolder)
		throws UnsupportedEncodingException {
	String uniqueName = getUniqueName();
       Map<String, Object> uProperties = new HashMap<String, Object>();
       uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
       uProperties.put(PropertyIds.NAME, uniqueName);
       
       ContentStreamImpl contentStream = new ContentStreamImpl();
       contentStream.setFileName("bob");
       String shortString = "short";
       contentStream.setStream(new ByteArrayInputStream(shortString.getBytes("UTF-8")));
       contentStream.setLength(new BigInteger("5"));
       contentStream.setMimeType("text/plain");
       
       Document uniqueDocument = newFolder.createDocument(uProperties, contentStream, VersioningState.MAJOR);
       return uniqueDocument;
}
 
Example #4
Source File: SetupTest.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test(priority = 2)
public void testModelMusicCanBeUsed() throws Exception
{
    // Create document of custom type
    FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-music");
    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:music:song");
    properties.put(PropertyIds.NAME, customFile.getName());
    properties.put("music:genre", "pop");
    properties.put("music:lyricist", "Me");

    cmisApi.authenticateUser(testUser).usingSite(testSite)
            .usingResource(testFolder)
            .createFile(customFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();
}
 
Example #5
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create test document with content
 * 
 * @param target
 * @param newDocName
 */
private static void createDocument(Folder target, String newDocName) {
	Map<String, String> props = new HashMap<String, String>();
	props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
	props.put(PropertyIds.NAME, newDocName);
	props.put(TypeManager.PROP_TAGS, "tag1,tag2,tag3");
	System.out.println("This is a test document: " + newDocName);
	String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
	byte[] buf = null;
	try {
		buf = content.getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	ByteArrayInputStream input = new ByteArrayInputStream(buf);
	ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
			"text/plain; fileNameCharset=UTF-8", input);
	target.createDocument(props, contentStream, VersioningState.NONE);
}
 
Example #6
Source File: SetupTest.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test(priority = 3)
public void testModelFinanceCanBeUsed() throws Exception
{
    // Create document of custom type

    FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "searchContent-finance");
    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:finance:Receipt");
    properties.put(PropertyIds.NAME, customFile.getName());
    properties.put("finance:ReceiptNo", 1);
    properties.put("finance:ReceiptValue", 30);

    cmisApi.authenticateUser(testUser).usingSite(testSite)
            .usingResource(testFolder)
            .createFile(customFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();

    Assert.assertTrue(waitForIndexing("cm:name:" + customFile.getName(),true),"New content could not be found");
}
 
Example #7
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState,
            List<String> policies, ExtensionsData extension)
{
    FileFilterMode.setClient(Client.cmis);
    try
    {
        return super.create(
                    repositoryId,
                    properties,
                    folderId,
                    contentStream,
                    versioningState,
                    policies,
                    extension);
    }
    finally
    {
        FileFilterMode.clearClient();
    }
}
 
Example #8
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 6 votes vote down vote up
public String createDocument(String repositoryId,
		Properties properties,
		String folderId,
		ContentStream contentStream,
		VersioningState versioningState,
		List<String> policies,
		Acl addAces,
		Acl removeAces,
		ExtensionsData extension) {

	return bridge.createDocument(config,
			properties,
			folderId,
			contentStream,
			versioningState,
			policies,
			addAces,
			removeAces,
			extension);
}
 
Example #9
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to capture content upload for publishing to analytics service.
 */
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState,
            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension)
{
    String newId = super.createDocument(
                repositoryId,
                properties,
                folderId,
                contentStream,
                versioningState,
                policies,
                addAces,
                removeAces,
                extension);
    return newId;
}
 
Example #10
Source File: CmisServiceImpl.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
                     VersioningState versioningState, List<String> policies, ExtensionsData extension) {
	log.debug("create({}, {}, {})", new Object[]{repositoryId, properties, folderId});
	ObjectData object = getRepository().create(getCallContext(), properties, folderId, contentStream, versioningState, this);
	return object.getId();
}
 
Example #11
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Document createDocument(String parentId, String name, Map<String, Serializable> properties, ContentStream contentStream, VersioningState versioningState)
{
    CmisObject o = getObject(parentId);

    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        if(properties == null)
        {
            properties = new HashMap<String, Serializable>();
        }
        String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
        String type = "cmis:document";
        if(objectTypeId == null)
        {
            objectTypeId = type;
        }
        if(objectTypeId.indexOf(type) == -1)
        {
            StringBuilder sb = new StringBuilder(objectTypeId);
            if(sb.length() > 0)
            {
                sb.append(",");
            }
            sb.append(type);
            objectTypeId = sb.toString();
        }

        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);

        Document res = f.createDocument(properties, contentStream, versioningState);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Parent does not exists or is not a folder");
    }
}
 
Example #12
Source File: SearchNonIndexedFields.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
    serverHealth.assertServerIsOnline();

    deployCustomModel("model/indexing-disabled-content-model.xml");
    
    dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);

    FolderModel testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();

    FileModel sampleFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Sample");
    sampleFile.setName("in1-" + sampleFile.getName());

    // One field indexed and one field not indexed
    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:index:sample");
    properties.put(PropertyIds.NAME, sampleFile.getName());
    properties.put("index:indexed", "Indexed");
    properties.put("index:nonIndexed", "Not indexed");

    cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(sampleFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();

    sampleFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "Sample");
    sampleFile.setName("in2-" + sampleFile.getName());

    // Only one field not indexed
    properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, "D:index:sample");
    properties.put(PropertyIds.NAME, sampleFile.getName());
    properties.put("index:nonIndexed", "Not indexed");

    cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).createFile(sampleFile, properties, VersioningState.MAJOR)
            .assertThat().existsInRepo();
    
    waitForIndexing(sampleFile.getName(), true);
    
}
 
Example #13
Source File: FilterCmisService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
		ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {
	return getObjectService().createDocument(repositoryId, properties, folderId, contentStream, versioningState,
			policies, addAces, removeAces, extension);
}
 
Example #14
Source File: FilterCmisService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
		String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
		ExtensionsData extension) {
	return getObjectService().createDocumentFromSource(repositoryId, sourceId, properties, folderId,
			versioningState, policies, addAces, removeAces, extension);
}
 
Example #15
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties,
		String folderId, ContentStream contentStream,
		VersioningState versioningState, List<String> policies,
		Acl addAces, Acl removeAces, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.CREATE_DOCUMENT)) {
		return objectService.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		cmisXml.addSubElement(buildXml("folderId", folderId));
		cmisXml.addSubElement(buildXml("versioningState", versioningState));

		XmlBuilder contentStreamXml = new XmlBuilder("contentStream");
		contentStreamXml.addAttribute("filename", contentStream.getFileName());
		contentStreamXml.addAttribute("length", contentStream.getLength());
		contentStreamXml.addAttribute("mimeType", contentStream.getMimeType());
		cmisXml.addSubElement(contentStreamXml);

		XmlBuilder propertiesXml = new XmlBuilder("properties");
		for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext();) {
			propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
		}
		cmisXml.addSubElement(propertiesXml);

		IPipeLineSession context = new PipeLineSessionBase();
		context.put("ContentStream", contentStream.getStream());
		context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
		Element result = eventDispatcher.trigger(CmisEvent.CREATE_DOCUMENT, cmisXml.toXML(), context);
		return XmlUtils.getChildTagAsString(result, "id");
	}
}
 
Example #16
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocumentFromSource(String repositoryId,
		String sourceId, Properties properties, String folderId,
		VersioningState versioningState, List<String> policies,
		Acl addAces, Acl removeAces, ExtensionsData extension) {
	// TODO Auto-generated method stub
	return objectService.createDocumentFromSource(repositoryId, sourceId, properties, folderId, versioningState, policies, addAces, removeAces, extension);
}
 
Example #17
Source File: TestCreateAction.java    From iaf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
	@Override
	public CmisSender createSender() throws ConfigurationException {
		CmisSender sender = spy(new CmisSender());

		sender.setUrl("http://dummy.url");
		sender.setRepository("dummyRepository");
		sender.setUsername("test");
		sender.setPassword("test");
		sender.setKeepSession(false);

		Session cmisSession = mock(Session.class);
		ObjectFactory objectFactory = mock(ObjectFactoryImpl.class);
		doReturn(objectFactory).when(cmisSession).getObjectFactory();

//			GENERIC cmis object
		ObjectId objectId = mock(ObjectIdImpl.class);
		doReturn(objectId).when(cmisSession).createObjectId(anyString());
		CmisObject cmisObject = spy(new CmisTestObject());
		doReturn(cmisObject).when(cmisSession).getObject(any(ObjectId.class));
		doReturn(cmisObject).when(cmisSession).getObject(any(ObjectId.class), any(OperationContext.class));
		
//			CREATE
		Folder folder = mock(FolderImpl.class);
		doReturn(cmisObject).when(folder).createDocument(anyMap(), any(ContentStreamImpl.class), any(VersioningState.class));
		doReturn(folder).when(cmisSession).getRootFolder();
		doReturn(objectId).when(cmisSession).createDocument(anyMap(), any(ObjectId.class), any(ContentStreamImpl.class), any(VersioningState.class));
		doReturn("dummy_id").when(objectId).getId();
		
		try {
			doReturn(cmisSession).when(sender).createCmisSession(any(ParameterValueList.class));
		} catch (SenderException e) {
			//Since we stub the entire session it won't throw exceptions
		}

		return sender;
	}
 
Example #18
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private void createTextDocument(Folder newFolder, String content, String fileName)
        throws UnsupportedEncodingException {
    byte[] buf = content.getBytes("UTF-8");
    ByteArrayInputStream input = new ByteArrayInputStream(buf);
    ContentStream contentStream = createSession().getObjectFactory()
            .createContentStream(fileName, buf.length, "text/plain; charset=UTF-8", input);

    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_DOCUMENT);
    properties.put(PropertyIds.NAME, fileName);
    newFolder.createDocument(properties, contentStream, VersioningState.NONE);
}
 
Example #19
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void DISABLED_testBasicFileOps()
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    // create folder
    Map<String,String> folderProps = new HashMap<String, String>();
    {
        folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
        folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate());
    }
    Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext());
    
    Map<String, String> fileProps = new HashMap<String, String>();
    {
        fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
        fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
    }
    ContentStreamImpl fileContent = new ContentStreamImpl();
    {
        ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt"));
        writer.putContent("Ipsum and so on");
        ContentReader reader = writer.getReader();
        fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        fileContent.setStream(reader.getContentInputStream());
    }
    folder.createDocument(fileProps, fileContent, VersioningState.MAJOR);
}
 
Example #20
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
        String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
        ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkId("Source Id", sourceId);

    try {
        return getWrappedService().createDocumentFromSource(repositoryId, sourceId, properties, folderId,
                versioningState, policies, addAces, removeAces, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #21
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets default value of <code>VersioningState</code> based on whether document is versionable or not.
 * 
 * @param versioningState
 * @param type
 * @return <code>VersioningState.MAJOR</code> if versioningState is {@code null} and object is versionable
 *         <code>VersioningState.NONE</code> if versioningState is {@code null} and object is not versionable
 *         versioningState if it's value is not {@code null}
 */
private VersioningState getDocumentDefaultVersioningState(VersioningState versioningState, TypeDefinitionWrapper type)
{
    if (versioningState == null)
    {
        DocumentTypeDefinition docType = (DocumentTypeDefinition) type.getTypeDefinition(false);
        versioningState = docType.isVersionable() ? VersioningState.MAJOR : VersioningState.NONE;
    }
    return versioningState;
}
 
Example #22
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
        ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createDocument(repositoryId, properties, folderId, contentStream,
                versioningState, policies, addAces, removeAces, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #23
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
		VersioningState versioningState, List<String> policies, ExtensionsData extension) {
	validateSession();
	ObjectData object = getRepository().create(getCallContext(), properties, folderId, contentStream,
			versioningState, this);
	return object.getId();
}
 
Example #24
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
		ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {
	validateSession();
	return getRepository().createDocument(getCallContext(), properties, folderId, contentStream, versioningState);
}
 
Example #25
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties, String folderId,
		VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
		ExtensionsData extension) {
	validateSession();
	return getRepository().createDocumentFromSource(getCallContext(), sourceId, folderId);
}
 
Example #26
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId, ContentStream contentStream,
        VersioningState versioningState, List<String> policies, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().create(repositoryId, properties, folderId, contentStream, versioningState,
                policies, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #27
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Applies a versioning state to a document.
 */
public void applyVersioningState(NodeRef nodeRef, VersioningState versioningState)
{
    if (versioningState == VersioningState.CHECKEDOUT)
    {
        if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
        {
            nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
        }

        // MNT-14687 : Creating a document as checkedout and then cancelling the checkout should delete the document
        nodeService.addAspect(nodeRef, ContentModel.ASPECT_CMIS_CREATED_CHECKEDOUT, null);

        getCheckOutCheckInService().checkout(nodeRef);
    }
    else if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR))
    {
        if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
        {
            nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
        }

        Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
        versionProperties.put(
                VersionModel.PROP_VERSION_TYPE,
                versioningState == VersioningState.MAJOR ? VersionType.MAJOR : VersionType.MINOR);
        versionProperties.put(VersionModel.PROP_DESCRIPTION, "Initial Version");

        versionService.createVersion(nodeRef, versionProperties);
    }
}
 
Example #28
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties,
        String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces,
        ExtensionsData extension) {
    return service.createDocumentFromSource(repositoryId, sourceId, properties, folderId, versioningState,
            policies, addAces, removeAces, extension);
}
 
Example #29
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
        ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension) {
    return service.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies,
            addAces, removeAces, extension);
}
 
Example #30
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testDownloadEvent() throws InterruptedException
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    String docname = "mydoc-" + GUID.generate() + ".txt";
    Map<String, String> props = new HashMap<String, String>();
    {
        props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
        props.put(PropertyIds.NAME, docname);
    }
    
    // content
    byte[] byteContent = "Hello from Download testing class".getBytes();
    InputStream stream = new ByteArrayInputStream(byteContent);
    ContentStream contentStream = new ContentStreamImpl(docname, BigInteger.valueOf(byteContent.length), "text/plain", stream);

    Document doc1 = rootFolder.createDocument(props, contentStream, VersioningState.MAJOR);
    NodeRef doc1NodeRef = cmisIdToNodeRef(doc1.getId());
    
    ContentStream content = doc1.getContentStream();
    assertNotNull(content);
    
    //range request
    content = doc1.getContentStream(BigInteger.valueOf(2),BigInteger.valueOf(4));
    assertNotNull(content);
}