Avoiding SOAP Bloat with JSON Services

In this post I am going to walk through writing and consuming JSON services using ASP.Net, WCF, and jQuery to request the stock price for a company.

Visual Studio 2010 Web Application Project Template Additions

  • jQuery Intellisense – let Visual Studio write your jQuery for you
  • AJAX-enabled WCF Service – item template that auto-generates the web.config entries for configuring a JSON service to be consumed and proxied by an ASP.Net ScriptManager
  • Targeted web.config files – easy way to manage different service endpoints for different environments

What is JSON?

Java Script Object Notation – JSON is a subset of the object literal notation of JavaScript. Since JSON is a subset of JavaScript, it can be used in the language with no muss or fuss.

var dog = {color: "grey", name: "Spot", size: 46};

SOAP Bloat

SOAP services are extremely verbose. This verbosity enables us to use tools like Visual Studio’s built-in ”Add Service Reference” to auto-generate client proxy classes.  The following examples demonstrate the XML that is used for requesting a stock price and the corresponding response:

Example SOAP Request

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPrice>
      <m:StockName>GOOG</m:StockName>
    </m:GetStockPrice>
  </soap:Body>
</soap:Envelope>

Example SOAP Response

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPriceResponse>
      <m:Price>534.5</m:Price>
    </m:GetStockPriceResponse>
  </soap:Body>
</soap:Envelope>

The above example when formatted as JSON is as follows:

GET Request

ticker=GOOG

JSON Response

{"d":534.5}

JSON Enabling a WCF Service

  1. Using the AJAX-enabled WCF Service item template pretty much does it all.  An additional step can be taken to eliminate the need for the additions to the web.config by configuring the channel factory directly on the service declaration (.svc) file:
    <%@ ServiceHost Language="C#" Debug="true"
        Service="Trentacular.JsonWcfDemo.StockPriceService"
        Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"
        CodeBehind="StockPriceService.svc.cs" %>
  2. Decorate the operation (service method) with the WebGetAttribute to enable the use of HTTP GET for data retrieval and return the response as JSON :
    [WebGet(ResponseFormat = WebMessageFormat.Json)]

Our resulting stock price service’s code behind will look like the following:

    [ServiceContract(Namespace = JsonWcfDemoNamespace.Value)]
    public class StockPriceService
    {
        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        [OperationContract]
        [WebGet(ResponseFormat=WebMessageFormat.Json)]
        public StockPrice GetStockPrice(string ticker)
        {
            ...
        }
 
        // Add more operations here and mark them with [OperationContract]
    }

Converting Text to JSON and Back

eval() – invokes the JavaScript compiler. The compiler will correctly parse the text and produce an object structure. The eval function is very fast. However, it can compile and execute any JavaScript program, so there can be security issues.

JSON.parse() – To defend against security issues with the eval function, it is preferred to use a JSON parser. A JSON parser will recognize only JSON text, rejecting all scripts. In browsers that provide native JSON support, JSON parsers are also much faster than eval. It is expected that native JSON support will be included in the next ECMAScript standard.

jQuery’s $.getJSON() Method

jQuery provides the getJSON method for easily making calls to services providing JSON-formatted responses and performing the JSON conversion.  Its signature is as follows:

$.getJSON( url, [ data ], [ callback(data, textStatus) ] )

url – A string containing the URL to which the request is sent.

data – A map or string that is sent to the server with the request.

callback(data, textStatus) – A callback function that is executed if the request succeeds.

Consuming our stock price service using the getJSON method will look like the following:

$.getJSON("StockPriceService.svc/GetStockPrice", { ticker: tickerValue }, function (data, textStatus) {
 
    if (textStatus != 'success' || !data.d) {
        $("#stockPricePanel")
            .html('<span class="error">Error looking up stock price.  Did you enter a valid ticker?</span>');
    } else {
        var stockPrice = data.d;
        var isIncrease = (stockPrice.Delta >= 0);
        var deltaStyle = isIncrease ? 'gain' : 'loss';
 
        $("#stockPricePanel")
            .html('<span class="price">' + stockPrice.Price + '</span>')
            .append('<span class="delta ' + deltaStyle + '">' + stockPrice.Delta + '</span>')
            .append('<span class="percent ' + deltaStyle + '">(' + stockPrice.PercentChange + '%)</span>');
    }
});

Working with WCF Serialized JSON Dates

One caveat when working with JSON is that WCF serializes DateTimes to JSON in the format:

/Date({milliseconds since 01/01/1970}-{time zone})/

