How to describe Sitecore to a SharePoint guy?

I have kicked off a new series of posts this week, on Paragon’s blog. This series explains a competitive web content management platform Sitecore to a SharePoint user.

The first post is called “How to describe Sitecore to a SharePoint Guy” and can be read in its entirety at http://sitecorecleveland.com/resources/blogs-posts/how_to_describe_sitecore_to_a_sharepoint_guy.

Your comments are always encouraged; feel free to leave them here or on the post. The next post will begin the dig into the practical details of Sitecore from the mindset of a SharePoint user.

Quick Refresh on SharePoint Development

A few months back I had a new client who was just testing the water in SharePoint development. They had recently inherited a project based on SharePoint 2007, but were not sure where they needed to start, so as the kind consultant I am, I first made the argument that we should look at an upgrade to 2010, while internally debated this I provided them with the following high level review of developing in a SharePoint environment.

Some of the details are very applicable to both SharePoint 2007 and 2010 development, with major differences called out.

SharePoint Version Naming

The term SharePoint can be used to describe a rather large collection of features, but during installing and development planning it is important to understand the different versions available and their corresponding names.

  • Windows SharePoint Services 3.0
    • Also referenced as WSS 3.0
    • This is the basic functionality for a collaboration site, it is free with all Server 2003/2008 licenses and is what MOSS 2007 was built on.
  • Microsoft Office SharePoint Server 2007
    • Also referenced as MOSS 2007
    • This is the enterprise instance of the SharePoint framework.
  • SharePoint Foundations 2010
    • Also referenced as SharePoint Foundations
    • This is the renamed and upgraded WSS.
    • Some users may call refer to this as WSS 4.0 but that is not found in official documentation.
    • This is free with most Server 2008 /2008 R2 licenses
  • SharePoint Server 2010
    • This is the enterprise installation.
    • The terminology of MOSS 2010 / MOSS has been mostly removed from the jargon, with just MOSS ninety-nine percent of the time always referring to Microsoft Office SharePoint Server 2007.

Throughout the following documentation I have used the term SharePoint 2007 to represent both WSS 3,0 in MOSS 2007 and SharePoint 2010 to refer to both SharePoint Foundations 2010 and SharePoint 2010 for simplicity sake.

The Environments

The following diagram shows the common separation of environments for most SharePoint development. The Team Development is defined in the next section, while your Testing and Production (the second and third boxes below) should be close to perfect clones of each other allowing for perfect testing before live deployment.

clip_image001

Pasted from <http://msdn.microsoft.com/en-us/library/ff650082.aspx>

A properly separated setup allows multiple developers to be working on either the same or different customizations at the same time and an avoidance of naming issues and toe stepping.

Developer’s Box

One of the biggest restraints is that development of custom code for SharePoint must be done in an environment that contains an installation of SharePoint. (For SharePoint 2007 this requires a Server OS installation, while SharePoint 2010 does provide an installation on a Windows 7 Professional OS.) No matter, the targeted version, the recommended approach is to use an all encompassing virtualized machine. This machine would include at the very least:

  • WSP Builder
  • Visual Studio Tools for SharePoint (Required for SharePoint 2007 and Visual Studio 2008 development)
  • Compression Software such as 7 Zip
  • Source Control software

This all encompassing box can then be cloned and redistributed to new developers as needed or allow for fresh environments to be generated as new task or customizations are assigned. Here are instructions to cloning a SharePoint 2007 development environment http://code-journey.com/2009/clone-sharepoint-moss-wss-stand-alone-developer-virtual-machine-rename-sharepoint-server/. Similar commands should work for a SharePoint 2010 virtual machine.

If there is any external data that the developers will need access to for there own development there is no issue with them sharing a centrally located SQL Server.

Deployment

Once your environments have been established, or at the very least planned out, a big worry becomes how difficult is it to move my customizations between the environments. SharePoint natively has a packaging concept that makes deployment of code between environments straight forward, clean, and simple.

The top level package component is called a SharePoint Solution file, these are identified by an extension of ‘wsp.’ At its basic level a solution is the collection of related files, customizations, and code which are packaged together for easy deployment. A solution is a recommended form of deployment for sets of customizations, because the solution has the capability to be deployed, upgraded, and even retracted.

A solution package ideal should be a collection o f SharePoint Features. A SharePoint Feature is the packaging of a single customization or functionality in a way that can be scoped and activated/deactivated as required by the solution.

Feature

The most basic/smallest package is called a feature. A feature contains a usually one piece of functionality that can be toggled on or off depending on the need. The following diagram shows most items which are packaged within a feature.

clip_image002

