<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Armedia Blog &#187; SharePoint</title>
	<atom:link href="http://www.armedia.com/blog/category/enterprise_content_management/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.armedia.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 15:53:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Modifying SharePoint Document Content Types and Libraries Using the Client Model</title>
		<link>http://www.armedia.com/blog/2011/09/modifying-sharepoint-document-content-types-and-libraries-using-the-client-model/</link>
		<comments>http://www.armedia.com/blog/2011/09/modifying-sharepoint-document-content-types-and-libraries-using-the-client-model/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 20:09:07 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[Data Migration]]></category>
		<category><![CDATA[eRoom]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual Studio 2010 - C#]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data migration]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1860</guid>
		<description><![CDATA[In a current eRoom to SharePoint migration project I wanted to preserve the &#8220;Date Created&#8221;, &#8220;Date Modified&#8221;, &#8220;Edited By&#8221;, and &#8220;Created By&#8221; fields in the eRoom documents. To do this I created a custom content type (in SharePoint 2010) based on the standard &#8220;Document&#8221; content type with four new fields to accept the migrated information. [...]]]></description>
			<content:encoded><![CDATA[<p>In a current eRoom to SharePoint migration project I wanted to preserve the &#8220;Date Created&#8221;, &#8220;Date Modified&#8221;, &#8220;Edited By&#8221;, and &#8220;Created By&#8221; fields in the eRoom documents. To do this I created a custom content type (in SharePoint 2010) based on the standard &#8220;Document&#8221; content type with four new fields to accept the migrated information. I also created a library template that uses this content type as well as the standard &#8220;Document&#8221; content type. I&#8217;ll explain why later in this article.</p>
<p>Once the documents are migrated I need to update the migrated list/library items. What I don&#8217;t want is to keep one set of &#8220;preserved&#8221; fields and another set of SharePoint fields. The SharePoint fields, as you probably guessed, set the author and editor as the individual doing the migration (or impersonated member) and the created and modified dates being the date of migration.</p>
<p>Updating list items is a pretty easy thing to do in SharePoint&#8217;s Client Object Model. The following code accomplishes this task.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>SP<span style="color: #008000;">.</span><span style="color: #0000FF;">ListItem</span> item <span style="color: #0600FF; font-weight: bold;">in</span> lstItems<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
<span style="color: #008080; font-style: italic;">//skip items not assigned to the migratedDoc document type</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> migType<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
row <span style="color: #008000;">=</span> listItems_dtbl<span style="color: #008000;">.</span><span style="color: #0000FF;">NewRow</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
row<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;List&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span><span style="color: #008000;">;</span><br />
title <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDBNull</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Title&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>title <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;&quot;</span> <span style="color: #008000;">&amp;&amp;</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;FileLeafRef&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span>   <span style="color: #008080; font-style: italic;">//set title if one does not exist</span><br />
title <span style="color: #008000;">=</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;FileLeafRef&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
title <span style="color: #008000;">=</span> title<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;File_x0020_Type&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
sEditor <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDBNull</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eEditor&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eEditor&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
sAuthor <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>Convert<span style="color: #008000;">.</span><span style="color: #0000FF;">IsDBNull</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eAuthor&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eAuthor&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">try</span><br />
<span style="color: #008000;">&#123;</span><br />
editor <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnsureUser</span><span style="color: #008000;">&#40;</span>sEditor<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0600FF; font-weight: bold;">catch</span><br />
<span style="color: #008000;">&#123;</span><br />
editor <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnsureUser</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;tlisko&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0600FF; font-weight: bold;">try</span><br />
<span style="color: #008000;">&#123;</span><br />
author <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnsureUser</span><span style="color: #008000;">&#40;</span>sAuthor<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0600FF; font-weight: bold;">catch</span><br />
<span style="color: #008000;">&#123;</span><br />
author <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">EnsureUser</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;tlisko&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Editor&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> editor<span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Author&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> author<span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Modified&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eModified&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;Created&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eCreated&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #008080; font-style: italic;">//remove values</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eEditor&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eAuthor&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eCreated&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;eModified&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
<br />
item<span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;ContentTypeId&quot;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> docType<span style="color: #008000;">.</span><span style="color: #0000FF;">Id</span><span style="color: #008000;">;</span><br />
item<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span><br />
<span style="color: #0600FF; font-weight: bold;">try</span><br />
<span style="color: #008000;">&#123;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>&#8220;ctx&#8221; is my ClientContext, though that is probably self-evident. You may also note that I only process items whose content type is my custom content type &#8220;migratedDoc&#8221; which is instantiated as &#8220;migType.&#8221; Only the migrated documents will have this content type.</p>
<p>eRoom documents do not have Titles, so I set a title based on the file name. You can leave Title blank &#8211; it isn&#8217;t a required field. Continuing through the code you will notice that I check that the names of the editor and author exist in the LDAP (ctx.Web.EnsureUser(sAuthor)). The update of the list/library item will fail if you try to use an editor or author that doesn&#8217;t exist.</p>
<p>I don&#8217;t really want to have a custom document library &#8211; the SharePoint default document library is just fine. So to get the result I want I need to reassign all the migrated items to the standard &#8220;Document&#8221; type. List items content types have a Name property. Unfortunately you can&#8217;t change it &#8211; it is read only. What you can change is the ContentTypeId and changing that value changes the content type of the list item. In the code above &#8220;docType&#8221; is local instance of the &#8220;Document&#8221; content type.</p>
<p>I said at the beginning of this article that I would explain why I wanted to keep the &#8220;Document&#8221; content type in addition to the creating a custom content type. The reason is that you can&#8217;t assign a list item to a content type if that content type isn&#8217;t in the list. That&#8217;s also why you can&#8217;t move a document from one SharePoint library to another unless its content type is in the target library as well.</p>
<p>Next I want to remove my custom content type from the list altogether. But to do that, I have to make sure that all those extra fields that are in the custom content type are set to null &#8211; which I do before changing the content type. The order of resetting these fields and reassigning the content type doesn&#8217;t matter. What does matter is that if these extra fields are not set to null, you will be unable to remove the content type from the list.</p>
<p>After processing all the list items I can now remove the custom content type from the list. Easy, two lines of code:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">migType<span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>But that still doesn&#8217;t remove the custom fields from the list. More code is needed.  Incorporating the delete of the custom content type you have this.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">migType<span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Fields</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetByTitle</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;eCreated&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Fields</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetByTitle</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;eModified&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Fields</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetByTitle</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;eAuthor&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Fields</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetByTitle</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;eEditor&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">DeleteObject</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p>And that&#8217;s it! The library looks like the default document library with only the &#8220;Document&#8221; content type as desired.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/09/modifying-sharepoint-document-content-types-and-libraries-using-the-client-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Multiple Filters in LINQ Query from Visual Studio</title>
		<link>http://www.armedia.com/blog/2011/09/implementing-multiple-filters-in-linq-query-from-visual-studio/</link>
		<comments>http://www.armedia.com/blog/2011/09/implementing-multiple-filters-in-linq-query-from-visual-studio/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 16:11:29 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual Studio 2010 - C#]]></category>
		<category><![CDATA[LINQ Query]]></category>
		<category><![CDATA[Microsoft SharePoint 2010]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Software Considerations]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1841</guid>
		<description><![CDATA[A best practice in any application making data calls is to push processing to the server and limit the amount of data that has to come back to the application. I recently worked on a windows application that uses the Microsoft SharePoint Client Object Model to manipulate lists and their elements. I needed to filter [...]]]></description>
			<content:encoded><![CDATA[<p>A best practice in any application making data calls is to push processing to the server and limit the amount of data that has to come back to the application.</p>
<p>I recently worked on a windows application that uses the Microsoft SharePoint Client Object Model to manipulate lists and their elements. I needed to filter the lists for processing in the application to just the document libraries that were not hidden, contained at least one item, and were not the &#8220;Site Assets&#8221; or &#8220;Style Library.&#8221;</p>
<p>Cleary a situation where filtering is desired. I found it easy to find examples for generating a list with one filter. For example:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var web <span style="color: #008000;">=</span> clientContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Web</span><span style="color: #008000;">;</span><br />
SP<span style="color: #008000;">.</span><span style="color: #0000FF;">ListCollection</span> listcoll <span style="color: #008000;">=</span> web<span style="color: #008000;">.</span><span style="color: #0000FF;">Lists</span><span style="color: #008000;">;</span><br />
<br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>listcoll,<br />
lists <span style="color: #008000;">=&gt;</span> lists<span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">BaseTemplate</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">101</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">ExecuteQuery</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
<p>However, examples on implementing multiple filters such as I needed proved much more challenging. I finally found an example where the implementation used many &#8220;.Where&#8221; clauses which led to the following attempt.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">...</span><br />
<span style="color: #0000FF;">ctx</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>listcoll,<br />
lists <span style="color: #008000;">=&gt;</span> lists<span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">BaseTemplate</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">101</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">ItemCount</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;Site Assets&quot;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;Style Library&quot;</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Hidden</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
<p>Unfortunately this would not even compile in Visual Studio 2010.</p>
<p>I decided to try implementing a more common syntax used in &#8216;if&#8217; statements &#8211; using &#8216;&amp;&amp;&#8217; to combine multiple conditions but within one .Where.</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">...</span><br />
<span style="color: #0000FF;">ctx</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>listcoll,<br />
lists <span style="color: #008000;">=&gt;</span> lists<span style="color: #008000;">.</span><span style="color: #0000FF;">Include</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span>, list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">ItemCount</span><span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>list <span style="color: #008000;">=&gt;</span> list<span style="color: #008000;">.</span><span style="color: #0000FF;">BaseTemplate</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">101</span> <span style="color: #008000;">&amp;&amp;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">ItemCount</span> <span style="color: #008000;">&gt;</span> <span style="color: #FF0000;">0</span> <span style="color: #008000;">&amp;&amp;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;Site Assets&quot;</span> <span style="color: #008000;">&amp;&amp;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;Style Library&quot;</span> <span style="color: #008000;">&amp;&amp;</span><br />
list<span style="color: #008000;">.</span><span style="color: #0000FF;">Hidden</span> <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></td></tr></tbody></table></div>
<p>YES &#8211; Success! Finally, listcoll finally had the libraries I needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/09/implementing-multiple-filters-in-linq-query-from-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging SharePoint 2010 Enterprise Edition Upgrade</title>
		<link>http://www.armedia.com/blog/2011/06/debugging-sharepoint-2010-enterprise-edition-upgrade/</link>
		<comments>http://www.armedia.com/blog/2011/06/debugging-sharepoint-2010-enterprise-edition-upgrade/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 18:07:53 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[ECM]]></category>
		<category><![CDATA[Enterprise Content Management]]></category>
		<category><![CDATA[records management]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1546</guid>
		<description><![CDATA[I&#8217;ve been doing my SharePoint development and testing using a locally installed instance of SharePoint. I originally installed my development environment following the instructions found in the MSDN library: &#8221;Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008&#8221; which is basically the foundation level version. This version of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing my SharePoint development and testing using a locally installed instance of SharePoint. I originally installed my development environment following the instructions found in the MSDN library: &#8221;<a href="http://msdn.microsoft.com/en-us/library/ee554869%28office.14%29.aspx">Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008</a>&#8221; which is basically the <a href="%22http:/sharepoint.microsoft.com/en-us/buy/Pages/Editions-Comparison.aspx">foundation</a> level version.</p>
<p>This version of SharePoint was fine for quite a while, but the day came that I needed to create and test features that are found at the Standard or Enterprise levels. The good news is that you can install SharePoint Enterprise on top of your current installation and preserve the work you have already done (well, almost as I will explain later).</p>
<p>Unfortunately this installation wasn&#8217;t terribly smooth. It might have gone easier if I had stopped the SharePoint services and IIS, but the installation does this so that probably would not make any difference.</p>
<p>SharePoint installation files come with a configuration xml file. The  MSDN article I referenced above instructs you to add a tag within that file to enable installation on a windows client. I did that but the installation failed with some error about missing Office parts. I forgot that, in my original installation, I edited my configuration file to look like the xml file example in the MSDN article. So, after uninstalling SharePoint and editing the  configuration file again the installation went fine. Even better, when I launched SharePoint it opened up my original site!</p>
<p>So far, so good. Now to check on the <a href="%22http:/msdn.microsoft.com/en-us/library/gg650433.aspx">Content Organizer</a> feature, which was what I was primarily interested in.</p>
<p>Horrors! That feature wasn&#8217;t there! I rebooted and to my relief the Content Organizer feature appeared. So, going to my site features admin page I click the feature to activate it. That action generated an error:</p>
<div>
<hr size="2" />
</div>
<p><em>The Site scoped feature being activated has a dependency on hidden Site Collection scoped feature &#8216;FeatureDefinition/0c8a9a47-22a9-4798-82f1-00e62a96006e&#8217; (ID: &#8217;0c8a9a47-22a9-4798-82f1-00e62a96006e&#8217;). Hidden features cannot be auto-activated across scopes. There may be one or more visible Site Collection scoped features that auto-activate the dependent hidden feature.</em></p>
<div>
<hr size="2" />
</div>
<p>What?! A file search came up with a Feature.xml file for the Document Routing Resources Feature. In that file there was a Hidden property set to &#8220;True.&#8221; After changing that to &#8220;False&#8221; (turns out the setting should be &#8220;True&#8221; which I corrected later) I tried the activation again. Got a little further &#8211; the error message clued me to enable the Enterprise Features in Document Collection. I went back through both &#8220;Manage Site Features&#8221; and &#8220;Site Collection Features&#8221; to make sure everything that might relevant was checked. Still not able to enable the Content Organizer feature.</p>
<p>OK, what to do next? In Central Admin (Update and Migration) I checked the &#8220;Enable Enterprise Features&#8221; link &#8211; the feature set was set to Enterprise, so that was OK. I noticed then the link for &#8220;Enable Features on Existing Sites.&#8221; Ahhh &#8211; that looked promising.  I checked the &#8220;enable&#8221; option and &#8220;OK.&#8221; The message back indicated success! Checking my site I found the Content Organizer was activated,  but then trying to add a content rule caused an error. Also when I deactivated the feature I could not reactivate it!</p>
<p>Looking at my Site Settings I noticed other anomalies: I saw &#8220;Navigation&#8221; rather than &#8220;Top Link Bar&#8221; under the &#8220;Look and Feel&#8221; section. I didn&#8217;t see &#8220;Term Store management&#8221; under &#8220;Site Administration.&#8221; So there was more wrong here than just the feature I was immediately interested in.</p>
<p>I next tried to create a new site based on the &#8220;Document Center&#8221; template knowing that Content Organizer would be one of the features. That failed completely with a message similar that I got when trying to enable the Content Organizer. I could create a Team Site, so SharePoint was not entirely broken.</p>
<p>One last thing I thought to try before completely uninstalling SharePoint. I deleted the Document Collection on my site. I then created a new Document Collection.</p>
<p>Finally &#8211; success! All the expected site features were there and they worked! I lost the work invested in my original site, but luckily it was more of a testbed so that was not a complete disaster for me.</p>
<p>So, removing the document collection for the root site fixed all the issues that appeared after updating my development SharePoint environment to the Enterprise Edition. It is an extreme action, though not as extreme as uninstalling and reinstalling SharePoint. I&#8217;m pretty sure that you can save your document collection and redeploy using some admin tools, but I&#8217;m not terribly familiar with them and  as I mentioned I wasn&#8217;t too concerned about losing the site. I had a couple other sites on the server that I deleted, so I don&#8217;t know if the enterprise features would have worked on them after removing the document collection on the root. That might be interesting to investigate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/06/debugging-sharepoint-2010-enterprise-edition-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SP Designer 2010 to Add Custom Buttons</title>
		<link>http://www.armedia.com/blog/2011/06/using-sp-designer-2010-to-add-custom-buttons/</link>
		<comments>http://www.armedia.com/blog/2011/06/using-sp-designer-2010-to-add-custom-buttons/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 18:16:51 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[Case Management]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[ECM Industry]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Content Management]]></category>
		<category><![CDATA[ECM]]></category>
		<category><![CDATA[enhancing performance]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1533</guid>
		<description><![CDATA[Sharepoint Designer  2010 provides a great quick way to add simple actions to your SharePoint application. I have a project that I wanted to add a couple buttons that would allow the user to navigate away from a &#8220;Drop-Off&#8221; library to the libraries where files are directed by my content organizer rules. So, without thought [...]]]></description>
			<content:encoded><![CDATA[<p>Sharepoint Designer  2010 provides a great quick way to add simple actions to your SharePoint application.</p>
<p>I have a project that I wanted to add a couple buttons that would allow the user to navigate away from a &#8220;Drop-Off&#8221; library to the libraries where files are directed by my content organizer rules. So, without thought to SP Designer I opened my VS 2010 and commenced to coding. The great thing about building your buttons in VS is the flexibility you have &#8211; but being so flexible means you have to build a lot even if you only want a little!</p>
<p>In this instance I only wanted my buttons in one library. Using VS2010 you start with an elements.xml file. Unfortunately the elements file can only point to a &#8220;type,&#8221; not a specific library or list. So, even though I only wanted to see my buttons in my &#8220;Drop Off&#8221; document library, all the document libraries would also display the buttons. You can certainly get around that by omitting the type and buttons and code them in or setting visibility, but I haven&#8217;t done that myself so I was less interested in getting the coding right and figuring out where to insert the coding.</p>
<p>Enter SharePoint Designer 2010. It provides an easy nterface for creating custom actions that aren&#8217;t complex. You can create buttons that will navigate to a form, initiate a workflow, or navigate to a URL. Even better, it only applies to the document library or list where you are adding the custom action &#8211; exactly what I wanted!</p>
<p>You can certainly add an image to your button &#8211; this was something I overlooked initially and was driving me crazy that I &#8220;couldn&#8217;t&#8221; add a button image! Well, of course you can add an image. Just move that scrollbar down on the side of the &#8220;Create Custom Action&#8221; screen to get to the &#8220;Advanced custome action options&#8221; &#8211; duh!</p>
<p>So, a couple limitations right off:</p>
<ul>
<li>You can&#8217;t create tabs, groups, or context groups with SP Designer so far as I can see</li>
<li>SP Designer placed my buttons in the &#8220;Manage&#8221; group of the &#8220;Documents&#8221; tab. There does not appear to be anyway to direct your buttons to a specific ribbon group or tab that you might prefer.</li>
</ul>
<p>In this case the SP Designer provided all the functionality I needed and saved me time I would have spent coding, testing, and deploying!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/06/using-sp-designer-2010-to-add-custom-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The latest word on SharePoint 2010 and CMIS REST bindings</title>
		<link>http://www.armedia.com/blog/2011/06/the-latest-word-on-sharepoint-2010-and-cmis-rest-bindings/</link>
		<comments>http://www.armedia.com/blog/2011/06/the-latest-word-on-sharepoint-2010-and-cmis-rest-bindings/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 18:34:42 +0000</pubDate>
		<dc:creator>dmiller</dc:creator>
				<category><![CDATA[CMIS]]></category>
		<category><![CDATA[Enterprise Content Management]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[ECM]]></category>
		<category><![CDATA[enhancing performance]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1487</guid>
		<description><![CDATA[A while back I described the problems I had checking files out of SharePoint 2010 using CMIS REST bindings (more specifically, using the excellent Apache Chemistry OpenCMIS client API for CMIS). At the time, it seemed odd to me Microsoft would release a CMIS stack missing this critical feature. Since then, I learned the SP2010 [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I <a href="http://www.armedia.com/blog/2011/05/cmis-sharepoint-2010-and-file-checkouts/">described the problems</a> I had checking files out of SharePoint 2010 using CMIS REST bindings (more specifically, using the excellent Apache Chemistry <a href="http://chemistry.apache.org/java/opencmis.html">OpenCMIS</a> client API for CMIS). At the time, it seemed odd to me Microsoft would release a CMIS stack missing this critical feature.</p>
<p>Since then, I learned the SP2010 CMIS stack&#8217;s REST bindings do provide a way to check files out; so the feature isn&#8217;t completely broken after all.  However, SP2010&#8242;s approach doesn&#8217;t seem compliant with the CMIS standard.  So, although it works and it is RESTful, it will never be supported by general-purpose CMIS tools such as OpenCMIS.</p>
<p>Below is a sample message sent by OpenCMIS to check out a document using the REST bindings.  This message <strong>is</strong> CMIS-compliant, and does <strong>not</strong> work with SP2010:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">'UTF-8'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:entry</span> <span style="color: #000066;">xmlns:atom</span>=<span style="color: #ff0000;">'http://www.w3.org/2005/Atom'</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">xmlns:cmis</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/core/200908/'</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">xmlns:cmisra</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/restatom/200908/'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>urn:uuid:00000000-0000-0000-0000-00000000000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:title<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/atom:title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2011-05-03T15:23:45Z<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmisra:object</span> <span style="color: #000066;">xmlns:ns3</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/messaging/200908/'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:propertyId</span> <span style="color: #000066;">propertyDefinitionId</span>=<span style="color: #ff0000;">'cmis:objectId'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1-3584<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmis:value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmis:propertyId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmis:properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmisra:object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Below is the message that should be sent to SP2010 to successfully check out a document.  This message is <strong>not</strong> CMIS-compliant (as far as I can tell, anyway), and <strong>does</strong> work with SP2010:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">'1.0'</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">'UTF-8'</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:entry</span> <span style="color: #000066;">xmlns:atom</span>=<span style="color: #ff0000;">'http://www.w3.org/2005/Atom'</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">xmlns:cmis</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/core/200908/'</span></span><br />
<span style="color: #009900;"><span style="color: #000066;">xmlns:cmisra</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/restatom/200908/'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>urn:uuid:00000000-0000-0000-0000-00000000000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:title<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/atom:title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;atom:updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2011-05-03T15:23:45Z<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmisra:object</span> <span style="color: #000066;">xmlns:ns3</span>=<span style="color: #ff0000;">'http://docs.oasis-open.org/ns/cmis/messaging/200908/'</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:objectId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1-3584<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmis:objectId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cmisra:object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/atom:entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>The OpenCMIS request (shown first) includes a property list, with the CMIS object ID as the only property. The SP2010 request (shown second) does not include a property list, just a <code class="codecolorer xml default"><span class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:objectId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></span></code> tag.</p>
<p>That <code class="codecolorer xml default"><span class="xml"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cmis:objectId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></span></code> tag is what makes the SP2010 request non-compliant.  The <a href="http://docs.oasis-open.org/cmis/CMIS/v1.0/os/CMIS-Core.xsd">CMIS Core XML Schema</a> defines no such tag; &#8220;cmis:objectId&#8221; appears only as an enum value for a property name (as shown in the OpenCMIS request).</p>
<p>Suppose you really wanted to use the REST bindings, what should you do? Well, you have to write a wrapper around OpenCMIS (or your other client CMIS stack of choice). The file checkout code in your wrapper bypasses your CMIS client stack, and issues a message as shown above, using whichever HTTP client software you are comfortable with. HTTP client software is pretty easy to work with, but don&#8217;t forget to parse the response and deal with the many different error codes that might be returned!</p>
<p>In reality this seems like too much work, especially since SP2010&#8242;s WSDL bindings seem to work just fine. So my advice is unchanged: Avoid the CMIS REST bindings if you plan to support SharePoint 2010 (or think you may support it in the future).  Stick with the WSDL bindings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/06/the-latest-word-on-sharepoint-2010-and-cmis-rest-bindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding and Removing SharePoint Features &#8211; Painful Lessons Learned</title>
		<link>http://www.armedia.com/blog/2011/06/adding-and-removing-sharepoint-features-painful-lessons-learned/</link>
		<comments>http://www.armedia.com/blog/2011/06/adding-and-removing-sharepoint-features-painful-lessons-learned/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 17:59:40 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Content Management]]></category>
		<category><![CDATA[ECM]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1432</guid>
		<description><![CDATA[My SharePoint development environment is my laptop. In this environment I have developed various kinds of web parts and have been deploying them to my local instance of SharePoint. So of course, the day came when I wanted to deploy my web part to an actual server. (why else would you be doing development!)   Many of the blogs I [...]]]></description>
			<content:encoded><![CDATA[<p>My SharePoint development environment is my laptop. In this environment I have developed various kinds of web parts and have been deploying them to my local instance of SharePoint. So of course, the day came when I wanted to deploy my web part to an actual server. (why else would you be doing development!)  </p>
<p>Many of the blogs I read say that you need to develop and deploy on the actual server. This strategy has never made sense to me. And, of course, the strategy wasnt where my confusion ended. There are any number of references for doing this. <a href="http://msdn.microsoft.com/en-us/library/ff597539.aspx">MSDN Library: Create Visual Web Parts for SharePoint 2010</a> for creating a web part. <a href="http://technet.microsoft.com/en-us/library/cc262995.aspx">Technet &#8211; Deploy Solution</a>, and <a href="http://technet.microsoft.com/en-us/library/ff607680.aspx">Technet &#8211; Deploy Feature</a> for deploying. Essentially the steps are to (using Visual Studio 2010)</p>
<ol>
<li>Create a web part</li>
<li>Deploy</li>
<li>Copy solution file (.wsp) to the SharePoint server</li>
<li>Add the solution to the web site using the SharePoint Management Shell console.</li>
<li>Deploy using either the SharePoint Management Shell or Central Administrator.</li>
</ol>
<p>So I build and deploy my solution and copy to file to the server. You can find the solution file by opening the Solution Explorer in VS2010 and checking the &#8220;Project Folder&#8221; property of your project. For me this path is &#8220;C:\Users\tlisko\Documents\Visual Studio 2010\Projects\mywebpart\&#8221;.  Then open the &#8220;\bin\Release&#8221; folder where you should find one &#8220;.dll&#8221;, one &#8220;.wsp&#8221;, and one &#8220;.pdb&#8221; file of your solution.</p>
<p>I logged in to the SharePoint server as the administrator, then added and deployed the solution just fine. Opening my SharePoint site I inserted the new web part into a page. I decided that I wanted to make a change to it. No problem, just make the change in Visual Studio and repeat the deployment process.</p>
<p>Doesn&#8217;t work that way, at least not completely. I copied the file, but since the old wsp file was there I had to use a different file name. No big deal. Then I tried to execute the &#8220;update-spsolution&#8221; cmdlet in the SharePoint Management Shell. That seemed to run fine. When I opened the Central Administration web site the solution status indicated that it was updating(deploying). Funny thing, the status never changed! To me that meant something wasn&#8217;t working &#8211; perhaps had I waited longer it would have worked, but I don&#8217;t think so.</p>
<p>So, I cancelled the deployment and tried to retract. Once again, once status was set to &#8220;retracting&#8221; there was no completion. I then removed the new web part from the web site where it was deployed. Tried retracting the solution again, but no luck. Ok, now I&#8217;m getting serious! <img src='http://www.armedia.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Going back to the SP Management Shell I see that the the solution appears as deployed. So &#8211; I run the &#8220;uninstall&#8221; cmdlet but, of course, it says the solution is deployed. Run again with -AllWebApplications flag. Seems to work. Now I want to remove the solution. When I run that cmdlet I get an error about only machine administrators being allowed to create service job definitions!</p>
<p>Ok &#8211; now what. It made sense to me that the admin user I was logged in as needed to be owner of the content databases in SQL Server (though I wouldn&#8217;t have been able to deploy in the first place if that wasn&#8217;t the case). SQL Server permissions are fine. But, I observed that the SQL Agent wasn&#8217;t running. Not sure if that would help I started it anyway. What else can I do? Well there is a &#8220;force&#8221; flag in the &#8220;Remove&#8221; cmdlet. Yup, same results as before. Still get the error.</p>
<p>When all attempts fail, try rebooting&#8230;That made things worse  &#8211; SP wasn&#8217;t working anymore! (for reasons I do not wish to disclose on the grounds it will incriminate me!) I got the SP site working again, but naturally the problem of removing the solution remained.</p>
<p>Doing a web search I found a blog by JPPinto.com that addressed this very <a href="http://www.jppinto.com/2010/10/error-only-machine-administrators-are-allowed-to-create-administration-service-job-definitions-of-type">error</a>! As unlikely as it seemed the cause of all this pain was due to the infamous User Account Control (UAC). Once I disabled that everything worked!</p>
<p>Just another day at the office&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/06/adding-and-removing-sharepoint-features-painful-lessons-learned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CMIS, SharePoint 2010, and File Checkins</title>
		<link>http://www.armedia.com/blog/2011/06/cmis-sharepoint-2010-and-file-checkins/</link>
		<comments>http://www.armedia.com/blog/2011/06/cmis-sharepoint-2010-and-file-checkins/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 21:32:52 +0000</pubDate>
		<dc:creator>dmiller</dc:creator>
				<category><![CDATA[CMIS]]></category>
		<category><![CDATA[ECM Industry]]></category>
		<category><![CDATA[Enterprise Content Management]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[ECM]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1403</guid>
		<description><![CDATA[A while back I wrote about checking out a SharePoint 2010 file using CMIS.  Getting checkout working excited me so much I forgot to try checking the file back in! Turns out there are a few tricks. We use Apache Chemistry as our CMIS client.  Chemistry&#8217;s checkin method allows you to provide a file content [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I wrote about <a href="http://www.armedia.com/blog/2011/05/cmis-sharepoint-2010-and-file-checkouts/">checking out a SharePoint 2010 file using CMIS</a>.  Getting checkout working excited me so much I forgot to try checking the file back in!</p>
<p>Turns out there are a few tricks.</p>
<p>We use <a href="http://chemistry.apache.org/">Apache Chemistry</a> as our CMIS client.  Chemistry&#8217;s checkin method allows you to provide a file content stream, such that the act of checking the file in also updates the file contents:</p>
<p>checkin(boolean major, Map&lt;String,?&gt; properties, ContentStream contentStream, String checkinComment)</p>
<p>However, sending a non-null contentStream to this method makes it fail!  You will get the famous &#8220;object reference not set to an instance of an object&#8221; message.  You <em>must</em> send null for this parameter.  So how do you update the file contents?  Right before the checkin, you can call the setContentStream method, as illustrated in the below code snippet.</p>
<p>Also, in the properties parameter, you must provide a property for the object name.  This is also illustrated in the below snippet.  You may provide other properties if you want, but if you don&#8217;t provide the object name, the checkin will fail.</p>
<p>The JUnit test case below illustrates how to connect to SP2010 via WSDL, find an object by path, check out the object, update its content stream, and check it back in.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.armedia.acm.ecm.service</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.math.BigInteger</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.api.Document</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.api.ObjectId</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.api.Repository</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.api.Session</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.api.SessionFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.PropertyIds</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.SessionParameter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.data.ContentStream</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.enums.BindingType</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.Test</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
*<br />
* @author millerd<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SharePointWSDLTest<br />
<span style="color: #009900;">&#123;</span><br />
<br />
@Test<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> connectViaWsdl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #003399;">String</span> cwd <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Working dir: &quot;</span> <span style="color: #339933;">+</span> cwd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// Default factory implementation of client runtime.</span><br />
SessionFactory sessionFactory <span style="color: #339933;">=</span> SessionFactoryImpl.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">Map</span> parameter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// User credentials.</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">USER</span>, <span style="color: #0000ff;">&quot;some_user&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">PASSWORD</span>, <span style="color: #0000ff;">&quot;some_password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// relative file-based URL works fine so long as you give it the</span><br />
<span style="color: #666666; font-style: italic;">// right relative path... ie. you have to know what the current</span><br />
<span style="color: #666666; font-style: italic;">// working directory is.</span><br />
<span style="color: #003399;">String</span> wsdl <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;file:target/classes/acmv2-sharepoint.wsdl&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// Connection settings.</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">BINDING_TYPE</span>, <span style="color: #003399;">BindingType</span>.<span style="color: #006633;">WEBSERVICES</span>.<span style="color: #006633;">value</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_ACL_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_DISCOVERY_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_MULTIFILING_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_NAVIGATION_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_OBJECT_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_POLICY_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_RELATIONSHIP_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_REPOSITORY_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">WEBSERVICES_VERSIONING_SERVICE</span>, wsdl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
parameter.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>SessionParameter.<span style="color: #006633;">AUTHENTICATION_PROVIDER_CLASS</span>,<br />
CmisBindingFactory.<span style="color: #006633;">STANDARD_AUTHENTICATION_PROVIDER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Create session.</span><br />
Session session <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003399;">List</span> repositories <span style="color: #339933;">=</span> sessionFactory.<span style="color: #006633;">getRepositories</span><span style="color: #009900;">&#40;</span>parameter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003399;">Repository</span> rep <span style="color: #339933;">:</span> repositories <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// My test file is in the &quot;Unapproved Files&quot; repository</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Unapproved Files&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>rep.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
session <span style="color: #339933;">=</span> rep.<span style="color: #006633;">createSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">Document</span> doc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Document</span><span style="color: #009900;">&#41;</span><br />
session.<span style="color: #006633;">getObjectByPath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/2011/05/03/10/31/19/dave-sharepoint.wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Doc ID: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span> doc <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #0000ff;">&quot; *NOT FOUND* &quot;</span> <span style="color: #339933;">:</span> doc.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> doc <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">try</span><br />
<span style="color: #009900;">&#123;</span><br />
ObjectId co <span style="color: #339933;">=</span> doc.<span style="color: #006633;">checkOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Checked out doc ID: &quot;</span> <span style="color: #339933;">+</span> co.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>CmisBaseException cbe<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Exception checking out; must be &quot;</span> <span style="color: #339933;">+</span><br />
<span style="color: #0000ff;">&quot;checked out already: &quot;</span> <span style="color: #339933;">+</span> cbe.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// create a new content stream to update the file contents</span><br />
<span style="color: #003399;">InputStream</span> is <span style="color: #339933;">=</span> <span style="color: #003399;">Thread</span>.<span style="color: #006633;">currentThread</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<br />
<span style="color: #006633;">getContextClassLoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResourceAsStream</span><span style="color: #009900;">&#40;</span><br />
<span style="color: #0000ff;">&quot;dave-sharepoint.wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">boolean</span> majorVersion <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">Map</span> props <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// Object name MUST b eprovided</span><br />
props.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>PropertyIds.<span style="color: #006633;">NAME</span>, <span style="color: #0000ff;">&quot;dave-sharepoint&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
BindingsObjectFactory bof <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BindingsObjectFactoryImpl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
ContentStream csNew <span style="color: #339933;">=</span> bof.<span style="color: #006633;">createContentStream</span><span style="color: #009900;">&#40;</span><br />
<span style="color: #0000ff;">&quot;dave-sharepoint.wsdl&quot;</span>,<br />
<span style="color: #003399;">BigInteger</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>is.<span style="color: #006633;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>,<br />
<span style="color: #0000ff;">&quot;text/plain&quot;</span>,<br />
is<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// OPTIONAL: update the file content stream</span><br />
doc.<span style="color: #006633;">setContentStream</span><span style="color: #009900;">&#40;</span>csNew, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// NOTE: DO NOT send a content stream in the checkIn call!</span><br />
<span style="color: #666666; font-style: italic;">// the call will fail</span><br />
ObjectId ci <span style="color: #339933;">=</span> doc.<span style="color: #006633;">checkIn</span><span style="color: #009900;">&#40;</span><br />
majorVersion,<br />
props,<br />
<span style="color: #000066; font-weight: bold;">null</span>,<br />
<span style="color: #0000ff;">&quot;test checkin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Object ID after checkin: &quot;</span> <span style="color: #339933;">+</span> ci.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/06/cmis-sharepoint-2010-and-file-checkins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOW TO: Retrieve and Display CMIS data in SharePoint using REST Atom Service</title>
		<link>http://www.armedia.com/blog/2011/05/how-to-retrieve-and-display-cmis-data-in-sharepoint-using-rest-atom-service/</link>
		<comments>http://www.armedia.com/blog/2011/05/how-to-retrieve-and-display-cmis-data-in-sharepoint-using-rest-atom-service/#comments</comments>
		<pubDate>Tue, 31 May 2011 14:16:42 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[CMIS]]></category>
		<category><![CDATA[Enterprise Content Management]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[RESTAtom]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1270</guid>
		<description><![CDATA[In a previous blog I discussed &#8220;how to&#8221; enable the Content Management Interoperability Service (CMIS) in SharePoint 2010. In that blog I also reviewed the SharePoint built in Web Part for getting data from a CMIS enabled site using WSDL. In this blog I will show how you can access CMIS data in SharePoint using [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous <a href="http://www.armedia.com/blog/2011/05/how-to-sharepoint-2010-–-implementing-cmis/">blog</a> I discussed &#8220;how to&#8221; enable the Content Management Interoperability Service (CMIS) in SharePoint 2010. In that blog I also reviewed the SharePoint built in Web Part for getting data from a CMIS enabled site using WSDL.</p>
<p>In this blog I will show how you can access CMIS data in SharePoint using the REST Atom Service. I borrowed primarily from Jaspers’ <a href="http://jsiegmund.wordpress.com/2010/04/25/sp2010-rest-data-sources-within-sharepoint-designer/">Weblog</a> for how to do this and from the msdn guidance for implementing CMIS. I ran into one problem along the way which I will discuss at the end.</p>
<p>The first step in getting data from a REST Atom Service is to create a data provider control in SharePoint.</p>
<p style="margin-bottom: 6pt; font-size: 10pt; text-decoration: underline;">Creating a REST Atom Service data provider control in SharePoint 2010</p>
<p><span style="margin-bottom: 6pt; Steps:</span></p>
<p style="margin-bottom: 6pt;"><span style="margin-left: 12pt;">1) Open SharePoint Designer and open the site you wish to display the remote data</span><br />
<span style="margin-left: 12pt;">2) Select “Data Sources” from the list of Site Objects in the navigation panel on the left part of the screen.</span><br />
<span style="margin-left: 12pt;">3) Click the “REST Service Connection” button from the “Data Sources” ribbon.</span></p>
<p><span style="margin-bottom: 0pt;">A dialog box for entering Data Source Properties will open. Enter the properties as follows.</span></p>
<p style="margin-bottom: 6.0pt; margin-left: 12pt;"><span style="text-decoration: underline;">General Tab</span><br />
Enter any name, description, and keywords that you wish</p>
<p style="margin-left: 12pt; margin-bottom: 6.0pt;"><span style="text-decoration: underline;">Source Tab</span><br />
<span style="margin-left: 18pt;">• Choose a HTTP method and data command.</span><br />
<span style="margin-left: 18pt;">• Enter connection URL. </span></p>
<p style="margin-bottom: 6.0pt; margin-left: 12pt;"><span style="text-decoration: underline;">MSDN URL Format</span><br />
http://<span style="color: #f4a460;">Site URL</span>/_vti_bin/cmis/rest/<span style="color: #4169e1;">[Library or List GUID]?command</span><br />
<span style="text-decoration: underline; margin-bottom: 6.0pt;">Example</span><br />
<span style="margin-bottom: 6.0pt;">http://<span style="color: #f4a460;">armws2008sp-01:2397</span>/_vti_bin/cmis/rest/<span style="color: #4169e1;">EF9A4CB3-BEF0-44B3-975A-611601D47425?getRepositoryInformation</span></span></p>
<p style="margin-left: 12pt; margin-bottom: 0pt; text-decoration: underline;">Jasper’s Weblog URL Format:</p>
<p><span style="margin-left: 12pt; margin-bottom: 6.0pt;">http://<span style="color: #f4a460;">web.site.com/sub/site/</span>_vti_bin/ListData.svc/<span style="color: #4169e1;">ListName</span></span><br />
<span style="text-decoration: underline; margin-left: 12pt; margin-bottom: 0pt;">Example</span><br />
<span style="margin-left: 12pt; margin-bottom: 6.0pt;">http://<span style="color: #f4a460;">armws2008sp-01:2397</span>/_vti_bin/ListData.svc/<span style="color: #4169e1;">SharedDocuments</span></span></p>
<p><span style="margin-left: 12pt; margin-bottom: 6.0pt;"><span style="text-decoration: underline;">Login Tab</span><br />
<span style="margin-left: 18pt;">• Select “Save this username and password in the connection”</span><br />
<span style="margin-left: 18pt;">• Enter the username and password.</span></p>
<p style="margin-left: 12pt;">4) Click “OK” to save.</p>
<p style="margin-left: 12pt; margin-bottom: 6.0pt;">All examples in step 3 work fine in the Firefox REST client extension. You would act on data in lists and libraries following the syntax from the MSDN example. In this case you have to have the GUID of the list or library. You get a list of lists and libraries, list items, and documents and their GUIDs following the example in Jasper’s web log.</p>
<p style="text-decoration: underline; margin-bottom: 6.0pt; font-size: 10.0pt;">Displaying REST provider data in a DataView</p>
<p><span style="margin-bottom: 6.0pt;">The following provides instructions for implementing a SharePoint DataView using a REST provider. This information comes primarily from Jaspers’ Web log.</span></p>
<p style="margin-left: 12pt;">1) Open the SharePoint site where REST/CMIS data is to be displayed in SharePoint Designer<br />
2) Open the page where you wish to insert the DataView<br />
3) Select the “Insert” ribbon.<br />
4) Select the “Data View” button from the ribbon and select the REST data source.</p>
<p>You can modify the presentation of the data view and which fields are shown while looking at the web part’s properties while still in SharePoint Designer.</p>
<p style="text-decoration: underline; margin-bottom: 6.0pt; font-size: 10.0pt;">REST Data Issue</p>
<p>I ran into a problem trying to get the CMIS data to display in the DataView control. I used the REST client extension in Firefox to investigate the problem. The response I would get started with</p>
<p style="margin-left: 12pt;">Status Code: 405 Method Not Allowed</p>
<p>For reasons I don&#8217;t recall &#8211; possibly inspecting events in the windows event viewer of the server I was targeting in my URL &#8211; my next step was to test the ListData.svc, which you can do by opening a browser to the ListData.svc URL:</p>
<p style="margin-left: 12pt;">http://<span style="color: #f4a460;">Web site or Localhost</span>/_vti_bin/listdata.svc/<br />
http://<span style="color: #f4a460;">armws2008sp-01:2397</span>/_vti_bin/ListData.svc/, for example</p>
<p>The error I got back was</p>
<p style="margin-left: 12pt;">&#8220;Could not load type ‘System.Data.Services.Providers.IDataServiceUpdateProvider’ from assembly ‘System.Data.Services, Version=3.5.0.0…’&#8221;</p>
<p>A google search brought me to “Michael’s coding thoughts” <a href="http://blog.hompus.nl/2010/03/26/could-not-load-type-idataserviceupdateprovider-when-using-rest-with-sharepoint-2010/">blog</a>. His similar issue was solved by installing an update to ADO.NET Data Services, which has in it the REST services.</p>
<p>In retrospect I should have checked if I had the updated dll version before running the update installation. Looking at the GAC it appeared to be version 3.5.0 which didn’t change after running the update. I finally realized I had to select the file and view its properties to verify the actual version In any event, that did not make the problem go away for me.</p>
<p>Further searching led me to the” XML Journal” <a href="http://xml.sys-con.com/node/1256846">blog</a> which identified the absence of ADO.NET Data Services 1.5 CTP2 as the cause of this issue. I installed this <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a71060eb-454e-4475-81a6-e9552b1034fc&amp;displaylang=en">software</a>, though for me, as for the author, it did not appear to fix the problem. Following his example I rebooted the server and the problem went away – just as it did for the blog author.</p>
<p>With any luck this information will help you if you are trying to implement CMIS in SharePoint 2010!</p>
<p></span> </p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/05/how-to-retrieve-and-display-cmis-data-in-sharepoint-using-rest-atom-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q: Why should I test my CMIS application against multiple repositories?</title>
		<link>http://www.armedia.com/blog/2011/05/q-why-should-i-test-my-cmis-application-against-multiple-repositories/</link>
		<comments>http://www.armedia.com/blog/2011/05/q-why-should-i-test-my-cmis-application-against-multiple-repositories/#comments</comments>
		<pubDate>Thu, 26 May 2011 20:30:27 +0000</pubDate>
		<dc:creator>dmiller</dc:creator>
				<category><![CDATA[Alfresco]]></category>
		<category><![CDATA[CMIS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ECM]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1249</guid>
		<description><![CDATA[A: To uncover my hidden assumptions! Let me tell you a story about SharePoint, Alfresco, design choices, and downloading files. My Java-based application uses SharePoint 2010 to store files.  CMIS is the obvious tool for my app to talk to SP 2010, and in fact, CMIS and SP2010 work just fine together, as you may [...]]]></description>
			<content:encoded><![CDATA[<p>A: To uncover my hidden assumptions!</p>
<p>Let me tell you a story about SharePoint, Alfresco, design choices, and downloading files.</p>
<p>My Java-based application uses SharePoint 2010 to store files.  <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis">CMIS </a>is the obvious tool for my app to talk to SP 2010, and in fact, CMIS and SP2010 work just fine together, as you may have gathered from my colleague Tim Lisko&#8217;s <a href="http://www.armedia.com/blog/2011/05/how-to-accessing-sharepoint-2010-from-java-application/">last</a> <a href="http://www.armedia.com/blog/2011/05/how-to-sharepoint-2010-%E2%80%93-implementing-cmis/">few</a> articles.</p>
<p>So it came time for me to write the download feature, thus allowing users to download the files stored in SP2010 from my application.  Chemistry makes it very easy to retrieve a file object by ID:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">InputStream</span> getFileContentStream<span style="color: #009900;">&#40;</span>Session session, <span style="color: #003399;">String</span> objectId<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">try</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #003399;">Document</span> file <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Document</span><span style="color: #009900;">&#41;</span> session.<span style="color: #006633;">getObject</span><span style="color: #009900;">&#40;</span>objectId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
ContentStream csFile <span style="color: #339933;">=</span> file.<span style="color: #006633;">getContentStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #003399;">InputStream</span> retval <span style="color: #339933;">=</span> csFile.<span style="color: #006633;">getStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">return</span> retval<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>CmisBaseException cbe<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> AcmRepositoryException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Could not get file contents&quot;</span>,<br />
cbe<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>So I said to myself: OK, I&#8217;ll just construct a URL including the CMIS object ID, then I&#8217;ll pass that object ID straight through to my Java method.</p>
<p>All you guys that have used CMIS against both Alfresco and SharePoint (hi <a href="http://www.armedia.com/blog/2011/05/cmis-sharepoint-2010-and-file-checkouts/comment-page-1/#comment-1385">Colin</a>!) know what&#8217;s coming next.</p>
<p>SP2010&#8242;s object ID looks like this: 42-512.  So my URL&#8217;s looked like this:</p>
<p>http://&lt;host&gt;/&lt;context&gt;/docs/download/2316/42-512</p>
<p>No problems here!  A nice valid URL, and my download code worked great!</p>
<p>So yesterday, I had an idea (actually, my boss had the idea). Let&#8217;s stand up the app against Alfresco!</p>
<p>Alfresco&#8217;s object IDs turn out to look like this:</p>
<p>workspace://SpacesStore/ecd60ff9-adbb-45fb-824d-9bc93aa61b0f</p>
<p>Which turned my download URL into this grim-looking thing:</p>
<p>http://&lt;host&gt;/&lt;context&gt;/docs/download/2316/workspace://SpacesStore/ecd60ff9-adbb-45fb-824d-9bc93aa61b0f</p>
<p>I&#8217;ll leave what happened when I clicked that link to your imagination (hint: it wasn&#8217;t pretty!).</p>
<p>Since I wanted to be up and running on Alfresco pretty quickly, I applied a short-term fix: I replace the colons and slashes in the object ID with strings that should not be part of any real object ID, and my download controller reverses the process.  Now my URLs look like this:</p>
<p>http://&lt;host&gt;/&lt;context&gt;/docs/download/2316/workspace-c!&#8211;s!&#8211;s!-SpacesStore-s!-ecd60ff9-adbb-45fb-824d-9bc93aa61b0f</p>
<p>The good: the download code works again.  The bad: I shouldn&#8217;t have to encode and decode my own download URL this way!  The ugly: as you can see, the aesthetics of the above URL leave a lot to be desired.</p>
<p>The long-term fix (by &#8220;long-term&#8221; I mean &#8220;by Monday&#8221;) is to not place the object ID in the URL in the first place, and use an opaque sequence-driven numeric database ID instead.  Then all my URLs will look like this, no matter what repository is in use at the moment:</p>
<p>http://&lt;host&gt;/&lt;context&gt;/docs/download/2316/42</p>
<p>Why didn&#8217;t I do this in the first place?  Well, I certainly should have.  For the most part I would never use a natural key such as the CMIS object ID in this situation.  I&#8217;m pretty sure I was trying to avoid a database lookup.  In the end I needed to do a database lookup anyway, but it never occurred to me to rethink my earlier design choices.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/05/q-why-should-i-test-my-cmis-application-against-multiple-repositories/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint 2010 &#8211; REST Atom Service and JAVA, part 2</title>
		<link>http://www.armedia.com/blog/2011/05/sharepoint-2010-rest-atom-service-and-java-part-2/</link>
		<comments>http://www.armedia.com/blog/2011/05/sharepoint-2010-rest-atom-service-and-java-part-2/#comments</comments>
		<pubDate>Thu, 26 May 2011 20:09:22 +0000</pubDate>
		<dc:creator>Tim Lisko</dc:creator>
				<category><![CDATA[CMIS]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Solutions]]></category>
		<category><![CDATA[JAVA]]></category>

		<guid isPermaLink="false">http://www.armedia.com/blog/?p=1238</guid>
		<description><![CDATA[This is the second of two blogs where I demonstrate how to use the openCMIS library from a JAVA client to connect to a CMIS enabled SharePoint site through the REST Atom service of SharePoint. My previous blog “SharePoint 2010 – REST Atom Service.” provided information on how to connect to a SharePoint site and [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second of two blogs where I demonstrate how to use the openCMIS library from a JAVA client to connect to a CMIS enabled SharePoint site through the REST Atom service of SharePoint.</p>
<p>My previous blog <a href="http://www.armedia.com/blog/2011/05/how-to-accessing-sharepoint-2010-from-java-application/"><em>“SharePoint 2010 – REST Atom Service.”</em></a> provided information on how to connect to a SharePoint site and examined some of the SharePoint site&#8217;s capabilities. In this blog I will show how to use the openCMIS library and REST Atom Service to: 1) Access and Create Folders; 2) Iterate over SharePoint folders; and 3) Add documents to a SharePoint folder. This blog builds on the previous one, so reference it if you aren&#8217;t able to follow the code in this one.</p>
<p style="font-family: Calibri; font-size: 14px; margin-bottom: 3.0pt;"><em>Accessing and Creating SharePoint Folders</em></p>
<p style="margin-bottom: 4.0pt;">The following exmple will show you how to get and create folder objects. An additional class library is imported for accessing folders and another for getting a CMIS object by path.</p>
<table>
<tbody>
<tr>
<td> </td>
<td style="background-color: #f2f2f2; border: 1px solid; font-family: Tahoma; font-size: 13px; padding: 6px;">…<br />
import org.apache.chemistry.opencmis.client.api.Folder;<br />
import org.apache.chemistry.opencmis.client.api.CmisObject;<br />
…<br />
Folder folder = session.getRootFolder();<br />
String folderprops=twolines + &#8220;ROOT FOLDER:&#8221; + newline +<br />
tab + &#8220;ID: &#8221; + folder.getId().toString() + newline +<br />
tab + &#8220;name: &#8221; + folder.getName() + newline +<br />
tab + &#8220;path: &#8221; + folder.getPath();//create new folder in the root folder<br />
Map properties = new HashMap();<br />
properties.put(PropertyIds.OBJECT_TYPE_ID, &#8220;cmis:folder&#8221;);<br />
properties.put(PropertyIds.NAME, “mynewfolder”);<br />
Folder newFolder = folder.createFolder(properties);//Check properties<br />
String folderprops=twolines + &#8220;NEW FOLDER:&#8221; + newline +<br />
tab + &#8220;ID: &#8221; + newFolder.getId().toString() + newline +<br />
tab + &#8220;name: &#8221; + newFolder.getName() + newline +<br />
tab + &#8220;path: &#8221; + newFolder.getPath();</p>
<p>//Get another folder by path that already exists; CmisObject does not have a “getPath” method,<br />
//so convert it to a CMIS folder<br />
CmisObject cmisObj = session.getObjectByPath(&#8220;/2011&#8243;);<br />
Folder fo = (Folder) cmisObj;</p>
<p>//Check properties<br />
folderprops=twolines + &#8220;2011 FOLDER:&#8221; + newline +<br />
tab + &#8220;ID: &#8221; + fo.getId().toString() + newline +<br />
tab + &#8220;name: &#8221; + fo.getName() + newline +<br />
tab + &#8220;path: &#8221; + fo.getPath();</td>
</tr>
</tbody>
</table>
<div style="margin-bottom: .0001pt; text-align: left; line-height: normal;">
<div><span style="font-size: 8.0pt;"> </span></div>
<hr size="1" />
<p> </p>
<p style="margin-bottom: .6pt; line-height: normal; page-break-after: avoid;">Results:</p>
<table width="50">
<tbody>
<tr>
<td> </td>
<td style="background-color: #ffffcc; border: 1px solid; font-family: Tahoma; font-size: 13px; padding: 12px; width: 100;">ROOT FOLDER:<br />
ID: -1<br />
name: Shared Documents<br />
path: /NEW FOLDER:<br />
ID: 87<br />
name: mynewfolder<br />
path: /mynewfolder2011 FOLDER:<br />
ID: 83<br />
name: 2011<br />
path: /2011</td>
</tr>
</tbody>
</table>
<p><br\></p>
<p style="margin-bottom: .0001pt; line-height: normal;">Things to note:</p>
<p style="margin-left: 12pt;">1) The path is relative to the Repository, so the “Shared Documents” library could be accessed at its top level with the path “/”.</p>
<p style="font-family: Calibri; font-size: 14px; margin-bottom: 3.0pt;"><em>Iterating over SharePoint Folders</em></p>
<p style="margin-bottom: .0001pt; line-height: normal;">The following exmple will show you how to iterate over the folder objects. An additional class library is imported iterating over CMIS objects.<br />
<span style="font-size: 8.0pt;"> </span></p>
<table>
<tbody>
<tr>
<td> </td>
<td style="background-color: #f2f2f2; border: 1px solid; font-family: Tahoma; font-size: 13px; padding: 12px;">…<br />
import org.apache.chemistry.opencmis.client.api.ItemIterable;<br />
…<br />
FileList.setText(&#8220;FOLDER (Name; ID)&#8221; + newline + tab + &#8220;CHILDREN (Name; ID)&#8221;);folder = session.getRootFolder();<br />
FileList.append(twolines+folder.getName()+&#8221;; &#8221; + folder.getId());<br />
tabs = tab;<br />
this.getKids(folder);<br />
}</p>
<p>private void getKids(Folder folder) {<br />
//recursive method to go through library</p>
<p>ItemIterable children = folder.getChildren();<br />
for ( CmisObject obj : children )<br />
{<br />
if(obj.getBaseTypeId().toString()!=&#8221;CMIS_FOLDER&#8221;)<br />
{<br />
FileList.append(newline+tabs+obj.getName()+&#8221;; &#8221; + obj.getId());<br />
}<br />
}<br />
children = folder.getChildren();<br />
for ( CmisObject obj : children )<br />
{<br />
if(obj.getBaseTypeId().toString()==&#8221;CMIS_FOLDER&#8221;)<br />
{<br />
folder = (Folder) obj;<br />
FileList.append(newline+tabs+&#8221;/&#8221; + folder.getName()+&#8221;; &#8221; + folder.getId());<br />
tabs = tabs + tab;<br />
this.getKids(folder);<br />
   }<br />
  }<br />
}</td>
</tr>
</tbody>
</table>
<div style="margin-bottom: .0001pt; text-align: left; line-height: normal;">
<br\></p>
<p style="margin-bottom: .6pt; line-height: normal; page-break-after: avoid;">Results:</p>
</div>
<table>
<tbody>
<tr>
<td> </td>
<td style="background-color: #ffffcc; border: 1px solid; font-family: Tahoma; font-size: 13px; padding: 12px;">FOLDER (Name; ID)<br />
CHILDREN (Name; ID)Shared Documents; -1<br />
/2011; 83<br />
/05; 84<br />
/03; 85</td>
</tr>
</tbody>
</table>
<div style="margin-bottom: .0001pt; text-align: left; line-height: normal;"><span style="font-size: 8.0pt;"> </span></div>
<p style="margin-bottom: .0001pt; line-height: normal;">Things to note:</p>
<p style="margin-left: 12pt;">1) The root ID of SharePoint libraries is always “-1”<br />
2) You can detect and display properties of files within the folders by using the base type “CMIS_DOCUMENT”.<br />
3) The document ID produced from CMIS_DOCUMENT is not the one you see exposed in the SharePoint GUI, but it is the one you use to access a document in CMIS.</p>
<p style="font-family: Calibri; font-size: 14px; margin-bottom: 3.0pt;"><em>Adding a Document to a Folder</em></p>
<p style="margin-bottom: .0001pt; line-height: normal;">Putting documents into a SharePoint folder is typical operation you would need to do. I’ve shown how you get and create a folder, so now you have a place to put your file. A number of additional libraries are needed for this operation.<br />
<span style="font-size: 8.0pt;"> </span></p>
<table>
<tbody>
<tr>
<td> </td>
<td style="background-color: #f2f2f2; border: 1px solid; font-family: Tahoma; font-size: 13px; padding: 12px;">…<br />
import java.io.FileInputStream;<br />
import java.io.InputStream;<br />
import java.io.File;<br />
import java.io.IOException;<br />
import java.math.BigInteger;<br />
import java.io.ByteArrayInputStream;<br />
import org.apache.chemistry.opencmis.commons.data.ContentStream;<br />
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;<br />
import org.apache.chemistry.opencmis.client.api.Document;<br />
…<br />
//details of the fileChooser not shown here. The goal is to get an InputStream<br />
File file = fileChooser.getSelectedFile();<br />
InputStream is = new FileInputStream(file);<br />
long length = file.length();<br />
BigInteger bi = BigInteger.valueOf(length);<br />
ContentStream contentStream = new ContentStreamImpl(file.getName(), bi, &#8220;text/plain&#8221;, is);<br />
Map properties = new HashMap();<br />
properties.put(PropertyIds.OBJECT_TYPE_ID, &#8220;cmis:document&#8221;);<br />
properties.put(PropertyIds.NAME, file.getName());folder = session.getRootFolder();<br />
Document doc = folder.createDocument(properties, contentStream, VersioningState.MINOR);</td>
</tr>
</tbody>
</table>
<div style="margin-bottom: .0001pt; text-align: left; line-height: normal;">
<br\></p>
<p style="margin-bottom: .0001pt; line-height: normal;">Things to note:</p>
<p style="margin-left: 12pt;">1) This code shows the essentials, but actual implementation should provide for the various exceptions that could arise, CmisConstraintException and IOException for example.<br />
2) New ContentStreamImpl requires a BigInteger, hence the conversion of the file length from long.<br />
3) VersioningState can be MAJOR, MINOR, NONE, or CHECKEDOUT. Whichever you use must match the versioning enabled in the SharePoint library.</p>
<p style="margin-bottom: 6.0pt; line-height: normal; page-break-after: avoid;">I have shown how you can use the Chemistry openCMIS library and REST Atom Service to:<br />
1) Access and Create Folders; 2) Iterate over SharePoint folders; and 3) Add documents to a SharePoint folder.</p>
<p>I hope this will &#8220;de-mystify&#8221; how to perform common DM operations in SharePoint using the CMIS standard!</p>
</div>
</div>
<hr size="1" />
]]></content:encoded>
			<wfw:commentRss>http://www.armedia.com/blog/2011/05/sharepoint-2010-rest-atom-service-and-java-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