image
Unfortunately, native JSON conversion does not automatically convert the date string to a JavaScript date object. The following method shows an example of how to convert a JSON date string to a javascript Date object:

function convertJSONToDate(json) {
    return eval(json.replace(/\/Date\((.*?)\)\//gi, "new Date($1)"));
}

Download the Demo Application

image
Download Now Download Now

MOSS FullTextSqlQuery API: Little Known Flags on Managed Properties

I just wrapped up a custom implementation of a faceted search web part that uses the MOSS Full Text Sql Query API. During the development, I ran into issues querying certain multi-valued Managed Properties, specifically Skills and Interests. In my query, I was using the CONTAINS predicate like such:

SELECT
UserProfile_GUID, PreferredName, JobTitle, Department, WorkPhone, OfficeNumber,
AboutMe, PictureURL, WorkEmail, WebSite, Path, HitHighlightedSummary,
HitHighlightedProperties, Responsibility, Skills, SipAddress
FROM scope()
WHERE freetext(defaultproperties,'+trent')
AND ("scope" = 'People')
AND CONTAINS(Skills, '"numchucks"')
AND CONTAINS(Skills, '"rockstar"')

Use of the CONTAINS predicate was purely due to my need to query multi-valued properties. If you are not querying a multi-valued property, you may simply use the ‘=’ or ‘LIKE’ predicates.

It turns out that the CONTAINS predicate will only work against managed properties that have been enabled as FullTextQueriable. I am not aware of a way to enable a property in the SSP Search Settings, so this has to be done using the API. I ended up including the following method as part of a Web Application scoped Feature Receiver to ensure certain Managed Properties were ‘FullTextQueriable’.

    using Microsoft.Office.Server;
    using Microsoft.Office.Server.Search.Administration;
 
    private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext, params string[] managedPropertyNames)
    {
        var schema = new Schema(SearchContext.GetContext(serverContext));
        foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
        {
            if (!managedPropertyNames.Contains(managedProperty.Name))
                continue;
 
            if (managedProperty.FullTextQueriable)
                continue;
 
            try
            {
                managedProperty.FullTextQueriable = true;
                managedProperty.Update();
                Log.Info(m => m("Successfully set managed property {0} to be FullTextQueriable", managedProperty.Name));
            }
            catch (Exception e)
            {
                Log.Error(m => m("Error updating managed property {0}", managedProperty.Name), e);
            }
        }
    }

So on the same note of Managed Property flags not visible in the SSP Search Settings, you may also want to know about the Retrievable flag. This flag prevents a Managed Property’s value from being returned if specified as a column in the SELECT statement.

The following table lists most of the out of the box Managed Properties and their default FullTextQueriable, HasMultipleValues, and Retrievable flag values.

Name FullTextQueriable HasMultipleValues Retrievable
AboutMe     X
Account X   X
AccountName     X
AssignedTo X   X
Assistant     X
Author X   X
Authority     X
BestBetKeywords X X X
Birthday     X
CachedPath     X
CategoryNavigationUrl X   X
CollapsingStatus     X
Company     X
contentclass X   X
ContentSource     X
ContentType X   X
Created     X
CreatedBy X   X
DataSource     X
DatePictureTaken     X
Department     X
Description X   X
DisplayTitle     X
DocComments X   X
DocKeywords X X X
DocSignature     X
DocSubject X   X
DottedLine     X
EMail X   X
EndDate     X
Fax     X
FileExtension     X
Filename X   X
FirstName X   X
FollowAllAnchor X    
HighConfidenceDisplayProperty1     X
HighConfidenceDisplayProperty10     X
HighConfidenceDisplayProperty11     X
HighConfidenceDisplayProperty12     X
HighConfidenceDisplayProperty13     X
HighConfidenceDisplayProperty14     X
HighConfidenceDisplayProperty15     X
HighConfidenceDisplayProperty2     X
HighConfidenceDisplayProperty3     X
HighConfidenceDisplayProperty4     X
HighConfidenceDisplayProperty5     X
HighConfidenceDisplayProperty6     X
HighConfidenceDisplayProperty7     X
HighConfidenceDisplayProperty8     X
HighConfidenceDisplayProperty9     X
HighConfidenceImageURL     X
HighConfidenceMatching   X X
HighConfidenceResultType     X
HireDate     X
HitHighlightedProperties     X
HitHighlightedSummary     X
HomePhone     X
Interests   X X
IsDocument     X
JobTitle     X
Keywords X   X
LastModifiedTime     X
LastName X   X
Location     X
Manager     X
MemberOf     X
Memberships X X X
MobilePhone     X
ModifiedBy X   X
MySiteWizard     X
NLCodePage      
Notes X   X
objectid     X
OfficeNumber     X
OWS_URL X    
PastProjects   X X
Path X   X
Peers   X X
PersonalSpace     X
PictureHeight X   X
PictureSize X   X
PictureThumbnailURL     X
PictureURL     X
PictureWidth X   X
PreferredName     X
Priority X   X
ProxyAddresses     X
PublicSiteRedirect     X
Purpose X   X
Rank     X
RankDetail     X
Responsibilities   X X
Schools   X X
SID     X
SipAddress     X
Site      
SiteName     X
SiteTitle     X
Size     X
Skills   X X
StartDate     X
Status X   X
Title X   X
UrlDepth X    
UserName     X
UserProfile_GUID     X
WebId     X
WebSite     X
WorkAddress X   X
WorkCity X   X
WorkCountry X   X
WorkEmail     X
WorkId     X
WorkPhone     X
WorkState X   X
WorkZip X   X

Productivity: What Causes You Friction?

As I am waiting for Reflector to load and my browser to unfreeze, I thought maybe if I write down all the things that cause me friction when attempting to be productive, I may just feel a little less frustrated by it all.

So here it goes:

  1. Lotus Notes takes up to 20 seconds to redraw itself when returning from my VM
  2. SameTime can also take this long
  3. SharePoint Development Requirements – Lots of RAM and Windows Server OS
  4. SharePoint GAC Deployment – Recycling of App Pools gets old
  5. Getting distracted writing this blog post after Reflector finished loading 5 minutes ago
  6. Visual Studio Add Reference Dialog (can’t wait to get my whole team over to VS 2010 to cross this one off the list)
  7. Misleading WCF Add Service Reference Error Messages
  8. Did I mention Lotus Notes
  9. Web Meetings and Teleconferencing
  10. Two-factor authentication with a 5 minute timeout (Explanation: I am working for a defense contractor)

On the other hand, there are certain things that just plain allow me to be productive:

  1. My Wife Sarah
  2. GMail
  3. Google Reader
  4. Google Chat
  5. Visual Studio Intellisense
  6. FireBug
  7. Notepad++
  8. My Colleague Winston’s MindTree application
  9. Pencil and Paper (not the name of some app, I mean physical pencil and paper)
  10. Whiteboards

So what is causing you friction?

Extension Method of the Day: OrderBy with a Descending Flag

The title should say it all. Not sure why this didn’t make it into the System.Linq.Enumerable class, but this seems like a no-brainer. You need to sort a collection, but whether you sort ascending or descending is determined by a boolean argument instead of having to call a different method for each scenario.  Add this to your collection utilities class immediately:

        /// <summary>
        /// Sorts the elements of a sequence according to a key.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">source or keySelector is null.</exception>
        /// <typeparam name="TSource">The type of the elements of source.</typeparam>
        /// <typeparam name="TKey">The type of the key returned by keySelector.</typeparam>
        /// <param name="source">A sequence of values to order.</param>
        /// <param name="keySelector">A function to extract a key from an element.</param>
        /// <param name="descending">if set to <c>true</c>, sorts the elements in descending order; otherwise in ascending order.</param>
        /// <returns>An System.Linq.IOrderedEnumerable<TElement> whose elements are sorted according to a key.</returns>
        public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, bool descending)
        {
            if (descending)
                return source.OrderByDescending(keySelector);
 
            return source.OrderBy(keySelector);
        }

