Author Archives: admin

Cyrus Upgrade Error on Ubuntu

For several months now, I’ve been getting an error every time I tried to do an upgrade of my ubuntu system:


 Converting from /var/lib/cyrus/deliver.db (berkeley-nosync) to /tmp/deliver.db.cOT3kOvz (skiplist)
 fatal error: can't open old database
 dpkg: error processing cyrus-common-2.4 (--configure):
 subprocess installed post-installation script returned error exit status 75
 dpkg: dependency problems prevent configuration of cyrus-pop3d-2.4:
 cyrus-pop3d-2.4 depends on cyrus-common-2.4 (= 2.4.12-2); however:
 Package cyrus-common-2.4 is not configured yet.
 dpkg: error processing cyrus-pop3d-2.4 (--configure):
 dependency problems - leaving unconfigured
 dpkg: dependency problems prevent configuration of cyrus-pop3d:
 cyrus-pop3d depends on cyrus-pop3d-2.4; however:
 Package cyrus-pop3d-2.4 is not configured yet.
 dpkg: error processing cyrus-pop3d (--configure):
 dependency problems - leaving unconfigured
 

I tried removing cyrus altogether. But there were so many inter-dependencies that it wasn’t an option.

I finally found a clue as to how to fix it here, but I had to modify it a bit for my own situation.

I moved the deliver.db and tls_sessions.db files, then ran the upgrade command and voila! everything worked!


 sudo su -
 cd /var/lib/cyrus
 mv deliver.db deliver.db.old
 mv tls_sessions.db tls_sessions.db.old
 

Once the upgrades are done, the ‘old’ files can be removed. Yes, you might be able to get away with just deleting those files in the first place. But I like to play it safe.

Note: does this mean that there may be local mail not delivered? It could. But my local mail is only used for notifications, so it wasn’t a big deal to me.

XPath and C#

Our C# application needs to retrieve data from a Java SOAP source. And, anyone who has dealt with SOAP for any time knows that standards aren’t. In our case, the null dates in the data were being passed back with a date that the Java system, I supposed, considered ‘null’: 1899-01-01 00:00:00. But our C# system parsed the incoming XML and saw a ‘Date Format Exception’.

This all happened when we used Visual Studio’s automagic object creator (Add Service Reference/Advanced/Add Web Reference). When we switched to used the ‘standard’ Add Service Reference, this error disappeared. But we then saw a Number Format Exception error. We couldn’t figure out where this one was coming from, so we started seeking other options.

The Java SOAP services are being created using Axis 2, which permits the user to also make REST calls. So I changed my code to use an XPathDocument to make a REST call for the data. The data returned is still in XML format. But this allows me to walk through the elements myself and either ignore the elements if I don’t need them, or handle a single element’s value if it causes issues.

I found about 5 different ways of accomplishing this exercise before settling on the XPathDocument method I found in Using Returned XML with C#. The one ‘gotcha’ that I had to contend with was remembering to use the XMLNamespaceManager once I created it. Using it is optional when searching for nodes.

The one ‘gotcha’ I ran into was remembering to include *all* the namespaces used within the document, and to use the optional namespace argument when searching for nodes. Without it, I ran into expected – and unexpected – errors:

1) The obvious one – it complained about the fact I was using ‘:’ within the node name but not declaring namespaces.
2) I ran into one error – I can’t reproduce it now – but it complained about the ‘:’ and only told me that was an illegal character to use within a node name, without telling me why.
3) I put one namespace in, but not both that were used in the document and ran into problems with that as well.

LINQ and Dynamic Queries

Our users need to filter through a list of groups from one list to bring in the groups that should have access on another. The one list is overwhelming, since a group may be created on the fly for special purposes at any time. But the list of groups needed for this secondary application may be quite small in comparison.

But each users’ organization will have a different beginning and ending group list. So filtering criteria will be different for each. Hence, to provide that capability, I need to be able to create filters for these lists dynamically.

Looking for a solution, I ran across this article that I thought would work. But it broke down when I tried to use more than one ‘where’ statement.

The solution I did use may not be elegant. And I’m hoping it can be made more so, yet more flexible, in the future. But it works. So I wanted to pass it on, in case someone else could use it:

public static List GetFilteredRoles(List roleFilterList) {
   EntityObject context = new EntityObject();
   IQueryable matches = context.Roles;
   List integers = new List();

   IEnumerable filterSet = from r in context.Roles
                                 select r;
            

// now figure out a filter

   foreach (GroupFilterCLR filter in roleFilterList) {
      String strTmp = filter.Regex;
      List tmp = new List();
      if (filter.Status == FilterStatus.INCLUDE) {
         if (filter.Relation == FilterRelation.CONTAINS) {
            tmp = (from r in context.Roles
                   where r.Name.Contains(strTmp)
                   select r).ToList();
                       
          } else if (filter.Relation == FilterRelation.STARTS_WITH) {
               tmp = (from r in context.Roles
                     where r.Name.StartsWith(strTmp)
                     select r).ToList();

          } else if (filter.Relation == FilterRelation.ENDS_WITH) {
                tmp = (from r in context.Roles
                       where r.Name.EndsWith(strTmp)
                       select r).ToList();
          }
                    
      } else {
         if (filter.Relation == FilterRelation.CONTAINS) {
            tmp = (from r in context.Roles
                   where !r.Name.Contains(strTmp)
                   select r).ToList();
          } else if (filter.Relation == FilterRelation.STARTS_WITH) {
                     tmp = (from r in context.Roles
                            where !r.Name.StartsWith(strTmp)
                            select r).ToList();
          } else if (filter.Relation == FilterRelation.ENDS_WITH) {
                      tmp = (from r in context.Roles
                             where !r.Name.EndsWith(strTmp)
                             select r).ToList();
           }
        }
           filterSet = filterSet.Intersect(tmp);
      }
   return Mapper.Map<List<Role>, List<RoleDTO>>(filterSet.ToList());

}

Notice, too, that it shows how to negate an expression.