Thursday, July 22, 2010

WebCenter Spaces for iPhone

Just to let you know the WebCenter Spaces application for iPhone is now available at Apple's App Store.
Here is the link for you -- http://itunes.apple.com/us/app/oracle-webcenter-spaces-11g/id382334215?mt=8

Wednesday, June 23, 2010

WebCenter WIKI Macro - Table of Contents

WebCenter WIKI Macro - Table of Contents I was asked to help extending Oracle WebCenter's Wiki server, to add a macro to auto-generate a Table of Contents for a wiki page. It follows the same layout as Wikipedia's table of contents, and also has the ability to hide/show itself.

Description:
The <macro:Toc> will generate a simple Table of Contents, in the forms of Wikipedia's Table of Contents. It will search the wiki page content for all Header tags (!, !!, !!!, !!!!) up to 4h level.
Anchors to the title are automatically generated based text for this title
Example: !Description generates anchor <a name="Description"></a><h1>Description</h1>

Syntax:
#1) simple -- will create TOC with title = "Contents" and no auto numbering:
<macro:Toc>
</macro>

#2) with numbering -- numbers are automatically added to the TOC
<macro:Toc numbering="true">
</macro>

#3) with title & numbering -- the title will be set to the text within the macro tags
<macro:Toc numbering="true">
My Table of Contents
</macro>

If you want to give it a try, get the following files and place them on the location below:
Note: It was tested with WebCenter 11g 11.1.1.3.0
-- $WLS_HOME/user_projects/applications//owc_wiki/tags/toc.vm
-- $WLS_HOME/user_projects/applications//owc_wiki/WEB-INF/classes/org/jzwiki/macros/TocMacro.class
-- $WLS_HOME/user_projects/applications//owc_wiki/WEB-INF/lib/yawiki-engine-2.1.jar - file changed is org.jzonic.yawiki.converter.HeaderConverter.class

Here is a screenshot of the macro in action :


Monday, June 7, 2010

WLP Portlet Subscribe/Unsubscribe

Last week, I had to simulate a "subscribe/unsubscribe" mechanism for WebLogic Portal (WLP) 10.3. The basic idea is that the user has an option to subscribe to a portlet, from a list of available portlets, and that is displayed in his main page.

After some research, I found some good reference from Balz Schreier on the WLP Portlet Preferences APIs. In his example, Balz shows how to get access to PortalCustomizationManager which allows us to perform various operations, including removing - .removePlaceable - and adding - .addPlaceable - portlets to a Page.

Using similar code, we could also get access to PortletDefinitionManager , which will give us access to all portlets for the Web Application - .getPublicPortletDefinitions.

In my example, the idea is to "replace" the existing portlet subscription with a new one. To simplify things in my example, I have 2 portlets - weather & stocks - and user can either view one or the other. So, when it is time to change the subscription, I just look for the one that is currently showing - _oldPlaceableView -, so I can get its PlaceholderDefinitionId & PlaceHolderPosition. This is needed, as the new portlet - _newPortletDef - will show up in the same location.

Now, we have all the APIs to:
  • getPortalCustomizationManager -- return instance of PortalCustomizationManager.
  • getPortletDefinitionManager -- return instance of PortletDefinitionManager.
  • getAllPortlets -- returns a list of all available portlets for the Web Application.
  • findPortlet -- finds the PortletDefinition for the new portlet to be subscribed to.
  • findPlaceableView -- finds the PlaceableView instance of the current portlet.
  • deleteCustomizations -- helper to clean up all the customizations for this user, and reset the original state of the page. Useful for the testing, where things start getting messy after some time, and you want to clean it all up. I received this code from an Oracle peer.
  • subscribePortlet -- wraps all the calls into a single method, to make it easier for the test JSP page.
It is also important to say that the user must be authenticated for this to work the way we wanted. In my test.jsp, I have a reference to an authenticate  method, that simply calls  com.bea.p13n.security.Authentication.login.

Putting it all together, here is WlpHelper.java and test.jsp. The idea is to start with a simple JSP just to validate the flow, but that later could turn into a "Preferences Page" of some sort, where user views all the available portlets and can choose which one to subscribe to.

Here is the original page, showing the Stocks portlet:


and this is after executing the test.jsp with the following parameters:
http://localhost:7001/tutorial_portalWeb/test.jsp?username=rolima&password=welcome1&action=subWeather


The example is really simple, but the starting APIs are there for you build from it.
Have fun!

Wednesday, May 12, 2010

Gwibber on Ubuntu 10.04 LTS

