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/services/profiler JetspeedProfilerService.java TestProfilerService.java
Date Fri, 08 Nov 2002 10:04:13 GMT
raphael     2002/11/08 02:04:13

  Modified:    src/java/org/apache/jetspeed/services/profiler
                        JetspeedProfilerService.java
                        TestProfilerService.java
  Log:
  Add factory-like methods in Profiler interface to create new Profile and ProfileLocator
  instances
  Use new media-type methods in CapabilityMap
  
  Revision  Changes    Path
  1.40      +46 -16    jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java
  
  Index: JetspeedProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- JetspeedProfilerService.java	3 Nov 2002 15:11:35 -0000	1.39
  +++ JetspeedProfilerService.java	8 Nov 2002 10:04:12 -0000	1.40
  @@ -437,7 +437,7 @@
                   }
   
                   // Create a new profile for the user
  -                ProfileLocator locator = new BaseProfileLocator();
  +                ProfileLocator locator = createLocator();
                   locator.setUser((JetspeedUser) data.getUser());
                   locator.setMediaType(mediaType);
                   locator.setName(this.resourceDefault + this.resourceExt);
  @@ -494,7 +494,7 @@
           try
           {
               JetspeedRunData rundata = (JetspeedRunData)data;
  -            Profile profile = new BaseProfile();
  +            Profile profile = createProfile();
               JetspeedUser user = rundata.getJetspeedUser();
   
               // get the media type from the capability map or rundata
  @@ -630,7 +630,7 @@
           throws ProfileException
       {
           PSMLDocument doc =  fallback(locator);
  -        BaseProfile profile = new BaseProfile(locator);
  +        Profile profile = createProfile(locator);
           profile.setDocument(doc);
           return profile;
       }
  @@ -763,8 +763,8 @@
       {
           if (Log.getLogger().isDebugEnabled())
           {
  -                Log.debug( "Profiler: fallback called with: " + locator );
  -                }
  +            Log.debug( "Profiler: fallback called with: " + locator );
  +        }
   
           PSMLDocument doc = PsmlManager.getDocument( locator );
           if (null != doc)
  @@ -849,17 +849,14 @@
                   return paramMediaType;
           }
   
  -        MediaTypeRegistry mregistry = (MediaTypeRegistry)Registry.get(Registry.MEDIA_TYPE);
  -        Iterator i = mregistry.findForCapability(cm);
  +        String media = cm.getPreferredMediaType();
   
  -        if (null != i)
  +        if (media == null)
           {
  -            if (i.hasNext())
  -            {
  -                return  ((MediaTypeEntry)i.next()).getName();
  -            }
  +            media = "";
           }
  -        return "";
  +
  +        return media;
       }
   
       /**
  @@ -973,6 +970,39 @@
       }
   
       /**
  +     * Creates a new Profile object that can be successfully managed by
  +     * the current Profiler implementation
  +     *
  +     * @return A new Profile object
  +     */
  +    public Profile createProfile()
  +    {
  +        return new BaseProfile();
  +    }
  +
  +    /**
  +     * Creates a new Profile object for a specific locator.
  +     *
  +     * @param locator The description of the profile.
  +     * @return A new Profile object
  +     */
  +    public Profile createProfile(ProfileLocator locator)
  +    {
  +        return new BaseProfile(locator);
  +    }
  +
  +    /**
  +     * Creates a new ProfileLocator object that can be successfully managed by
  +     * the current Profiler implementation
  +     *
  +     * @return A new ProfileLocator object
  +     */
  +    public ProfileLocator createLocator()
  +    {
  +        return new BaseProfileLocator();
  +    }
  +
  +    /**
        * Create a new profile given a profile locator
        *
        * @param locator The description of the new profile to be created.
  @@ -986,7 +1016,7 @@
           {
               portlets = new PsmlPortlets();
           }
  -        Profile profile = new BaseProfile(locator);
  +        Profile profile = createProfile(locator);
           PSMLDocument doc = new BasePSMLDocument(null, portlets);
           profile.setDocument(doc);
           doc = PsmlManager.createDocument(profile);
  @@ -1030,7 +1060,7 @@
   
               try
               {
  -                ProfileLocator locator = new BaseProfileLocator();
  +                ProfileLocator locator = createLocator();
                   locator.setUser( JetspeedSecurity.getUser(from) );
   
                   locator.setMediaType(contentType);
  
  
  
  1.3       +9 -9      jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/TestProfilerService.java
  
  Index: TestProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/TestProfilerService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestProfilerService.java	15 Oct 2002 17:35:32 -0000	1.2
  +++ TestProfilerService.java	8 Nov 2002 10:04:13 -0000	1.3
  @@ -78,7 +78,7 @@
    * @version $Id$
    */
   
  -public class TestProfilerService extends TestCase {    
  +public class TestProfilerService extends TestCase {
   
       /**
        * Defines the testcase name for JUnit.
  @@ -88,7 +88,7 @@
       public TestProfilerService( String name ) {
           super( name );
       }
  -    
  +
       /**
        * Start the tests.
        *
  @@ -97,7 +97,7 @@
       public static void main(String args[]) {
           junit.awtui.TestRunner.main( new String[] { TestProfilerService.class.getName()
} );
       }
  - 
  +
       public void setup() {
           System.out.println("Setup: Testing categories of Profiler Service");
        }
  @@ -116,11 +116,11 @@
        * Tests categories
        * @throws Exception
        */
  -    public void testCreateProfile() throws Exception 
  +    public void testCreateProfile() throws Exception
       {
           try
           {
  -            ProfileLocator locator = new BaseProfileLocator();
  +            ProfileLocator locator = Profiler.createLocator();
               locator.setGroupByName("apache");
               locator.setName("create-test");
   
  @@ -139,7 +139,7 @@
               // this only works with the default configuration (Castor/Filebased)
               File file = new File(doc.getName());
               assertTrue(file.exists());
  -            //file.delete();            
  +            //file.delete();
           }
           catch (Exception e)
           {
  @@ -154,8 +154,8 @@
         ( uses turbine.properties )
       */
       private static TurbineConfig config = null;
  -    
  -    /*    
  +
  +    /*
         Sets up TurbineConfig using the system property:
         <pre>turbine.properties</pre>
       */
  
  
  

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


Mime
View raw message