Dominik Juszczyk Technical blog

29Jun/100

Playing with Microsoft Search Server 2010 Express

Recently I was asked to find out if we can use new version of search server in one of our new projects together with the module we did develop to integrate it (Search Server 2008) with EPiServer.
I have started to search, investigating and I have few findings which I want to share here (mostly to have everything in one place :) )

I have started with quick comparison of the 2008 and 2010 version - there is nice page that gives the overview what was introduced in new version. On that page you can find summary of new features introduced in version 2010.

Next thing I did was installing the Microsoft Search Server 2010 Express. The idea was to install it, try to crawl the page that was already using search server (but in version 2008) and try to just change the URL to the search web service.  Of course there were some tricks to do it. For example I had error message when I wanted to crawl any page. I got the error: "Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled." Luckily I found that post. Following the instructions from that post helped to solve it.

Good news is that it occurred that Query Search Schema of version 2010  is compatible  with that one from version 2008. So the module we did develop to use it with Search Server 2008 is working with Search Server 2010 without changing single line in code :)

I am wondering if elements of search query SortByProperties and  SortByProperty are finally working (they weren't with version 2008) :D

When I will do anything more with new versions and I will have any interesting findings I will share it with you here :)

18Mar/100

The “Exec” task needs a command to execute.

I have lost one hour trying to figure out what is the source of the message: "The "Exec" task needs a command to execute." (Visual Studio 2005)

It occurred that when modifying  the post-build action I have left one empty line... Removing it solved the problem...

26Oct/091

Microsoft Search Server Express 2008 – two issues

Recently we have started using Miscrosoft Search Server Express 2008 (MOSS) as a search engine for some of EPiServer based projects (replacing default EPiServer  search engine). But the context of usage is not that important now.

To be clear - I think MOSS is a very nice product that is great for medium projects. But we encountered two issues with it - one already solved and one still not fixed.

Starting with solved one ;) It occurred that MOSS by default is not crawling pdf files. I'm not sure why - because pdf files are one of the most popular ones...  I found solution to that on Nicholas's blog - Microsoft Search Server PDF iFilter Installation

You can read about details on his blog. Just to highlgiht those are steps to add pdf crawling to MOSS:

  • you will need to install Acrobat Reader on the same machine where MOSS is installed
  • modify some register keys
  • add pdf extension to the list of files extensions to be crawled

That was quite easy ;)

Update: Some times there might be still the problem with PDF crawling. It might be an issue with wrong CLSID of Adobe IFilter.  Here can be found a solution to that:  http://blogs.msdn.com/ifilter/archive/2007/03/29/indexing-pdf-documents-with-adobe-reader-v-8-and-moss-2007.aspx

Second issue is still waiting for solving.

What is the problem? Results sorting, not by rank but by chosen managed properties.
We are using QueryEx. According to MSDN it is possible to change default sorting of results returned by search server. You can see that the QueryPacket has element:

It should be possible to send QueryPacket with SortByProperties element set to something like this:

1
2
3
4
<SortByProperties>
  <SortProperty name="Page" direction="ascending" order="1"></SortProperty>
  <SortProperty name="Heading" direction="ascending" order="2"></SortProperty>
</SortByProperties>

where both Path and Heading are managed properties that are available in results.
Unfortunately, there is no change in results sorting - they are still sorted by rank. We have even tried to add names of the properties in lowercase - as someone suggested in comments.

I'm still looking for a solution to the second problem - so, if you have any suggestion please, do not hesitate to let me know ;)

9Oct/090

Get LinkURL in context of choosen language

Recently I had a problem with getting URL of the page in context of the language different that master one.

I had a PageDataCollection with pages:

1
2
3
4
5
6
7
8
9
LanguageSelector language = new LanguageSelector("EN") ;

foreach (PageData childPage in DataFactory.Instance.GetChildren(startPage, language))

{

...

}

In the collection I had correct pages - children of startPage that had English language version.

Then for each page I wanted to write it's URL using childPage.LinkURL Unfortunately all those pages had different master language (Norwegian) and I was receiving URLs like "/no/mypage"

After searching for the solution for a while  my colleague Robert told me how to do it. The solution is:

