taylor 2004/10/20 18:45:50
Modified: applications/pam/src/webapp/WEB-INF/view profiler-admin.jsp
applications/pam/src/java/org/apache/jetspeed/portlets/profiler
ProfileRulesExtent.java ProfileRuleForm.java
applications/pam/src/webapp/WEB-INF faces-config.xml
portlet.xml
Added: applications/pam/src/webapp/WEB-INF/view profiler-help.html
profiler-criterion.jsp
applications/pam/src/java/org/apache/jetspeed/portlets/profiler/resources
ProfilerResources.properties
applications/pam/src/java/org/apache/jetspeed/portlets/profiler
ProfileCriterionForm.java
Log:
Profiler Admin basic operations completed.
Its pretty ugly, but my first real MyFaces-bridged portlet.
Most JSF operations seem to be functioning including navigations, beans, keeping
state.
Having an issue with validation message not printing
I really need to spend some time working on the styles and layouts. Its pretty damn
ugly.
Problem is my designer skills are crap.
If anyone is willing to help me out here, I think we set a precedent for style and
use it in other admin portlets...
Revision Changes Path
1.7 +83 -35
jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/profiler-admin.jsp
Index: profiler-admin.jsp
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/profiler-admin.jsp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- profiler-admin.jsp 15 Oct 2004 21:46:46 -0000 1.6
+++ profiler-admin.jsp 21 Oct 2004 01:45:50 -0000 1.7
@@ -1,5 +1,3 @@
-<%@ page import="net.sourceforge.myfaces.custom.tree.DefaultMutableTreeNode,
- net.sourceforge.myfaces.custom.tree.model.DefaultTreeModel"%>
<%@ page session="true" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
@@ -23,59 +21,109 @@
*/
//-->
-<link href='css/security-admin.css' type='text/css'/>
+<f:loadBundle
basename="org.apache.jetspeed.portlets.profiler.resources.ProfilerResources"
var="MESSAGE" />
<f:view>
<h:panelGrid columns='2'>
<h:panelGroup>
<h:dataTable
value="#{rules.extent}"
- var="erule"
+ var="mRule"
styleClass="portlet-section-body"
- headerClass="portlet-form-button"
- rowClasses="portlet-menu-item-selected,portlet-MintyBlue"
+ headerClass="portlet-section-subheader"
>
<h:column>
<f:facet name="header">
- <h:outputText value="Rule Id" />
+ <h:outputText styleClass='portlet-section-header'
value="#{MESSAGE['profiler.title.rules']}" />
</f:facet>
<x:commandLink actionListener="#{rule.listen}" immediate="true" >
- <h:outputText value="#{erule.id}" />
- <f:param name='selectedRule' value="#{erule.id}"/>
+ <h:outputText value="#{mRule.id}" />
+ <f:param name='selectedRule' value="#{mRule.id}"/>
</x:commandLink>
</h:column>
-
- <h:column>
- <f:facet name="header">
- <h:outputText value="Description"
- style="font-weight: bold"/>
- </f:facet>
- <h:outputText value='#{erule.title}'/>
- </h:column>
- <h:column>
- <h:selectBooleanCheckbox value="false"/>
- </h:column>
</h:dataTable>
</h:panelGroup>
-<h:panelGroup>
+<h:panelGroup rendered="#{rule != null && rule.id != '{empty}'}">
+
<h:form id="ruleForm" name="ruleForm">
- <h:panelGrid columns="2" >
- <f:facet name="header">
- <h:outputText id="cfH" value="Edit Rule"/>
- </f:facet>
- <f:facet name="footer">
- <h:outputText value="End"/>
- </f:facet>
-
- <h:outputLabel for="title" value="Title"/>
- <h:panelGroup>
- <h:inputText id="title" value="#{rule.title}" required="true" />
- <h:message for="title" styleClass="error" showDetail="true"
showSummary="false" />
- </h:panelGroup>
+ <h:panelGrid columns="3">
- </h:panelGrid>
+ <h:outputLabel for="xid" value="#{MESSAGE['profiler.rule.id']}: "/>
+ <h:inputText readonly='#{rule.updating}' id="xid"
styleClass='portlet-form-label' value="#{rule.id}" size='80'/>
+ <h:message for="xid" styleClass="error" showDetail="true"
showSummary="false" />
+
+ <h:outputLabel for="title" value="#{MESSAGE['profiler.rule.title']}: "/>
+ <h:inputText id="title" styleClass='portlet-section-header'
value="#{rule.title}" size='100'/>
+ <h:message for="title" styleClass="error" showDetail="true"
showSummary="false" />
+
+ <h:outputLabel for="classname" value="#{MESSAGE['profiler.rule.class']}: "/>
+ <h:selectOneMenu id="classname" styleClass='portlet-section-header'
value="#{rule.classname}">
+ <f:selectItems value="#{rule.classnames}"/>
+ </h:selectOneMenu>
+ <h:message for="classname" styleClass="error" showDetail="true"
showSummary="false" />
+
+ </h:panelGrid>
+
+ <h:panelGroup/>
+ <h:commandButton id="saveProfile" value="#{MESSAGE['profiler.rule.save']}"
action="#{rule.saveProfile}"/>
+ <h:commandButton id="newProfile" value="#{MESSAGE['profiler.rule.new']}"
action="#{rule.createNewProfile}"/>
+ <h:commandButton id="removeProfile"
value="#{MESSAGE['profiler.rule.remove']}" action="#{rule.removeProfile}"/>
+ <h:panelGroup/>
+
</h:form>
+<!-- criteria -->
+ <br/>
+ <h:outputText styleClass='portlet-section-header'
value="#{MESSAGE['criteria.title']}"/>
+ <br/>
+
+ <h:dataTable
+ value="#{rule.criteria}"
+ var="mCriterion"
+ styleClass="portlet-section-body"
+ headerClass="portlet-section-body"
+ >
+ <h:column>
+ <f:facet name="header">
+ <h:outputText styleClass="portlet-section-body"
value="#{MESSAGE['criterion.name']}" />
+ </f:facet>
+ <x:commandLink action='gotoCriterionForm'
actionListener="#{criterion.listen}" immediate="true" >
+ <h:outputText value="#{mCriterion.name}" />
+ <f:param name='selectedCriterion' value="#{mCriterion.name}"/>
+ <f:param name='selectedRule' value="#{rule.id}"/>
+ </x:commandLink>
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText styleClass="portlet-section-body"
value="#{MESSAGE['criterion.value']}" />
+ </f:facet>
+ <h:outputText value="#{mCriterion.value}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText styleClass="portlet-section-body"
value="#{MESSAGE['criterion.resolver']}" />
+ </f:facet>
+ <h:outputText value="#{mCriterion.type}" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText styleClass="portlet-section-body"
value="#{MESSAGE['criterion.fallback.order']}" />
+ </f:facet>
+ <h:outputText value="#{mCriterion.fallbackOrder}" />
+ </h:column>
+
+ </h:dataTable>
+
+ <h:panelGroup/>
+ <h:commandLink id="addCriterion" value="#{MESSAGE['criteria.new']}"
immediate='true'
+ action="gotoCriterionForm"
actionListener="#{criterion.listen}">
+ <f:param name='selectedRule' value="#{rule.id}" />
+ </h:commandLink>
+ <h:panelGroup/>
+
+
</h:panelGroup>
+
</h:panelGrid>
+
</f:view>
1.1
jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/profiler-help.html
Index: profiler-help.html
===================================================================
<h1>
Profiler Help
</h1>
<h3>NOTE: This help file is in English Only. TODO: add a option to locate by locale
to the GenericServletPortlet</h3>
<h3>NOTE: Please DO NOT TRANSLATE since its still under construction.</h3>
<p>
The Profiler locates portal resources given a set of request parameters, properties,
and attributes
The Profiler is invoked during the request processing pipeline.
It requires that the request context is already populated with the portal request
and response,
and capability and user information. The request context parameters, properties and
attributes
make up the profile criterion which the profiler uses to locate portal resources:
<ul>
<li>page
<li>navigations
<li>document lists
</ul>
The profiler does not actually locate the document.
It creates a Profile Locator, an abstract definition of a resource locator.
</p>
<h2>Rules</h2>
Rules define how a resource locator is created.
A rule is an ordered sequence of one or more criterion.
The profiler will apply all criteria for a given rule in fallback order.
It will start from the lowest fallback number for a criteria, and continue
trying to locate until it either locates a resource, or until the fallback type of
the
criteria dictates that it either stop or continue to loop.
<h2>Resolvers</h2>
Resolvers are Java classes associated with a criterion.
A resolver determines what runtime parameters and state to look at when building a
profile locator.
<table>
<tr>
<td>
path
</td>
<td>
<ul>
<li>Looks at the Request Path of the request.
</ul>
</td>
</tr>
<tr>
<td>
group
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at current authenticated subject, finding all group principals for
the subject.
</ul>
</td>
</tr>
<tr>
<td>
role
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at current authenticated subject, finding all role principals for the
subject.
</ul>
</td>
</tr>
<tr>
<td>
user
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at current authenticated subject, finding all user principals for the
subject.
</ul>
</td>
</tr>
<tr>
<td>
language
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at the Locale.LanguageCode for the current request.
</ul>
</td>
</tr>
<tr>
<td>
mediatype
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at the Mediatype (Mime Type) for the current request.
</ul>
</td>
</tr>
<tr>
<td>
country
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Next looks at the Locale.CountryCode for the current request.
</ul>
</td>
</tr>
<tr>
<td>
hard.coded
</td>
<td>
<ul>
<li>Applies the value specified in this rule as a constant.
</ul>
</td>
</tr>
<tr>
<td>
path.session
</td>
<td>
<ul>
<li>Looks in HTTP Request Parameter (Standard) for the named parameter.
<li>Looks in Portal's Servlet Session for the named attribute.
</ul>
</td>
</tr>
<tr>
<td>
group.user.role
</td>
<td>
<ul>
<li>todo
</ul>
</td>
</tr>
</tr>
</table>
<h2>Fallback Types</h2>
<table>
<tr>
<td>
</td>
</tr>
</table>
1.1
jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/view/profiler-criterion.jsp
Index: profiler-criterion.jsp
===================================================================
<%@ page session="true" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.sourceforge.net/tld/myfaces_ext_0_9.tld" prefix="x"%>
<!--
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//-->
<f:loadBundle
basename="org.apache.jetspeed.portlets.profiler.resources.ProfilerResources"
var="MESSAGE" />
<f:view>
<h:panelGrid>
<h:panelGroup>
<br/>
<h:outputText styleClass='portlet-section-header'
value="#{MESSAGE['criteria.title']}"/>
<br/>
<h:form id="criterionForm" name="criterionForm">
<h:panelGrid columns="3">
<h:outputLabel for="name" value="#{MESSAGE['criterion.name']}: "/>
<h:inputText required='true' id="name" styleClass='portlet-form-label'
value="#{criterion.name}" size='80'/>
<h:message for="name" styleClass="error" showDetail="true"
showSummary="false" />
<h:outputLabel for="value" value="#{MESSAGE['criterion.value']}: "/>
<h:inputText id="value" styleClass='portlet-form-label'
value="#{criterion.value}" size='128'/>
<h:message for="value" styleClass="error" showDetail="true"
showSummary="false" />
<h:outputLabel for="resolver" value="#{MESSAGE['criterion.resolver']}: "/>
<h:selectOneMenu id="resolver" styleClass='portlet-form-label'
value="#{criterion.resolver}">
<f:selectItems value="#{criterion.resolvers}"/>
</h:selectOneMenu>
<h:message for="resolver" styleClass="error" showDetail="true"
showSummary="false" />
<h:outputLabel for="fallbackType"
value="#{MESSAGE['criterion.fallback.type']}: "/>
<h:selectOneMenu id="fallbackType" styleClass='portlet-form-label'
value="#{criterion.fallbackType}">
<f:selectItems value="#{criterion.fallbackTypes}"/>
</h:selectOneMenu>
<h:message for="fallbackType" styleClass="error" showDetail="true"
showSummary="false" />
<h:outputLabel for="fallbackOrder"
value="#{MESSAGE['criterion.fallback.order']}: "/>
<h:inputText id="fallbackOrder" styleClass='portlet-form-label'
value="#{criterion.fallbackOrder}" />
<h:message for="fallbackOrder" styleClass="error" showDetail="true"
showSummary="false" />
</h:panelGrid>
<h:panelGroup/>
<h:commandButton id="saveCriterion"
value="#{MESSAGE['profiler.rule.save']}" action="#{criterion.saveCriterion}"/>
<h:commandButton id="removeCriteria" value="#{MESSAGE['criteria.remove']}"
action="#{criterion.removeCriterion}"/>
<h:commandButton id="cancelCriterion"
value="#{MESSAGE['profiler.rule.cancel']}"
action="returnFromCriterion" immediate='true'>
</h:commandButton>
<h:panelGroup/>
</h:form>
</h:panelGroup>
</h:panelGrid>
</f:view>
1.1
jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/resources/ProfilerResources.properties
Index: ProfilerResources.properties
===================================================================
# Copyright 2004 The Apache Software Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# $Id: ProfilerResources.properties,v 1.1 2004/10/21 01:45:50 taylor Exp $
#
profiler.title.rules=Rules
profiler.rule.title=Rule Title
profiler.rule.id=Rule Id
profiler.rule.class=Rule Class
profiler.rule.save=Save
profiler.rule.new=New
profiler.rule.cancel=Cancel
profiler.rule.remove=Remove
criteria.title=Rule Criteria
criteria.new=New Criteria
criteria.remove=Remove Criteria
criterion.name=Name
criterion.value=Value
criterion.fallback.order=Order
criterion.resolver=Resolver Type
criterion.fallback.type=Fallback
1.2 +2 -1
jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/ProfileRulesExtent.java
Index: ProfileRulesExtent.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/ProfileRulesExtent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfileRulesExtent.java 15 Oct 2004 21:46:46 -0000 1.1
+++ ProfileRulesExtent.java 21 Oct 2004 01:45:50 -0000 1.2
@@ -17,6 +17,7 @@
// import java.io.Serializable;
import java.util.Collection;
+//import java.util.LinkedList;
import java.util.Map;
import javax.faces.context.FacesContext;
1.2 +110 -4
jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/ProfileRuleForm.java
Index: ProfileRuleForm.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/ProfileRuleForm.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfileRuleForm.java 15 Oct 2004 21:46:46 -0000 1.1
+++ ProfileRuleForm.java 21 Oct 2004 01:45:50 -0000 1.2
@@ -16,17 +16,20 @@
package org.apache.jetspeed.portlets.profiler;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
import org.apache.jetspeed.portlets.pam.PortletApplicationResources;
import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.ProfilerException;
import org.apache.jetspeed.profiler.rules.ProfilingRule;
/**
- * User state.
+ * Profile state.
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id$
@@ -34,11 +37,26 @@
public class ProfileRuleForm
implements Serializable
{
+ private boolean isNew = false;
private transient Profiler profiler = null;
private transient ProfilingRule rule = null;
+ private transient SelectItem[] classnames =
+ {
+ new
SelectItem("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule"),
+ new
SelectItem("org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule")
+ };
public ProfileRuleForm()
{
+ }
+
+ public boolean getUpdating()
+ {
+ return !isNew;
+ }
+
+ public void listen(ActionEvent event)
+ {
Map appMap =
(Map)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
profiler =
(Profiler)appMap.get(PortletApplicationResources.CPS_PROFILER_COMPONENT);
Map params =
(Map)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
@@ -46,11 +64,13 @@
if (selected != null && profiler != null)
{
rule = profiler.getRule(selected);
- }
+ isNew = false;
+ }
}
- public void listen(ActionEvent event)
+ public SelectItem[] getClassnames()
{
+ return classnames;
}
public String getTitle()
@@ -62,6 +82,31 @@
return rule.getTitle();
}
+ public void setTitle(String title)
+ {
+ if (rule != null)
+ {
+ this.rule.setTitle(title);
+ }
+ }
+
+ public String getClassname()
+ {
+ if (rule == null)
+ {
+ return "{empty}";
+ }
+ return rule.getClassname();
+ }
+
+ public void setClassname(String classname)
+ {
+ if (rule != null)
+ {
+ this.rule.setClassname(classname);
+ }
+ }
+
public String getId()
{
if (rule == null)
@@ -71,5 +116,66 @@
return rule.getId();
}
+ public void setId(String id)
+ {
+ if (rule != null)
+ {
+ this.rule.setId(id);
+ }
+ }
+
+ // actions
+
+ public String saveProfile()
+ {
+ try
+ {
+ profiler.storeProfilingRule(this.rule);
+ isNew = false;
+ }
+ catch (ProfilerException e)
+ {
+ System.out.println("Failed to UPDATE: rule = " + rule.getId());
+ // TODO: forward to an error page
+ }
+ return null;
+ }
+
+ public String removeProfile()
+ {
+ try
+ {
+ profiler.deleteProfilingRule(rule);
+ }
+ catch (ProfilerException e)
+ {
+ System.out.println("Failed to REMOVE: rule = " + rule.getId());
+ // TODO: forward to an error page
+ }
+ return null;
+ }
+
+ public String createNewProfile()
+ {
+ try
+ {
+ Class defaultClass =
profiler.getClass().getClassLoader().loadClass("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
+ this.rule = (ProfilingRule)defaultClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ System.out.println("Failed to CREATE NEW: rule = " + rule.getId());
+ // TODO: forward to an error page
+ }
+ this.setId("");
+ this.setTitle("");
+
this.setClassname("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
+ isNew = true;
+ return null;
+ }
+ public Collection getCriteria()
+ {
+ return rule.getRuleCriteria();
+ }
}
1.1
jakarta-jetspeed-2/applications/pam/src/java/org/apache/jetspeed/portlets/profiler/ProfileCriterionForm.java
Index: ProfileCriterionForm.java
===================================================================
/*
* Copyright 2000-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.portlets.profiler;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import org.apache.jetspeed.portlets.pam.PortletApplicationResources;
import org.apache.jetspeed.profiler.Profiler;
import org.apache.jetspeed.profiler.rules.ProfilingRule;
import org.apache.jetspeed.profiler.rules.RuleCriterion;
/**
* Criterion state.
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id: ProfileCriterionForm.java,v 1.1 2004/10/21 01:45:50 taylor Exp $
*/
public class ProfileCriterionForm implements Serializable
{
private boolean isNew = false;
private transient Profiler profiler = null;
private transient RuleCriterion criterion = null;
private transient ProfilingRule rule = null;
private static final String FALLBACK_CONTINUE = "Continue";
private static final String FALLBACK_STOP = "Stop";
private static final String FALLBACK_LOOP = "Loop";
private transient SelectItem[] resolvers =
{
new SelectItem("request"),
new SelectItem("session"),
new SelectItem("request.session"),
new SelectItem("hard.coded"),
new SelectItem("group.role.user"),
new SelectItem("user"),
new SelectItem("group"),
new SelectItem("role"),
new SelectItem("mediatype"),
new SelectItem("country"),
new SelectItem("language"),
new SelectItem("roles"),
new SelectItem("path"),
new SelectItem("page"),
new SelectItem("path.session")
};
private transient SelectItem[] fallbackTypes =
{
new SelectItem(FALLBACK_CONTINUE),
new SelectItem(FALLBACK_LOOP),
new SelectItem(FALLBACK_STOP)
};
public ProfileCriterionForm()
{
}
public boolean getUpdating()
{
return !isNew;
}
public SelectItem[] getResolvers()
{
return resolvers;
}
public SelectItem[] getFallbackTypes()
{
return fallbackTypes;
}
public void listen(ActionEvent event)
{
Map appMap =
(Map)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
profiler =
(Profiler)appMap.get(PortletApplicationResources.CPS_PROFILER_COMPONENT);
Map params =
(Map)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String selectedRule = (String)params.get("selectedRule");
if (selectedRule != null && profiler != null)
{
rule = profiler.getRule(selectedRule);
if (rule != null)
{
String selected = (String)params.get("selectedCriterion");
if (selected == null || selected.length() == 0)
{
isNew = true;
try
{
Class defaultClass =
profiler.getClass().getClassLoader().loadClass("org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl");
this.criterion = (RuleCriterion)defaultClass.newInstance();
}
catch (Exception e)
{
System.out.println("Failed to CREATE NEW: rule = " +
rule.getId());
// TODO: forward to an error page
}
}
else
{
Iterator it = rule.getRuleCriteria().iterator();
while (it.hasNext())
{
RuleCriterion c = (RuleCriterion)it.next();
if (c.getName().equals(selected))
{
criterion = c;
isNew = false;
break;
}
}
}
}
}
}
public String getName()
{
if (criterion == null)
{
return "{empty}";
}
return criterion.getName();
}
public void setName(String name)
{
if (criterion != null)
{
this.criterion.setName(name);
}
}
public String getValue()
{
if (criterion == null)
{
return "{empty}";
}
return criterion.getValue();
}
public void setValue(String value)
{
if (criterion != null)
{
this.criterion.setValue(value);
}
}
public String getResolver()
{
if (criterion == null)
{
return "{empty}";
}
return criterion.getType();
}
public void setResolver(String resolver)
{
if (criterion != null)
{
this.criterion.setType(resolver);
}
}
public int getFallbackOrder()
{
if (criterion == null)
{
return 0;
}
return criterion.getFallbackOrder();
}
public void setFallbackOrder(int order)
{
if (criterion != null)
{
this.criterion.setFallbackOrder(order);
}
}
public String getFallbackType()
{
if (criterion == null)
{
return FALLBACK_CONTINUE;
}
int type = criterion.getFallbackType();
switch (type)
{
case RuleCriterion.FALLBACK_CONTINUE:
return FALLBACK_CONTINUE;
case RuleCriterion.FALLBACK_LOOP:
return FALLBACK_LOOP;
default:
return FALLBACK_STOP;
}
}
public void setFallbackType(String type)
{
if (criterion != null)
{
if (type.equals(FALLBACK_CONTINUE))
{
this.criterion.setFallbackType(RuleCriterion.FALLBACK_CONTINUE);
}
else if (type.equals(FALLBACK_LOOP))
{
this.criterion.setFallbackType(RuleCriterion.FALLBACK_LOOP);
}
else
{
this.criterion.setFallbackType(RuleCriterion.FALLBACK_STOP);
}
}
}
// actions
public String saveCriterion()
{
try
{
if (isNew)
{
criterion.setRuleId(rule.getId());
rule.getRuleCriteria().add(criterion);
}
profiler.storeProfilingRule(rule);
isNew = false;
}
catch (Exception e)
{
// TODO: handle errors better
System.out.println("Failed to UPDATE: rule = " + rule.getId());
return "gotoCriterionForm";
}
return "returnFromCriterion";
}
public String removeCriterion()
{
try
{
if (!isNew)
{
rule.getRuleCriteria().remove(criterion);
profiler.storeProfilingRule(rule);
isNew = true;
}
}
catch (Exception e)
{
// TODO: handle errors better
System.out.println("Failed to UPDATE: rule = " + rule.getId());
return "gotoCriterionForm";
}
return "returnFromCriterion";
}
}
1.5 +23 -1
jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/faces-config.xml
Index: faces-config.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/faces-config.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- faces-config.xml 15 Oct 2004 21:46:46 -0000 1.4
+++ faces-config.xml 21 Oct 2004 01:45:50 -0000 1.5
@@ -31,6 +31,22 @@
</locale-config>
</application>
+ <navigation-rule>
+ <from-view-id>/WEB-INF/view/profiler-admin.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>gotoCriterionForm</from-outcome>
+ <to-view-id>/WEB-INF/view/profiler-criterion.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/WEB-INF/view/profiler-criterion.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>returnFromCriterion</from-outcome>
+ <to-view-id>/WEB-INF/view/profiler-admin.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
<managed-bean>
<managed-bean-name>tableData</managed-bean-name>
<managed-bean-class>org.apache.jetspeed.portlets.site.beans.TableData</managed-bean-class>
@@ -59,7 +75,13 @@
<managed-bean>
<managed-bean-name>rule</managed-bean-name>
<managed-bean-class>org.apache.jetspeed.portlets.profiler.ProfileRuleForm</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>criterion</managed-bean-name>
+
<managed-bean-class>org.apache.jetspeed.portlets.profiler.ProfileCriterionForm</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
1.14 +6 -2
jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/portlet.xml
Index: portlet.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/applications/pam/src/webapp/WEB-INF/portlet.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- portlet.xml 12 Oct 2004 21:27:57 -0000 1.13
+++ portlet.xml 21 Oct 2004 01:45:50 -0000 1.14
@@ -142,7 +142,12 @@
<init-param>
<description>This parameter sets the template used in view mode.</description>
<name>ViewPage</name>
- <value>/WEB-INF/view/profiler-admin.jsp</value>
+ <value>/WEB-INF/view/profiler-admin.jsp</value>
+ </init-param>
+ <init-param>
+ <description>This parameter sets the template used in help mode.</description>
+ <name>HelpPage</name>
+ <value>/WEB-INF/view/profiler-help.html</value>
</init-param>
<portlet-name>ProfilerAdmin</portlet-name>
<display-name>Profiler Admin</display-name>
@@ -151,7 +156,6 @@
<expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
- <portlet-mode>EDIT</portlet-mode>
<portlet-mode>VIEW</portlet-mode>
<portlet-mode>HELP</portlet-mode>
</supports>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]