<?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>Codality &#187; Software</title>
	<atom:link href="http://blog.najmanowicz.com/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.najmanowicz.com</link>
	<description>Code and Effect - solving problem with just enough amount of code - by Adam Najmanowicz</description>
	<lastBuildDate>Mon, 08 Feb 2010 12:01:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Eric Evans on Domain Driven Design</title>
		<link>http://blog.najmanowicz.com/2009/06/15/eric-evans-on-domain-driven-design/</link>
		<comments>http://blog.najmanowicz.com/2009/06/15/eric-evans-on-domain-driven-design/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 10:30:21 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Domain Driven Design]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/06/15/eric-evans-on-domain-driven-design/</guid>
		<description><![CDATA[Eric Evans of Domain Driven Design will be giving a talk at PUT just before Eclipse DemoCamp, June 24th @ 18:00.&#160; Cognifide are sponsoring the event and it would be a great chance for you guys to dust of those design skills.&#160; Domain Driven Design is going to be course that we hope to run [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://domaindrivendesign.org/about#eric">Eric Evans</a> of <a href="http://domaindrivendesign.org/">Domain Driven Design</a> will be giving a talk at PUT just before Eclipse DemoCamp, June 24th @ 18:00.&#160; <a href="http://www.cognifide.com/">Cognifide</a> are sponsoring the event and it would be a great chance for you guys to dust of those design skills.&#160; Domain Driven Design is going to be course that we hope to run out of the Cognifide Office late this year with the a little help from our friends at <a href="http://www.skills-matter.com">Skills Matter</a>.</p>
<p><a href="http://skillsmatter.com/event/design-architecture/an-introduction-to-domain-driven-design">Register</a> for the Domain Driven Design that is platform-neutral and in fact, Eric gives .NET and Java versions of the courses.</p>
<p>More on Eric &amp; DDD:    <br /><a href="http://skillsmatter.com/course/design-architecture/domain-driven-design">http://skillsmatter.com/course/design-architecture/domain-driven-design</a>     <br /><a href="http://skillsmatter.com/podcast/design-architecture/domain-driven-design">http://skillsmatter.com/podcast/design-architecture/domain-driven-design</a>     <br /><a href="http://www.infoq.com/interviews/domain-driven-design-eric-evans">http://www.infoq.com/interviews/domain-driven-design-eric-evans</a></p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=141&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/06/15/eric-evans-on-domain-driven-design/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Advanced Language Manipulation Tool for EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:49:11 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Microsoft SqlServer]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/</guid>
		<description><![CDATA[Have you ever (or have your customers) created and edited a page in one language only to realize that their selected locale was wrong? Have you ever wished you could delete a master language branch of a page&#160; after creating its localized counterpart but you could only delete the newly created slave language instead? Have [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever (or have your customers) created and edited a page in one language only to realize that their selected locale was wrong? Have you ever wished you could delete a master language branch of a page&#160; after creating its localized counterpart but you could only delete the newly created slave language instead? Have a customer ever requested that they could copy a whole branch and you convert it to another language so that they could then translate in-place?</p>
<p>Well I have… and I’m sure I will. And so did Fredrikj on the our #epicode IRC channel ;).</p>
<p>Basically I had the tool that would convert from one language to another, but Fredrikj requested something that would switch master language of a page from one to another. Since I’ve already had some of the work done, I’ve updated the stored procedure I’ve written some time ago and slapped a nice GUI up on it. Here’s the result:</p>
<p>&#160;</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/04/andvancedlanguagetool.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AndvancedLanguageTool" border="0" alt="AndvancedLanguageTool" src="http://blog.najmanowicz.com/wp-content/uploads/2009/04/andvancedlanguagetool-thumb.png" width="480" height="484" /></a> </p>
<p>What the tool allows you to do is perform either language conversion or master branch switching on a selected page and all of its children (if you choose so).</p>
<p>The stored procedure have been updated to work on CMS5 R2 (will no longer work on R1 – but if you need that functionality, comment here or give me a shout and I’ll create a compatible version for you).</p>
<p>A word of caution though – I take no guarantee whatsoever about its operation. Especially, if you wreck your client’s database with it. I did what I could to prevent some of the obvious problems (like <strong><em>switching</em></strong> to a non existing master or <strong><em>converting</em></strong> to an existing one) but I will not be responsible if it won’t work for you. make a database backup and experiment there before you do any changes on the real data. That said – it works for me, so I think it should also work for you.</p>
<p>You can download the <a title="Episerver Advanced Language Tools" href="http://www.najmanowicz.com/blog_bin/EPiServerLanguageTools.zip" rel="enclosure">archive containing the tool here</a>. unzip it to your EPiServer web application folder keeping the folder structure or the plugin reference will be wrong. Include the *.aspx and the *.cs files in your project and apply the SQL file to your database (The manipulation is performed by a stored procedure located in the file).</p>
<p>Also if you’re performing the change in a load balanced environment, you may need to restart the other servers once you do the changes. I reset the DataFactory cache, but I am not sure it propagates through to other servers.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=124&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Get out of my way! &#8230; or the story of file metadata for VirtualPathProvider in EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 00:18:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/</guid>
		<description><![CDATA[Immediately after you implement the VirtualPathProvider proxy from my previous post you will notice a one fairly serious lack in it. Namely all the files within that provider will be hiding behind the registration form. That is not cool for a couple of reasons…

You may want to keep all of the files in one store [...]]]></description>
			<content:encoded><![CDATA[<p>Immediately after you implement the VirtualPathProvider proxy from my previous post you will notice a one fairly serious lack in it. Namely all the files within that provider will be hiding behind the registration form. That is not cool for a couple of reasons…</p>
<ul>
<li>You may want to keep all of the files in one store – being forced to put them into a designated folder is not desired. </li>
<li>You may want to make some file freely available for some time and lock it after a while, or the other way around (e.g. to allow the robots to crawl it initially). having to move them is just silly and defeats the purpose. </li>
</ul>
<p>So how do you discriminate the files that you want locked from those that you want to be publically available, and potentially from those that you want only the logged in users to be able to get?</p>
<h2></h2>
<h2>Specifying the EPiServer File Metadata sweetness</h2>
<p>One of the potential solutions would be to define a special rights group and check for that group for the people that have your “registered” magic-cookie. That however introduces a bogus group, and I would rather like to avoid that. However if you look into the <strong><em>FileSummary.config</em></strong> file that’s located in your web application folder you will find a slightly mysterious content. A bit of hacking reveals that you can actually add your own metadata to the file. For example adding the access rights based on what I’ve established above would look as follows (the content you can already find in the file that comes with the public templates that-we-all-oh-so-love is skipped):</p>
<p><span id="more-120"></span></p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">&lt;</span><span style="color: #a31515">root</span><span style="color: blue"> </span><span style="color: red">xmlns:xforms</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://www.w3.org/2002/xforms</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">      </span><span style="color: red">xmlns:xsi</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://www.w3.org/2001/XMLSchema-instance</span>&quot;<span style="color: blue">&gt;</span>

<span style="color: blue">  &lt;</span><span style="color: #a31515">model</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">instance</span><span style="color: blue">&gt;</span>
      ...
<span style="color: blue">      &lt;</span><span style="color: #a31515">AccessLevel</span><span style="color: blue"> /&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">instance</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">model</span><span style="color: blue">&gt;</span>

  ...
<span style="color: blue">  &lt;</span><span style="color: #a31515">xforms:select1</span><span style="color: blue"> </span><span style="color: red">appearance</span><span style="color: blue">=</span>&quot;<span style="color: blue">full</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">                  </span><span style="color: red">ref</span><span style="color: blue">=</span>&quot;<span style="color: blue">AccessLevel</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">id_field51</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Unrestricted<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>Unrestricted<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Requires Registration<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>RequireRegistration<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Requires CMS Login<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>LoggedUserAccess<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">xforms:select1</span><span style="color: blue">&gt;</span>
  ...

<span style="color: blue">&lt;/</span><span style="color: #a31515">root</span><span style="color: blue">&gt;</span></div>
</pre>
<p>Great. So what does it look in the file manager now?</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/03/metadataeditor.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="metadata-editor" border="0" alt="metadata-editor" src="http://blog.najmanowicz.com/wp-content/uploads/2009/03/metadataeditor-thumb.png" width="518" height="355" /></a> </p>
<p>Splendid!</p>
<h2>Accessing the metadata</h2>
<p>Now that we gave the user to specify the metadata, we need the VPP to act upon them. For the benefit of automation of parsing I’ve specified the enum defining the access levels as follows:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">enum</span> <span style="color: #2b91af">FileAccessLevel</span>
{
    Unrestricted,
    RequireRegistration,
    LoggedUserAccess
}
</div>
</pre>
<p>Now we need to update the GetFile method to discriminate the access levels (I have decorated the core lines with <font color="#ff0000">&#8211;<strong>&gt;</strong></font>) those are the lines that access the meta data based on their format specified in the <strong><em>FileSummary.config</em></strong>.</p>
<pre class="brush: csharp; highlight: [11, 12, 13]">
public override VirtualFile GetFile(string virtualPath)
{
    string handledPath;

    if (TryGetHandledAbsolutePath(virtualPath, out handledPath))
    {
        UnifiedFile file = base.GetFile(virtualPath) as UnifiedFile;

        if (file != null)
        {
            string strAccessLevel = (string) file.Summary.Dictionary["AccessLevel"] ??
                                    FileAccessLevel.RequireRegistration.ToString();
            FileAccessLevel accessLevel = (FileAccessLevel) Enum.Parse(typeof (FileAccessLevel), strAccessLevel);

            bool isLoggedIn = HttpContext.Current.Profile != null &#038;&#038; !HttpContext.Current.Profile.IsAnonymous;
            bool isRegistered = HttpContext.Current.Request.Cookies.AllKeys.Contains(PASS_COOKIE_NAME);
            string email = isRegistered ? HttpContext.Current.Request.Cookies[PASS_COOKIE_NAME].Value :
                (isLoggedIn ? HttpContext.Current.Profile.UserName : "unregistered");

            switch (accessLevel)
            {
                case (FileAccessLevel.Unrestricted):
                    return file;
                    break;
                case(FileAccessLevel.RequireRegistration):
                    if (!isRegistered &#038;&#038; ! isLoggedIn)
                    {
                        HttpContext.Current.Response.Redirect(
                            string.Format(registrationFormUrl,
                                          HttpContext.Current.Server.HtmlEncode(virtualPath)));
                        return null;
                    }
                    return file;
                    break;
                case(FileAccessLevel.LoggedUserAccess):
                    if (isLoggedIn)
                    {
                        return file;
                    }
                    return null;
                    break;
                default:
                    return file;
            }
        }
    }
    return Previous.GetFile(virtualPath);
}
</pre>
<p>Now the user is really in control of what is published to the general public and robots, what is protected with the registration form and what is only available to logged in users. (now you may add more granularity with file rights naturally, this is just a basic setting that an editor without administrative rights can add.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=120&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple registration for files served by EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 21:01:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/</guid>
		<description><![CDATA[With the culture of knowledge sharing and open source spreading, everyone races to show they have something valuable that you may want. And while you may not ask for money for your content you may still want to get something in return, say a contact, an email address that’s verified (or not), to keep in [...]]]></description>
			<content:encoded><![CDATA[<p>With the culture of knowledge sharing and open source spreading, everyone races to show they have something valuable that you may want. And while you may not ask for money for your content you may still want to get something in return, say a contact, an email address that’s verified (or not), to keep in touch with the consumer of your content. </p>
<p>Yet a full fledged registration doesn’t seem like a proper thing to do – cluttering your EPiServer user repository with (let’s face it – for a large part fake or temporary email addresses that user create only to get your content).</p>
<p>While there may be a lot of ways to handle that (streaming it through a page Response.WriteFile might seem as one of the more obvious ones), I would like to show you a cleaner, simpler and more elegant way that I’ve come up with.</p>
<p>We really don’t want people to deep link to our files without them knowing the files are from our site, that’s just rude – so hiding them behind an obscure URL wouldn’t work (thus we cannot use the regular file providers). We’ve already establish that we don’t want to log them in, so setting file rights are useless. But I want all the benefits including client-side caching.</p>
<p>Basically the solution boils down to creating a thin layer over the File provider of our choice, in my case the versioning file provider. The only method we need to override in it is <strong>GetFile</strong>. I want to allow downloading for logged in users and I want to allow downloading for all users that have a “magic-cookie” set. If either of the conditions are met, the file just downloads using the underlying provider’s routines including all the logic EPiServer has put for caching and rights. But if neither of the requirements are met, the user is directed to a page of our choice. </p>
<p><span id="more-117"></span></p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt"><span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">VirtualFile</span> GetFile(<span style="color: blue">string</span> virtualPath)
{
    <span style="color: blue">string</span> handledPath;

    <span style="color: blue">if</span> (TryGetHandledAbsolutePath(virtualPath, <span style="color: blue">out</span> handledPath))
    {
        <span style="color: blue">if</span> ((<span style="color: #2b91af">HttpContext</span>.Current.Profile != <span style="color: blue">null</span> &amp;&amp; !<span style="color: #2b91af">HttpContext</span>.Current.Profile.IsAnonymous) ||
            <span style="color: #2b91af">HttpContext</span>.Current.Request.Cookies.AllKeys.Contains(PASS_COOKIE_NAME))
        {
            <span style="color: blue">return</span> <span style="color: blue">base</span>.GetFile(virtualPath);
        }

        <span style="color: #2b91af">HttpContext</span>.Current.Response.Redirect(
            <span style="color: blue">string</span>.Format(registrationFormUrl,<span style="color: #2b91af">HttpContext</span>.Current.Server.HtmlEncode(virtualPath)));
        <span style="color: blue">return</span> <span style="color: blue">null</span>;
    }
    <span style="color: blue">return</span> Previous.GetFile(virtualPath);
}</div>
</pre>
<p>How you specify that page’s totally up to you, but there is a nice initialization routine called during the Virtual Path Provider loading phase where all of the settings that are specified in your relevant web.config VPP declaration are passed to you, why not use it? What you’ll need define your VPP in the web.config is what follows:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">&lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">showInFileManager</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue"> </span><span style="color: red">virtualName</span><span style="color: blue">=</span>&quot;<span style="color: blue">CookieEnabled</span>&quot;<span style="color: blue"> </span><span style="color: red">virtualPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">~/CookieEnabled/</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">bypassAccessCheck</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">CookieEnabled</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">Cognifide.EPiServer.CookieEnabledVirtualPathProvider.CookieEnabledVirtualPathProvider,Cognifide.EPiServer.CookieEnabledVirtualPathProvider</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">indexingServiceCatalog</span><span style="color: blue">=</span>&quot;<span style="color: blue">Web</span>&quot;<span style="color: blue"> </span><span style="color: red">physicalPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">C:\vpp\Resources</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">RegistrationFormUrl</span><span style="color: blue">=</span>&quot;<span style="color: blue">/File-Asset-Request-Form/?filepath={0}</span>&quot;<span style="color: blue"> /&gt;</span>
</div>
</pre>
<p>
  <br />you can then define your class as:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">CookieEnabledVirtualPathProvider</span> : <span style="color: #2b91af">VirtualPathVersioningProvider</span>
{
    <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">string</span> REGISTRATION_FORM_URL_WEB_CONFIG_PARAM_NAME = <span style="color: #a31515">&quot;RegistrationFormUrl&quot;</span>;
    <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> PASS_COOKIE_NAME = <span style="color: #a31515">&quot;ResourcePass&quot;</span>;
    <span style="color: blue">private</span> <span style="color: blue">string</span> registrationFormUrl;

    <span style="color: blue">public</span> CookieEnabledVirtualPathProvider(<span style="color: blue">string</span> name, <span style="color: #2b91af">NameValueCollection</span> configParameters) :
        <span style="color: blue">base</span>(name, configParameters)
    {
        registrationFormUrl = configParameters[REGISTRATION_FORM_URL_WEB_CONFIG_PARAM_NAME];
    }

    ...

}
</div>
</pre>
<p>So we know now where we want to direct people without a “magic-cookie” who want to get our assets, and how to do it, but how do we finally allow that file to get down to them?</p>
<p>In your page – for the same of simplicity I assume you will be using XForms for gathering the user data, but that really does not matter. When you validate the form data (or get the user to click on a link that you’ve sent them) you just set the “magic” cookie that I called “ResourcePass” to any value and to to expire in some a long amount of time, like a year. So that they can now access your files unrestrained and direct them BACK at the URL they came from – and now the VPP will allow them to just download the file they initially requested:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">protected</span> <span style="color: blue">void</span> XForm_BeforeSubmitPostedData(<span style="color: blue">object</span> sender, <span style="color: #2b91af">SaveFormDataEventArgs</span> e)
{
    <span style="color: blue">if</span> (!Page.IsValid)
    {
        e.CancelSubmit = <span style="color: blue">true</span>;
    }
    <span style="color: blue">else</span>
    {
        <span style="color: blue">string</span> requestedFile = Request.Params[<span style="color: #a31515">&quot;filepath&quot;</span>];
        <span style="color: #2b91af">HttpCookie</span> cookie = <span style="color: blue">new</span> <span style="color: #2b91af">HttpCookie</span>(<span style="color: #2b91af">CookieEnabledVirtualPathProvider</span>.PASS_COOKIE_NAME, <span style="color: #a31515">&quot;true&quot;</span>);
        cookie.Expires = <span style="color: #2b91af">DateTime</span>.Now.AddYears(1);
        cookie.HttpOnly = <span style="color: blue">true</span>;
        Response.Cookies.Add(cookie);
        <span style="color: blue">if</span> (!<span style="color: blue">string</span>.IsNullOrEmpty(requestedFile))
        {
            Response.Redirect(requestedFile);
        }
    }
}
</div>
</pre>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=117&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WebParts based Sidebar for EPiServer &#8211; how to use it?</title>
		<link>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/</link>
		<comments>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 17:06:47 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>
		<category><![CDATA[WebParts]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/</guid>
		<description><![CDATA[Once you’ll update the framework to the extended one, you will immediately notice that… nothing has changed. Hmm… did something go wrong? 
Well, not really. By default the framework will be run in the “legacy mode”. Thanks to an old article by our own Marek Blotny, I’ve learned how to build Plugin settings which are [...]]]></description>
			<content:encoded><![CDATA[<p>Once you’ll update the framework to the extended one, you will immediately notice that… nothing has changed. Hmm… did something go wrong? </p>
<p>Well, not really. By default the framework will be run in the “legacy mode”. Thanks to <a href="http://marekblotny.blogspot.com/2008/07/plugins-and-datafactory-event-handlers.html">an old article by our own Marek Blotny</a>, I’ve learned how to build Plugin settings which are just perfect for the purpose!</p>
<p align="left">So to configure and enable the new features you need to open your admin UI and in the “Config” click on the “Plugin Manager” item and select our framework plugin as shown in the picture</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings1.png"><img title="WebPartFrameworkPluginSettings1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="WebPartFrameworkPluginSettings1" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings1-thumb.png" width="244" border="0" /></a></p>
<p>The available options are:</p>
<p><span id="more-110"></span><br />
<table cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr>
<td><b>Setting Name</b></td>
<td><b>Meaning</b></td>
<td><b>Sample</b></td>
</tr>
<tr>
<td><b><i>Default WebParts Path Pattern</i></b></td>
<td>The pattern to be used when no pattern is defined for a page.</td>
<td>%inherit%</td>
</tr>
<tr>
<td><b><i>WebParts Path Patterns</i></b></td>
<td>The semicolon separated pairs of pattern;pattern name;          <br />This is the part you will want to customize most.</td>
<td>%template%|%pageid%%legacyregion%;Legacy regionalized;%template%|%pageid%;Legacy globalized;page|%pageid%|%region%;Page/region;pagetype|%pagetypeid%;Page Type</td>
</tr>
<tr>
<td><b><i>Cache WebParts in Memory</i></b></td>
<td>Determines whether the WebParts are to be cached&#160; between usages (this is useful for a small set of WebParts (like a number of sidebars) but rather discouraged if you use the legacy mode as there can be a lot of those in such case.</td>
<td>unchecked by default (check to improve performance in sidebar mode)</td>
</tr>
<tr>
<td><b><i>Legacy WebParts Support (per-page only)</i></b></td>
<td>If checked, disables the extensions described by this blog.</td>
<td>checked by default (uncheck to enable the sidebar extensions)</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>As shown here:</p>
<p><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings2.png"><img title="WebPartFrameworkPluginSettings2" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="179" alt="WebPartFrameworkPluginSettings2" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings2-thumb.png" width="244" border="0" /></a> </p>
<p>&#160;</p>
<p>Once you fill in the settings as they are suggested in the above table the context menu (or adjust to your needs) will show you the new options:</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings3.png"><img title="WebPartFrameworkPluginSettings3" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="173" alt="WebPartFrameworkPluginSettings3" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings3-thumb.png" width="244" border="0" /></a> </p>
</p>
<p>The new sub menu will allow you to change the pattern by which the WebParts are selected, while “Edit Web Parts” option will enable you to edit the WebParts for the current effective WebPart set.</p>
<p><font color="#ff0000"><strong>First of all – if you want to select a pattern on a page you need a means of storing it. At this moment The framework does it in a property. Which means &#8211; for every page type that wants to redefine the web parts rather than using the default pattern (in our case %inherited%) you need to add String property with a “WebPartsPath” name (I may actually add some routines to add the property definition automatically if there will be enough demand for that).</strong></font></p>
<h1>What does “Effective WebPart Set” mean?</h1>
<p>Assuming (which is the most interesting scenario) that %inherit% is the default pattern the following is true: </p>
<p>&#160;</p>
<table border="1">
<tbody>
<tr>
<td><b>Page</b></td>
<td><b>WebPartsPath</b></td>
<td><b>Effective path</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>Start</td>
<td>&#160;</td>
<td>%root%</td>
<td>Since it&#8217;s a start page and it does not define path %root% is used.</td>
</tr>
<tr>
<td>+ News</td>
<td>&#160;</td>
<td>%root%</td>
<td>inherits from start page which does not define path but inherits from %root%.</td>
</tr>
<tr>
<td>+ Events</td>
<td>page|%pageid%</td>
<td>page|5</td>
<td>directly implements its own pattern.</td>
</tr>
<tr>
<td>| + Partner Day</td>
<td>%inherit%</td>
<td>page|5</td>
<td>Inherits after its parent page.</td>
</tr>
<tr>
<td>+ International</td>
<td>page|%pageid%|%region%</td>
<td>page|6|en, page|6|se</td>
<td>Defines separate WebParts for every language that the page is created for.</td>
</tr>
<tr>
<td>| + Sweden</td>
<td>%inherit%</td>
<td>page|6|se</td>
<td>Inherits after its parent page in its own language.</td>
</tr>
<tr>
<td>| + England</td>
<td>%inherit%</td>
<td>page|6|en</td>
<td>Inherits after its parent page in its own language.</td>
</tr>
</tbody>
</table>
<p>Once you select the effective web parts for the page or just agree with the WebParts pre-selected for you based on the default path you can edit them just like previously. Mind that when you edit WebParts on a page all the pages that have the same “effective path” are going to change as well. (which was our intention in the first place).</p>
<p>&#160;</p>
<p>The library extension is going to be posted on Epicode as soon as I get a hold of Steve to approve the changes :)</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=110&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebParts based Sidebar for EPiServer &#8211; the motivation and specification</title>
		<link>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/</link>
		<comments>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 14:04:12 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>
		<category><![CDATA[WebParts]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/</guid>
		<description><![CDATA[Back in the day when we started designing our last project we’ve been presented with a following problem – a big number of templates with slightly different sidebars.
Hmm… 
Is sidebar a part of content? No, rather not. We don’t want the editors to have to setup the sidebar for every article they write (and the [...]]]></description>
			<content:encoded><![CDATA[<p>Back in the day when we started designing our last project we’ve been presented with a following problem – a big number of templates with slightly different sidebars.</p>
<p>Hmm… </p>
<p>Is sidebar a part of content? No, rather not. We don’t want the editors to have to setup the sidebar for every article they write (and the site has a few dozens of articles created on it every day).</p>
<p>Is sidebar more of a template thing? Well… more like it, but still… we have articles all over the site with different sidebar elements when the articles are in different parts of the site (ok so we could add rules what controls display in which part of the site). <strong>But wait! There’s more!</strong> The sidebar will be different for every language (region). Now we’re talking a dozen of templates or a rules engine just to make the sidebar different. Customising the template with properties isn’t ideal either as it makes EPiServer UI very cluttered. Additionally we want to change sidebars across many templates so the whole branch/section of the site will be able to share the same sidebar.</p>
<p>To a degree this is an academic discussion as we’ve been through it with the previous version of the site and we already knew that integrating this stuff into templates just won’t work and we will be in a world of pain just changing the templates over and over adding little tweaks and changes while the customer ads promotions and performs ad campaigns. Well, we can do it, of course, but it’s not a work a programmer will enjoy, and we all want to do new and more exciting things, don’t we?</p>
<p>We have an internally developed&#160; module to make something like that, that is fully home-grown by another internal team (we now have 3 “squads” capable or making incredible things with EPiServer and we tend to share a lot of technologies and try to rotate people around to adopt the good habits and experiences) and I was (and still am) VERY impressed by it. The technology uses EPiServer pages for defining every module (which are located somewhere outside the site root branch. and then you can mix and match them either declaratively in the code) or by handpicking them in the UI. It’s really cool, though, during the discussions it turned out that we might have to add big chunks of functionality and might end up with separate branches of module-pages for different languages/regions, but… frankly… about that time <a href="http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/8/Using-web-parts-in-EPiServer/">an article by Ted Nyberg</a> reminded me about a technology I have read about quite a while ago in <a href="http://labs.episerver.com/en/Blogs/Stein-Viggo-Grenersen/Dates/112262/2/EPiServer-on-steroids/">an article by Stein-Viggo Grenersen</a> and ooohhhhhh… I got seduced. I really wanted to try if for a long time and Ted’s article made it a snap to try and get convinced, and more important… convince Stu ;) that it’s the right way to explore.</p>
<h2>So I started to dig.</h2>
<p><span id="more-103"></span></p>
<h2></h2>
<p><a href="http://labs.episerver.com/en/Blogs/Stein-Viggo-Grenersen/Dates/112262/2/EPiServer-on-steroids/"><img style="display: inline; margin: 0px 10px 0px 0px" src="http://www.najmanowicz.com/blog_images/DragDropWebPartsmaller.gif" align="left" /></a>Talked with <a href="http://stevecelius.spaces.live.com/">Steve</a> (the original creator of the Framework) a bit and learned that I can “customize a path rewriter” to suit my needs. Great! I just hoped I won’t have to deal with some nasty GUID’s matching, but no! Turns out, all it takes to identify a WebPart set is to have any unique string naming it.</p>
<p>So basically what we needed was a manager to deal with the naming templates and a way to determine the WebParts set to be used per page.</p>
<p>Till now the framework used template file name followed by the page ID, followed by an eventual language/region if a page was not the master branch, for example:</p>
<blockquote><p>~/templates/Demo/WebPartPage.aspx|26    <br />~/templates/Demo/WebPartPage.aspx|26|en-us </p></blockquote>
<p>which makes them unique per page, which is not as appealing when you use EPiServer as it for a big part duplicates its functionality. Also a bit of a caveat here for agile programming methodology which promotes an often and early refactoring – if you move your page around or change its name – you lose the WebParts for all pages using it.</p>
<p>What we needed is a flexible and extensible scheme for reusing “WebParts sets” and that’s what our extension allows for.</p>
<p>Also since we’re very performance sensitive, and we operate in a multi server scenarios a lot we’ve added web parts blobs caching. Meaning that the site does not have to reach to the database every time a page is rendered.</p>
<p>The very appealing side of the framework is that it can be extended form the bottom (persistence) from the top (editors, controls, webparts), as well as being pluggable with custom plumbing.</p>
<h2>The Sidebar Extensions for WebParts Framework</h2>
<p>So to put all the requirements together, we needed the sidebars to be:</p>
<ul>
<li>customizable (out of the box) </li>
<li>easy to use for both developers and editors (out of the box) Wow Steve, I can’t really appreciate enough how cool it is to code for it and how nice it is for the users! </li>
<li>localizable </li>
<li>reusable </li>
<li>inheritable for site branches </li>
</ul>
<h2>WebParts path patterns</h2>
<p>The main idea was to free the path names from the restriction they had – being hardcoded for a page. So to do it without hard-coding them I’ve introduced path patterns. </p>
<h3>What is a pattern?</h3>
<p>Basically a pattern is a way the framework is supposed to encode the WebParts&#160; id for the system to identify. Your site can have any number of “named patterns” and the framework gives you means of switching between them. Pattern allow for almost any string to be a part of it although some tokens have special meaning:</p>
<table cellspacing="0" cellpadding="2" width="680" border="0">
<tbody>
<tr>
<td valign="top" width="200"><strong>Token</strong></td>
<td valign="top" width="478"><strong>Replacemnt Value</strong></td>
</tr>
<tr>
<td valign="top" width="200">%pageid%</td>
<td valign="top" width="478">id of the page the path is formed for</td>
</tr>
<tr>
<td valign="top" width="200">%region%</td>
<td valign="top" width="478">language/region of the WebParts</td>
</tr>
<tr>
<td valign="top" width="200">%pagetypeid%</td>
<td valign="top" width="478">type of the page</td>
</tr>
<tr>
<td valign="top" width="200">%template%</td>
<td valign="top" width="478">legacy token to make it possible to use template names as part of path.          <br />This is just for compatibility so you can have some of the pages using an old scheme.</td>
</tr>
<tr>
<td valign="top" width="200">%legacyregion%</td>
<td valign="top" width="478">legacy token for regionalizable pages (usage described later)</td>
</tr>
<tr>
<td valign="top" width="200">%inherited%</td>
<td valign="top" width="478">states that a page shoud inherit its WebParts from its parent in the page hierarchy (this can only be used as a complete pattern – cannot be a part of a larger pattern)</td>
</tr>
<tr>
<td valign="top" width="200">%root%</td>
<td valign="top" width="478">(again whole pattern) the %root% token is used when the inheritance based on hierarchy does not resolve into another token while reaching the root page.</td>
</tr>
</tbody>
</table>
<h3>Some sample patterns</h3>
<table cellspacing="0" cellpadding="2" width="600" border="1">
<tbody>
<tr>
<td valign="top" width="100"><strong>Name</strong></td>
<td valign="top" width="100"><strong>Pattern</strong></td>
<td valign="top" width="150"><strong>Sample Instance</strong> <strong>of the Pattern</strong></td>
<td valign="top" width="200"><strong>Description</strong></td>
</tr>
<tr>
<td valign="top" width="100">Root pattern</td>
<td valign="top" width="100">%root%</td>
<td valign="top" width="150">%root%</td>
<td valign="top" width="200">The pattern that all inheritance automatically falls back to</td>
</tr>
<tr>
<td valign="top" width="100">Inherited</td>
<td valign="top" width="100">%inherit%</td>
<td valign="top" width="150">anything parent defines</td>
<td valign="top" width="200">Tells the page to use the web parts its parent is using – the inheritance is possible all the way up in the hierarchy to the %root% pattern, meaning – if my parent inherits its WebParts from its parent, so will I.</td>
</tr>
<tr>
<td valign="top" width="100">Legacy regionalized</td>
<td valign="top" width="100">%template%|%pageid%%legacyregion%</td>
<td valign="top" width="150">~/templates/Demo/​​WebPartPage.aspx|26|en-us</td>
<td valign="top" width="200">Creates legacy “non language independent path”</td>
</tr>
<tr>
<td valign="top" width="100">Legacy global </td>
<td valign="top" width="100">%template%|%pageid%</td>
<td valign="top" width="150">~/templates/Demo/​​WebPartPage.aspx|26</td>
<td valign="top" width="200">Creates legacy “language independent path”</td>
</tr>
<tr>
<td valign="top" width="100">Page/region specific</td>
<td valign="top" width="100">page|%pageid%|%region%</td>
<td valign="top" width="150">page|26|en-us</td>
<td valign="top" width="200">template independent per-page/per-language pattern</td>
</tr>
<tr>
<td valign="top" width="100">PageType specific</td>
<td valign="top" width="100">pagetype|%pagetypeid%</td>
<td valign="top" width="150">pagetype|5</td>
<td valign="top" width="200">page type specific path (notice how the previous pattern has “page” and this one has “pagetype” in it) – this is done to avoid conflicts in numbers between pages and page types of the same id</td>
</tr>
<tr>
<td valign="top" width="100">My Sidebar</td>
<td valign="top" width="100">my-sidebar</td>
<td valign="top" width="150">my-sidebar</td>
<td valign="top" width="200">You can create “named sets” that will stay the same across all pages using it</td>
</tr>
<tr>
<td valign="top" width="100">My Localizable Sidebar</td>
<td valign="top" width="100">my-sidebar|%region%</td>
<td valign="top" width="150">my-sidebar|en-us</td>
<td valign="top" width="200">A localized version of the previous “named set”</td>
</tr>
</tbody>
</table>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=103&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Text-Image generation &#8211; VirtualPathProvider for EPiServer (and ASP.NET in general) &#8211; Part 2 (configuration)</title>
		<link>http://blog.najmanowicz.com/2008/06/24/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-2-configuration/</link>
		<comments>http://blog.najmanowicz.com/2008/06/24/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-2-configuration/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 18:36:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2008/06/24/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-2-configuration/</guid>
		<description><![CDATA[
The configuration of the module is a descendant of any EPiServer Virtual Path Provider configuration. This aspect is fairly well described on EPiServer pages. 
A sample configuration for the TextImageVirtualPathProvider can look as follows

&#60;configuration&#62;
  &#60;episerver&#62;
    &#60;virtualPath
      &#60;providers&#62;
        &#60;add showInFileManager="false"
 [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>The configuration of the module is a descendant of any EPiServer Virtual Path Provider configuration. This aspect is fairly well <a href="http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-SP2/Virtual-Path-Providers-in-EPiServer-CMS-5/">described on EPiServer pages</a>. </p>
<p>A sample configuration for the TextImageVirtualPathProvider can look as follows</p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: blue">&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;</span><span style="color: #a31515">episerver</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">virtualPath</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">providers</span><span style="color: blue">&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">showInFileManager</span><span style="color: blue">=</span>"<span style="color: blue">false</span>"
<span style="color: blue">             </span><span style="color: red">virtualName</span><span style="color: blue">=</span>"<span style="color: blue">Text Images</span>"
<span style="color: blue">             </span><span style="color: red">virtualPath</span><span style="color: blue">=</span>"<span style="color: blue">~/TextImages/</span>"
<span style="color: blue">             </span><span style="color: red">bypassAccessCheck</span><span style="color: blue">=</span>"<span style="color: blue">false</span>"
<span style="color: blue">             </span><span style="color: red">name</span><span style="color: blue">=</span>"<span style="color: blue">TextImages</span>"
<span style="color: blue">             </span><span style="color: red">type</span><span style="color: blue">=</span>"<span style="color: blue">Cognifide.ImageVirtualPathProvider.TextImageVirtualPathProvider,Cognifide.ImageVirtualPathProvider</span>"
<span style="color: blue">             </span><span style="color: red">physicalPath</span><span style="color: blue">=</span>"<span style="color: blue">C:\temp\TextImages</span>"
<span style="color: blue">             </span><span style="color: red">allowedReferers</span><span style="color: blue">=</span>"<span style="color: blue">(localhost)</span>"
<span style="color: blue">             </span><span style="color: red">allowNullReferrer</span><span style="color: blue">=</span>"<span style="color: blue">false</span>"
<span style="color: blue">             </span><span style="color: red">replacementStrings</span><span style="color: blue">=</span>"<span style="color: blue">$colon$,:,$gt$,&gt;,$dot$,.,$quot$,</span><span style="color: red">&amp;quot;</span><span style="color: blue">,$amp$,</span><span style="color: red">&amp;amp;</span><span style="color: blue">,$star$,*,$eol$,</span><span style="color: red">&amp;#10;</span><span style="color: blue">,</span>"<span style="color: blue">/&gt;</span>
<span style="color: blue">      &lt;/</span><span style="color: #a31515">providers</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">virtualPath</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">episerver</span><span style="color: blue">&gt;</span>
<span style="color: blue">&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span>
</div>
</pre>
<p>&nbsp;</p>
<p>where:</p>
<ul>
<li>physicalPath is where the cached version of images will be stored
</li>
<li>shownInFileManager is “false” as there is nothing to present for the user in the file manager.
</li>
<li>allowedReferrers is the regular expression containing the filter for sites that are allowed to access the path provider and get images. This has been added so that your server does not turn into the internet’s text-image open service :)
</li>
<li>allowNullReferrer should be set to false in production environment but allows for testing by directly creating URL’s without using a page to fill in the referrer.
</li>
<li>replacementStrings – this one actually turned out to be very useful since some characters are invalid and not even reaching the VPP if EPiServer or ASP detects them. so to allow for characters like colon or &lt; or even a dot (which would make it hard to form regular expression if it was explicitly available) or * you need to create an escape token for them. The string is a coma separated list of token,value,token,value,…
</li>
<li>virtualPath is something you need to change if you want your VPP to serve images under a different root level folder. (e.g. if you have a page with that name already)</li>
</ul>
<p>&nbsp;</p>
<p>Additionally for IIS6 (most common scenario) you need to add &lt;location&gt; node to configuration for the VPP to work. </p>
<p><span style="color: blue">&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp; &lt;</span><span style="color: #a31515">location</span><span style="color: blue"> </span><span style="color: red">path</span><span style="color: blue">=</span>&#8220;<span style="color: blue">TextImages</span>&#8220;<span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211;</span><span style="color: green"> Setup the StaticFileHandler for the wildcard mapping to work in IIS6</span><span style="color: blue">&#8211;&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">httpHandlers</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">path</span><span style="color: blue">=</span>&#8220;<span style="color: blue">*</span>&#8220;<span style="color: blue"> </span><span style="color: red">verb</span><span style="color: blue">=</span>&#8220;<span style="color: blue">GET,HEAD</span>&#8220;<span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&#8220;<span style="color: blue">System.Web.StaticFileHandler</span>&#8220;<span style="color: blue"> </span><span style="color: red">validate</span><span style="color: blue">=</span>&#8220;<span style="color: blue">true</span>&#8220;<span style="color: blue"> /&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">httpHandlers</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&nbsp;&nbsp;&nbsp; &lt;</span><span style="color: #a31515">staticFile</span><span style="color: blue"> </span><span style="color: red">expirationTime</span><span style="color: blue">=</span>&#8220;<span style="color: blue">-1.0:0:0</span>&#8220;<span style="color: blue"> /&gt;</span><br /><span style="color: blue">&nbsp; &lt;/</span><span style="color: #a31515">location</span><span style="color: blue">&gt;</span><br /><span style="color: blue">&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span></p>
<pre>
</pre>
<p>Unless you want to change the location of the virtual path provider can be found under, there is nothing you need to change here.</p>
<p>The <a href="https://www.coderesort.com/p/epicode/browser/Cognifide.ImageVirtualPathProvider/5.x">code is accessible on EPiCode</a>, but you can also <a href="http://www.najmanowicz.com/blog_bin/Cognifide.ImageVirtualPathProvider.zip">download a compiled binary here</a>. All you need to do then is to unzip the archive to the “bin” folder within your site and set the web.config values to your preference.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=101&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2008/06/24/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-2-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Text-Image generation &#8211; VirtualPathProvider for EPiServer (and ASP.NET in general) &#8211; Part 1</title>
		<link>http://blog.najmanowicz.com/2008/06/23/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-1/</link>
		<comments>http://blog.najmanowicz.com/2008/06/23/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-1/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 18:00:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2008/06/23/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-1/</guid>
		<description><![CDATA[The module code is already available on Epicode SVN, the relevant wiki pages will be following as soon as documentation is complete.
The use case is as follows:

The client wants the site to look exactly as in a template provided as a image, 
the text is using a non standard font that is not available on [...]]]></description>
			<content:encoded><![CDATA[<p>The module code is already available on Epicode SVN, the relevant wiki pages will be following as soon as documentation is complete.</p>
<p>The use case is as follows:</p>
<ul>
<li>The client wants the site to look exactly as in a template provided as a image, </li>
<li>the text is using a non standard font that is not available on 60% of Windows machines, </li>
<li>the site does not use flash. </li>
<li>the site needs to be equally good looking in IE6 (more about it later) </li>
</ul>
<p>The solution was to generate images, but how to do it the right way? This has presented us with a once-in-a-lifetime :) opportunity to create a virtual path provider, do something good and learn something new &amp; cool in the process.</p>
<h2>Creating a new virtual path provider.</h2>
<p>this functionality in itself is fairly well <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx">documented on MSDN</a> one thing to pay attention to is to remember to pass the control to the next provider in the provider queue if your provider does not want to serve the request, so in my case:</p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new">        <span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">VirtualFile</span> GetFile(<span style="color: blue">string</span> virtualPath)
        {
            <span style="color: blue">if</span> (IsPathVirtual(virtualPath))
                <span style="color: #2b91af">VirtualFile</span> file = <span style="color: blue">new</span> <span style="color: #2b91af">TextImageVirtualFile</span>(<span style="color: blue">this</span>, virtualPath);
                <span style="color: blue">return</span> file;
            <span style="color: blue">else</span>
                <span style="color: red"><strong>return Previous.GetFile(virtualPath);</strong></span>
        }</div>
</pre>
<p>this is necessary so you don’t have to have all-or nothing solution (your provider either serving everything the user requests or not being accessible at all) and honestly I’ve spent quite a while before I found out that… I was just being silly – thinking the technology by itself will resolve that ;)</p>
<p>If your Virtual path provider does not actually implement directories you don’t have to make the very provider to do a lot of complicated things. you are perfectly fine to limit the implementation to providing a custom constructor so that EPiServer passes you the configuration data and a couple of methods to tell whether a file is what you want to handle or not</p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: green">// this one is actually really cool - whatever values you set in your web.config </span>
<span style="color: green">// will be passed to you in the collection so you can really make your VPP </span></div>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: green">// as configurable as necessary</span>
<span style="color: blue">public</span> TextImageVirtualPathProvider(<span style="color: blue">string</span> name, <span style="color: #2b91af">NameValueCollection</span> configAttributes)</div>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new">
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: green">// This one resolves if the file can be generated</span>
<span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">bool</span> FileExists(<span style="color: blue">string</span> virtualPath) { <span style="color: green">/* ... */</span> }

<span style="color: green">// Pretty much only passes the info that directory was not found </span>
<span style="color: green">// found if the virtual path matches a path that we should handle</span>
<span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: blue">bool</span> DirectoryExists(<span style="color: blue">string</span> virtualDir) {  <span style="color: green">/* ... */</span>  }

<span style="color: green">// Retrieves the virtual file that generates the image if the</span>
<span style="color: green">// Virtual path matches our pattern or disregards the request if it doesn't</span>
<span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">VirtualFile</span> GetFile(<span style="color: blue">string</span> virtualPath) {  <span style="color: green">/* ... */</span>  }

<span style="color: green">// Again this is only a pass through method as we don't support directories</span>
<span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">VirtualDirectory</span> GetDirectory(<span style="color: blue">string</span> virtualDir) {  <span style="color: green">/* ... */</span> }</div>
</div>
</pre>
<p>Now that we have ASP passing the request to us we need to wonder how to format the request in a way that is intuitive to the user, I wanted the URL to be straightforward and follow the path of EPiServer’s friendly URL-S so that they are easily formed by editors. So how about:</p>
<p><a href="http://my.server.com/color/font-name/font-size/The%20text%20i%20want%20toprint.gif">http://my.server.com/color/font-name/font-size/The%20text%20i%20want%20to%20print.gif</a></p>
<p>Ok.. well…, that won’t fly for GIFs &#8211; the font will be plain ugly if I don’t use antialiasing and if I do I will have an ugly black background underneath it. The solution to that would be using translucent PNG (which the VPP supports) but IE6 does not support those with transparency without ugly hacks. So I need to replace the blacks with a hint so that it generates a background colour when it merges the background with the font for antialiasing. For the sake of this article let’s assume it was an easy switch (IT WASN’T!) and let’s extend the URL to:</p>
<p><a href="http://my.server.com/color/antialias-hint-color/font-name/font-size/the-text-i-want-to-print.gif">http://my.server.com/color/antialias-hint-color/font-name/font-size/The%20text%20i%20want%20to%20print.gif</a></p>
<p>But I need the font to be bold! Ok… ok…</p>
<p><a href="http://my.server.com/color/antialias-hint-color/font-name/font-size/font-formatting/The%20text%20i%20want%20to%20print.gif">http://my.server.com/color/antialias-hint-color/font-name/font-size/font-formatting/The%20text%20i%20want%20to%20print.gif</a></p>
</p>
<p>Can I have the image rotated too? Sigh….</p>
</p>
<p><a href="http://my.server.com/color/antialias-hint-color/font-name/font-size/font-formatting(optional)/transformatio(optional)/The%20text%20i%20want%20to%20print.gif">http://my.server.com/color/antialias-hint-color/font-name/font-size/font-formatting(optional)/transformatio(optional)/The%20text%20i%20want%20to%20print.gif</a></p>
<p>The image rotation follows the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.rotatefliptype(VS.71).aspx">RotateFlipType enumeration</a> so you can specify any string that is defined in the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.rotatefliptype(VS.71).aspx">MSDN documentation for the enumeration</a>.</p>
</p>
<p>A sample result for the URL:</p>
<p><a title="http://cms5.cognifide.com/TextImages/Blue/white/Courier%20New/40/BUI/rotate270flipnone/Hello$eol$from$eol$Cognifide!.gif" href="http://my.server.com/TextImages/Blue/white/Courier%20New/40/BUI/rotate270flipnone/Hello$eol$from$eol$Cognifide!.gif">http://my.server.com/TextImages/Blue/white/Courier%20New/40/BUI/rotate270flipnone/Hello$eol$from$eol$Cognifide!.gif</a></p>
<p>Will look as follows</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2008/06/helloeolfromeolcognifide.png"><img title="Hello$eol$from$eol$Cognifide!" style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="240" alt="Hello$eol$from$eol$Cognifide!" src="http://blog.najmanowicz.com/wp-content/uploads/2008/06/helloeolfromeolcognifide-thumb.png" width="124" border="0" /></a>&#160;</p>
<h2></h2>
<h2>For the curious</h2>
<p>The final string format matching regular expression looks as follows: </p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: #2b91af">Regex</span> regex = <span style="color: blue">new</span> <span style="color: #2b91af">Regex</span>(
<span style="color: #a31515">    @&quot;^(?&lt;colour&gt;                  # The first match - starting form the beginning of the string</span></div>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: #a31515">    ([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[a-zA-Z]*))   # match either a 6 hex digit string or a name of a known color - this is for text color</span>
<span style="color: #a31515">    /                             # now we expect the first separating slash</span>
<span style="color: #a31515">    (?&lt;hint&gt;                      # next match group is about background hint for antialiasing</span>
<span style="color: #a31515">    ([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[a-zA-Z]*))   # match either a 3 or 6 hex digit string or a name of a known color - this is for antialiasing color hint</span>
<span style="color: #a31515">    /                             # again separating slash</span>
<span style="color: #a31515">    (?&lt;font&gt;[\w\s]*)              # font family name - accept white spaces</span>
<span style="color: #a31515">    /                             # yet another separating slash</span>
<span style="color: #a31515">    (?&lt;size&gt;[\d]{0,3})            # font size </span>
<span style="color: #a31515">    /                             # oh noes! another slash!</span>
<span style="color: #a31515">    ((?&lt;style&gt;[BIUSRN\s]*)        # font style Bold, Italic, Underline, Strikethrough</span>
<span style="color: #a31515">    /){0,1}                       # this group is optional.</span>
<span style="color: #a31515">    ((?&lt;transform&gt;[\w]*)          # transformation name as specified with System.Drawing.RotateFlipType - this group is optional</span>
<span style="color: #a31515">    /){0,1}                       # this group is optional too.</span>
<span style="color: #a31515">    (?&lt;text&gt;[\s\S]*[^\.])         # the text to render - basically anything but a dot - use relacement strings for dots</span>
<span style="color: #a31515">    [\.]                          # separating dot - now that's a nice change!</span>
<span style="color: #a31515">    (?&lt;extension&gt;(png|gif))       # the file extension - so that we know whether to generate png or gif</span>
<span style="color: #a31515">    $                             # everything comes to an end  </span>
<span style="color: #a31515">    &quot;</span>,
    <span style="color: #2b91af">RegexOptions</span>.Compiled | <span style="color: #2b91af">RegexOptions</span>.IgnoreCase | <span style="color: #2b91af">RegexOptions</span>.IgnorePatternWhitespace | <span style="color: #2b91af">RegexOptions</span>.CultureInvariant);</div>
</pre>
<p>&#160;</p>
<h2>Usability concerns</h2>
<p>The Colours can be provided as both named Colours (red, green, etc..) or html hex formatted colours (e.g. ff00bb, fob, fff, badfoo) both 6 and 3 hex digits strings are accepted.</p>
<p>The URL accepts spaces, and whatever text string that cannot be passed as a part of the url or is invalidated by EPiServer can be escaped by defining a token for it in web.config so for example as you can see in the above url the end of line “\n” character has been escaped into $eol$.</p>
<p>Obviously the font selection is limited to what is installed on your server.</p>
<h2>Performance concerns</h2>
<p>The basic concern that comes to mind is – how does this impact the server performance if the image is generated every time? Even though the performance impact seemed to be negligible I’ve decided to cache content. These things simply pile up if you have a high load site so why take the chance? Once an URL is called it is saved on first generation asserting the uniqueness of each parameter. Colours like black and 000 will be treated as same colour and cached only once. </p>
<h2>Security concerns</h2>
<p>So what was done to prevent our server to be an open server for generating images for everyone on the Internet? The VPP only allows for the images to be generated if the request referrer is in a domain or a host that is specified in the web.config. Additionally for testing you can enable the referrer to be null (direct call to images, as opposed to referring to them from a page). </p>
<p>Also as a seconds line of defence, it’s wise to define the cache folder on a share with a quota so we don’t get our server filled up with images should the referrer limiting measure fail for some reason.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=100&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2008/06/23/text-image-generation-virtualpathprovider-for-episerver-and-aspnet-in-general-part-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CogniScale &#8211; virtual hosting made easy</title>
		<link>http://blog.najmanowicz.com/2008/06/02/cogniscale-virtual-hosting-made-easy/</link>
		<comments>http://blog.najmanowicz.com/2008/06/02/cogniscale-virtual-hosting-made-easy/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 21:10:03 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Microsoft SqlServer]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2008/06/02/cogniscale-virtual-hosting-made-easy/</guid>
		<description><![CDATA[We&#8217;ve not been talking much about it and that&#8217;s partially my fault as well (busy with other projects), but Cognifide has a really cool initiative called Cognifide Labs that we intend to grow over time. The plan is to devote up to 10% company time into side projects that help us grow expertise and allow [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve not been talking much about it and that&#8217;s partially my fault as well (busy with other projects), but <a href="http://www.cognifide.com/">Cognifide</a> has a really cool initiative called <a href="http://labs.cognifide.com/">Cognifide Labs</a> that we intend to grow over time. The plan is to devote up to 10% company time into side projects that help us grow expertise and allow our devs to dwell into interesting technologies, methodologies and languages and develop their skills.</p>
<p>One of the first projects (that I took part in) is <a href="http://cogniscale.cognifide.com/">CogniScale</a> &#8211; an app that allows <a href="http://www.flexiscale.com/">FlexiScale</a> users to manage their servers. Here&#8217;s the story&#8230; </p>
<p>Being the agile company taking part in many <a href="http://www.episerver.com/">EPiServer</a> projects we never seem to have enough environments to test our web-apps and software in general in various scenarios. We find ourselves constantly reinstalling and trying to keep our servers in a state that can can at least remotely be called as stable. After all how many deployments and tearing down of various <a href="http://www.episerver.com/">EPiServer</a>, <a href="http://ccnet.thoughtworks.com/">CruiseControl</a>, <a href="http://www.jetbrains.com/teamcity/">TeamCity</a>, SQL Server and other &quot;I need to have&quot; apps can a server take before slowing down to a crawl or collapsing all together (that said I bow before our faithful THOTH for taking all the abuse it does). We definitely needed more servers! And we needed them now! </p>
<p>Early this year we&#8217;ve started to talk to the guys at XCalibre that came up with a great idea. What if you could have an unlimited amount of servers available for you at any given time? I mean really what if you could have 0 servers one day and the next day have a rich farm of servers for literally no cost, paying only when you power them up and not paying a bit if you take them down.&#160; This turned out to be quite a project for them that turned to materialize as FlexiScale. (<a href="http://flexiscale.com/about_us.html">you can read more about it here</a>). Looking at all that I&#8217;ve mentioned before while eliminating the cost of maintaining the servers locally we decided to give FlexiScale a spin. </p>
<p><span id="more-97"></span></p>
<p>Early this year FlexiScale published a set of API&#8217;s that we looked at and (being the geeks we are) tried to utilize it in a desktop application with a limited success. It turned out that the initial API was perfectly accessible from dynamically typed languages while statically typed languages like C# didn&#8217;t really get their love in the initial release :) So we started opening the support tickets and shortly after that establishing a lively dialogue with the great folks there. Let me tell you, the guys in the FlexiScale support are really an amazing and responsive bunch. Not only did we get the support and the fixes we needed for the language we chose but we also pretty much got all our suggestions implemented and added to the API&#8217;s.</p>
<p>Thus <a href="http://cogniscale.cognifide.com/">CogniScale</a> was born:</p>
<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="470" alt="cogniscale" src="http://blog.najmanowicz.com/wp-content/uploads/2008/06/cogniscale_main_form.jpg" width="644" border="0" />&#160; </p>
<p>The app allows for easy powering up and down the servers (allowing you to describe the reason for the action) from a nice and shiny GUI as well as scheduling it with windows task scheduler through its command line interface. it allows you to connect using FTP or Remote Desktop as well as any other app you can run from command line (it features a custom command editor that allows you to configure any app to work with it) with a single click. The app also allows you to quickly go through the history of servers&#8217; maintenance to determine how often and for what reason were they taken on and off-line.</p>
<p>Should you decide that FlexiScale is your thing, please give <a href="http://cogniscale.cognifide.com/">CogniScale</a> a whirl and let us know what you think.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=97&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2008/06/02/cogniscale-virtual-hosting-made-easy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Faceted Service Structure</title>
		<link>http://blog.najmanowicz.com/2008/01/24/faceted-service-structure/</link>
		<comments>http://blog.najmanowicz.com/2008/01/24/faceted-service-structure/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 16:18:33 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Faceted Navigation]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2008/01/24/faceted-service-structure/</guid>
		<description><![CDATA[This article is a part of the series describing the faceted navigation system for EPiServer that we have developed in Cognifide and that&#8217;s already proven to be a robust solution for delivering tagged content a heavy traffic site. The engine will be released shortly as an open source project.
So how is the faceted engine structured?

 [...]]]></description>
			<content:encoded><![CDATA[<p>This article is a part of the <a href="http://blog.najmanowicz.com/category/episerver/faceted-navigation/">series describing the faceted navigation system for EPiServer</a> that we have developed in <a href="http://www.cognifide.com/">Cognifide</a> and that&#8217;s already proven to be a robust solution for delivering tagged content a heavy traffic site. The engine will be released shortly as an open source project.<br />
<h2>So how is the faceted engine structured?</h2>
</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2008/01/facetednavigationschema.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="195" alt="FacetedNavigationSchema" src="http://blog.najmanowicz.com/wp-content/uploads/2008/01/facetednavigationschema-thumb.png" width="244" border="0"/></a> </p>
<p><span id="more-91"></span></p>
<h2>Content provider</h2>
<p>As you can see the driving force behind the engine is the Facet Tagged Content Provider. If you know EPiServer, the basic functionality of the module is roughly an an equivalent of find page with criteria for categories, which allows for searching pages tagged with facets with exclusion of some other facets and tagged some optional data, the module however is paging and and allows you to plug a feedback event handler so that your controls can accept or deny a story before they are sent to is and take part in the paging. The stories are provided to you in reverse order of publishing so you always get the latest stories first, (pretty much what any blog and any news site wants).</p>
<p>Another function of the content provider is assertion of story uniqueness on the page. This is actually a pretty cool mechanism that deserves closer attention.</p>
<p>Let&#8217;s imagine a page having a control with &#8220;main story&#8221; that is pre-selected by an editor, and then some &#8220;featured stories&#8221; also pre-selected, then there is a control with &#8220;latest news concerning facet A&#8221; and a &#8220;latest news concerning facet B&#8221;. The problem with this scenario is that if a story was pre-selected for the &#8220;main story&#8221; and perhaps then someone added it to &#8220;featured stories&#8221;, and the story actually is tagged by facet A and facet B &#8211; in a traditional search you would normally get it in all of the controls&#8230; not cool! </p>
<p>The solution that we&#8217;ve come up with is based on a free market rules. And the procedure is as follows:</p>
<ol>
<li>The request starts and the engine opens a bidding for articles.  </li>
<li>All the controls request their interest in stories by either providing the engine with pre-selected stories they would like to display or asking it to provide the freshest content based on the facets the content is tagged with. They also provide it with their value (priority). And a callback for the engine to provide them with the stories.  </li>
<li>The acceptance phase ends and the engine distributes the stories looking from the highest value controls down the list in the following way
<ul>
<li>when the control provide the list of articles if so check for each article if it has not been taken yet, and otherwise feed it back to the control  </li>
<li>otherwise if the control provided it with the facets it&#8217;s &#8220;interested in&#8221; it asks the tagged content store for articles tagged with this context and feeds them to the control if they have not been otherwise provided to another control with higher priority, until it reaches the number requested by the control. (this way of providing articles also allows for paging).</li>
</ul>
</li>
<li>Upon satisfying all the controls the bidding is closed and all articles become available again.</li>
</ol>
<h2>Content Accelerator</h2>
<p>Content accelerator is a caching module that we have made mandatory that all of our EPiServer calls must pass through. The engine turns the pages into objects with a well defined and hard typed objects rather than a-bag-of-strings-and-the-likes your usual PageData is.</p>
<p>This makes it much more efficient for us to cache only the important data contained in any given page and only the data that we use frequently, e.g. page name and page URL that are used by URL provider and that are likely to be called multiple times within any given user request. This has been been implemented to compensate for the slowness of GetPage calls.</p>
<p>For that to work effectively we always tread content accelerator as a proxy for GetPage &#8211; which allows us to filter any expired or not yet published pages faster and refresh the content and accessibility for everyone, any time any given content is refreshed.</p>
<p>The For this concept to work &#8211; any page type that is going to be used in it has to have its own class added to it with the properties you will usually access (this however should be done with caution, for example you can cache article intro, but caching a potentially big article is a bad idea &#8211; also a full article text is very unlikely to be displayed on a high traffic page so caching all of your article full texts will not offset for a potential quick running out of memory).</p>
<p>Also the content cache is written using generics in a way that allows you to specify a multiple classes for any page types &#8211; the class consuming the cache defines how it wants to treat the content and access it. The different cache classes will then be chain linked and refreshed.</p>
<p>The content expires on an arbitrary set time (1 minute in our case but you can specify any other period), but we&#8217;ve also written a web service allowing for expiring a page-cache-item whenever it is changed on any of servers in a multiserver scenario. This for this to work &#8211; you have to plug into the global EPiServer event handlers. Which I&#8217;ll describe later.</p>
<p>The accelerator is used extensively by the faceted engine, but it can also be used directly and is completely independent of the rest of the faceted engine.</p>
<h2>Facet Context Provider</h2>
<p>This provides the control with ewasy facility to retrieve the facets with which the request was performed.</p>
<h2>Facet URL Provider</h2>
<p>This service allows you to construct URLs based on a facet context &#8211; with automatic determination of a preferred visualisation (hub page). Naturally you can still force the provider to format the URL for a pre-determined page. The effect will be a request that can later be succesfully parsed by the Context Provider once that URL is executed on the server.</p>
<h2>Auto Tagging Module</h2>
<p>This block which originally was a separate module is now basically shrunk to a single method that you can plug into EPiServer in the Global.asax. The routine tags a page with facets predefined in its parent, during the process of a page creation. This is useful for tagging e.g. all the &#8220;technology&#8221; stories with &#8220;technology&#8221; facet and an &#8220;News&#8221; facet once its created in the &#8220;Technology articles&#8221; branch.</p>
<h2>Furniture</h2>
<p>Part of the faceted navigation, but not directly part of the engine are editors for facet roles, the very facets and facet selectors.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=91&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2008/01/24/faceted-service-structure/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