1
2
string LanguageBranch = "EN";
string link = UriSupport.AddLanguageSelection(childPage.LinkURL, LanguageBranch);

Now I get URLs that looks like this one: "/en/mypage"

Thank you Robert ;)

17Sep/090

Fragments of Apple’s keynote – most used words

Extracted fragments of  the Apple's Keynote in September 2009 - outstanding, amazing, great ;)

Filed under: Uncategorized No Comments
6Sep/090

Joomla – simple CMS for smaller sites

Recently I've been looking for simple CMS to use it for my son's nursery website. I wanted it to be:

  • free
  • PHP based (I have hosting that is Linux based)
  • very simple to use - I wanted this site to be edited and updated by teachers from nursery
  • extensible - to easily add new functionalities (like for example gallery)
  • I wanted to limit the development to minimum - meaning no development at all as a goal ;)
  • free templates should be there -  to use with chosen CMS

If you check sites like for example: CMS Watch you will see that it is not easy to choose the proper one. I checked quite a few of CMSes but at the end I had only three to choose from: Drupal, Joomla and... Umbraco. The last one was a little bit surprising since it didn't fulfill my initial requirements - it is .Net based - but I had some experience with it from my work and it is similar to EPiServer in many areas ;) .

After playing with demos ( Drupal demo site, Joomla demo site) I decided to perform test installation. I stared with Joomla because I didn'tliked Drupal at all (based what I've seen in demo site) and I knew  Umbraco from work. I installed it and it occurred that I it was good choice :) Just from playing in administrator mode I was able to build the site I was looking for - with functionality, structure and everything  I needed.

Next step was to find template that was right for kindergarten site - and also in this area Joomla was the right choice. There is a lot of sties with Joomla free templates.

Finally, it occurred that after two days of work I managed to build the working site - ready to be publish  :) There was only one surprise for me - the way how pages were organized. I was used to "tree" structure - after all those projects with EPiServer :) . In Joomla editor has two "tools" to organize pages in the site:

  • each page has to be assigned to section and category. Primary use of sections and categories is to make kind of listing pages. There is possibility to create page that list all pages in section (from all categories) or all pages from chosen category. Also thanks to this it is easier to find pages in administrator view.
  • menus - if there is no tree structure there is nothing we can based menus on... So menus in Joomla are built from scratch. Administrator has to build the desired menu structure ("tree") and for each node he/she has to select the type of the node. And there are many to choose from:
    • article - menu node will be just link to article,
    • category - list all pages with chosen category,
    • section - list all pages with chosen section,
    • external link,
    • search page,
    • start page,
    • many more...

At last I was able to built the kindergarten site: Przedszkole nr 6 w Bochni (site is in Polish ). I also created for them Google Apps account - for domain przedszkole6.bochnia.org - as e-mail service and Picasa account as a pictures storage. Which all together makes quite nice connection and application (almost like SOA :D )

After this "project" - from my perspective - those are pros and cons of Joomla:

Pros:

  • free
  • really easy to install
  • installed version is ready to work with and easy to customize
  • huge number of extensions: Joomla extensions site
  • easy to find free template,
  • templates are quite easy to modify

Cons:

  • no tree pages structure - structure of pages is flat,
  • menus has to be created from scratch (can be advantage in some cases),
  • when linking to the page in WYSIWYG editor there is no internal type of link - so editor has to copy paste URL, instead of have possibility to choose from existing pages directly from WYSIWYG add link dialog,
  • lack of possibility to add access right to chosen section/category - for example to create administrator account for news updating. There is only administrator and editor kind of roles. Good thing is that editor can set right to only edit and another role to publish.

I think it is very good CMS for smaller sites with not that many pages. I think that with lager sites lack of tree strcuture might cause some problems in flexible management of the site. I haven't tested performance yet, I will do it and let you know how it went.

14Dec/081

LinkItemCollection property in EPiServer

I was really happy reading on EPiServer Labs blog post by Ted Nyberg that in EPiServer CMS 5 R2 there is a new property type introduced - LinkItemCollection. You can read more on Ted's blog - but in short, it is a native property that does what old good Multi-page property has done so far (and some others implementation of multi link property).

