Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@www.apache.org Received: (qmail 38585 invoked from network); 8 Oct 2004 21:45:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Oct 2004 21:45:58 -0000 Received: (qmail 30166 invoked by uid 500); 8 Oct 2004 21:45:56 -0000 Delivered-To: apmail-jakarta-jetspeed-dev-archive@jakarta.apache.org Received: (qmail 30089 invoked by uid 500); 8 Oct 2004 21:45:55 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jetspeed Developers List" Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 30072 invoked by uid 500); 8 Oct 2004 21:45:55 -0000 Received: (qmail 30068 invoked by uid 500); 8 Oct 2004 21:45:54 -0000 Received: (qmail 30065 invoked by uid 99); 8 Oct 2004 21:45:54 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,CASHCASHCASH,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 08 Oct 2004 14:45:54 -0700 Received: (qmail 38534 invoked by uid 1265); 8 Oct 2004 21:45:53 -0000 Date: 8 Oct 2004 21:45:53 -0000 Message-ID: <20041008214553.38533.qmail@minotaur.apache.org> From: taylor@apache.org To: jakarta-jetspeed-2-cvs@apache.org Subject: cvs commit: jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl JetspeedProfiler.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N taylor 2004/10/08 14:45:53 Modified: components/profiler/src/test/org/apache/jetspeed/profiler TestProfiler.java components/profiler/src/java/org/apache/jetspeed/profiler/impl JetspeedProfiler.java Log: added api getLocatorNamesForPrincipal Revision Changes Path 1.5 +12 -2 jakarta-jetspeed-2/components/profiler/src/test/org/apache/jetspeed/profiler/TestProfiler.java Index: TestProfiler.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/profiler/src/test/org/apache/jetspeed/profiler/TestProfiler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TestProfiler.java 8 Oct 2004 06:49:37 -0000 1.4 +++ TestProfiler.java 8 Oct 2004 21:45:53 -0000 1.5 @@ -361,5 +361,15 @@ System.out.println("locator = " + path); assertTrue("locator path: " + path, path.equals("path:/football/nfl/chiefs")); } - + + public void testGetLocatorNames() throws Exception + { + assertNotNull("profiler service is null", profiler); + String[] result = profiler.getLocatorNamesForPrincipal(new UserPrincipalImpl("guest")); + for (int ix = 0; ix < result.length; ix++) + { + System.out.println("$$$ result = " + result[ix]); + assertTrue("locator name = " + result[ix], result[ix].equals("page")); + } + } } 1.6 +32 -4 jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiler.java Index: JetspeedProfiler.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JetspeedProfiler.java 8 Oct 2004 06:49:38 -0000 1.5 +++ JetspeedProfiler.java 8 Oct 2004 21:45:53 -0000 1.6 @@ -18,6 +18,7 @@ import java.security.Principal; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Properties; @@ -231,9 +232,14 @@ // TODO: throw appropriate exception } persistentStore.getTransaction().commit(); - principalRules.put(principal.getName(), pr); + principalRules.put(makePrincipalRuleKey(principal.getName(), locatorName), pr); } + private String makePrincipalRuleKey(String principal, String locator) + { + return principal + ":" + locator; + } + /** * Helper function to lookup principal rule associations by principal * @@ -244,7 +250,7 @@ */ private PrincipalRule lookupPrincipalRule(String principal, String locatorName) { - PrincipalRule pr = (PrincipalRule) principalRules.get(principal); + PrincipalRule pr = (PrincipalRule) principalRules.get(makePrincipalRuleKey(principal, locatorName)); if (pr != null) { return pr; @@ -254,7 +260,7 @@ filter.addEqualTo("locatorName", locatorName); Object query = persistentStore.newQuery(principalRuleClass, filter); pr = (PrincipalRule) persistentStore.getObjectByQuery(query); - principalRules.put(principal, pr); + principalRules.put(makePrincipalRuleKey(principal, locatorName), pr); return pr; } @@ -349,4 +355,26 @@ return this.anonymousUser; } + public String[] getLocatorNamesForPrincipal(Principal principal) + { + Filter filter = persistentStore.newFilter(); + filter.addEqualTo("principalName", principal); + Object query = persistentStore.newQuery(principalRuleClass, filter); + Collection result = persistentStore.getCollectionByQuery(query); + if (result.size() == 0) + { + return new String[]{}; + } + String [] names = new String[result.size()]; + Iterator it = result.iterator(); + int ix = 0; + while (it.hasNext()) + { + PrincipalRule pr = (PrincipalRule)it.next(); + names[ix] = pr.getLocatorName(); + ix++; + } + return names; + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org