首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >2013年DotCMIS与SharePoint基金会的连接

2013年DotCMIS与SharePoint基金会的连接
EN

Stack Overflow用户
提问于 2014-12-10 12:53:22
回答 1查看 408关注 0票数 1

我想将DotCMIS.dll连接到我的SharePoint,但工作不正确。

我在SharePoint 2013命令行管理程序中打开脚本。

我使用我的用户权限(这不是一个农场用户)

可能是提供正确链接的问题所在。org.apache.chemistry.dotcmis.binding.atompub.url=?

你知道sharepoint的链接到哪里去了吗?

例子网站:

http://chemistry.apache.org/dotnet/powershell-example.html

错误

代码语言:javascript
复制
You cannot call a method on a null-valued expression.
At line:6 char:7
+       $b = $contentStream.Stream.Read($buffer, 0, 4096)
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

我剧本的重要部分

代码语言:javascript
复制
$sp["org.apache.chemistry.dotcmis.binding.atompub.url"] = "http://localhost/_layouts/15/start.aspx#/SitePages/WebSite.aspx"
    $sp["org.apache.chemistry.dotcmis.user"] = "mylogin"
    $sp["org.apache.chemistry.dotcmis.password"] = "mypassword"

全剧本

代码语言:javascript
复制
# load DotCMIS DLL
[Reflection.Assembly]::LoadFile("C:\dotCmisServer\DotCMIS.dll")


# -----------------------------------------------------------------

# helper functions
function New-GenericDictionary([type] $keyType, [type] $valueType) {  
   $base = [System.Collections.Generic.Dictionary``2]  
   $ct = $base.MakeGenericType(($keyType, $valueType))  
   New-Object $ct
}

function New-ContentStream([string] $file, [string] $mimetype) {
   $fileinfo = ([System.IO.FileInfo]$file)

   $contentStream = New-Object "DotCMIS.Data.Impl.ContentStream"
   $contentStream.Filename = $fileinfo.Name
   $contentStream.Length = $fileinfo.Length
   $contentStream.MimeType = $mimetype
   $contentStream.Stream = $fileinfo.OpenRead()

   $contentStream
}

function Download-ContentStream([DotCMIS.Client.IDocument] $document, [string] $file) {
   $contentStream = $document.GetContentStream()   
   $fileStream = [System.IO.File]::OpenWrite($file)

   $buffer = New-Object byte[] 4096  
   do {  
      $b = $contentStream.Stream.Read($buffer, 0, 4096)  
      $fileStream.Write($buffer, 0, $b)  
   }  
   while ($b -ne 0)

   $fileStream.Close()
   $contentStream.Stream.Close()
}


# -----------------------------------------------------------------

# create session
$sp = New-GenericDictionary string string
$sp["org.apache.chemistry.dotcmis.binding.spi.type"] = "atompub"
$sp["org.apache.chemistry.dotcmis.binding.atompub.url"] = "http://localhost/_layouts/15/start.aspx#/SitePages/WebSite.aspx"
$sp["org.apache.chemistry.dotcmis.user"] = "mylogin"
$sp["org.apache.chemistry.dotcmis.password"] = "mypassword"

$factory = [DotCMIS.Client.Impl.SessionFactory]::NewInstance()
$session = $factory.GetRepositories($sp)[0].CreateSession()


# print the repository infos
$session.RepositoryInfo.Id
$session.RepositoryInfo.Name
$session.RepositoryInfo.Vendor
$session.RepositoryInfo.ProductName
$session.RepositoryInfo.ProductVersion


# get root folder
$root = $session.GetRootFolder()


# print root folder children
$children = $root.GetChildren()
foreach ($object in $children) {
   $object.Name + "     (" + $object.ObjectType.Id + ")" 
}


# run a quick query
$queryresult = $session.Query("SELECT * FROM cmis:document", $false)
foreach ($object in $queryresult) {
   foreach ($item in $object.Properties) {
      $item.QueryName + ": " + $item.FirstValue
   }
   "----------------------------------"
}


# create a folder
$folderProperties = New-GenericDictionary string object
$folderProperties["cmis:name"] = "myNewFolder"
$folderProperties["cmis:objectTypeId"] = "cmis:folder"

$folder = $root.CreateFolder($folderProperties)


# create a document 
$documentProperties = New-GenericDictionary string object
$documentProperties["cmis:name"] = "myNewDocument"
$documentProperties["cmis:objectTypeId"] = "cmis:document"

$source = $home + "\source.txt"
$mimetype = "text/plain"
$contentStream = New-ContentStream $source $mimetype

$doc = $folder.CreateDocument($documentProperties, $contentStream, $null)


# download a document
$target = $home + "\target.txt"
Download-ContentStream $doc $target


# clean up
$doc.Delete($true)
$folder.Delete($true)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-14 09:46:48

不幸的是,在2013年的SharePoint基金会中,我不得不编写自己的C#软件。

SharePoint Foundation 2013 IMPORT\EXPORT dbo.allDocs file\files

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27401540

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档