July 2008 Archives

I've seen a couple questions lately about ways to connect to the ALUI API Service. There are two ways to use the EDK to connect to the API server. Which way you connect depends on the intend of the specific application.

One way to connect is with a specific username and password. That works well if you need the API server to access information or do actions not necessarily available to the browsing user. Let's take the example where you want to report the number of portlets in the system.

If you want all users to see the total number of portlets including portlets they do not have access too, then you would specify a privileged user for the API connection so that it could query everything. This would be hardcoded or set in admin preferences.

If you want users to see only the number of portlets to which they have access, then you would make the API connection using the credential of the current user. This uses something called the login token, and it is obtained programmatically.

I'll give example code for both, but let me first say that in either case, a variable should be set in the web.config file. The API call will want to know where the PTHOME directory is, and that's is best set in web.config rather than hardcoded. So with either solution, this should be in web.config:

    <add key="pthome" value="i:\\apps\\plumtree"/>

Then either case, you'll grab that variable from your code.

So if you want to connect using a specific user (usually one with elevated permissions), then you would do it like this:

  // create a session to portal and connect
  string sAdminName = ConfigurationSettings.AppSettings["admin-name"];
  string sAdminPass = ConfigurationSettings.AppSettings["admin-pass"];
  string sPTHome = ConfigurationSettings.AppSettings["pthome"] + "";
  com.plumtree.openkernel.config.IOKContext context = com.plumtree.openkernel.factory.OKConfigFactory.createInstance( sPTHome + "\\settings", "portal");
  IPTSession session = PortalObjectsFactory.CreateSession();

The admin-name and admin-pass for a production application should be set with an administrative preference and retrieved through the EDK so that they are not visible in the source file.

And if you want to connect with the individual user's context, then do this:

  // connect a session
  string sPTHome = ConfigurationSettings.AppSettings["pthome"] + "";
  com.plumtree.openkernel.config.IOKContext context = com.plumtree.openkernel.factory.OKConfigFactory.createInstance( sPTHome + "\\settings", "portal");
  session = PortalObjectsFactory.CreateSession();
  // we'll use the context of the logged in user

I have a sample portlet application attached that uses the user's individual context to connect to the API service and gather some information. Its zip file is here. It has a folder called install-resources with some install instructions.

I hope that helps,


Installing Movable Type

| | Comments (0)
One part of Oracle's post-acquisition integration is to retire the subsumed company's blogs. Thus, the blog I used to maintain at BEA Systems before we were bought by Oracle is going away. I've initiated the process of getting an Oracle blog, but ... well, why not take this opportunity to break free? I do care to preserve my blog posts, and if they live exclusively within a company, they're subject to certain upheavals now and again. Also, occasionally I'll want to blog about something that won't fit at Oracle, such as ... my notes on installing Movable Type.

I decided to migrate my old BEA posts to http://blog.billbenac.com, and I chose Movable Type as my blog platform. The process went like this:

  • SSH into web server
  • Login to MYSQL to create my database and user.

      drop database thedb;
      create database thedb;
      GRANT USAGE ON thedb.* TO 'theuser'@'localhost';
      ON thedb.*
      TO 'theuser'@'localhost'
      IDENTIFIED BY 'thepassword';
  • Download MT: http://www.movabletype.com/download/personal/MTP-4.12-en.tar.gz
  • Extract as a folder under the root of the desired website such as /mt. This gives me blog.billbenac.com/httpdocs/mt/mt.cgi, among other things. This directory will be used for administration.
  • Browse to MT setup page, in my case http://blog.billbenac.com/mt with a login button that brings me to http://blog.billbenac.com/mt/mt-wizard.cgi
  • Use CPAN to download the necessary Perl modules
  • Fill out the wizard screens. When it asks about the configuration file, mt-config.cgi, click the link to view the generated file (Show the mt-config.cgi file generated by the wizard). Copy the contents, and put it on the server manually. Tell the wizard you did so, and continue.
  • After choosing a blog name, edit the URL and publishing path as appropriate. I made the URL and path different from the default. The URL is http://blog.billbenac.com/blog, and the publishing path ends with blog.billbenac.com/httpdocs/blog/. I created the directory manually on the server and set its permissions with: mkdir blog;chmod 777 blog
  • After logging in, the automatic post didn't display. I republished it, and that was that.
  • But man is it ugly. Login and try in the right actions column to refresh blog templates. Refresh the classics. Don't bother backing up templates. Hit continue. That might not have done anything though...
  • In the web admin section, to to Design-> Styles. Pick one. I grabbed Unity Tricolor from the Default Styles category.
  • Finally, I wanted to configure Live Writer to connect to the site so I could migrate my old BEA Dev2Dev posts. It didn't like my password a few times. It turns out Movable Type uses a different password for the API. Thanks to http://www.alexlomas.com/blog/2006/08/live_writer.html for this advice:

      Log into Movable Type.
      Click on your username in the top navigational menu to go to your profile.
      Scroll down to the bottom where you see API Password.
      Input a password of your choice and save. For security reasons, it should be different from your normal author password.
      Use this new password in live writer.
  • At this point I thought I was in business. But when I tried publishing from Live Writer to my site, I got this error:
  • Statement has no result columns to bind (perhaps you need to successfully call execute first) at {my path}/mt/extlib/Data/ObjectDriver/Driver/DBI.pm line 119.
  • One post suggested it could be a database version problem, and indeed, I was an unsupported MySQL from 2003: 3.23.58. I asked my hosting company to upgrade me, and now I'm on 4.1.15.
  • I publish, and? "Server Error Server Occurred. Statement has no result columns to bind (perhaps you need to successfully call execute first) at {my path}/mt/extlib/Data/ObjectDriver/Driver/DBI.pm line 119.
  • When I log into the web interface of my site though, I see that my posts that failed to publish actually did get created in my MT database, but they hadn't made been published entirely. I was able to open them up and successfully republish.
  • When new users registered to comment, the web site said it was sending them confirmation emails, but these didn't arrive. I had to go to System-> Preferences-> General and set the outgoing email address to resolve the problem.

I prefer Drupal!