| By Chris Lockhart | Article Rating: |
|
| June 7, 2005 03:00 PM EDT | Reads: |
33,027 |
The Content Bean
Content-nodes in the PSI are referenced by the Content bean. This bean lets you search for a particular content-node, view its settings, update the settings, create a new content-node or delete a content-node.
If I was curious to know some details about the Corporate Directory content-node, I could invoke the Content bean to tell me about it. The Content bean uses the following syntax for a search:
$Content find <type> <by> <value>
So to find and display some info about the Corporate Directory node with uniquename wps.myportal.CorpDir, I would use:
$Content find any uniquename "wps.myportal.CorpDir"
More specifically, since I know the CorpDir is of type 'page,' I could execute a more concise search:
$Content find page uniquename "wps.myportal.CorpDir"
There are several different kinds of searches you can do. Executing
$Content help search-types
will show you these different searches. Keep in mind the help function for the Content bean is always available using:
$Content help
Okay, so big deal, you found the content-node. It's far more interesting if you were to display some other info about this node. Before you can display other attributes of the node, you have to "select" the node. Finding it isn't enough, you have to "select" it before running an additional command against it:
$Content find any uniquename "wps.myportal.CorpDir" select
Now that you've got it selected, try any of the following:
$Content get type
$Content get "wps.myportal.CorpDir" id
$Content current
The ID of the content-node (or any portal object for that matter) is the UID or Unique ID of the object. With this interface, most of the actions (get or set) are invoked against the UID of an object. Once you have this id, some of the operations become easier.
There are a few special id values that we can use. The most useful is called 'the root.'
$Content select the root
This command will select the root content node. Second in usefulness is the 'the parent' special id:
$Content select the parent
This command will select the immediate parent of the currently selected content node.
Let's say for example that the unique ID of our CorpDir node (the UID that was auto-generated by the Portal when we created the page) was found using one of the commands above. Let's say for argument's sake that this id is _6_00KJL57F9D04J770_D. We could then issue some other commands such as:
$Content get "wps.myportal.CorpDir" id
$Content get _6_00KJL57F9D04J770_Dthemename
$Content set _6_00KJL57F9D04J770_Dtheme "Finance"
$Content get _6_00KJL57F9D04J770_Dposition
If we were interested in what was underneath our WorkPlace content-node, we could select it and then search on that content-node for objects called compositions (or pages to you and me):
$Content find label uniquename
wps.myportal.WorkPlace select
$Content search composition
This will return a list of all the pages (or compositions) contained under the WorkPlace label.
But surely this isn't the exciting part. No, we're much more interested in creating some content-nodes instead of merely displaying information about them. Luckily for us, the Content bean has a method called 'create.' Let's use our CorpDir content-node as an example (we retrieved its uid in one of the above examples):
$Content select _6_
00KJL57F9D04J770_D
$Content create composition
"SubPage" html
This will select the CorpDir content-node and then create a page underneath it called SubPage with html as the supported markup.
$Content select the root
$Content create label "NewLabel"
html select
$Content create composition
"NewSubPage" html
This sequence first selects the content root, then creates a new label underneath it and selects this new label, then creates a page underneath it. By contrast, we could also delete the content-nodes:
$Content delete <id>
This command would delete the content-node with the id specified. For safety, the system doesn't let you delete a content-node with children. Gotta make sure those kids have parents!
Lens on Portlets
Even though we can't affect portlets directly using the PSI, we can definitely get some good information about the portlets defined in our portal repository. To do so we use the Portlet bean.
$Portlet search webmodule namehas "News"
Seems pretty straightforward. This command will execute the Portlet bean with the search method against objects of the webmodule type whose names contain the word "News." Once we have those objects returned, we could take the uid of one of them and gather more info:
$Portlet get webmodule <id>
contextroot
$Portlet get webmodule <id> name
Of course, the Portlet bean also has a help function (as do its methods) in case you get stuck.
Sadly, there's no "set" capability with the Portlet bean. Perhaps we should start a campaign to get that functionality added...
Published June 7, 2005 Reads 33,027
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Chris Lockhart
Chris Lockhart is a senior technical resource at Perficient, a firm recognized for its expertise around IBM technologies. Chris has worked with IBM's WebSphere, Tivoli and Lotus Software platforms for more than 6 years. For more information, please visit www.perficient.com
- Oracle To Keynote Cloud Computing Expo
- Is the PR Business Extinct? Yes
- The Difference Between Web Hosting and Cloud Computing
- GovIT Expo Highlights Cloud Computing
- The End of IT 1.0 As We Know It Has Begun
- Cloud Computing Best Practices
- Gang of Four Creates Cloud BI Stack
- The Case for Single-Purpose Services
- VIP Invitation For the GovIT Panel October 6, Washington DC
- Product Evaluation: JBoss TCO Calculator
- Oracle To Keynote Cloud Computing Expo
- How to Diagnose Java Resource Starvation
- Is the PR Business Extinct? Yes
- Anatomy of a Java Finalizer
- IBM & Cloud Computing: Exclusive Q&A
- IBM & Cloud Computing: How "SOA in the Cloud" Can Produce Real Change
- SOA & Cloud Bootcamp: Comparing Cloud Computing Providers
- WebSphere Guru to Keynote at SOA World
- IBM Researcher Solves In-Cloud Data Encryption Puzzle
- The Difference Between Web Hosting and Cloud Computing
- Java vs C++ "Shootout" Revisited
- Where Are RIA Technologies Headed in 2008?
- WebSphere Application Server Java Dumps
- Breaking News: New Internal IBM Report Says "Another Flawed Study"
- Last Exclusive JDJ Interview With "IBM's" John A. Swainson, Now CA's Newly Appointed CEO
- How To Deploy Scalable WebSphere Applications Using "Maven" Build Tool
- Your Guide to Portal Clustering in WebSphere Portal Server 5.1
- Developing Java and Web Services Applications on Rational Application Developer V6
- Automated Deployment of Enterprise Application Updates
- Putting IBM's WAS On Unix - WebSphere Application Server

































