2014-12-10 3 views
1

Я хотел бы подключить DotCMIS.dll к моему SharePoint, но не работает правильно.DotCMIS подключиться к SharePoint Foundation 2013

Открываем сценарий в командной консоли SharePoint 2013.

Я использую свои права доступа пользователей (Это не является пользователем Farm)

Вероятно, здесь проблема с приданием правильную ссылку. org.apache.chemistry.dotcmis.binding.atompub.url =?

Есть ли у вас какие-либо идеи, по какой ссылке в sharepoint нужно идти?

Сайт Например:

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) 

ответ

Смежные вопросы