raphael 01/06/09 08:42:47
Modified: src/java/org/apache/jetspeed/portal BasePortletSet.java
src/java/org/apache/jetspeed/portal/portlets
AbstractPortlet.java
src/java/org/apache/jetspeed/portal/portlets/customize
CustomizePortlet.java
src/java/org/apache/jetspeed/portal/service
ServiceFactory.java
src/java/org/apache/jetspeed/util PSMLManager.java
src/java/org/apache/jetspeed/util/customization
PSMLDocument.java
Removed: src/java/org/apache/jetspeed/portal/service
PersistenceServiceImpl.java
src/java/org/apache/jetspeed/profiler DefaultProfiler.java
MultiDeviceUserProfiler.java Profiler.java
ProfilerFactory.java UserProfiler.java
Log:
- remove obsolete Profiler package
- update classes depdendant on old profiler to use new profiler
- update PSMLManager to use the new PsmlManager
Revision Changes Path
1.9 +1 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java
Index: BasePortletSet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BasePortletSet.java 2001/06/08 10:06:47 1.8
+++ BasePortletSet.java 2001/06/09 15:42:45 1.9
@@ -60,7 +60,6 @@
import java.util.Enumeration;
//Jetspeed stuff
-import org.apache.jetspeed.profiler.*;
import org.apache.jetspeed.capability.*;
import org.apache.jetspeed.util.*;
import org.apache.jetspeed.portal.expire.*;
@@ -81,7 +80,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
- * @version $Id: BasePortletSet.java,v 1.8 2001/06/08 10:06:47 raphael Exp $
+ * @version $Id: BasePortletSet.java,v 1.9 2001/06/09 15:42:45 raphael Exp $
*/
public class BasePortletSet implements PortletSet, Portlet, PortletState
{
1.42 +1 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
Index: AbstractPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- AbstractPortlet.java 2001/06/04 17:46:59 1.41
+++ AbstractPortlet.java 2001/06/09 15:42:45 1.42
@@ -57,7 +57,6 @@
//jetspeed
import org.apache.jetspeed.portal.*;
import org.apache.jetspeed.portal.expire.*;
-import org.apache.jetspeed.profiler.*;
import org.apache.jetspeed.capability.*;
import org.apache.jetspeed.util.*;
import org.apache.jetspeed.services.portletcache.Cacheable;
@@ -93,7 +92,7 @@
@author <A HREF="mailto:[EMAIL PROTECTED]">Kevin A. Burton</A>
@author <A HREF="mailto:[EMAIL PROTECTED]">Rapha�l Luta</A>
-@version $Id: AbstractPortlet.java,v 1.41 2001/06/04 17:46:59 raphael Exp $
+@version $Id: AbstractPortlet.java,v 1.42 2001/06/09 15:42:45 raphael Exp $
*/
public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
{
1.15 +86 -47
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java
Index: CustomizePortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- CustomizePortlet.java 2001/06/07 22:00:29 1.14
+++ CustomizePortlet.java 2001/06/09 15:42:46 1.15
@@ -57,15 +57,14 @@
import org.apache.jetspeed.xml.api.portletmarkup.*;
-import org.apache.jetspeed.services.PortletFactory;
import org.apache.jetspeed.om.newregistry.*;
-import org.apache.ecs.html.*;
-import org.apache.jetspeed.portal.portlets.*;
+import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.portal.portlets.AbstractPortlet;
import org.apache.jetspeed.portal.*;
-import org.apache.jetspeed.profiler.*;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.JetspeedSecurity;
+import org.apache.jetspeed.services.PortletFactory;
import org.apache.jetspeed.util.*;
@@ -114,9 +113,6 @@
/** parameter to call the second page */
public static final String SAVE_SETTINGS = "save";
-
-
-
/**
* getAvailablePortlets( ) reads the available Portlets from the PortletRegistry
and
* stores them in the local Vector.
@@ -173,43 +169,55 @@
* @return org.apache.ecs.ConcreteElement - the ECS element that contains the
content
* @param data org.apache.turbine.util.RunData - the data object generated by
Turbine
*/
- public ConcreteElement getContent( RunData data )
- {
- if( data.getUser( ).hasLoggedIn( ) )
+ public ConcreteElement getContent( RunData data )
+ {
+ try
{
- this.setTitle( "Customize your Layout" );
- this.setDescription( "Customize the appearance of your home page and
the portlets you selected" );
-
- // First check the URL for the parameters that have been set
- String page = data.getRequest( ).getParameter( "page" );
- if ( page == null || PAGE_ONE.equals( page ) )
- {
- Log.note( "Customizer--> Call page one" );
- return getPageOne( data );
- }
- else if ( SAVE_SETTINGS.equals( page ) )
+ if( data.getUser( ).hasLoggedIn( ) )
{
- Log.note( " Customizer --> Save settings for ( " + data.getUser(
).getUserName( ) + ") and return to Homepage " );
- saveSettings( data );
- // forward to the homepage
- data.setStatusCode( HttpServletResponse.SC_MOVED_TEMPORARILY );
- try
+ this.setTitle( "Customize your Layout" );
+ this.setDescription( "Customize the appearance of your home page
and the portlets you selected" );
+
+ // First check the URL for the parameters that have been set
+ String page = data.getRequest( ).getParameter( "page" );
+
+ if ( page == null || PAGE_ONE.equals( page ) )
{
- data.setRedirectURI( URILookup.getURI( URILookup.TYPE_HOME,
URILookup.SUBTYPE_NONE, data ) );
- return null;
+ Log.note( "Customizer--> Call page one" );
+ return getPageOne( data );
}
- catch( JetspeedException ex )
+ else if ( SAVE_SETTINGS.equals( page ) )
{
- Log.error( "CustomizePortlet: Could not redirect to
HomeScreen--> " + ex.getMessage( ) );
+ Log.note( " Customizer --> Save settings for ( " +
data.getUser( ).getUserName( ) + ") and return to Homepage " );
+ saveSettings( data );
+ // forward to the homepage
+ data.setStatusCode( HttpServletResponse.SC_MOVED_TEMPORARILY );
+
+ try
+ {
+ data.setRedirectURI( URILookup.getURI( URILookup.TYPE_HOME,
URILookup.SUBTYPE_NONE, data ) );
+ return null;
+ }
+ catch( JetspeedException ex )
+ {
+ Log.error( "CustomizePortlet: Could not redirect to
HomeScreen--> " + ex.getMessage( ) );
+ }
}
+
+ return getPageOne( data );
+ }
+ else
+ {
+ return new StringElement("Please login first");
}
- return getPageOne( data );
}
- else
+ catch (Exception e)
{
- return new H1( "Please login first" );
- }
- }
+ Log.error("Customizer exception ",e);
+ return new StringElement(e.toString());
+ }
+ }
+
/**
* getPageOne( ) generates the first page.
* To pass the generated data to the JSP
@@ -288,16 +296,6 @@
}
// now sort the array
-/* sun.misc.Sort.quicksort( portletDataBeans, new sun.misc.Compare( )
- {
- public int doCompare( Object first, Object second )
- {
- PortletDataBean firstBean = ( PortletDataBean ) first;
- PortletDataBean secondBean = ( PortletDataBean ) second;
- return firstBean.getTitle( ).compareTo( secondBean.getTitle( ) );
- }
- });
-*/
sun.misc.Sort.quicksort( portletDataBeans, new PortletDataBeanCompare());
bean.setHomeURL( homeURL ) ;
bean.setPage2URL( page2URL ) ;
@@ -434,9 +432,36 @@
if ( rightEntry != null )
right.addEntry( rightEntry ) ;
}
+
+ Profile profile = null;
+
+ try
+ {
+ profile = Profiler.getProfile( data, mime );
+ }
+ catch (Exception e)
+ {
+ String username = data.getUser().getUserName();
+ try
+ {
+ Profiler.createUserProfile( data, username, mime );
+ profile = Profiler.getProfile( data, mime );
+ }
+ catch (Exception e2)
+ {
+ Log.error("Error creating default profile for mime
"+mime,e2);
+ }
+ }
- PSMLManager.setPSMLContent( data, MimeType.HTML, psmlFile );
- Log.note( "HTML file successfully written... " );
+ try
+ {
+ profile.getDocument().setPortlets( psmlFile );
+ profile.store();
+ }
+ catch (Exception e)
+ {
+ Log.error("Error saving PSML file",e);
+ }
}
}
@@ -771,5 +796,19 @@
return false;
}
+ public boolean allowCustomize(RunData data)
+ {
+ return false;
+ }
+
+ public boolean allowMinimize(RunData data)
+ {
+ return false;
+ }
+
+ public boolean allowClose(RunData data)
+ {
+ return false;
+ }
}
1.5 +2 -9
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/ServiceFactory.java
Index: ServiceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/ServiceFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServiceFactory.java 2001/05/21 02:03:49 1.4
+++ ServiceFactory.java 2001/06/09 15:42:46 1.5
@@ -55,7 +55,6 @@
package org.apache.jetspeed.portal.service;
import org.apache.turbine.util.RunData;
-import org.apache.jetspeed.services.resources.JetspeedResources;
/**
** The <TT>ServiceFactory</TT> class is a singleton that allows to instantiate
@@ -119,10 +118,7 @@
if (aServiceInterface == PersistenceService.class)
{
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
- service = new JetspeedPersistenceService ();
- else
- service = new PersistenceServiceImpl ();
+ service = new JetspeedPersistenceService ();
}
if (service != null)
@@ -139,10 +135,7 @@
if (aServiceInterface == PersistenceService.class)
{
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
- service = new JetspeedPersistenceService ();
- else
- service = new PersistenceServiceImpl ();
+ service = new JetspeedPersistenceService ();
}
if (service != null)
1.10 +48 -133
jakarta-jetspeed/src/java/org/apache/jetspeed/util/PSMLManager.java
Index: PSMLManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/PSMLManager.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PSMLManager.java 2001/06/04 17:47:13 1.9
+++ PSMLManager.java 2001/06/09 15:42:47 1.10
@@ -61,20 +61,21 @@
* @author <a href="mailto:[EMAIL PROTECTED]">David S. Faller</a>
*/
-import org.apache.jetspeed.cache.disk.*;
-import org.apache.jetspeed.om.profile.*;
-import org.apache.jetspeed.services.profiler.*;
-
-import org.apache.jetspeed.portal.*;
-import org.apache.jetspeed.services.PsmlManager;
-import org.apache.jetspeed.services.PortalToolkit;
-import org.apache.jetspeed.profiler.*;
-import org.apache.jetspeed.util.*;
-import org.apache.jetspeed.xml.api.portletmarkup.*;
-import org.apache.turbine.util.*;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.Profiler;
-import org.apache.jetspeed.om.profile.*;
+import org.apache.jetspeed.services.PsmlManager;
+import org.apache.jetspeed.services.PortalToolkit;
+import org.apache.jetspeed.services.Registry;
+import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.om.profile.ProfileException;
+import org.apache.jetspeed.om.profile.PSMLDocument;
+import org.apache.jetspeed.om.profile.BasePSMLDocument;
+import org.apache.jetspeed.om.newregistry.MediaTypeEntry;
+import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
+import org.apache.jetspeed.xml.api.portletmarkup.Entry;
+
+import org.apache.turbine.util.RunData;
+import org.apache.turbine.util.Log;
import java.io.*;
import java.util.*;
@@ -86,16 +87,11 @@
public class PSMLManager
{
- // The UserProfiler that handles conversions by MimeTypes
- private static MultiDeviceUserProfiler profiler = null;
-
/** the output format for pretty printing when saving PSML */
private static OutputFormat format = null;
static
{
- profiler = new MultiDeviceUserProfiler();
-
// create the serializer output format
format = new OutputFormat();
format.setIndenting(true);
@@ -117,35 +113,14 @@
Log.error("PSMLManager: Mime-Type must not be NULL!");
return null;
}
- MimeType[] types = getSupportedMimeTypes();
- boolean found = false;
- for (int i = 0; i < types.length; i++)
- {
- if (mimetype.equals(types[i]))
- found = true;
- }
- if (!found)
- {
- Log.error("PSMLManager: Must specify a valid Mime-Type!");
- return null;
- }
-
+
// Get the URL to the appopriate PSML file
- String url = null;
+ Profile profile = null;
try
{
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
- {
- Profile profile = Profiler.getProfile( data, mimetype );
- url = profile.getURL();
- }
- else
- url = profiler.getUserURL(username, mimetype);
-
- // Test if the PSML file exists
- DiskCacheEntry pde = JetspeedDiskCache.getInstance().getEntry( url );
+ profile = Profiler.getProfile( data, mimetype );
- if ( pde.getData() == null && ! pde.isLocal() )
+ if ( profile.getDocument().getPortlets() == null )
{
throw new Exception();
}
@@ -153,40 +128,27 @@
catch (Exception e)
{
Log.note("Profiled URL doesn't exist, using default");
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
+
+ try
{
- try
- {
- Profile profile = Profiler.getProfile( null, mimetype );
- url = profile.getURL();
- }
- catch (ProfileException ex)
- {} // url will be null
+ profile = Profiler.getProfile( null, mimetype );
}
- else
- url = profiler.getUserURL(null, mimetype);
+ catch (ProfileException ex)
+ {} // url will be null
}
- if (url == null)
+ Portlets portlets = profile.getDocument().getPortlets();
+
+ if (portlets == null)
{
Log.error("PSMLManager: Could not resolve URL of user's PSML file!");
return null;
}
- Log.note("PSMLManager: Reading "+username+"'s PSML for
"+mimetype.toString()+" from "+url);
-
- Portlets portlets = PsmlManager.getDocument(url).getPortlets();
+ Log.note("PSMLManager: Reading "+username+"'s PSML for
"+mimetype.toString()+" from "+profile.getURL());
return portlets;
}
- /**
- * Get the MimeTypes that are supported
- * @return org.apache.jetspeed.util.MimeType[] the supported MimeTypes
- */
- public static MimeType[] getSupportedMimeTypes()
- {
- return profiler.getSupportedMimeTypes();
- }
/**
* Insert the method's description here.
@@ -205,20 +167,6 @@
return false;
}
- MimeType[] types = getSupportedMimeTypes();
- boolean found = false;
- for (int i = 0; i < types.length; i++)
- {
- if (mimetype.equals(types[i]))
- found = true;
- }
-
- if (!found)
- {
- Log.error("PSMLManager: Must specify a valid Mime-Type!");
- return false;
- }
-
// Verify the username is specified
if ((username == null) || (portlets == null))
{
@@ -226,40 +174,32 @@
return false;
}
- String url ;
+ Profile profile = null;
+
try
{
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
- {
- try {
- Profile profile = Profiler.getProfile( data, mimetype );
- url = profile.getURL();
- }
- catch (Exception e)
- {
- // the profile didn't exist - create a specific profile for
this mimetype
- Profiler.createUserProfile( data, username, mimetype );
- Profile profile = Profiler.getProfile( data, mimetype );
- url = profile.getURL();
- }
- }
- else
- url = profiler.getUserURL(username, mimetype);
- if (url == null)
+ try
+ {
+ profile = Profiler.getProfile( data, mimetype );
+ }
+ catch (Exception e)
{
+ // the profile didn't exist - create a specific profile for this
mimetype
+ Profiler.createUserProfile( data, username, mimetype );
+ profile = Profiler.getProfile( data, mimetype );
+ }
+
+ if (profile.getURL() == null)
+ {
Log.error("PSMLManager: Could not resolve URL of user's PSML
file!");
return false;
}
-
- Log.note("PSMLManager: Writing "+username+"'s PSML for
'"+mimetype.toString()+"' to '"+url+"'");
+ Log.note("PSMLManager: Writing "+username+"'s PSML for
'"+mimetype.toString()+"' to '"+profile.getURL()+"'");
- DiskCacheEntry pde = JetspeedDiskCache.getInstance().getEntry( url );
- java.io.Writer out = pde.getWriter();
- portlets.marshal(out);
- out.flush();
- out.close();
-
+ profile.getDocument().setPortlets(portlets);
+ profile.store();
+
return true;
}
catch (Exception e)
@@ -278,36 +218,11 @@
*/
public static boolean setPSMLContent(RunData data, String url, Portlets
portlets)
{
-
- String username = data.getUser().getUserName();
+ PSMLDocument doc = new BasePSMLDocument();
+ doc.setName(url);
+ doc.setPortlets(portlets);
- // Verify the username is specified
- if ((username == null) || (portlets == null))
- {
- Log.error("PSMLManager: Must specify a username and a Portlets
object!");
- return false;
- }
-
- Log.note("PSMLManager: Writing "+username+"'s PSML for to '"+url+"'");
-
- try
- {
- DiskCacheEntry pde = JetspeedDiskCache.getInstance().getEntry( url );
- java.io.Writer out = pde.getWriter();
-
- Serializer serializer = new XMLSerializer(out, format);
- portlets.marshal(serializer.asDocumentHandler());
- out.flush();
- out.close();
-
- return true;
- }
- catch (Exception e)
- {
- Log.error("PSMLManager: Error writing PSML", e);
- }
-
- return false;
+ return PsmlManager.saveDocument(doc);
}
}
1.4 +90 -145
jakarta-jetspeed/src/java/org/apache/jetspeed/util/customization/PSMLDocument.java
Index: PSMLDocument.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/customization/PSMLDocument.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PSMLDocument.java 2001/06/04 17:47:15 1.3
+++ PSMLDocument.java 2001/06/09 15:42:47 1.4
@@ -57,33 +57,22 @@
// Basic Java stuff
import java.io.*;
-import org.apache.turbine.util.RunData;
import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
import org.apache.jetspeed.xml.api.portletmarkup.Entry;
-
-// For portlets marshalling.
-import org.apache.jetspeed.services.resources.JetspeedResources;
-import org.apache.jetspeed.cache.disk.DiskCacheEntry;
-import org.apache.jetspeed.cache.disk.JetspeedDiskCache;
-import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.xml.api.portletmarkup.Skin;
import org.apache.jetspeed.xml.api.portletmarkup.Property;
import org.apache.jetspeed.xml.api.portletmarkup.Layout;
+
import org.apache.jetspeed.util.PSMLManager;
import org.apache.jetspeed.util.MimeType;
-import org.apache.jetspeed.profiler.*;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.om.profile.*;
-
// Turbine
import org.apache.turbine.om.security.User;
+import org.apache.turbine.util.RunData;
import org.apache.turbine.util.Log;
-// Castor
-import org.exolab.castor.xml.ValidationException;
-import org.exolab.castor.xml.MarshalException;
-
/**
*
* PSMLDocument is a class that represents the psml document itself. This class
@@ -93,164 +82,92 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Yoo </a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ernest Ros </a>
- * @version $Id: PSMLDocument.java,v 1.3 2001/06/04 17:47:15 raphael Exp $
+ * @version $Id: PSMLDocument.java,v 1.4 2001/06/09 15:42:47 raphael Exp $
*
*/
public class PSMLDocument
{
-
- private JetspeedColors jColors;
- private RunData rundata;
- private Portlets portlets;
- private DiskCacheEntry diskEntry;
- private String psmlFileName;
- private String psmlFilePath;
-
-
- // The UserProfiler that handles conversions by MimeTypes
- private static MultiDeviceUserProfiler profiler = null;
-
- static
- {
- profiler = new MultiDeviceUserProfiler();
- }
- /**
- * The constructor extracts the Jetspeed configuration information to locate
- * the psml file to be read. The Porlets class then unmarshals the file.
- */
- public PSMLDocument(RunData rdata) throws CustomizerException,
- FileNotFoundException, UserNotLoggedInException
- {
+ private JetspeedColors jColors;
+ private RunData rundata;
+ private Portlets portlets;
+ private String psmlFileName;
+ private String psmlFilePath;
+
+ /**
+ * The constructor extracts the Jetspeed configuration information to locate
+ * the psml file to be read. The Porlets class then unmarshals the file.
+ */
+ public PSMLDocument(RunData rdata) throws
UserNotLoggedInException,CustomizerException
+ {
+ // Create a JetspeedColors object.
+ this.jColors = new JetspeedColors();
- // Create a JetspeedColors object.
- this.jColors = new JetspeedColors();
+ // Set rundata
+ this.rundata = rdata;
- // Set the default file name in case it is needed.
- String defaultFileName =
JetspeedResources.getString(JetspeedResources.PSML_DEFAULT_USER_KEY)
- + ".psml";
+ // Determine the name of this user's psml file.
+ User theUser = this.rundata.getUser();
- // Set rundata
- this.rundata = rdata;
-
- // Determine the name of this user's psml file.
- User theUser = this.rundata.getUser();
- if (theUser.hasLoggedIn())
- {
- this.psmlFileName = theUser.getUserName() + ".psml";
- }
- else
- throw new UserNotLoggedInException("The user must log in before attempting
to" +
- " customize preferences.");
- // end if-else
-
- // Set the location of the psml files.
- this.psmlFilePath =
JetspeedResources.getString(JetspeedResources.PSML_BASE_URL_KEY);
-
- MimeType mimetype = new MimeType("text/html");
+ if (!theUser.hasLoggedIn())
+ {
+ throw new UserNotLoggedInException("The user must log in before
attempting to"
+ + " customize preferences.");
+ }
- String psmlURL = "";
- if (JetspeedResources.getBoolean("services.Profiler.enable", false))
- {
- try {
- Profile profile = Profiler.getProfile( rundata, mimetype );
- psmlURL = profile.getURL();
+ Profile profile = null;
+ try
+ {
+ profile = Profiler.getProfile( rundata, MimeType.HTML );
}
catch (Exception e)
{
Log.note("Profiled URL doesn't exist, using default");
- try {
- Profile profile = Profiler.getProfile( null, mimetype );
- psmlURL = profile.getURL();
+ try
+ {
+ profile = Profiler.getProfile( null, MimeType.HTML );
}
catch (ProfileException ex)
- {} // url will be null
+ {} // url will be null
}
- }
- else
- psmlURL = profiler.getUserURL( rundata.getUser().getUserName(),
mimetype.HTML );
- try
- {
-
- DiskCacheEntry pde = JetspeedDiskCache.getInstance().getEntry( psmlURL );
- Reader theReader;
-
- try
- {
+ this.portlets = profile.getDocument().getPortlets();
- // Open the user's psml file.
- theReader = pde.getReader();
+ }// end constructor
- }
- catch (FileNotFoundException fnfe)
- {
+ /**
+ * getEntry finds the Entry object in the portlets object with the name
+ * given. getEntry then packages the entry into a PSMLEntry object so it can
+ * include the positioning information for the indicated Entry.
+ */
+ public PSMLEntry getPSMLEntry(String portletName) throws
ElementNotFoundException
+ {
+ return this.find(portletName, this.portlets);
+ }// end PSMLEntry()
- pde = JetspeedDiskCache.getInstance().getEntry( this.psmlFilePath +
defaultFileName );
- theReader = pde.getReader();
+ /**
+ * addPSMLEntry adds an entry to the portlets object indicated by the
+ * coordinates of the PSMLEntry object passed in.
+ */
+ public void addPSMLEntry(PSMLEntry theEntry) throws CustomizerException
+ {
- }// end try-catch
+ Portlets thePortlets = null;
try
{
-
- // Unmarshal the PSML file and build the portlets object.
- this.portlets = Portlets.unmarshal(theReader);
-
- }
- catch (ValidationException ve)
- {
-
- throw new CustomizerException("The psml file is invalid.");
-
+ // Get the "parent" portlets object.
+ thePortlets = this.getPortletsObject(theEntry.getCoordinates());
}
- catch (MarshalException me)
+ catch (ElementNotFoundException enf)
{
-
- throw new CustomizerException("An error occurred while reading the psml "
- + "file.");
- }
-
- }
- catch (Exception e)
- {
- Log.error("PSMLDocument: Error reading PSML", e);
- }
-
- }// end constructor
-
- /**
- * getEntry finds the Entry object in the portlets object with the name
- * given. getEntry then packages the entry into a PSMLEntry object so it can
- * include the positioning information for the indicated Entry.
- */
- public PSMLEntry getPSMLEntry(String portletName) throws ElementNotFoundException
- {
- return this.find(portletName, this.portlets);
- }// end PSMLEntry()
-
- /**
- * addPSMLEntry adds an entry to the portlets object indicated by the
- * coordinates of the PSMLEntry object passed in.
- */
- public void addPSMLEntry(PSMLEntry theEntry) throws CustomizerException
- {
- Portlets thePortlets = null;
-
- try
- {
- // Get the "parent" portlets object.
- thePortlets = this.getPortletsObject(theEntry.getCoordinates());
- }
- catch (ElementNotFoundException enf)
- {
- enf.printStackTrace();
- throw new CustomizerException("The coordinates of the entry are invalid.");
- }// end try-catch
+ enf.printStackTrace();
+ throw new CustomizerException("The coordinates of the entry are
invalid.");
+ }// end try-catch
- // Add the new Entry.
- thePortlets.addEntry(theEntry.getEntry());
- }// end addPSMLEntry
+ // Add the new Entry.
+ thePortlets.addEntry(theEntry.getEntry());
+ }// end addPSMLEntry
/**
* setPSMLEntry re-sets an existing entry in the portlets object indicated by
@@ -400,7 +317,35 @@
{
MimeType mimetype = new MimeType ( "text/html" );
- PSMLManager.setPSMLContent ( rundata, mimetype.HTML, this.portlets );
+ Profile profile = null;
+
+ try
+ {
+ Profiler.getProfile( rundata, mimetype );
+ }
+ catch (Exception e)
+ {
+ String username = rundata.getUser().getUserName();
+ try
+ {
+ Profiler.createUserProfile( rundata, username, mimetype );
+ profile = Profiler.getProfile( rundata, mimetype );
+ }
+ catch (Exception e2)
+ {
+ Log.error("Error creating default profile for type "+mimetype,e2);
+ }
+ }
+
+ try
+ {
+ profile.getDocument().setPortlets( this.portlets );
+ profile.store();
+ }
+ catch (Exception e)
+ {
+ Log.error("Error writing PSML file",e);
+ }
}// end writePSMLDocument()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]