While playing with the new Ubuntu 10.04 LTS, I saw the Gwibber client for Twitter, Facebook, Digg, Flickr and others. I know this has not much to do with WebCenter, Enterprise 2.0, Fusion, or even Oracle, but just would like to share in case you read my earlier post and decided to use Ubuntu 10.04.

I tried to make it work, so I could just see the tweets popping up on the desktop via notification-applet, but the first tries were frustrating...
I did manage to add my twitter account, but no updates would come. Facebook was even worst, as I could not even add the account.

After spending some time searching around, I found this bug #530195, where the comment #22 suggested that you increased the timeout in network.py.

I opened up  /usr/lib/python2.6/dist-packages/gwibber/microblog/network.py and noticed the original connection timeout was set to 8secs.

Not sure what internet provider people are using, and I actually thought I had a good speed (around 20Mbps), but that was still not enough. I'm also not sure about the DNS tricks (openDNS + google DNS = magic DNS :), so I just went the lazy way -- multiply by 10 :)

#/usr/lib/python2.6/dist-packages/gwibber/microblog/network.py

    self.curl.setopt(pycurl.TIMEOUT, 150)
    self.curl.setopt(pycurl.CONNECTTIMEOUT, 80)

That solved the Twitter problem, but I was still not able to add my account to Facebook.
After some more research, I found another bug #552227, with many suggestions on how to overcome that. I tried all the suggestions on that page but still no luck.

Ok, let's try the "twitter-hack" then :)... Found that there connection timeout was actually being set on another file -- /usr/lib/python2.6/dist-packages/gwibber/microblog/util/facelib.py

I again applied the "lazy 10x higher" fix:
#/usr/lib/python2.6/dist-packages/gwibber/microblog/util/facelib.py

    c.setopt(pycurl.TIMEOUT, 150)
    c.setopt(pycurl.CONNECTTIMEOUT, 80)

Yay! Finally able to see both Twitter and Facebook accounts on Gwibber! And the cool desktop icon notifications keep popping up now,  a quick not-that-intrusive way to keep updated on things. I really like it better than having either  an extra browser window, or another application running.

WebCenter on Ubuntu 10.04 LTS

Just finished installing WebCenter 11.1.1.2 on Ubuntu 10.04 LTS.
Note: -- this is *not* a supported configuration, I just did as a quick test environment!!!!

The steps are not much different from what I posted before, but you will get a lot of complaints during the initial system/environment checks. I decided just to ignore all the complaints from the Installer, and continue with the install.

This time, I used the newly released WebLogic Server 10.3.3, Repository Content Utility (rcu) 11.1.1.3, Oracle XE 10.2.0.1.1, and WebCenter 11.1.1.2 (you must install this before you can apply the 11.1.1.3 patch).

After installing WebCenter 11.1.1.2, and before applying the patch, I decided to start all servers to check the status of the install.
Both WLS_Admin, and WLS_Services started fine, but WLS_Spaces failed with the following error:
(........ initialization messages .........)
<May 12, 2010 10:36:50 AM EDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
<May 12, 2010 10:36:50 AM EDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
[[Cjava.lang.NoClassDefFoundError: javax/wsdl/Definition
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.privateGetPublicMethods(Class.java:2557)
at java.lang.Class.getMethods(Class.java:1410)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.getImplementedInterfaces(EjbAnnotationProcessor.java:1687)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionAnnotations(EjbAnnotationProcessor.java:447)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:310)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:180)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:344)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:204)
at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1242)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:395)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
(........ bunch of errors .........)

Did a quick search, and found out a copy of wsdl4j.jar under
$DOMAIN_HOME/servers/WLS_Spaces/tmp/_WL_user/oracle.webcenter.jive.dependency/38f82s/APP-INF/lib/wsdl4j.jar
I copied under $DOMAIN_HOME/lib and tried starting WLS_Spaces again, but it failed with exact same error message.

Looking at the output from server start, notice the line that reads:
<May 12, 2010 10:35:55 AM EDT> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
/opt/wls/user_projects/domains/base_domain/lib/mbeantypes/csp-id-asserter.jar:/opt/wls/user_projects/domains/base_domain/lib/wsdl4j.jar>

shows after the line that sets the classpath, and the line with the java ..... weblogic.Server ... not sure if this could be the problem -- classpath being set too late?

In any case, I just edited setDomainEnv.sh to make sure it would include wsdl.jar
# add the following line ....
POST_CLASSPATH=${DOMAIN_HOME}/lib/wsdl4j.jar${CLASSPATHSEP}${POST_CLASSPATH}

# BEFORE this line
if [ "${POST_CLASSPATH}" != "" ] ; then
    if [ "${CLASSPATH}" != "" ] ; then
        CLASSPATH="${POST_CLASSPATH}${CLASSPATHSEP}${CLASSPATH}"
        export CLASSPATH
    else
        CLASSPATH="${POST_CLASSPATH}"
        export CLASSPATH
    fi