When developing a feature, it must be determined at what level within the SharePoint hierarchy the contain functionality can be activated, this is commonly referred to as the feature’s scope. Possible options in tree form are:

  • Farm
    • Web Application
      • Site (Site Collection)
        • Web (web site / sub site)

It is common that a feature activated at a higher level of the hierarchy the functionality will be accessible/working at the lower levels.

Installing Solutions and Features

Features are not reliant on a solution file for deployment to the server, but may require additional manual steps or a more detailed script to be deployed. This is one of the benefits of solution deployment files are properly copied and loaded onto the server natively by SharePoint.

Deployment for either SharePoint 2007 or 2010 can be done via script files or performed via the Central Administrator UI. For reproducibility, it is recommended to perform the deployments with a script file. SharePoint 2007 relies on the command line command STSADM (found in the bin directory of the 12 hive., while SharePoint 2010 has been designed to leverage the power of PowerShell (the STSADM is there but no longer the recommended scripting language.)

SharePoint 2007 Deployment Commands
Solution Deployment

  • stsadm –o addsolution
  • stsadm –o deploysolution
  • stsadm –o execadmsvcjobs

Feature Installation and Activation

  • Stsadm -o installfeature
    • This does not need to be ran if the feature was part of a solution. The solution handles feature installation.
  • Stsadm -o activatefeature
    • Depending on the solution this may or may not need to be ran.

SharePoint Object Model Hierarchy

When writing custom code for SharePoint 2007 and SharePoint 2010 there is a specific hierarchy to common objects required to interact with your SharePoint data. The following image is taken from a presentation by Lynn Langit called "SharePoint Development with Microsoft Visual Studio 2010" and can be found at http://blogs.msdn.com/b/socaldevgal/archive/2010/08/09/sharepoint-2010-for-net-developers.aspx. I thought this graphic is the simplest and easiest way to see how the major SharePoint objects are nested within each other.

clip_image003

Help Links for Reference on SharePoint 2007 Development

Helpful Links for Reference on SharePoint 2010 Development

SharePoint Modal Dialogs

SharePoint 2010 finally provided a way out of the horrible page refresh and post backs of SharePoint 2007 when it comes to viewing, editing, and adding items to libraries and list in the form of wonderful JavaScript modal dialogs.

What is even more awesome is that the even provided a way to make it optional for us. Why would would you want to provide full page navigation to these forms? The most common reason is if you have a complex custom form with a lot of fields or data, the full screen version provides benefit to the user, in limiting the amount of required scrolling they may need to do. Also, a concern is for accessibility issues where a screen reader may not detect the modal causing your user to miss out on there details they were hoping to consume.

Turn Off From GUI
To turn off the Modal Dialog from the GUI, the web browser is simple enough.

  1. Navigate to the list. From the List Tools of the Ribbon click List –> List Settings.
    image
  2. This will bring up the List Settings page. From here under General Settings  click Advanced settings.
    image
  3. You will then see the Advance Settings screen. Scroll to the bottom and you will find a row titled "Dialogs" with a radio buttons for Yes and No.
    As the description describes this turns the modal dialogs on and off.
    Yes being display as modals, and No being display as a page.
    image
  4. Click OK and the setting will take effect. Simple once you know where to look.

Turn Off via Object Model
Sometimes there is a need to set the Dialog value via code in the object model. There does exist a property on an SPList object called "NavigateForFormsPages" which controls this setting. As with many other SharePoint object properties the name does not always describe the related purpose.

"NavigateForFormsPages" is a boolean value where
True causes the forms to render as a full page, post back and all. While False, indicates that form rendering should be in the modal dialog. As with any list property settings don’t forget to call SPList.Update() after setting the value.

Here is some sample code of how to set the NavigateForFormsPages value from a Web scoped feature receiver:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    using (SPWeb web = (SPWeb)properties.Feature.Parent)
    {
        web.AllowUnsafeUpdates = true;
        SPList newList = web.Lists["CourseDirectory"];
        if (newList != null)
        {
            //True - full page rendering
            //False - modal dialog rendering.
            newList.NavigateForFormsPages = true; 
            newList.Update();
        }
    }
}

See http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.navigateforformspages.aspx on MSDN for the super technical details regarding this list property.

Modal Dialogs and Custom Forms

You’ve written a super sweet custom application page for your content type, and am ready to set it free in your environment. Turns out during the stage testing (you do have a stage server right?) you custom form doesn’t actually close the modal dialog it resides in. Instead the modal dialog opens the redirect link in the current dialog. Possibly your close event code looks something like the following:

protected void btnExit_OnClick(object sender, EventArgs e)
{
    if (Request.QueryString["Source"] != null)
        Response.Redirect(Request.QueryString["Source"], true);
    else
        Response.Redirect(SPContext.Current.List.DefaultViewUrl, true);
}

