taylor 2004/10/21 11:41:04
Modified: components/profiler/src/java/org/apache/jetspeed/profiler/impl
JetspeedProfiler.java
Log:
impl of new apis for managing 1..n Principal Rules
Revision Changes Path
1.13 +47 -6
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JetspeedProfiler.java 21 Oct 2004 01:47:26 -0000 1.12
+++ JetspeedProfiler.java 21 Oct 2004 18:41:04 -0000 1.13
@@ -328,7 +328,6 @@
*/
public Collection getRules()
{
-
return persistentStore.getExtent(profilingRuleClass);
}
@@ -377,15 +376,25 @@
return names;
}
+ public Collection getRulesForPrincipal(Principal principal)
+ {
+ Filter filter = persistentStore.newFilter();
+ filter.addEqualTo("principalName", principal.getName());
+ Object query = persistentStore.newQuery(principalRuleClass, filter);
+ Collection result = persistentStore.getCollectionByQuery(query);
+ return result;
+ }
+
+
public Map getProfileLocators(RequestContext context, Principal principal)
throws ProfilerException
{
Map locators = new HashMap();
- String locatorNames[] = getLocatorNamesForPrincipal(principal);
-
- for (int ix = 0; (ix < locatorNames.length); ix++)
+ Iterator it = getRulesForPrincipal(principal).iterator();
+ while (it.hasNext())
{
- locators.put(locatorNames[ix], getProfile(context, locatorNames[ix]));
+ PrincipalRule pr = (PrincipalRule)it.next();
+ locators.put(pr.getLocatorName(), getProfile(context,
pr.getLocatorName()));
}
return locators;
}
@@ -425,4 +434,36 @@
}
+ public void storePrincipalRule(PrincipalRule rule)
+ throws ProfilerException
+ {
+ try
+ {
+ Transaction tx = persistentStore.getTransaction();
+ tx.begin();
+ persistentStore.makePersistent(rule);
+ persistentStore.lockForWrite(rule);
+ tx.commit();
+ }
+ catch (Exception e)
+ {
+ throw new ProfilerException("failed to store: " +
rule.getLocatorName(), e);
+ }
+ }
+
+ public void deletePrincipalRule(PrincipalRule rule)
+ throws ProfilerException
+ {
+ try
+ {
+ Transaction tx = persistentStore.getTransaction();
+ tx.begin();
+ persistentStore.deletePersistent(rule);
+ tx.commit();
+ }
+ catch (Exception e)
+ {
+ throw new ProfilerException("failed to delete: " +
rule.getLocatorName(), e);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]