当前位置: 首页>>代码示例>>Java>>正文


Java VersioningState类代码示例

本文整理汇总了Java中org.apache.chemistry.opencmis.commons.enums.VersioningState的典型用法代码示例。如果您正苦于以下问题:Java VersioningState类的具体用法?Java VersioningState怎么用?Java VersioningState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VersioningState类属于org.apache.chemistry.opencmis.commons.enums包,在下文中一共展示了VersioningState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
/**
 * Creates a new document with the given name and content under the given
 * folder.
 * 
 * @param name
 *            the name of the document.
 * @param rootFolder
 *            the root folder.
 * @param content
 *            the content of the document.
 * @return the created document.
 */
public Document createDocument(Folder rootFolder, String fileName, InputStream inputStream) {
	logger.debug(DEBUG_CREATING_NEW_DOCUMENT, fileName, rootFolder);

	Document document = null;

	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put(PropertyIds.OBJECT_TYPE_ID, CMIS_DOCUMENT_TYPE);
	properties.put(PropertyIds.NAME, fileName);
	ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(fileName, -1,
			MIME_TYPE_TEXT_PLAIN_UTF_8, inputStream);
	try {
		document = rootFolder.createDocument(properties, contentStream, VersioningState.NONE);
	} catch (CmisNameConstraintViolationException e) {
		String errorMessage = MessageFormat.format(ERROR_FILE_ALREADY_EXISTS, fileName);
		logger.error(errorMessage);
		throw new CmisNameConstraintViolationException(errorMessage, e);
	}
	logger.debug(DEBUG_DOCUMENT_CREATED, fileName);

	return document;
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:34,代码来源:EcmRepository.java

示例2: createDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:OpenCmisLocalTest.java

示例3: create

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:PublicApiAlfrescoCmisService.java

示例4: createDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:PublicApiAlfrescoCmisService.java

示例5: createUniqueDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:CMISDataCreatorTest.java

示例6: create

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
/**
 * Create* dispatch for AtomPub.
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
        VersioningState versioningState, ObjectInfoHandler objectInfos) {
    boolean userReadOnly = checkUser(context, true);

    String typeId = FileBridgeUtils.getObjectTypeId(properties);
    TypeDefinition type = typeManager.getInternalTypeDefinition(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);
    } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
        objectId = createFolder(context, properties, folderId);
    } else {
        throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
    }

    return compileObjectData(context, getFile(objectId), null, false, false, userReadOnly, objectInfos);
}
 
开发者ID:cmisdocs,项目名称:ServerDevelopmentGuideV2,代码行数:25,代码来源:FileBridgeRepository.java

示例7: createDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
public Document createDocument(String docName, String contentType) {
  Session session = getSession();
  Folder folder = (Folder) session.getObjectByPath("/" + getFolderName());
  String timeStamp = new Long(System.currentTimeMillis()).toString();
  String filename = docName + " (" + timeStamp + ")";
  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put(PropertyIds.OBJECT_TYPE_ID, contentType);
  properties.put(PropertyIds.NAME, filename);
  properties.put(PropertyIds.IS_MAJOR_VERSION, true);
  properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION, true);

  String docText = "Lorem ipsum";
  byte[] content = docText.getBytes();
  InputStream stream = new ByteArrayInputStream(content);
  ContentStream contentStream = session.getObjectFactory().createContentStream(
      filename,
      Long.valueOf(content.length),
      "text/plain",
      stream);
  Document doc = folder.createDocument(
      properties,
      contentStream,
      VersioningState.MAJOR);

  return doc;
}
 
开发者ID:Alfresco,项目名称:alfresco-indexer,代码行数:27,代码来源:CMISUtils.java

示例8: uploadFile

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
private void uploadFile(String path, File file, Folder destinationFolder) throws FileNotFoundException {
  for (int x = 0; x < 3; x++) {
    try {
      Map<String, Serializable> properties = new HashMap<String, Serializable>();

      properties.put(PropertyIds.NAME, file.getName());
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");

      ContentStream contentStream = new ContentStreamImpl(file.getAbsolutePath(), BigInteger.valueOf(file.length()), _mimetype, new FileInputStream(file));

      _session.clear();

      Document document = destinationFolder.createDocument(properties, contentStream, VersioningState.MAJOR);

      getLog().info("Uploaded '" + file.getName() + "' to '" + path + "' with a document id of '" + document.getId() + "'");

      return;
    } catch (Exception ex) {
      getLog().debug("Upload failed, retrying...");
    }
  }
}
 
开发者ID:Redpill-Linpro,项目名称:artifact-upload-maven-plugin,代码行数:23,代码来源:CmisUploadMojo.java

示例9: applyVersioningState

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:CMISConnector.java

示例10: getDocumentDefaultVersioningState

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AlfrescoCmisServiceImpl.java

示例11: DISABLED_testBasicFileOps

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:OpenCmisLocalTest.java

示例12: testDownloadEvent

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:OpenCmisLocalTest.java

示例13: createFileFromUpload

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
@Override
public FileCustom createFileFromUpload(ByteArrayInOutStream file, String mimeType, String filename, 
		long length, String typeFichier, String prefixe, Candidature candidature, Boolean commune) throws FileException{
	try{
		String name = prefixe+"_"+filename;
		Map<String, Object> properties = new HashMap<String, Object>();
		properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
		properties.put(PropertyIds.NAME, name);

		ByteArrayInputStream bis = file.getInputStream();
		ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(length), mimeType, bis);	
		Folder master;
		if (typeFichier.equals(ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE)){
			master = getFolderGestionnaire();
		}else{
			master = getFolderCandidature(candidature, commune);
		}
		
		//versioning
		VersioningState versioningState = VersioningState.NONE;
		if (enableVersioningCmis!=null && enableVersioningCmis){
			versioningState = VersioningState.MINOR;
		}
		
		Document d = master.createDocument(properties, contentStream, versioningState);
		file.close();
		bis.close();
		return getFileFromDoc(d,filename, prefixe);
	}catch(Exception e){
		logger.error("Stockage de fichier - CMIS : erreur de creation du fichier ",e);
		throw new FileException(applicationContext.getMessage("file.error.create", null, UI.getCurrent().getLocale()),e);
	}		
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:34,代码来源:FileManagerCmisImpl.java

示例14: createDocument

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
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");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:41,代码来源:PublicApiClient.java

示例15: create

import org.apache.chemistry.opencmis.commons.enums.VersioningState; //导入依赖的package包/类
@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();
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:8,代码来源:CmisServiceImpl.java


注:本文中的org.apache.chemistry.opencmis.commons.enums.VersioningState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。