SharePoint: Enabling WebDAV on a Development Server

I am currently customizing the display of SharePoint search results for my client and wanted a quick way to do iterative development of the XSLT style sheet used to render the results.  I decided to upload the style sheet to a Document Library in the Search Center site, configure the Core Results Web Part’s XSL Link to point to the url of the style sheet, and use WebDAV to iteratively edit/save the file, having my changes appear instantly in the Core Results Web Part.

What I didn’t realize is there are some additional steps to take to enable WebDAV for use on my development server (Windows Server 2003 VM).  Here they are in case you are trying to do something similar:

  1. Enable WebDAV in IIS (found in the Web Service Extensions section)
  2. Enable and start the WebClient service

Apparently in Windows Server 2003, the WebClient service is disabled by default.  In case you are wondering what this service does, here is its description:

Enables Windows-based programs to create, access, and modify Internet-based files.  If this service is stopped, these functions will not be available.  If this service is disabled, any services that explicitly depend on it will fail to start.

Wahlah, I am now able to access the document library using Windows Explorer with a path like the following:

\\mossdev\sites\SearchCenter\Documents

SharePoint “Smart” Editor Parts

Stealing the name from Jan Tielens’ SmartPart for SharePoint, I’ve put together a framework for building “Smart” Editor Parts — “Smart” Editor Parts being User Controls that serve as Editor Parts.  This blog post is an excerpt from the complete writeup of the framework.