I was using multi-page property in many projects and still I will be using it on all EPiServer 4.6x projects, but for sure, in all new CMS 5 I will go with LinkItemCollection. Especially that what I have just checked it is "smarter" then Multi-page property. "Smarter" because it knows what links it stores - and for example, while moving document (or deleting) that is referred by LinkItemCollection now we will get a warning. This was  not possible with Multi-page property.

Still there are some areas where probably I will stick to Multi-page property. It is great base for creating new specialized properties for different purposes.  We have created few new properties for which Multi-page property source code was a base like for example property called multi-image list - which allows for adding images with caption, alt text, link URL and so on. I'm not sure for now if it is possible with the new property - if not multi-page property isn't dead for us (at least for the time being :) )

7Jun/082

How to make a page type a ‘leaf’

In one of my projects I had to create page type that was supposed to be a 'leaf' in page tree structure (for this page type no children should be possible to create). First thought was to go to admin mode, to configuration of page types and turn off all page types on "Available page types". I was very surprised that it can't be done. Even if one chooses no page types to be available and save configuration it does not work (when one will open this tab again - all page types will be chosen).
After short investigation I have found post on EPiServer forum. Greger Olofsson describes there some possibilities how this can be achieved. I have tried two of them:

  • create a dummy page type and choose it not to be available in edit mode and then select it as only one available for our 'leaf' page type,
  • subscribe to the CreatingPage event and check what page type name (or id) is used and abort the creation of the new page

Both of them works but have some drawbacks. When selecting dummy page for our 'leaf' page type in edit mode, after clicking 'Create New' link (from context menu or toolbar) we get this page:


It may be confusing for editors because it gives no information why there is no new page page type to choose.
Subscribing to CreatingPage event is not better. I did it with this code (in Global.asax.cs):

protected void Application_Start(Object sender, EventArgs e)
{
EPiServer.DataFactory.Instance.CreatingPage  = new EPiServer.PageEventHandler(OnCreatingPage);
}

private string[] GetLeafPageTypes()
{
string leafPageTypesConfigurationValue =   System.Web.Configuration.WebConfigurationManager.AppSettings["leafPageTypes"];
string delimStr = ",";
char[] delimiter = delimStr.ToCharArray();

return leafPageTypesConfigurationValue.Split(delimiter);
}

protected void OnCreatingPage(object sender, PageEventArgs e)
{
PageData parentPage = EPiServer.DataFactory.Instance.GetPage(e.Page.ParentLink);
foreach (string leafPageType in GetLeafPageTypes())
{
if (parentPage.PageTypeName.ToLower() == leafPageType.ToLower().Trim())
{
e.CancelAction = true;
e.CancelReason = "Page type is lea";
return;
}
}
}

Few words of explanation. I decided to keep configuration which page type is a leaf in web.config which looks like this:

<appSettings>
<add key="leafPageTypes" value="[Public] Start page,[Public] Search page" />
</appSettings>;

It does work and does not allow new page to be created. It does show my warning to the editor ("Page type is a leaf"). But it is done after choosing page type of new page and after pressing Save button (so also after editor has filled in all properties values and after seeing informations which properties are mandatory to fill).

Then for some time I tried to modify context menu (the one that is showing on right mouse button) but I realized that I will also have to modify toolbar (where new page button is present also). And then I decided to do it in NewPage.aspx file located in edit folder. I know that this shouldn't be done mostly because it will be lost (it can be lost to be more specific) during upgrades. But my change is very simply and very easy to add after possible upgrade. What I did? I have added to this page similar code as I tested on CreatingPage event. I have added to markup file those lines:

<%@  Import namespace="EPiServer"%>
<%@  Import namespace="EPiServer.Core" %>
<script runat="server">
private string[] GetLeafPageTypes()
{
string leafPageTypesConfigurationValue =   System.Web.Configuration.WebConfigurationManager.AppSettings["leafPageTypes"];

string delimStr = ",";
char[] delimiter = delimStr.ToCharArray();
return leafPageTypesConfigurationValue.Split(delimiter);
}

