2014-12-10 1 views
1

DotCMIS.dll을 SharePoint에 연결하고 싶지만 올바르게 작동하지 않습니다.DotCMIS가 SharePoint Foundation 2013에 연결

SharePoint 2013 관리 셸에서 스크립트를 엽니 다.

는 내 사용자 권한 (이 팜의 사용자가 아닌)

가 아마 여기에 올바른 링크를주는 문제입니다 사용할 수 있습니다. org.apache.chemistry.dotcmis.binding.atompub.url =?

셰어 포인트의 링크가 어디로 가야하는지 알고 있습니까? 예

웹 사이트 :

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

오류 내 스크립트의

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 

중요한 부분

$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" 

모든 스크립트

# 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) 

답변

관련 문제