Downloads

SharePoint Smart Editor Parts.docx (~159 KB)
A complete writeup of the SharePoint “Smart” Editor Part framework

Trentacular.SharePoint.SmartEditorPart.zip (~ 320 KB)
The Visual Studio solution of the SharePoint “Smart” Editor Part framework
(Requires Visual Studio 2010 and WSPBuilder Extensions 2010)

Introduction

About the SharePoint Web Part Platform

Windows SharePoint Services 3.0 (WSS) offers a robust platform for hosting Web Parts, providing a Web Part Manager implementation that builds a rich tool pane for configuring the Web Parts.  Out of the box, WSS provides tool panes for customizing the appearance and layout, and will even generate basic fields for custom Web Part properties that are marked with the appropriate attributes.   The following table describes how custom property types are displayed in the property pane:

Custom Property Type Generated Property Pane Field
bool Check Box
DateTime Text Box
enum Dropdown List
int Text Box
string Text Box

Building Custom Editor Parts

When a custom property requires a user interface element other than the ones listed above or needs custom validation, you can write a custom Editor Part that inherits from System.Web.UI.WebControls.WebParts.EditorPart and have your Web Part implement System.Web.UI.WebControls.WebParts.IWebEditable to create your custom Editor Part.

If you would like to build your custom Editor Part using a User Control, there are a few more steps you will have to take, because the abstract System.Web.UI.WebControls.WebParts.EditorPart base class does not inherit from the System.Web.UI.UserControl class.  The rest of this guide will walk you through the steps to create a framework for building Editor Parts with User Controls.

Inheriting from a Web Part Base Class

Web Parts inheriting from Microsoft.SharePoint.WebPartPages.WebPart can also take advantage of this framework with slight modifications to this guide.  You will be creating a base class that inherits from System.Web.UI.WebControls.WebParts.WebPart that will encapsulate the majority of the Editor Part framework and will be used by the example Site Members Web Part.  If you prefer to inherit from Microsoft.SharePoint.WebPartPages.WebPart, you may change the base class you will be creating to inherit from this class instead; however, Microsoft recommends that you inherit from System.Web.UI.WebControls.WebParts.WebPart whenever possible.

Overview of the User Control Editor Part Framework

Overview of Building an Editor Part

In order for a Web Part to have a custom Editor Part, the Web Part can implement the System.Web.UI.WebControls.WebParts.IWebEditable interface.  The abstract WebPart class that is typically used as the base class for custom Web Part implementations already implements the IWebEditable interface, which includes two exposed members.  The WebBrowsableObject property provides a way for EditorPart controls to get a reference to the associated Web Part.  The CreateEditorParts method is used to create an instance of each custom EditorPart control associated with the Web Part, and return them as a collection.  Custom Web Parts that inherit from the abstract WebPart class need only to override the CreateEditorParts method in order to add additional Editor Parts.

The EditorPart class exposes a property named WebPartToEdit of type WebPart that the Editor Part can use to read and set the configurable properties of the Web Part.  Additionally, two abstract methods SyncChanges and ApplyChanges are exposed that are called by the Web Part framework at the appropriate times when the Editor Part should read or set these properties on the associated Web Part.

Extending the Editor Part Framework to Support User Controls

In order to use a User Control as an Editor Part, a generic Editor Part called UserControlEditorPart<T> is needed that will wrap the appropriate User Control.  The UserControlEditorPart<T> will also need to pass the SyncChanges and ApplyChanges method calls along to the User Control.  This can be accomplished by defining an interface to be implemented by the User Control.  This interface will be called IWebPartEditor<T>.

The UserControlEditorPart<T> class is generic because it will inherit from another base class that is also generic called BaseEditorPart<T>.  This base class is extracted so that it can be inherited by both the UserControlEditorPart <T> and any other custom non-User Control Editor Parts.  Its sole purpose is to provide the convenience of casting the WebPartToEdit property of the EditorPart abstract class to the specific Web Part type associated to the EditorPart.