You might see the following strange behavior where you modal never actually closes.

First, we open our item in the custom form, and see

image

After clicking CLOSE button which has the above custom code we get this:

image

Since our current context is still the frame set of the modal dialog our supposed closing just loads the code into the current window frame. Luckily,  with a little code and checking the current HTTP context we can close the modal or redirect if modal is turned off. Our new close event code would be this:

protected void btnExit_OnClick(object sender, EventArgs e)
{
    HttpContext context = HttpContext.Current;
    if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
    {
        context.Response.Write("<script type=text/javascript>     window.frameElement.commitPopup();</script>");
        context.Response.Flush();
        context.Response.End();
    }
    else if (Request.QueryString["Source"] != null)
        Response.Redirect(Request.QueryString["Source"], true);
    else
        Response.Redirect(SPContext.Current.List.DefaultViewUrl, true);
}

Now, the following will happen:

image

And after close, a view of the All Items page of our list:

image

Now you have the know how to take advantage of the new modal dialog feature of SharePoint 2010.

Early to Plan and Early to Test Makes an Upgrade

…Intuitive, Effective, and Calm.

On Wednesday, November 17th I had the opportunity to speak to the Fort Wayne SharePoint User Group. This was the first time I have spoken to a use group, and feel over all it was a successful presentation. The title of the presentation was “Early to Plan and Early to Test, Makes an Upgrade Intuitive, Effective, and Calm.” During the presentation I spoke about the different approaches and steps to upgrading a SharePoint 2007 farm to SharePoint 2010, as a number of those in attendance are looking to begin upgrade projects during the first quarter next year.

I told those attending that I would be posting my notes and slides. I tried to format everything to include in the body of this post, but I couldn’t find a nice way to do it without hand editing a lot of HTML. (Any suggestions for a good blog editor for Word Press, I’m currently using Windows Live Writer.) Here is a link to download everything as a docx file:

image

Creative Commons License
Early to Plan and early to Test makes an Upgrade intuitive, effective, and calm by Scott Gillis is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Based on a work at thecodeattic.wordpress.com.
Permissions beyond the scope of this license may be available at https://thecodeattic.wordpress.com/about/.

ULS (The Ugly Log Stream) Is No More

Any SharePoint administrator or developer has been faced with ugly task of digging through the ULS (officially known as Unified Logging Service, to me as the Ugly Log Stream) looking for clues as to why "Unexpected Error.." is being thrown. Most often this involves opening the ULS in some sort of text editor, and trying to maneuver around as best you can to pinpoint the cause of the issue.

Because this is such a daunting task, I’ve been on the lookout for a magical solution to turn the ULS from the Ugly Log to the Unbelievable Log. The first place I looked was on CodePlex, where I found a few, but nothing that made me say, "Wow!"

I then stumbled across the ULS Viewer in the MSDN Code Gallery and knew my life had just become infinitely easier. As I said, this gem of an application can be found in the MSDN Code Gallery under ULS Viewer. It hasn’t been updated since October 2009, but I have had no problems using it with Server 2008 R2 and SharePoint 2010, instances of MOSS 2007 on 32-bit hardware, or Windows 7 and XP. The biggest issue people have reported is date formatting issues with non English culture settings. I am going to pull out a few of the features that I have found to be most helpful, but in no way is this going to be a complete list of the different options that are available to you.

To start with, the ULS Viewer is a small executable 500MB in size, that doesn’t require any installation. Just double click and your up and running in ULS heaven. With this size it won’t be hard to added it to your USB stick and have it with you always. (I think we can all spare 500MB on our 8 or 16 GB sticks we all have…or can afford to skip the coffee for a week to get ourselves one.) In addition, to not having to install anything, as long as you have access via the network to the log location of your SharePoint server, there is no need to even log onto the SharePoint Application server. (Another point for this little baby.)
image

To view your logs you have two options. The first is to open a log file via File -> Open From -> File, which allows you to open any defined file in a the given browsed to location. This is excellent if you are wanting to view a PSConfig log file or historical ULS log files. The second option is to open File -> Open From -> ULS is were this really shines. You provide the path to your SharePoint log files and it will automatically refresh the screen as new lines are logged. No longer must you close and reopen, or refresh the screen. In addition, when using viewing via the ULS option, you can pause the live stream and start it back up as you want.
image

The next feature I find great is the ability to view only certain message types. By default all the message types are shown, which are VerboseEx, Verbose, Medium, and High. Sadly, there is not a single button to filter out Warning type messages, but this can be easily achieved via the filtering system provided.
image