fi

Now WLS_Spaces started correctly, and I was able to login to WebCenter Spaces pages.

Again -- this is not supported, so I'm not sure what errors could still be ahead when I try more things.
In any case, I'll now try to setup the SAML-based Single Sign-on and will post the results here.

Tuesday, April 6, 2010

Lazy Developer


I was reading some tutorials for Oracle WebLogic Portal (WLP), and they mention it is good practice to separate your WLP project in a folder structure  to make it easier to manage and add it to source control.

One structure I found to be good, is to use the following:

HOME/workspaces/projectX/           # workspace directory for Project X

HOME/projects/projectX/             # directory for the Project X projects
                 prjX_portalEAR/    # your EAR project
                 prjX_portalWeb/    # your WAR project
                 prjX_datasync/     # a Datasync project
                 prjX_ejb/          # an EJB project
                 prjX_utility/      # a J2EE utility project
                 prjX_webServices/  # a J2EE utility project

HOME/domains/prjX_domain/           # domain directory for Project X

Note: You may have a structure that looks a bit different, and that is ok. The main point of this post is not the structure itself, but being lazy about it :-)

I started running through tutorials, and first time, you go ahead and manually create the folder structure. Then you try, and nothing works, so you erase it all, and start again. Once again, you go ahead with File Explorer, and make all these folders.

You notice this is a painful process. After all, the whole idea is to have the computer do the work, and not you. Also, I'm a bit lazy developer, and I really like automating things, so I don't have to do the work over and over. BTW, there is also a great post about this -- "When Windows are not enough".

So, I sit down and write the following BAT script that receives 2 parameters:
  • Project_Name -- projectX from example above
  • Project_Prefix -- prjX from example above

Here is the BAT file:
@echo off

IF not "%1"=="" GOTO GOOD
:EXIT
echo "Error in %0 - Invalid Argument Count"
echo "Syntax: %0 Project_Name Project_Prefix"
goto END

:GOOD
echo "SETTING UP PROJECT: %1 [%2]";

echo "CLEAN UP..."
rmdir /s /q domains\%2_domain\
rmdir /s /q projects\%1\
rmdir /s /q workspaces\%1\

echo "CREATE DOMAIN..." 
mkdir domains\%2_domain\

echo "CREATE WORKSPACE..."
mkdir workspaces\%1

echo "CREATE PROJECTS..."
mkdir projects\%1\%2_datasync
mkdir projects\%1\%2_ejb
mkdir projects\%1\%2_portalEAR
mkdir projects\%1\%2_portalWeb
mkdir projects\%1\%2_utility
mkdir projects\%1\%2_webServices

echo "DONE!"

:END

I also created similar script in shell script, as I have dual boot and I keep switching from Ubuntu to Win7.
#!/bin/sh

if [ $# -ne 2 ]
then
    echo "Error in $0 - Invalid Argument Count"
    echo "Syntax: $0 Project_Name Project_Prefix"
    exit
fi

echo "SETTING UP PROJECT: $1 [$2]";


echo "CLEAN UP..."
rm -rf domains/$2_domain/
rm -rf projects/$1/
rm -rf workspaces/$1/

echo "CREATE DOMAIN..."
mkdir -pv domains/$2_domain

echo "CREATE WORKSPACE..."
mkdir -pv workspaces/$1

echo "CREATE PROJECTS..."
mkdir -pv projects/$1/$2_datasync
mkdir -pv projects/$1/$2_ejb
mkdir -pv projects/$1/$2_portalEAR
mkdir -pv projects/$1/$2_portalWeb
mkdir -pv projects/$1/$2_utility
mkdir -pv projects/$1/$2_webServices

echo "DONE!"

Again, the script itself and the folder structure can be different, does not matter. What you really should always strive for is automation! Let the computer do the hard/tedious work, not you. You should be focusing on your solution (or your tutorial :)


Friday, April 2, 2010

N-1 WebCenter-UCM Install


Sometimes, you may want to have a single instance of Oracle UCM shared to multiple instances of Oracle WebCenter. One good example we had for this, is a fellow Oracle employee running a bootcamp in China. Instead of installing 1-1 instances, he would like to have a N-1 topology, where you have N instances of WebCenter pointing to 1 instance of UCM.

The following is a link to Gary's post about how to do this installation -- 
http://blogs.oracle.com/garyniu/2010/04/content_management_for_webcenter_installation_guide.html

It is also a good read if you are having some other issues with your UCM install, specially the last section about "Configuring the Identity Store".

Thanks Gary!