Enabling Attribute Decorations for Editor Part Associations

While it is relatively straight-forward to implement the IWebEditable interface’s CreateEditorParts method in a custom Web Part class, the framework additionally abstracts this step away, enabling you to associate Editor Parts to your Web Part using attributes.  This is accomplished by supplying two additional classes: WebEditableWebPart and EditorPartAttribute.

The WebEditableWebPart class is a new base class to be used by your custom Web Parts.  The class inherits from WebPart and overrides the CreateEditorParts method to add any Editor Parts to the Web Part that are specified by the EditorPartAttribute class.

The EditorPartAttribute class is to be applied as a class attribute to a Web Part requiring a custom Editor Part.  The attribute allows for an Editor Part to be specified by either its type or by a virtual path to a User Control that implements IWebPartEditor<T>.

User Control Editor Part Framework Class Diagram

Using the User Control Editor Part Framework

With the User Control Editor Part framework in place, there are now just three steps needed in order to create an Editor Part as a User Control:

  1. Ensure the Web Part inherits from WebEditableWebPart.  In the case where you are already using a custom base class for your Web Parts, you may simply change your custom base class to inherit from WebEditableWebPart.
  2. Create a User Control that implements IWebPartEditor<T>.
  3. Decorate your Web Part using the EditorPartAttribute class specifying the virtual path to the User Control.

SharePoint FBA: Basic “All Authenticated Users” Role Provider

When managing users and groups within a SharePoint Web application configured to use Windows Integrated Authentication,  there is a convenient “Add all authenticated users” link that adds a special Active Directory group – NT AUTHORITY\authenticated users – to the Users/Groups People Editor.  This group refers to any non-anonymous user, which if you ask me, seems like a pretty common group to have around.  However, when working within a SharePoint Web application configured to use Forms Based Authentication (FBA), this convenient group is no longer available.

When using FBA, the only “non-SharePoint” groups available to us are the roles exposed by an ASP.Net Role Provider.  If you are already using a custom Role Provider and are not able to make changes to it, then you can stop here.  This post is not for you.  If you are like me though, and are using FBA merely for authentication and are leveraging SharePoint for all authorization, then the single “All Authenticated Users” role is all I need from my Role Provider.  As a result, there is no need to use a heavy weight Role Provider (i.e., the SQL Role Provider) to accomplish this, but rather roll your own very dumb role provider.  There is only a single method that you will need to implement – GetRolesForUser – in which you can assume the user is already authenticated and always return the “All Authenticated Users” role for the user. Here is the Role Provider I am currently using:

using System;
using System.Web.Security;
 
namespace Trentacular.Web.Security
{
    public class SimpleAllAuthenticatedUsersRoleProvider : RoleProvider
    {
        public const string AllAuthenticatedUsersRoleName = "All Authenticated Users";
 
        public override string ApplicationName { get; set; }
 
        public override string[] GetRolesForUser(string username)
        {
            return new[] { AllAuthenticatedUsersRoleName };
        }
 
        #region Methods Not Implemented
 
        public override string[] GetAllRoles() { throw new NotImplementedException(); }
        public override bool IsUserInRole(string username, string roleName) { throw new NotImplementedException(); }
        public override bool RoleExists(string roleName) { throw new NotImplementedException(); }
        public override void AddUsersToRoles(string[] usernames, string[] roleNames) { throw new NotImplementedException(); }
        public override void CreateRole(string roleName) { throw new NotImplementedException(); }
        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { throw new NotImplementedException(); }
        public override string[] FindUsersInRole(string roleName, string usernameToMatch) { throw new NotImplementedException(); }
        public override string[] GetUsersInRole(string roleName) { throw new NotImplementedException(); }
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { throw new NotImplementedException(); }
 
        #endregion
    }
}

After rolling your own role provider, you will need to register it in the web.config inside the <system.web> section as such:

<roleManager enabled="true" defaultProvider="SimpleAllAuthenticatedUsersRoleProvider">
    <providers>
        <add name="SimpleAllAuthenticatedUsersRoleProvider" type="Trentacular.Web.Security.SimpleAllAuthenticatedUsersRoleProvider, Trentacular.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa" />
    </providers>
</roleManager>

Installing SharePoint Server 2010 Beta on Windows 7

So I am about to install SharePoint Server 2010 Beta on a fresh Windows 7 install. I am planning on continually updating this post with my progress. So here goes nothing.

Step 1: Find out what others are saying