protected override void OnLoad(System.EventArgs e)
{
foreach( string leafPageType in GetLeafPageTypes() )
{
if (CurrentPage.PageTypeName.ToLower() == leafPageType.ToLower().Trim())
{
ErrorMessage.Text = "Page type is leaf. Cannot have children";
PageTypeList.Visible = false;
Cancel.Visible = false;
}
}
base.OnLoad(e);
}
</script>

and Label control to display my message:

<asp:Label ID="ErrorMessage" runat="server" ForeColor="red" ></asp:Label>

I'm still using appSettings key to keep configuration which page type are a 'leaf' ones. Now when editor wants to create new page under 'leaf' page type page after clicking "Create New" link he/she sees that information:

So as you can see I achieved two things:

  • it is possible to define page type (or page types) as a 'leaf' by editing one key in web.config
  • it is easy to make page type a 'leaf' just for some time without changing it's configuration (available page types)
  • editor now can see information why he/she can't create new page with chosen parent.

I suppose that there are different way to do something similar. If you know them - please let me know :)

23May/081

Get posted data (XFormData) from XForm

Recently we have had to get posted data from xform from code. To do it we developed this method:

/// <summary>/// Retives posted data for xform defined for CurrentPage.
///</summary>
/// <param name="pageReference">PageReference of page for each posted data of xform should be returned</param>
/// <param name="xFormPropertyName">Property name of CurrenPage page type. Property has to be of type XForms</param>
/// <param name="xFormFolderPath">XFormFolder path where xForm is saved.</param>
/// <returns>Returns list of XFormData objects - each XFormData object contains data posted with xform</returns>

private IList<XFormData> GetXFormData(PageReference pageReference, string xFormPropertyName, string xFormFolderPath)
{
   if (pageReference == null || pageReference == PageReference.EmptyReference)
       return null;

   PageData pageData = GetPage(pageReference);

   PropertyData xFormProperty = pageData.Property[xFormPropertyName];
   if (xFormProperty == null || xFormProperty.Value == null)
       return null;

   if (!(xFormProperty is PropertyXForm))
       return null;

   IList<XForm> xFormFolder;
   if( xFormFolderPath != String.Empty )
       xFormFolder = XFormFolder.GetForms(xFormFolderPath);
   else
       xFormFolder = XFormFolder.GetForms();

   foreach (XForm xform in xFormFolder)
   {
       Guid formGuid = new Guid(CurrentPage[xFormPropertyName].ToString());

       if (formGuid.CompareTo((Guid)xform.Id) == 0)
       {
           return xform.GetPostedData(CurrentPage.PageLink.ID, DateTime.Now.AddDays(-7), DateTime.Now);
       }
   }

   return null;
}

It gets as parameters PageReference of page for which posted data should be returned, property name of property that contains XForm and folder name where xform is stored (if any). As output from method we get list of XFormData objects where each item contains data posted with xform.
It works in EPiServer CMS 5 where some changes in XForm handling has been introduced (strong typing).
Here is post on forum where is shown how to do it in EPiServer 4.6x.

13May/080

WebResource.axd problem in EPiServer CMS 5

With our first EPiServer CMS 5 based solution we had strange problem related with WebResource.axd. We were getting the exception:

The WebResource.axd handler must be registered in the configuration to process this request

After searching for this exception in Google I have found a post about this on Fredrik Haglund's blog. We have had applied his patch and it seems to solve the problem (at least until it will be solved by EPiServer or whoever responsible for that).
Anyway I thought that we did something special in that one project and that this problem is that project specific only. Unfortunately it occurred that the exception is thrown from time to time in all our EPiServer CMS 5 projects. The worst thing is that we are not able to reproduce error or identify what makes this error more probable to occur. It is thrown from time to time without any clear reason.
For now we have started to adding patch to all ours CMS 5 projects. But this is something that has to be solved somehow. We are monitoring EPiServer's forum and waiting for this problem to be solved. When you will read comments to the Fredrik's post you can see that they are working on that - and I will keep my finger crossed for them to fix it :)

UPDATE:
Today I have found this post. It seems that the reason of error has been found and that there is a workaround.