Categories
bdg dev2dev Featured Posts Plumtree • BEA AquaLogic Interaction • Oracle WebCenter Interaction

UUID Object Opener, The Coolest ALI Taglib Yet

Anyone who’s ever done a major Plumtree/ALUI deployment knows of this problem: You create a portlet or community (or any other object) in Dev and then you migrate it to Test and on to Production. The problem is that you’ve also written some code in your navigation portlet or in another portlet that depends on an ObjectID (e.g. you’ve used a pt:standard:opener tag) and now, in each environment, your ObjectID has changed and you’re basically hosed.

Pre-G6, I came up with a solution described (somewhat hastily) in this post, but it requires a lot of leg work and — worse yet — manual configuration in each environment.

Enter G6 and the magic of taglibs. (Am I beginning to sound like a broken record? Yes, I know, you can’t fix every problem with a taglib, just 95% of them, right?) With this new taglib I wrote today, I extend AOpenerLinkTag and simply convert a UUID to an ObjectID and ClassID so that you can use the same taglib invocation in every environment. I don’t want to toot my own horn too much here, but honestly, this is pretty much the most useful taglib I’ve ever encountered, and once again, it took under 30 minutes to write.

Before I dive into the source, let me back up and say that I had to bend the rules a bit. OOTB, there are two subclasses of ATagAttribute: RequiredTagAttribute and OptionalTagAttribute. I added a third: MutableTagAttribute. It looks and smells like a tag attribute, but under the covers it’s not. Instead of grabbing its value out of the tag invocation, it allows you to set/change the value at runtime inside the taglib code. Granted, this is a little weird, but it’s what I needed to do in order to subclass AOpenerLinkTag and keep it happy dappy.

MutableTagAttribute.java:

package com.bdgportal.alui.taglibs;

import com.plumtree.portaluiinfrastructure.tags.metadata.*;

public class MutableTagAttribute extends ATagAttribute {

  private String value;
  
  public MutableTagAttribute(String name, String desc, AttributeType type) {
    super(name, desc, type);
  }
  
  public String GetDefaultValue() {
    return value;
  }

  public void SetDefaultValue(String value) {
    this.value = value;
  }
  
  public boolean GetIsRequired() {
    return false;
  }
}

Now that we have a tag attribute that we can change on-the-fly, writing the taglib was a snap.

UUIDObjectOpener.java:

package com.bdgportal.alui.taglibs;

import com.plumtree.portaluiinfrastructure.tags.*;
import com.plumtree.portaluiinfrastructure.tags.metadata.*;
import com.plumtree.xpshared.htmlelements.*;
import com.plumtree.taglib.standard.basetags.*;
import com.plumtree.server.*;

public class UUIDObjectOpener extends AOpenerLinkTag
{
  public static final RequiredTagAttribute UUID;
  private MutableTagAttribute OBJECT_ID;
  private MutableTagAttribute CLASS_ID;


  public UUIDObjectOpener() {
    OBJECT_ID = new MutableTagAttribute("objectid", "Not used -- do not set a value for this!", AttributeType.INT);
    CLASS_ID = new MutableTagAttribute("classid", "Not used -- do not set a value for this!", AttributeType.INT);
  }

  public ATagAttribute GetObjectIDAttribute()
  {
    return OBJECT_ID;
  }

  public ATagAttribute GetClassIDAttribute()
  {
    return CLASS_ID;
  }

  public static final ITagMetaData TAG;

  static
  {
    TAG = new TagMetaData("uuidobjectopener", "Opens an object based on its UUID.");
    UUID = new RequiredTagAttribute("uuid", "The UUID for the object you want to open.", AttributeType.STRING);
  }

  public HTMLElement DisplayTag()
  {
    Object[] objectAndClassId = ((IPTMigrationManager)(((IPTSession)GetEnvironment().GetUserSession()).OpenGlobalObject(PT_GLOBALOBJECTS.PT_GLOBAL_MIGRATION_MANAGER,
          false))).UUIDToObjectID(GetTagAttributeAsString(UUID));
  
OBJECT_ID.SetDefaultValue(objectAndClassId[PT_MIGRATION_OBJECT_COLS.PT_MOC_OBJECTID].toString());
    CLASS_ID.SetDefaultValue(objectAndClassId[PT_MIGRATION_OBJECT_COLS.PT_MOC_CLASSID].toString());
    return super.DisplayTag();
  }

  public ATag Create()
  {
    return new UUIDObjectOpener();
  }
}

To deploy this code, see the excellent section on edocs about creating custom Adaptive Tags.

To use this code in a portlet, do the following.

myportlet.htm:

<span xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'>
   <pt:mytaglibns.uuidobjectopener pt:uuid="{00000-0000-0000-000000}" pt:mode="2">Open My
   Object</pt:mytablibns.uuidobjectopener>
</span>

I did actually test this taglib and it worked swimmingly. Of course you need to substitute a real UUID for all those Os.