http://msdn.microsoft.com/en-us/library/ee554869%28office.14%29.aspx

http://weblogs.asp.net/sharadkumar/archive/2009/10/20/sharepoint-2010-setting-up-development-machine-on-windows-7.aspx

Step 2: Reinstall the correct version of Windows 7

Before getting started or reading any guides, I installed Windows 7 Ultimate N, which I now know the Beta only works on non-N versions of Windows 7.  So far off to a great start :(

http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/dec7a208-662f-4c4d-bbae-f04f937b2e86

http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/cfa12d9f-2253-4d70-9f6a-c73441d43fd5

Step 3: Install a butt-load of prereqs

Stuck to the MSDN guide and all went well.

Step 4: Install SharePoint Server 2007

Make sure to run the setup.exe in the extracted folder created by following the MSDN guide above, not the downloaded .exe.

Step 5: Configure the SharePoint Farm

I received the following error:

SharePoint Configuration Failed

Installing the following KB update corrected this problem:

http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=23806

Step 6: Tune SharePoint and SQL Server

I could use some recommendations for this step.  After completing the installation and creating my first Site Collection, there appears to be 4 IIS Worker Processes and 7 or more Windows Services running related to SharePoint.  I will be experimenting with timeout settings for the application pools and max memory settings for SQL Server and let you know what I come up with. If you’ve got some insight on tuning, please let me know!

Reblog this post [with Zemanta]

Galleriffic 2.0

Say hello to Galleriffic 2.0.

For first time readers, Galleriffic is a jQuery photo gallery optimized to handle high volumes of photos while conserving bandwidth.  h0bbel has posted a nice read on some of the benefits of Galleriffic over other photo gallery scripts.

New Features

  • Keyboard Navigation
  • Support for synchronized transitions (image cross-fades)
  • Ability to add or remove images after the gallery is initialized
  • Support for custom hash identifiers (when using history)
  • Better API to make it easier to customize
  • Smarter pagination
  • Integration with the jquery.history plugin for history support

Warnings to users attempting to upgrade from version 1.0

  • The onChange event in 1.0 has been renamed to onSlideChange.
  • All transition event handlers have new signatures, so you will need to make sure to update any transition event handlers you have implemented.
  • Using synchronized transitions requires changes to your stylesheet – primarily the additional of relative and absolutely positioning so that two images can occupy the same space at the same time.

There are now 5 examples, each builds on the previous.  For a visual treat, check out the last example, whose colors I inverted.

SharePoint smartsolutionupgrade stsadm command

I just released a new stsadm command in the Trentacular SharePoint 2007 Features CodePlex project called smartsolutionupgrade.  The purpose of this command is to perform Solution upgrades in a smart manner by performing the following actions:

  1. Accepts as input either a single Solution filename or a filename of a text file containing a list of Solutions to be upgraded
  2. Extracts and parses the Solution manifest file from each existing Solution to be upgraded in order to determine the Features that will be affected by the upgrade
  3. Inventories the deployment states of the existing Solutions
  4. Inventories the activation states of the affected Features at all scopes within the SharePoint Farm
  5. Deactivates all affected Features
  6. Retracts each of the existing Solutions and deletes them from the Solution store
  7. Adds the updated Solution to the Solution store
  8. Deploys each of the upgraded Solutions according to their previous deployment state
  9. Activates all affected Features according to their previous activation state

Usage

stsadm -o smartsolutionupgrade [-filename <Solution filename>] [-filenamelist <Path to text file containing each of the solution filenames on separate lines>]

Job Definition Execution

Included in the project is a Job Definition Executor that takes care of running one-time scheduled service jobs and waiting for their completion before releasing control.  One particular issue addressed by the Job Definition Executor is the “A web configuration modification operation is already running” error caused by successive execution of the stsadm -o activatefeature command on Features that perform web configuration modifications.

In a multi-server farm, web configuration modifications are delegated to Timer Jobs; therefore, the return from execution of the activatefeature command does not mean the Feature activation (and thus the web configuration modification) has completed.  So you might say, well duh, you need to also execute the execadmsvcjobs command, but this command simply kicks of the job execution and returns from execution while still not waiting for the jobs to actually complete.

The Job Definition Executor solves this problem by kicking of the jobs and monitoring for their completion.  We can now safely execute multiple web configuration modification Features in sequence.

Update

I just released a second stsadm command called smartexecjobdefs that simply wraps the Job Definition Executor and can be used as a substitute for the execadmsvcjobs command.