SaguiItay

My blog has moved!

You should be automatically redirected in 4 seconds. If not, visit:
http://itaysagui.wordpress.com
and update your bookmarks.

Wednesday, August 8, 2007

MOSS Documents Libraries naming policy

When you create a new Documents Library in MOSS, you are asked to provide a title for that Library. The provided title will be later used to define the internal name of the Library, as well as its URL. This is where the problems start. It only makes sense that MOSS allows the user to enter any value for the Library's title. However, there are a lot of limitations on internal names, and even more on URLs. This result in MOSS doing some kind of encoding/validation on the title. The result might range from having the name exactly the same as the title, to the name being completely different and unrelated. After some digging, I came up with the following logic:
For each char:
  if char is valid
    add it to URL
  if char is invalid
    if URL already ends with '_' (underscore)
      don't do anything
    else
      add '_' (underscore)

Strip '_' from beginning and end of URL
If URL is empty
replace URL with a legal DocLibXXX value where XXX is a number
Invalid characters are the following:
  1. Any character bellow 0x20
  2. Any of the following characters: ~!@#$%^&*{}[]-=+\:"'<>,?/.
  3. Any character that takes more than 1 byte (Unicode and such)

Labels: , ,

Thursday, August 2, 2007

Creating a user in Documentum

Here's 2 ways to create a user in Documentum: Using the DQL:

    create dm_cabinet object
    set object_name = '%USERNAME%'
    go

    create dm_user object
    set user_name = '%USER DISPLAY NAME%,
    set default_folder = '/%USERNAME%',
    set user_os_name = '%USERNAME%',
    set user_privileges = %PRIVILEGES%',
    set user_address = '%USER EMAIL%
    go

Using the IAPI:

    create,c,dm_user
    set,c,l,user_name
    set,c,l,user_os_name
    set,c,l,user_address
    save,c,l

Labels: ,

ListViewGroup - only one item per group

As I was working on a new GUI part of the software I'm working on, I needed to allow the user to choose only a single item in each category. I overloaded the ListView control, and override the OnItemCheck method. Here's the result:
public class SingleItemPerGroupListView : ListView
{
    public SingleItemPerGroupListView()
    { }

    protected override void OnItemCheck(ItemCheckEventArgs ice)
    {
        // Always behave regulary when user uncheck an item
        if (ice.NewValue == CheckState.Unchecked)
        {
            base.OnItemCheck(ice);
            return;
        }

        // Get the checked item
        ListViewItem lvi = this.Items[ice.Index];

        // If no item has no group, handle regulary
        if (lvi.Group == null)
        {
            base.OnItemCheck(ice);
            return;
        }

        // If another item is checked, uncheck item
        foreach (ListViewItem otherLvi in lvi.Group.Items)
        {
            if (otherLvi == lvi)
                continue;

            if (otherLvi.Checked)
            {
                otherLvi.Checked = false;
            }
        }
    }
}

Labels: , ,