portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raph...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service JetspeedPersistenceService.java PersistenceServiceImpl.java
Date Mon, 04 Jun 2001 17:41:50 GMT
raphael     01/06/04 10:41:50

  Modified:    src/java/org/apache/jetspeed/portal/service
                        JetspeedPersistenceService.java
                        PersistenceServiceImpl.java
  Log:
  update the Persistence services to work with the new PSML and Portal
  services
  
  Revision  Changes    Path
  1.7       +26 -99    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/JetspeedPersistenceService.java
  
  Index: JetspeedPersistenceService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/JetspeedPersistenceService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JetspeedPersistenceService.java	2001/05/31 17:11:14	1.6
  +++ JetspeedPersistenceService.java	2001/06/04 17:41:47	1.7
  @@ -58,69 +58,48 @@
   import java.util.Vector;
   import java.util.Hashtable;
   
  -import javax.servlet.http.*;
  -
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.Log;
  -import org.apache.jetspeed.capability.CapabilityMap;
  -import org.apache.jetspeed.capability.CapabilityMapFactory;
  -import org.apache.jetspeed.portal.factory.PortletSetFactory;
   import org.apache.jetspeed.portal.Portlet;
  -import org.apache.jetspeed.services.Profiler;
  -import org.apache.jetspeed.om.profile.*;
  -
  -import org.apache.jetspeed.util.MimeType;
  -import org.apache.jetspeed.xml.api.portletmarkup.*;
  -
  -import org.apache.jetspeed.util.PSMLManager;
  +import org.apache.jetspeed.services.PsmlManager;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +import org.apache.jetspeed.om.profile.Profile;
  +import org.apache.jetspeed.om.profile.PSMLDocument;
  +import org.apache.jetspeed.xml.api.portletmarkup.Entry;
  +import org.apache.jetspeed.xml.api.portletmarkup.Parameter;
   
   public class JetspeedPersistenceService implements PersistenceService
   {
      private final static String NAME = "Jetspeed Persistence Service 1.0";
   
  -    private RunData iRunData;
  +    private JetspeedRunData iRunData;
   
       private Vector iPages = new Vector ();
   
       public void init (RunData aRunData, Object [] aParams) throws ServiceException
       {
  -        iRunData = aRunData;
  +        iRunData = (JetspeedRunData)aRunData;
   
            if (aParams.length == 0)
  +         {
                throw (new ServiceException ("Portlet reference as parameter 0 expected"));
  +         }
   
  -       String portletName = ((Portlet) aParams [0]).getName ();
  +        String portletName = ((Portlet) aParams [0]).getName ();
   
           // FIX ME
           // we urgently need a "what pages does a user have" method
           // for now we just assume it's those two only
  -        try
  -        {
  -            Profile profile = Profiler.getSessionProfile(aRunData);
  -            loadPage(portletName, profile);
  -        }
  -        catch (ProfileException ex)
  -        {
  -            throw new ServiceException("Persistence Service failed init: " + ex.toString());
  -        }
  -        // dst: loadPage (iProfiler.getUserURL (aRunData.getUser ().getUserName (), MimeType.HTML),
portletName);
  -        // dst: loadPage (iProfiler.getUserURL (aRunData.getUser ().getUserName (), MimeType.WML),
portletName);
  +        loadPage(portletName, iRunData.getProfile());
       }
   
       public void init (RunData aRunData, String param) throws ServiceException
       {
  -        iRunData = aRunData;
  +        iRunData = (JetspeedRunData)aRunData;
   
  -       String portletName = param;
  -       try
  -       {
  -            Profile profile = Profiler.getSessionProfile(aRunData);
  -            loadPage(portletName, profile);
  -        }
  -        catch (ProfileException ex)
  -        {
  -            throw new ServiceException("Persistence Service failed init: " + ex.toString());
  -        }
  +        String portletName = param;
  +    
  +        loadPage(portletName, iRunData.getProfile());
   
       }
   
  @@ -193,15 +172,7 @@
           Page page = null;
           String pageName = null;
   
  -        try
  -        {
  -            Profile profile = Profiler.getSessionProfile(iRunData);
  -            pageName = profile.getURL();
  -        }
  -        catch (ProfileException ex)
  -        {
  -            Log.error(ex);
  -        }
  +        pageName = iRunData.getProfile().getURL();
   
           for (Enumeration e = getPages (); e.hasMoreElements (); )
           {
  @@ -240,20 +211,12 @@
           return (iPages.elements ());
       }
   
  -
  -
       private void loadPage (String aPortletName, Profile profile)
       {
           String pageName = profile.getURL();
  -        PortletSetFactory factory = profile.getFactory();
  -        // a tree of portlets is held by the portlet set factory
  -
  -        Portlets portlets = factory.getPortlets ();
   
  -        // find the portlet within the tree
  +        Entry entry = profile.getDocument().getEntry(aPortletName);
   
  -        Entry entry = findEntry (portlets, aPortletName);
  -
           if (entry != null)
           {
               String pid = aPortletName + "." + pageName;
  @@ -261,7 +224,7 @@
   
               if (page == null)
               {
  -                page = new Page (pageName, portlets, entry);
  +                page = new Page (profile.getDocument(), entry);
                   iRunData.getUser().setTemp(pid, page);
               }
   
  @@ -269,55 +232,18 @@
           }
       }
   
  -    /**
  -     ** Traverses the portlets tree to find the one with the given name.
  -     ** Problem is: because of the lookup by name, no portlet can exist
  -     ** twice on any given page.
  -     **/
  -
  -    private Entry findEntry (Portlets aPortlets, String aPortletName)
  -    {
  -        Entry entry = null;
  -
  -        for (Enumeration e1 = aPortlets.enumerateEntry (); e1.hasMoreElements (); )
  -        {
  -            entry = (Entry) e1.nextElement ();
  -
  -            if (entry.getParent ().equals (aPortletName))
  -                 return (entry);
  -        }
  -
  -        entry = null;
  -
  -        for (Enumeration e2 = aPortlets.enumeratePortlets (); e2.hasMoreElements (); )
  -        {
  -            Portlets portlets = (Portlets) e2.nextElement ();
  -
  -            entry = findEntry (portlets, aPortletName);
  -
  -            if (entry != null)
  -                 break;
  -        }
  -
  -        return (entry);
  -    }
  -
       private static class Page implements PersistenceService.Page
       {
  -        private String iName;
  -
  -        private Portlets iPortlets;
  +        private PSMLDocument iDocument;
   
           private Entry iEntry;
   
           private Hashtable iAttributes = new Hashtable ();
   
  -        private Page (String aName, Portlets aPortlets, Entry aEntry)
  +        private Page (PSMLDocument aDocument, Entry aEntry)
           {
  -            iName = aName;
  +            iDocument = aDocument;
   
  -            iPortlets = aPortlets;
  -
               iEntry = aEntry;
   
               reset ();
  @@ -325,7 +251,7 @@
   
           public String getName ()
           {
  -            return (iName);
  +            return (iDocument.getName());
           }
   
           public String getAttribute (String aName)
  @@ -423,9 +349,10 @@
               }
   
               // now save it -- again, the page name == the file name is assumed
  -            if (! PSMLManager.setPSMLContent (aRunData, iName, iPortlets))
  +            if (! PsmlManager.saveDocument(iDocument))
  +            {
                  reset ();
  +            }
           }
  -
       }
   }
  
  
  
  1.6       +12 -51    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/PersistenceServiceImpl.java
  
  Index: PersistenceServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/PersistenceServiceImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PersistenceServiceImpl.java	2001/03/07 06:48:02	1.5
  +++ PersistenceServiceImpl.java	2001/06/04 17:41:48	1.6
  @@ -63,13 +63,13 @@
   import org.apache.turbine.util.RunData;
   import org.apache.jetspeed.capability.CapabilityMap;
   import org.apache.jetspeed.capability.CapabilityMapFactory;
  -import org.apache.jetspeed.portal.factory.PortletSetFactory;
   import org.apache.jetspeed.portal.Portlet;
   import org.apache.jetspeed.profiler.*;
   import org.apache.jetspeed.util.MimeType;
   import org.apache.jetspeed.xml.api.portletmarkup.*;
   
  -import org.apache.jetspeed.util.PSMLManager;
  +import org.apache.jetspeed.services.PsmlManager;
  +import org.apache.jetspeed.om.profile.PSMLDocument;
   
   public class PersistenceServiceImpl implements PersistenceService
   {
  @@ -218,18 +218,10 @@
   
       private void loadPage (String aURL, String aPortletName)
       {
  -        // a tree of portlets is held by the portlet set factory
  +        PSMLDocument document = PsmlManager.getDocument(aURL);
   
  -        PortletSetFactory factory = PortletSetFactory.getInstance (aURL);
  +        Entry entry = document.getEntry(aPortletName);
   
  -        factory.init (factory.getSingletonHandle());
  -
  -        Portlets portlets = factory.getPortlets ();
  -
  -        // find the portlet within the tree
  -
  -        Entry entry = findEntry (portlets, aPortletName);
  -
           if (entry != null)
           {
               // FIX ME
  @@ -248,7 +240,7 @@
   
               if (page == null)
               {
  -                page = new Page (pageName, portlets, entry);
  +                page = new Page (pageName, document, entry);
                   iRunData.getUser().setTemp(aPortletName + "." + pageName, page);
   
               }
  @@ -257,54 +249,21 @@
           }
       }
   
  -    /**
  -     ** Traverses the portlets tree to find the one with the given name.
  -     ** Problem is: because of the lookup by name, no portlet can exist
  -     ** twice on any given page.
  -     **/
  -
  -    private Entry findEntry (Portlets aPortlets, String aPortletName)
  -    {
  -        Entry entry = null;
  -
  -        for (Enumeration e1 = aPortlets.enumerateEntry (); e1.hasMoreElements (); )
  -        {
  -            entry = (Entry) e1.nextElement ();
  -
  -            if (entry.getParent ().equals (aPortletName))
  -                 return (entry);
  -        }
  -
  -        entry = null;
  -
  -        for (Enumeration e2 = aPortlets.enumeratePortlets (); e2.hasMoreElements (); )
  -        {
  -            Portlets portlets = (Portlets) e2.nextElement ();
  -
  -            entry = findEntry (portlets, aPortletName);
  -
  -            if (entry != null)
  -                 break;
  -        }
  -
  -        return (entry);
  -    }
  -
       private static class Page implements PersistenceService.Page
       {
           private String iName;
   
  -        private Portlets iPortlets;
  +        private PSMLDocument iDocument;
   
           private Entry iEntry;
   
           private Hashtable iAttributes = new Hashtable ();
   
  -        private Page (String aName, Portlets aPortlets, Entry aEntry)
  +        private Page (String aName, PSMLDocument aDocument, Entry aEntry)
           {
               iName = aName;
  -
  -            iPortlets = aPortlets;
  +            
  +            iDocument = aDocument;
   
               iEntry = aEntry;
   
  @@ -412,8 +371,10 @@
   
               // now save it -- again, the page name does not match the file name
   
  -            if (! PSMLManager.setPSMLContent ( aRunData, iName.equals ("HTML") ? MimeType.HTML
: MimeType.WML, iPortlets))
  +            if (! PsmlManager.saveDocument ( iDocument ))
  +            {
                    reset ();
  +            }
           }
   
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message