Which leads into the next super sweet feature…the ability to filter messages so you only have to look at those that apply to the current issue your investigating. You have the ability to filter all of the columns with standard contains, begins, not equals…and even regex expression matching. To make it even cooler you can save different filter sets off, to use again or to share amongst teammates investigating the same issue.
image

SharePoint provides the Correlation ID for error messages as a way for us to easily identify what message(s) in the log are related to the error, but often it is hard to locate all the related messages as they are rarely all clumped in a group. Well, ULS Viewer makes this easier for us to, by providing the Correlation Tree. This beauty l will list all of the correlation ids currently in the log file or that have already been shown if live streaming the ULS, you then can select the ID you want…poof…all logged messages related are shown, no more hunting with the Find to make sure you have seen all the messages.
image

BUT wait there’s more!!!!!
Also, provided to make finding related or specific messages is the ability to format the display. This includes the basics of which columns to show and the default size of said columns, but it gets better. You can establish filter rules which will then highlight that line in your chosen color, and just like the filter options you can save these off to use later or share. If you don’t want the entire line, you can even designate certain column to be highlights. By default it even highlights any critical level messages for you.
image
If the bells and whistles I’ve pulled out haven’t at least peaked your interest, maybe the simple yet great features will sell you on the ULS Viewer. When ever a line is selected the top frame of the window will display the entire message column in clean wrapped text. Now we don’t have to scroll forever left and right or try to determine what is wrapped text or a new line in the log. Of course, it even goes a step further, and if you double click a line in the ULS, you get a nice dialog box which breaks all of the columns down for you to easily view or even share.
image
Everyone knows you have to view the ULS Log at least once for any given SharePoint project, but it shouldn’t be something to hate. With the ULS Viewer the ULS Log is no longer a last phase in issue resolution, but becomes an excellent first stop in an investigation. The ULS Viewer can be downloaded from the MSDN Code Gallery at http://code.msdn.microsoft.com/ULSViewer.

Your Mid-Week Microsoft Fix

Sorry to all those who look forward to some lunch time reading each week. Last week, was just one of those weeks were anything you wanted to do just kept getting shuffled further down the queue. In the process of compiling this weeks links, I decided for a name change to “Your Mid-Week Microsoft Fix”. I hope you like the name change, I’m not sold on it yet, so if you have any suggestions leave them in the comments..

So without any further ado…here is this week’s Mid-Week Microsoft Fix.

Security in SharePoint 2010: How Do I: Use the New SharePoint 2010 Security Model (Part 1)

This module concentrates on the security aspects in SharePoint 2010. We’ll concentrate on securing the deployment and also to new claims based authentication option. Learn about the new claims-based identity model available in SharePoint 2010. Presented


How Do I: Create a Business Data Connectivity Model for SharePoint 2010 Using Visual Studio 2010?

Microsoft Visual Studio 2010 provides a project type that enables developers to build Business Data Connectivity (BDC) Models that produce Microsoft .NET connectivity assemblies for Business Connectivity Services (BCS) in Microsoft SharePoint 2010.

TechNet Radio: Security with SharePoint 2010

In this session we spend time with Microsoft Certified Master and SharePoint Ranger Bryan Porter to discuss security with SharePoint 2010, its various implementations, and supporting technologies that help to ensure your data remains secure and protected

ASP.NET Security Patch

Last week I cross-posted, about a security flaw in ASP.NET which could allow an attacker to get access to files on the server.

Microsoft has announced an out-of-band patch for this on Tuesday, September 28, 2010.

Here is the blog post from the Microsoft SharePoint Team blog with details and links.

x-post from the Microsoft Security Response Center blog — The download links for the security updates are in the Security Bulletin.

As we announced yesterday, today we released Security Bulletin MS10-070 out-of-band to address a vulnerability in ASP.NET. The bulletin and the blog by Scott Guthrie, corporate vice president of Microsoft’s .NET Developer Platform are available for more information.

This security update addresses a vulnerability affecting all versions of the .NET Framework when used on Windows Server operating system. While desktop systems are listed as affected, consumers are not vulnerable unless they are running a web server from their computer.

The update will be made available initially only through the Microsoft Download Center and then released through Windows Update and Windows Server Update Services within the next few days. This allows customers the option to deploy it manually now without delaying for broader distribution.

For customers who use Automatic Updates, the update will be automatically applied once it is released broadly. Once the Security Update is applied, customers are protected against known attacks related to Security Advisory 2416728.

If you can, please join me and Dustin Childs today for a live webcast where we will cover the details of this bulletin and take customer questions live. Here is the registration information:

Date: Tuesday September 28, 2010
Time: 1:00 p.m. PDT
Click Here to Register

Thanks,
Dave Forstrom
Director, Trustworthy Computing