In closing, here’s a little shameless plug: I’ve been asked by BEA to give a short, 20-minute talk at BEA World on my favorite subject (duh, taglibs) at the ALUI Developer User Group on Monday, September 18th in Moscone Center, San Francisco. It will happen some time between 1 and 5:30 PM. The ALUI User Groups are free for conference attendees. I hope to see you there or at the bdg booth. Please come on up and introduce yourself — I always like to meet members of this great community in person.

Enjoy!

Comments

Comments are listed in date ascending order (oldest first)

  • Will there be any performance issues using this tag as it involves additional operations of getting Object ID and Class ID from the UUID?

    Posted by: psudhir_it on February 6, 2007 at 10:15 PM

  • From what I can tell, the tag makes a single SQL query (something like select objectid, classid from ptmigration where uuid = ?) which should be a pretty darn fast query, especially since there’s probably an index on uuid.

    The portal is making database calls left and right when you’re displaying a portal page, so making one more database call to generate an opener link shouldn’t really be a performance factor. Nonetheless, it’s definitely something to think about and I’m glad you brought it up.

    Posted by: bucchere on February 7, 2007 at 5:53 PM

  • Hi Chris! Am attempting to move this over to .NET; can you tell me which reference I need to add to resolve com.plumtree.taglib.standard and the AOpenerLinkTag? I’m not sure how to convert this Java fragment, which appears to have two seperate definitions of TAG: public static final ITagMetaData TAG; static { TAG = new TagMetaData(“uuidobjectopener”, “… UUID.”); …can you tell me what it means, and any tips on converting to C# ? Should have an opportunity to throw some load at this later on; will post my results here. My customer is already sensitive to performance problems caused by header portlets making DB calls; so I will also be looking into the caching possibilities. Cheers, Rob

    Posted by: rwagner on October 10, 2007 at 11:04 AM

  • Here is another option. The little known server.pt?uuID={XYZ-UUID} syntax. We use this in our public site which is not gatewayed to deep link into portal content without the need for an adaptive tag. We also use this to establish fqdns in apache that redirect to portal pages. For example in apache setup a fqdn of docs.bea.com which points to portal.bea.com/portal/server.pt?uuID={XYZ-UUID}.

    Posted by: ryanyoder on February 11, 2008 at 6:18 AM

  • Wow, very cool! I totally didn’t know that syntax even existed. If it’s supported, it ought to be documented, because it’s quite handy.

    One gotcha is that you need to pass mode=2 if you want to open the object in view mode because the default is edit mode, e.g.: /portal/server.pt?uuID={46514C0F-0187-4340-AA24-84E41C00C60F}&mode=2

    Posted by: bucchere on February 11, 2008 at 6:31 AM

Categories
Plumtree • BEA AquaLogic Interaction • Oracle WebCenter Interaction

More adventures in desktop linux

Everything I do in linux seems to be an adventure. That couldn’t be more true for Oracle 10g. After fighting with the installer, monkeying around with the ALUI database scripts and editing the start-up script, I got the database to start, but it would only shut down immediately afterword. Drats!

This morning, I deleted every trace of Oracle 10g from my system and attempted an install of Oracle 9i. The adventure begins . . . .

First off, Oracle 9i requires JRE 1.3.1, which Sun is planning to retire very soon (as soon as Java 6 comes out). Damn, I remember working on Java 1.0 — am I getting old?

JRE 1.3.1 doesn’t install cleanly on Fedora Core 5. Then again, does anything? Java is closed-source — meaning you can’t build it yourself — so once again I was in a linux bind. When I tried to unpack the 1.3.1 JRE I downloaded from Sun, it gave me this:

tail: `-1' option is obsolete; use `-n 1' since this will be removed in the future
Unpacking...
tail: cannot open `+486' for reading: No such file or directory
Checksumming...
1 The download file appears to be corrupted. [etc]

I downloaded the file again a few times to make sure it really wasn’t corrupted. Of course it wasn’t.

Then I found this great blog post that explained exactly what was going wrong and offered an easy fix. Easy, that is, if you’re a developer. (I’m becoming more and more convinced every day that linux is not at all poised to take over the desktop unless the entire earth’s population goes out and gets a CS degree.)

Alas, the antiquated JRE was really to roll and now it was time to run the Oracle installer. Of course, that didn’t run either. Instead, it spat out JRE errors;

Error occurred during initialization of VM
Unable to load native library: /tmp/OraInstall2006-08-19_11-59-35AM/jre/lib/i386/libjava.so: symbol __libc_wait, version GLIBC_2.0 not defined in file libc.so.6 with link time reference

Nice. Back to Google.

The fix this time came (ironically) from IBM’s web site. No problem, just make a change to libcwait.c, recompile it as a shared object and then set the LD_PRELOAD variable. I’m sure my mom could do that, right?

Then of course I had the standard “this only works under X” problem, but I had already figured that one out. Here’s the error:

Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
at java.awt.Window.(Window.java:188)
at java.awt.Frame.(Frame.java:315)
at java.awt.Frame.(Frame.java:262)
at oracle.sysman.oii.oiic.OiicInstaller.main(OiicInstaller.java:593)

And the fix (as root):

%>xhost +
%>xterm &
%>su - oracle
%>/tmp/Disk1/runInstaller &

And finally, the Oracle 9i installer launched. Now of course it’s totally hung at 18% on “Linking Oracle Net Required Support Files” and it’s been stuck there since before I started writing this blog post.

Gotta love it.

Categories
dev2dev Plumtree • BEA AquaLogic Interaction • Oracle WebCenter Interaction

ALI Install Issues on Fedora Core 5

Note: I don’t think this is officially supported, so YMMV.

I encountered a problem installing ALUI G6 on Fedora Core 5. Just for the record, it’s not a problem with ALUI — it’s a problem with InstallAnywhere, the software that BEA uses to install ALUI.

Here are the errors I got:

[plumtree@bdg-chris]# ./PlumtreeFoundation_v6-0
Preparing to install...
Extracting the JRE from the installer archive...
Unpacking the JRE...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
awk: error while loading shared libraries: libdl.so.2:
cannot open shared object file: No such file or directory
dirname: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory
/bin/ls: error while loading shared libraries: librt.so.1:
cannot open shared object file: No such file or directory
basename: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory
dirname: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory
basename: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory
hostname: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory

Launching installer...

grep: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory
/tmp/install.dir.17585/Linux/resource/jre/bin/java: error while loading
shared libraries: libpthread.so.0: cannot open shared object file:
No such file or directory

I resolved these errors by doing the following:

[plumtree@bdg-chris]# cat PlumtreeFoundation_v6-0 | sed
"s/export LD_ASSUME_KERNEL/#xport LD_ASSUME_KERNEL/" >
PlumtreeFoundation_v6-0.new

[plumtree@bdg-chris]# chmod a+x PlumtreeFoundation_v6-0.new

[plumtree@bdg-chris]# ./PlumtreeFoundation_v6-0.new

This may work to get ALUI installed on other unsupported flavors of *nix, although I’ve never tried it, so again, YMMV.

Comments

Comments are listed in date ascending order (oldest first)

  • once you got it installed how did it run on core 5?

    Posted by: phil- on April 13, 2007 at 12:30 PM

  • It ran pretty well aside from the occasional JVM segfault, which I could have probably fixed by upgrading to the latest 1.4.2 JVM and plugging that into Tomcat 5, rather than running the OOTB bundled Tomcat/JVM supplied by BEA.

    Instead, I’ve switched to Ubuntu (with Oracle XE), which is a great platform because, for the most part, it just takes care of itself. It’s like having RHEL with a lifetime subscription to RHN, but without actually paying for it! 😉

    Posted by: bucchere on April 14, 2007 at 6:17 AM

Categories
dev2dev Featured Posts Plumtree • BEA AquaLogic Interaction • Oracle WebCenter Interaction

Caveat Emptor: Using Varpacks in Pluggable Navigation

I got burned by this today, so I thought I would share it with you all. I had a perfectly good and working pluggable navigation that loaded a remote portlet in the left navigation pane. The only problem was that I had hardcoded the portlet ID and I wanted to make it configurable. So naturally I put the portlet ID and some other settings in a varpack, which is a reasonable thing to do. I then called my varpack from the constructor of my pluggable navigation class that implements IView.

Then I spent the next hour banging my head against the keyboard.

I kept getting a nasty Invocation Target Exception coming out of the reflection methods used to pre-load pluggable navigations. Eventually, using the handy space=MemoryDebug trick, I was able to ascertain that my varpack XML syntax was wrong and my varpack was looking empty to ALUI. So I fixed that and still, I got an ITE.

Then I looked at a PTSpy log and I discovered that the loading order of objects in ALUI was to blame. The portal loads built-in varpacks first, then it loads pluggable navigations, then it loads custom varpacks. So you can’t use the varpack from the IView constructor. I moved it to the Display method and everything started working again. Phew. 😐

So, shame on me for trying to use a custom varpack before it was loaded. Make sure not to make the same mistake!

Categories
Plumtree • BEA AquaLogic Interaction • Oracle WebCenter Interaction

Watch for deprecated methods in the G6 server API

We’re doing a G6 upgrade at one of our customer sites and we noticed that one of our PEIs (that used to set a user preference) was dying due to our use of APIs that worked in 5.0.4 but no longer work in G6.

(Just for the record, I guess I have a different idea of the meaning of deprecated when it comes to APIs. I thought that if you deprecate an API it means “please don’t use this as it might be removed in future versions of the API.” For BEA AquaLogic, I guess it means “this method just doesn’t work any more.”)

Here’s an example: AddPersonalSetting has been replaced by AddPreference.

public Redirect OnAfterLogin(Object userSession, ApplicationData applicationData)
{
IPTSession session = ((IPTSession)userSession);
session.GetMyPages().OpenPage(0 - userId)
.AddPersonalSetting("UserSettingName", "UserSettingValue");
}

Here’s the new G6 way to do this:

public Redirect OnAfterLogin(Object userSession, ApplicationData applicationData)
{
IPTSession session = ((IPTSession)userSession);
session.GetSessionInfo()
.AddPreference("UserSettingName", "UserSettingValue", 0);
}