taylor 2003/11/28 13:51:51
Modified: portal maven.xml
portal/src/java/org/apache/jetspeed/profiler
ProfileLocator.java ProfilerService.java
portal/src/java/org/apache/jetspeed/profiler/impl
JetspeedProfilerService.java
portal/src/java/org/apache/jetspeed/profiler/rules
ProfilingRule.java RuleCriterion.java
portal/src/java/org/apache/jetspeed/profiler/rules/impl
AbstractProfilingRule.java RuleCriterionImpl.java
StandardProfilingRule.java
portal/src/sql/hsql create-db-phase2.sql drop-db.sql
populate-db-default.sql
portal/src/webapp/WEB-INF/conf jetspeed.properties
portal/src/webapp/WEB-INF/conf/ojb repository_page.xml
portal/src/webapp/WEB-INF/conf/test jetspeed.properties
portal/src/webapp/WEB-INF/db/hsql Registry.script
Added: portal/src/java/org/apache/jetspeed/profiler/impl
JetspeedProfileLocator.java
portal/src/test/org/apache/jetspeed/profiler
TestProfiler.java
Log:
- Start of unit tests for profiler, rules
- basic schema for Desktop/Page/PageGroup relationships
Revision Changes Path
1.13 +2 -2 jakarta-jetspeed-2/portal/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/maven.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- maven.xml 26 Nov 2003 04:52:41 -0000 1.12
+++ maven.xml 28 Nov 2003 21:51:50 -0000 1.13
@@ -4,8 +4,8 @@
xmlns:reactor="reactor">
<!-- Target of maven test:single test -->
-<!-- <property name='testcase'
value='org.apache.jetspeed.services.registry.TestRegistry'/> -->
- <property name='testcase' value='org.apache.jetspeed.test.PrefsTest'/>
+<!-- <property name='testcase'
value='org.apache.jetspeed.services.registry.TestRegistry'/> -->
+<property name='testcase' value='org.apache.jetspeed.profiler.TestProfiler'/>
<!--
1.2 +1 -166
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfileLocator.java
Index: ProfileLocator.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfileLocator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfileLocator.java 26 Nov 2003 04:52:41 -0000 1.1
+++ ProfileLocator.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -63,172 +63,7 @@
*/
public interface ProfileLocator extends Serializable, Cloneable
{
- /*
- * populates this profile locator from a given path in the format:
- *
- * user/<name>/media-type/<mediaType>/language/<language>
- * /country/<country>/<page>/page
- *
- * group/ ""
- * role/ ""
- *
- * @param path The formatted profiler path string.
- */
- public void createFromPath(String path);
- /*
- * Gets the unique profile locator id, which is a combination of the params
- * This ID must follow the one of the 4 sequences below:
- *
- * <username>/<mediaType>/<language>/<country>/<page>
- * <group>/<mediaType>/<language>/<country>/<page>
- * <role>/<mediaType>/<language>/<country>/<page>
- *
- * @return The profile locator id
- */
- public String getId();
-
- /*
- * Gets the unique profile locator path, which is a combination of the params
- * This Path must follow the one of the 4 sequences below:
- *
- * user/<name>/media-type/<mediaType>/language/<language>
- * /country/<country>/<page>/page
- *
- * group/ ""
- * role/ ""
- *
- * @return The profile locator path
- */
- public String getPath();
-
- String getParameter(String name);
-
- String setParameter(String name, String value);
-
- /*
- * Gets the resource name parameter for this profile.
- *
- * @return The resource name parameter for this profile.
- */
- String getName();
-
- /*
- * Sets the resource name parameter for this profile.
- *
- * @param name The resource name parameter for this profile.
- */
- void setName(String name);
-
- /*
- * Gets the media type parameter for this profile.
- * Media types are values such as html, wml, xml ...
- *
- * @return The media type parameter for this profile.
- */
- public String getMediaType();
-
- /*
- * Sets the media type parameter for this profile.
- * Media types are values such as html, wml, xml ...
- *
- * @param mediaType The media type parameter for this profile.
- */
- public void setMediaType(String mediaType);
-
- /*
- * Gets the language parameter for this profile.
- * Language values are ISO-639 standard language abbreviations
- * en, fr, de, ...
- *
- * @return The language parameter for this profile.
- */
- public String getLanguage();
-
- /*
- * Sets the language parameter for this profile.
- * Language values are ISO-639 standard language abbreviations
- * en, fr, de, ...
- *
- * @param language The language parameter for this profile.
- */
- public void setLanguage(String language);
-
- /*
- * Gets the country code parameter for this profile.
- * Country code values are ISO-3166 standard country code abbreviations.
- * GB, US, FR, CA, DE, ...
- *
- * @return The country code parameter for this profile.
- */
- public String getCountry();
-
- /*
- * Sets the country code parameter for this profile.
- * Country code values are ISO-3166 standard country code abbreviations.
- * GB, US, FR, CA, DE, ...
- *
- * @param country The country code parameter for this profile.
- */
- public void setCountry(String country);
-
- /*
- * Gets the user parameter for this profile.
- *
- * @return The user parameter for this profile.
- */
- public String getUser();
-
- /*
- * Sets the user parameter for this profile.
- *
- * @param user The user parameter for this profile.
- */
- public void setUser(String user);
-
- /*
- * Gets the anonymous user flag for this profile.
- *
- * @return True if this profile is anonymous.
- */
- public boolean getAnonymous();
-
- /*
- * Sets the user parameter as the anonymous user
- *
- * @param anonymous True indicates this is an anonymous user.
- */
- public void setAnonymous(boolean anonymous);
-
- /*
- * Gets the role parameter for this profile.
- *
- * @return The role parameter for this profile.
- */
- public String getRole();
-
- /*
- * Sets the role parameter for this profile.
- *
- * @param role The role parameter for this profile.
- */
- public void setRole( String role );
-
- /*
- * Gets the group parameter for this profile.
- *
- * @return The group parameter for this profile.
- */
- public String getGroup();
-
- /*
- * Sets the group parameter for this profile.
- *
- * @param group The group parameter for this profile.
- */
- public void setGroup( String group );
-
-
/**
* @see Object#clone
* @return an instance copy of this object
1.2 +9 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfilerService.java
Index: ProfilerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/ProfilerService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilerService.java 26 Nov 2003 04:52:41 -0000 1.1
+++ ProfilerService.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -54,6 +54,7 @@
package org.apache.jetspeed.profiler;
import java.security.Principal;
+import java.util.Collection;
import org.apache.jetspeed.cps.CommonService;
import org.apache.jetspeed.om.desktop.Desktop;
@@ -83,7 +84,7 @@
public interface ProfilerService extends CommonService
{
/** The name of this service */
- public String SERVICE_NAME = "Profiler";
+ public String SERVICE_NAME = "profiler";
/**
* Get the Profile object using the request parameters.
@@ -134,5 +135,10 @@
* @return The portal's default profiling rule.
*/
ProfilingRule getDefaultRule();
-
+
+ /**
+ * @return
+ */
+ Collection getRules();
+
}
1.2 +12 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfilerService.java
Index: JetspeedProfilerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfilerService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JetspeedProfilerService.java 26 Nov 2003 04:52:41 -0000 1.1
+++ JetspeedProfilerService.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -54,6 +54,7 @@
package org.apache.jetspeed.profiler.impl;
import java.security.Principal;
+import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -112,7 +113,7 @@
String pluginName =
getConfiguration().getString("persistence.plugin.name", "jetspeed");
plugin = ps.getPersistencePlugin(pluginName);
setInit(true);
- }
+ }
}
/* (non-Javadoc)
@@ -235,5 +236,14 @@
{
return (ProfileLocator)this.createObject(locatorClass);
}
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.ProfilerService#getRules()
+ */
+ public Collection getRules()
+ {
+ return plugin.getExtent(profilingRuleClass);
+ }
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfileLocator.java
Index: JetspeedProfileLocator.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.profiler.impl;
import org.apache.jetspeed.profiler.ProfileLocator;
/**
* ProfileLocatorImpl
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: JetspeedProfileLocator.java,v 1.1 2003/11/28 21:51:50 taylor Exp $
*/
public class JetspeedProfileLocator implements ProfileLocator
{
/**
* @see Object#clone
* @return an instance copy of this object
*/
public Object clone() throws java.lang.CloneNotSupportedException
{
return super.clone();
}
}
1.2 +3 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
Index: ProfilingRule.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilingRule.java 26 Nov 2003 04:52:41 -0000 1.1
+++ ProfilingRule.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -53,6 +53,7 @@
*/
package org.apache.jetspeed.profiler.rules;
+import java.util.Collection;
import java.util.SortedMap;
import org.apache.jetspeed.profiler.ProfileLocator;
@@ -123,7 +124,7 @@
*
* @return a sorted map of rule criteria.
*/
- SortedMap getRuleCriteria();
+ Collection getRuleCriteria();
/**
* Gets the unique identifier for this rule
1.2 +3 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java
Index: RuleCriterion.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RuleCriterion.java 26 Nov 2003 04:52:41 -0000 1.1
+++ RuleCriterion.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -122,13 +122,13 @@
*
* @return The rule's unique identifier
*/
- String getId();
+ String getRuleId();
/**
* Sets the unique rule identifier for the associated owner rule
*
* @param id The rule's unique identifier
*/
- void setId(String id);
+ void setRuleId(String ruleId);
}
1.2 +7 -5
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java
Index: AbstractProfilingRule.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/AbstractProfilingRule.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractProfilingRule.java 26 Nov 2003 04:52:42 -0000 1.1
+++ AbstractProfilingRule.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -53,8 +53,10 @@
*/
package org.apache.jetspeed.profiler.rules.impl;
+import java.util.Collection;
import java.util.SortedMap;
import java.util.TreeMap;
+import java.util.Vector;
import org.apache.jetspeed.profiler.ProfileLocator;
import org.apache.jetspeed.profiler.ProfilerService;
@@ -69,9 +71,9 @@
*/
public abstract class AbstractProfilingRule implements ProfilingRule
{
- private SortedMap criteria = new TreeMap();
- private String id;
- private String title;
+ protected Collection criteria = new Vector();
+ protected String id;
+ protected String title;
protected String ojbConcreteClass;
/* (non-Javadoc)
@@ -82,7 +84,7 @@
/* (non-Javadoc)
* @see org.apache.jetspeed.profiler.rules.ProfilingRule#getRuleCriterion()
*/
- public SortedMap getRuleCriteria()
+ public Collection getRuleCriteria()
{
return criteria;
}
1.2 +8 -7
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RuleCriterionImpl.java
Index: RuleCriterionImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/RuleCriterionImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RuleCriterionImpl.java 26 Nov 2003 04:52:42 -0000 1.1
+++ RuleCriterionImpl.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -64,6 +64,7 @@
public class RuleCriterionImpl implements RuleCriterion
{
private String id;
+ private String ruleId;
private String type;
private String name;
private String value;
@@ -102,19 +103,19 @@
}
/* (non-Javadoc)
- * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getId()
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getRuleId()
*/
- public String getId()
+ public String getRuleId()
{
- return id;
+ return ruleId;
}
/* (non-Javadoc)
- * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setId(java.lang.String)
+ * @see
org.apache.jetspeed.profiler.rules.RuleCriterion#setRuleId(java.lang.String)
*/
- public void setId(String id)
+ public void setRuleId(String ruleId)
{
- this.id = id;
+ this.ruleId = ruleId;
}
/* (non-Javadoc)
1.2 +2 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardProfilingRule.java
Index: StandardProfilingRule.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/rules/impl/StandardProfilingRule.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StandardProfilingRule.java 26 Nov 2003 04:52:42 -0000 1.1
+++ StandardProfilingRule.java 28 Nov 2003 21:51:50 -0000 1.2
@@ -77,7 +77,7 @@
*/
public ProfileLocator apply(RequestContext context, ProfilerService service)
{
- Iterator criteria = this.getRuleCriteria().values().iterator();
+ Iterator criteria = this.getRuleCriteria().iterator();
while (criteria.hasNext())
{
RuleCriterion criterion = (RuleCriterion)criteria.next();
1.5 +19 -0 jakarta-jetspeed-2/portal/src/sql/hsql/create-db-phase2.sql
Index: create-db-phase2.sql
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/sql/hsql/create-db-phase2.sql,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- create-db-phase2.sql 26 Nov 2003 04:52:42 -0000 1.4
+++ create-db-phase2.sql 28 Nov 2003 21:51:50 -0000 1.5
@@ -14,6 +14,24 @@
UNIQUE(DESKTOP_ID)
);
+-- associates a desktop with its top level pages
+CREATE TABLE DESKTOP_PAGES
+(
+ DESKTOP_ID VARCHAR(80) NOT NULL,
+ PAGE_ID VARCHAR(80) NOT NULL
+);
+
+CREATE INDEX IX_DESKTOP_PAGES_1 ON DESKTOP_PAGES (DESKTOP_ID, PAGE_ID);
+
+-- associates a page with its sub group pages
+CREATE TABLE SUB_PAGES
+(
+ PAGE_ID VARCHAR(80) NOT NULL,
+ SUB_PAGE_ID VARCHAR(80) NOT NULL
+);
+
+CREATE INDEX IX_SUB_PAGES_1 ON SUB_PAGES (PAGE_ID, SUB_PAGE_ID);
+
----------------------------------------------------------------------------
-- Page Definitions
----------------------------------------------------------------------------
@@ -100,6 +118,7 @@
CREATE TABLE RULE_CRITERION
(
+ CRITERION_ID VARCHAR(80) PRIMARY KEY,
RULE_ID VARCHAR(80) NOT NULL,
FALLBACK_ORDER INTEGER,
REQUEST_TYPE VARCHAR(40) NOT NULL,
1.7 +2 -0 jakarta-jetspeed-2/portal/src/sql/hsql/drop-db.sql
Index: drop-db.sql
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/sql/hsql/drop-db.sql,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- drop-db.sql 26 Nov 2003 04:52:42 -0000 1.6
+++ drop-db.sql 28 Nov 2003 21:51:50 -0000 1.7
@@ -41,6 +41,8 @@
DROP TABLE MEDIATYPE_TO_MIMETYPE IF EXISTS
DROP TABLE DESKTOP IF EXISTS
+DROP TABLE DESKTOP_PAGES IF EXISTS
+DROP TABLE SUB_PAGES IF EXISTS
DROP TABLE PAGE IF EXISTS
DROP TABLE FRAGMENT IF EXISTS
DROP TABLE PAGE_FRAGMENTS IF EXISTS
1.2 +10 -10 jakarta-jetspeed-2/portal/src/sql/hsql/populate-db-default.sql
Index: populate-db-default.sql
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/sql/hsql/populate-db-default.sql,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- populate-db-default.sql 26 Nov 2003 04:52:42 -0000 1.1
+++ populate-db-default.sql 28 Nov 2003 21:51:50 -0000 1.2
@@ -1,17 +1,17 @@
insert into PROFILING_RULE values ('j1',
'org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule',
'The default profiling rule following the Jetspeed-1 hard-coded profiler
fallback algorithm.');
-insert into RULE_CRITERION values ('j1', 0, 'request', 'name', 'default');
-insert into RULE_CRITERION values ('j1', 1, 'standard', 'user', null);
-insert into RULE_CRITERION values ('j1', 2, 'standard', 'mediatype', null);
-insert into RULE_CRITERION values ('j1', 3, 'standard', 'language', null);
-insert into RULE_CRITERION values ('j1', 4, 'standard', 'country', null);
+insert into RULE_CRITERION values (1, 'j1', 0, 'request', 'name', 'default');
+insert into RULE_CRITERION values (2, 'j1', 1, 'standard', 'user', null);
+insert into RULE_CRITERION values (3, 'j1', 2, 'standard', 'mediatype', null);
+insert into RULE_CRITERION values (4, 'j1', 3, 'standard', 'language', null);
+insert into RULE_CRITERION values (5, 'j1', 4, 'standard', 'country', null);
insert into PROFILING_RULE values ('role-fallback',
'org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule',
'A role based fallback algorithm based on Jetspeed-1 role-based fallback');
-insert into RULE_CRITERION values ('role-fallback', 0, 'request', 'name',
'default');
-insert into RULE_CRITERION values ('role-fallback', 1, 'standard', 'role-based',
null);
-insert into RULE_CRITERION values ('role-fallback', 2, 'standard', 'mediatype',
null);
-insert into RULE_CRITERION values ('role-fallback', 3, 'standard', 'language',
null);
-insert into RULE_CRITERION values ('role-fallback', 4, 'standard', 'country', null);
+insert into RULE_CRITERION values (6, 'role-fallback', 0, 'request', 'name',
'default');
+insert into RULE_CRITERION values (7, 'role-fallback', 1, 'standard', 'role-based',
null);
+insert into RULE_CRITERION values (8, 'role-fallback', 2, 'standard', 'mediatype',
null);
+insert into RULE_CRITERION values (9, 'role-fallback', 3, 'standard', 'language',
null);
+insert into RULE_CRITERION values (10, 'role-fallback', 4, 'standard', 'country',
null);
1.1
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/profiler/TestProfiler.java
Index: TestProfiler.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.profiler;
import java.util.Collection;
import java.util.Iterator;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.jetspeed.cps.CommonPortletServices;
import org.apache.jetspeed.profiler.rules.ProfilingRule;
import org.apache.jetspeed.profiler.rules.RuleCriterion;
import org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule;
import org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule;
import org.apache.jetspeed.test.JetspeedTest;
/**
* TestProfiler
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: TestProfiler.java,v 1.1 2003/11/28 21:51:50 taylor Exp $
*/
public class TestProfiler extends JetspeedTest
{
private ProfilerService service = null;
/**
* Defines the testcase name for JUnit.
*
* @param name the testcase's name.
*/
public TestProfiler(String name)
{
super(name);
}
/**
* Start the tests.
*
* @param args the arguments. Not used
*/
public static void main(String args[])
{
junit.awtui.TestRunner.main(new String[] { TestProfiler.class.getName()});
}
public void setup()
{
getService();
}
/**
* Creates the test suite.
*
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestProfiler.class);
}
protected ProfilerService getService()
{
if (service == null)
{
service = (ProfilerService)
CommonPortletServices.getPortalService(ProfilerService.SERVICE_NAME);
}
return service;
}
private static final String DEFAULT_RULE = "j1";
private static final String FALLBACK_RULE = "role-fallback";
private static final int EXPECTED_STANDARD = 1;
private static final int EXPECTED_FALLBACK = 1;
/**
* Tests
*
* @throws Exception
*/
public void testRules() throws Exception
{
service = getService();
assertNotNull("profiler service is null", service);
// Test Default Rule
ProfilingRule rule = service.getDefaultRule();
System.out.println("default rule = " + rule.getId());
assertNotNull("Default profiling rule is null", rule);
assertTrue("default rule unexpected, = " + rule.getId(),
rule.getId().equals(DEFAULT_RULE));
assertTrue("default rule class not mapped", rule instanceof
StandardProfilingRule);
// Test Retrieving All Rules
int standardCount = 0;
int fallbackCount = 0;
Iterator rules = service.getRules().iterator();
while (rules.hasNext())
{
rule = (ProfilingRule)rules.next();
if (rule.getId().equals(DEFAULT_RULE))
{
assertTrue("standard rule class not mapped", rule instanceof
StandardProfilingRule);
standardCount++;
}
else if (rule.getId().equals(FALLBACK_RULE))
{
assertTrue("role fallback rule class not mapped", rule instanceof
RoleFallbackProfilingRule);
fallbackCount++;
}
else
{
assertTrue("Unknown rule encountered: " + rule.getId(), false);
}
// criteria
Collection criteriaCollection = rule.getRuleCriteria();
assertNotNull("Criteria is null", criteriaCollection);
Iterator criteria = criteriaCollection.iterator();
while (criteria.hasNext())
{
RuleCriterion criterion = (RuleCriterion)criteria.next();
System.out.println("criteria = " +
criterion.getRuleId() + " - " +
criterion.getName());
}
}
assertTrue("didnt find expected number of standard rules, expected = " +
EXPECTED_STANDARD, standardCount == 1);
assertTrue("didnt find expected number of fallback rules, expected = " +
EXPECTED_FALLBACK, fallbackCount == 1);
}
}
1.11 +1 -4
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties
Index: jetspeed.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- jetspeed.properties 26 Nov 2003 04:52:42 -0000 1.10
+++ jetspeed.properties 28 Nov 2003 21:51:50 -0000 1.11
@@ -129,9 +129,6 @@
services.PersistenceService.path.resolver.class=org.apache.jetspeed.util.JetspeedPathResloverImpl
services.PersistenceService.earlyInit = true
-
-
-
# -------------------------------------------------------------------
# R E G I S T R Y
# -------------------------------------------------------------------
1.4 +17 -13
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/ojb/repository_page.xml
Index: repository_page.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/ojb/repository_page.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- repository_page.xml 26 Nov 2003 04:52:42 -0000 1.3
+++ repository_page.xml 28 Nov 2003 21:51:51 -0000 1.4
@@ -30,12 +30,11 @@
jdbc-type="VARCHAR"
/>
<collection-descriptor
- name="criterion"
- element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl"
- indirection-table="RULE_CRITERION">
- <fk-pointing-to-this-class column="RULE_ID"/>
- <fk-pointing-to-element-class column="CRITERION_ID"/>
- </collection-descriptor>
+ name="criteria"
+
element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl"
+ >
+ <inverse-foreignkey field-ref="ruleId"/>
+ </collection-descriptor>
</class-descriptor>
@@ -61,13 +60,11 @@
jdbc-type="VARCHAR"
/>
<collection-descriptor
- name="criterion"
- element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl"
- indirection-table="RULE_CRITERION">
- <fk-pointing-to-this-class column="RULE_ID"/>
- <fk-pointing-to-element-class column="CRITERION_ID"/>
- </collection-descriptor>
-
+ name="criteria"
+
element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl"
+ >
+ <inverse-foreignkey field-ref="ruleId"/>
+ </collection-descriptor>
</class-descriptor>
<!--
@@ -80,6 +77,13 @@
>
<field-descriptor
name="id"
+ column="CRITERION_ID"
+ jdbc-type="VARCHAR"
+ primarykey="true"
+ autoincrement="true"
+ />
+ <field-descriptor
+ name="ruleId"
column="RULE_ID"
jdbc-type="VARCHAR"
/>
1.7 +7 -1
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/test/jetspeed.properties
Index: jetspeed.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/test/jetspeed.properties,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- jetspeed.properties 20 Nov 2003 19:02:24 -0000 1.6
+++ jetspeed.properties 28 Nov 2003 21:51:51 -0000 1.7
@@ -50,3 +50,9 @@
services.DBPageManager.fragment.impl = org.apache.jetspeed.om.page.psml.FragmentImpl
services.DBPageManager.page.impl = org.apache.jetspeed.om.page.psml.PageImpl
services.DBPageManager.property.impl = org.apache.jetspeed.om.page.psml.PropertyImpl
+
+# -------------------------------------------------------------------
+# Profiler
+# -------------------------------------------------------------------
+services.profiler.persistence.plugin.name=jetspeed-test
+
1.9 +15 -11
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/db/hsql/Registry.script
Index: Registry.script
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/db/hsql/Registry.script,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Registry.script 26 Nov 2003 04:52:42 -0000 1.8
+++ Registry.script 28 Nov 2003 21:51:51 -0000 1.9
@@ -28,6 +28,10 @@
CREATE TABLE MEDIATYPE_TO_CAPABILITY(MEDIATYPE_ID INTEGER NOT NULL,CAPABILITY_ID
INTEGER NOT NULL)
CREATE TABLE MEDIATYPE_TO_MIMETYPE(MEDIATYPE_ID INTEGER NOT NULL,MIMETYPE_ID
INTEGER NOT NULL)
CREATE TABLE DESKTOP(DESKTOP_ID VARCHAR(80) NOT NULL PRIMARY KEY,TITLE
VARCHAR(100),COMPONENT_NAME VARCHAR(100),ACL VARCHAR(80),DEFAULT_PAGE_ID
VARCHAR(80),DEFAULT_THEME VARCHAR(100),DEFAULT_DECORATOR
VARCHAR(100),DEFAULT_PORTLET_DECORATOR VARCHAR(100),CONSTRAINT SYS_CT_1
UNIQUE(DESKTOP_ID))
+CREATE TABLE DESKTOP_PAGES(DESKTOP_ID VARCHAR(80) NOT NULL,PAGE_ID VARCHAR(80) NOT
NULL)
+CREATE INDEX IX_DESKTOP_PAGES_1 ON DESKTOP_PAGES(DESKTOP_ID,PAGE_ID)
+CREATE TABLE SUB_PAGES(PAGE_ID VARCHAR(80) NOT NULL,SUB_PAGE_ID VARCHAR(80) NOT
NULL)
+CREATE INDEX IX_SUB_PAGES_1 ON SUB_PAGES(PAGE_ID,SUB_PAGE_ID)
CREATE TABLE PAGE(PAGE_ID VARCHAR(80) NOT NULL PRIMARY KEY,TITLE
VARCHAR(100),DEFAULT_SKIN VARCHAR(100),DEFAULT_DECORATOR
VARCHAR(100),DEFAULT_PORTLET_DECORATOR VARCHAR(100),ACL VARCHAR(80),CONSTRAINT
SYS_CT_3 UNIQUE(PAGE_ID))
CREATE TABLE FRAGMENT(FRAGMENT_ID VARCHAR(80) NOT NULL PRIMARY KEY,COMPONENT_NAME
VARCHAR(100),ACL VARCHAR(80),TITLE VARCHAR(100),TYPE VARCHAR(40),SKIN
VARCHAR(80),DECORATOR VARCHAR(80),STATE VARCHAR(40))
CREATE TABLE PAGE_FRAGMENTS(PAGE_ID VARCHAR(80) NOT NULL,FRAGMENT_ID VARCHAR(80)
NOT NULL)
@@ -39,7 +43,7 @@
CREATE TABLE FRAGMENT_REF(FRAGMENT_REF_ID VARCHAR(80) NOT NULL PRIMARY
KEY,FRAGMENT_ID VARCHAR(80) NOT NULL,NAME VARCHAR(80) NOT NULL,TITLE VARCHAR(100))
CREATE TABLE FRAGMENT_REFS(FRAGMENT_REF_ID VARCHAR(80) NOT NULL,FRAGMENT_ID
VARCHAR(80) NOT NULL)
CREATE TABLE PROFILING_RULE(RULE_ID VARCHAR(80) NOT NULL PRIMARY KEY,CLASS_NAME
VARCHAR(100) NOT NULL,TITLE VARCHAR(100))
-CREATE TABLE RULE_CRITERION(RULE_ID VARCHAR(80) NOT NULL,FALLBACK_ORDER
INTEGER,REQUEST_TYPE VARCHAR(40) NOT NULL,NAME VARCHAR(80) NOT NULL,VALUE VARCHAR(128))
+CREATE TABLE RULE_CRITERION(CRITERION_ID VARCHAR(80) NOT NULL PRIMARY KEY,RULE_ID
VARCHAR(80) NOT NULL,FALLBACK_ORDER INTEGER,REQUEST_TYPE VARCHAR(40) NOT NULL,NAME
VARCHAR(80) NOT NULL,VALUE VARCHAR(128))
CREATE INDEX IX_RULE_CRITERION_1 ON RULE_CRITERION(RULE_ID,FALLBACK_ORDER)
CREATE TABLE PRINCIPAL_RULE_ASSOC(PRINCIPAL_NAME VARCHAR(80) NOT NULL,RULE_ID
VARCHAR(80) NOT NULL,CONSTRAINT SYS_CT_5 UNIQUE(PRINCIPAL_NAME))
CREATE TABLE PROFILE_DESKTOP_ASSOC(LOCATOR_HASH VARCHAR(40) NOT NULL,DESKTOP_ID
VARCHAR(80) NOT NULL)
@@ -119,13 +123,13 @@
CREATE ALIAS REPLACE FOR "org.hsqldb.Library.replace"
INSERT INTO PROFILING_RULE
VALUES('j1','org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule','The
default profiling rule following the Jetspeed-1 hard-coded profiler fallback
algorithm.')
INSERT INTO PROFILING_RULE
VALUES('role-fallback','org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule','A
role based fallback algorithm based on Jetspeed-1 role-based fallback')
-INSERT INTO RULE_CRITERION VALUES('j1',0,'request','name','default')
-INSERT INTO RULE_CRITERION VALUES('j1',1,'standard','user',NULL)
-INSERT INTO RULE_CRITERION VALUES('j1',2,'standard','mediatype',NULL)
-INSERT INTO RULE_CRITERION VALUES('j1',3,'standard','language',NULL)
-INSERT INTO RULE_CRITERION VALUES('j1',4,'standard','country',NULL)
-INSERT INTO RULE_CRITERION VALUES('role-fallback',0,'request','name','default')
-INSERT INTO RULE_CRITERION VALUES('role-fallback',1,'standard','role-based',NULL)
-INSERT INTO RULE_CRITERION VALUES('role-fallback',2,'standard','mediatype',NULL)
-INSERT INTO RULE_CRITERION VALUES('role-fallback',3,'standard','language',NULL)
-INSERT INTO RULE_CRITERION VALUES('role-fallback',4,'standard','country',NULL)
+INSERT INTO RULE_CRITERION VALUES('1','j1',0,'request','name','default')
+INSERT INTO RULE_CRITERION VALUES('10','role-fallback',4,'standard','country',NULL)
+INSERT INTO RULE_CRITERION VALUES('2','j1',1,'standard','user',NULL)
+INSERT INTO RULE_CRITERION VALUES('3','j1',2,'standard','mediatype',NULL)
+INSERT INTO RULE_CRITERION VALUES('4','j1',3,'standard','language',NULL)
+INSERT INTO RULE_CRITERION VALUES('5','j1',4,'standard','country',NULL)
+INSERT INTO RULE_CRITERION VALUES('6','role-fallback',0,'request','name','default')
+INSERT INTO RULE_CRITERION
VALUES('7','role-fallback',1,'standard','role-based',NULL)
+INSERT INTO RULE_CRITERION VALUES('8','role-fallback',2,'standard','mediatype',NULL)
+INSERT INTO RULE_CRITERION VALUES('9','role-fallback',3,'standard','language',NULL)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]