Simple Content Repository Search Example

| Posted by watashii | Filed under Java, Programming, Web


Here is a simple code fragment to perform search on the Weblogic Portal 10 Content Repository using the search api.  The important part is the query string to extract the content, and the sort order. Some examples here.

String contentQuery = "cm_path like 'WLP Repository/*'";
ISortableFilterablePagedList<Node> nodes = null;
ISearchManager searchManager = ContentManagerFactory.getSearchManager();
ContentContext context = new ContentContext();
Search search = new Search(contentQuery);
search.setSortCriteria("cm_nodeName");
try
{
   nodes = searchManager.search(context, search);
}
catch (RepositoryException message)
{
   System.out.println(message);
}

for (Node node : nodes)
{
   /*
     process each node
   */
   Property[] props = null;
   try
   {
      props = node.getProperties();
   }
   catch (AuthorizationException message)
   {
      System.out.println(message);
   }
   for (Property property : props)
   {
      /*
        process each node property
      */
   }
}

Share:

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Print
  • email

Related Posts:

  1. Weblogic Portal Authorization – Get and Check User’s Roles
  2. Reading Portlet Preferences in Weblogic Portal

Tags: , , , ,

Leave a Reply