You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2005/02/08 19:15:40 UTC
svn commit: r152682 [16/17] - in lenya/trunk/src: java/org/apache/lenya/ac/
java/org/apache/lenya/ac/cache/ java/org/apache/lenya/ac/file/
java/org/apache/lenya/ac/impl/ java/org/apache/lenya/ac/ldap/
java/org/apache/lenya/cms/ac/ java/org/apache/lenya/cms/ac/cocoon/
java/org/apache/lenya/cms/ac/usecase/ java/org/apache/lenya/cms/ac/usecases/
java/org/apache/lenya/cms/ac/workflow/ java/org/apache/lenya/cms/ant/
java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/cocoon/acting/
java/org/apache/lenya/cms/cocoon/bean/
java/org/apache/lenya/cms/cocoon/components/modules/input/
java/org/apache/lenya/cms/cocoon/flow/
java/org/apache/lenya/cms/cocoon/generation/
java/org/apache/lenya/cms/cocoon/matching/
java/org/apache/lenya/cms/cocoon/scheduler/
java/org/apache/lenya/cms/cocoon/source/
java/org/apache/lenya/cms/cocoon/task/
java/org/apache/lenya/cms/cocoon/transformation/
java/org/apache/lenya/cms/cocoon/uriparameterizer/
java/org/apache/lenya/cms/metadata/dublincore/
java/org/apache/lenya/cms/metadata/usecases/
java/org/apache/lenya/cms/publication/
java/org/apache/lenya/cms/publication/file/
java/org/apache/lenya/cms/publication/task/
java/org/apache/lenya/cms/publication/templating/
java/org/apache/lenya/cms/publication/util/
java/org/apache/lenya/cms/publishing/ java/org/apache/lenya/cms/rc/
java/org/apache/lenya/cms/scheduler/ java/org/apache/lenya/cms/scheduler/xml/
java/org/apache/lenya/cms/search/usecases/ java/org/apache/lenya/cms/site/
java/org/apache/lenya/cms/site/tree/
java/org/apache/lenya/cms/site/usecases/ java/org/apache/lenya/cms/task/
java/org/apache/lenya/cms/usecase/ java/org/apache/lenya/cms/workflow/
java/org/apache/lenya/lucene/ java/org/apache/lenya/lucene/html/
java/org/apache/lenya/lucene/index/ java/org/apache/lenya/lucene/parser/
java/org/apache/lenya/net/ java/org/apache/lenya/search/
java/org/apache/lenya/search/crawler/ java/org/apache/lenya/util/
java/org/apache/lenya/workflow/ java/org/apache/lenya/workflow/impl/
java/org/apache/lenya/xml/ test/org/apache/lenya/ac/file/
test/org/apache/lenya/ac/impl/ test/org/apache/lenya/cms/
test/org/apache/lenya/cms/authoring/
test/org/apache/lenya/cms/cocoon/generation/
test/org/apache/lenya/cms/publication/
test/org/apache/lenya/cms/publication/file/ test/org/apache/lenya/cms/rc/
test/org/apache/lenya/cms/site/tree/ test/org/apache/lenya/cms/task/
test/org/apache/lenya/cms/workflow/ test/org/apache/lenya/net/
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/HistoryImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/HistoryImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/HistoryImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/HistoryImpl.java Tue Feb 8 10:13:39 2005
@@ -29,6 +29,8 @@
import java.util.Date;
import java.util.List;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.lenya.workflow.BooleanVariable;
@@ -43,8 +45,10 @@
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.xpath.XPathAPI;
+import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
/**
* <p>
@@ -59,24 +63,51 @@
*/
public abstract class HistoryImpl implements History, WorkflowListener {
+ /**
+ * <code>WORKFLOW_ATTRIBUTE</code> The workflow attribute
+ */
public static final String WORKFLOW_ATTRIBUTE = "workflow";
+ /**
+ * <code>HISTORY_ELEMENT</code> The history element
+ */
public static final String HISTORY_ELEMENT = "history";
+ /**
+ * <code>VERSION_ELEMENT</code> The version element
+ */
public static final String VERSION_ELEMENT = "version";
+ /**
+ * <code>STATE_ATTRIBUTE</code> The state attribute
+ */
public static final String STATE_ATTRIBUTE = "state";
+ /**
+ * <code>EVENT_ATTRIBUTE</code> The event attribute
+ */
public static final String EVENT_ATTRIBUTE = "event";
+ /**
+ * <code>VARIABLE_ELEMENT</code> The variable element
+ */
public static final String VARIABLE_ELEMENT = "variable";
+ /**
+ * <code>NAME_ATTRIBUTE</code> The name attribute
+ */
public static final String NAME_ATTRIBUTE = "name";
+ /**
+ * <code>VALUE_ATTRIBUTE</code> The value attribute
+ */
public static final String VALUE_ATTRIBUTE = "value";
+ /**
+ * <code>DATE_ATTRIBUTE</code> The date attribute
+ */
public static final String DATE_ATTRIBUTE = "date";
/**
* Creates a new history object. A new history file is created and
* initialized.
- * @param workflowId The workflow ID.
* @param situation The current situation.
* @throws WorkflowException when something went wrong.
*/
public void initialize(Situation situation) throws WorkflowException {
+
try {
File file = getHistoryFile();
file.getParentFile().mkdirs();
@@ -93,23 +124,33 @@
historyElement.appendChild(initialVersionElement);
DocumentHelper.writeDocument(helper.getDocument(), file);
- } catch (Exception e) {
+ } catch (DOMException e) {
+ throw new WorkflowException(e);
+ } catch (TransformerConfigurationException e) {
+ throw new WorkflowException(e);
+ } catch (IOException e) {
+ throw new WorkflowException(e);
+ } catch (ParserConfigurationException e) {
+ throw new WorkflowException(e);
+ } catch (WorkflowException e) {
+ throw new WorkflowException(e);
+ } catch (TransformerException e) {
throw new WorkflowException(e);
}
}
/**
* Creates a new history object for a workflow instance.
- * @param instance The workflow instance.
+ * @param _instance The workflow instance.
* @throws WorkflowException if an error occurs.
*/
- protected HistoryImpl(WorkflowInstanceImpl instance) throws WorkflowException {
- this.instance = instance;
+ protected HistoryImpl(WorkflowInstanceImpl _instance) throws WorkflowException {
+ this.instance = _instance;
if (isInitialized()) {
NamespaceHelper helper = getNamespaceHelper();
- restoreState(instance, helper);
- restoreVariables(instance, helper);
- instance.addWorkflowListener(this);
+ restoreState(_instance, helper);
+ restoreVariables(_instance, helper);
+ _instance.addWorkflowListener(this);
}
}
@@ -125,7 +166,11 @@
try {
Document document = DocumentHelper.readDocument(getHistoryFile());
helper = new NamespaceHelper(Workflow.NAMESPACE, Workflow.DEFAULT_PREFIX, document);
- } catch (Exception e) {
+ } catch (final ParserConfigurationException e) {
+ throw new WorkflowException(e);
+ } catch (final SAXException e) {
+ throw new WorkflowException(e);
+ } catch (final IOException e) {
throw new WorkflowException(e);
}
return helper;
@@ -177,16 +222,20 @@
* invocation.
* @param helper The namespace helper of the history document.
* @param situation The current situation.
- * @param workflowId The workflow ID.
* @return An XML element.
* @throws WorkflowException when something went wrong.
*/
protected Element createInitialVersionElement(NamespaceHelper helper, Situation situation)
throws WorkflowException {
- Element versionElement = createVersionElement(helper, situation);
+ Element versionElement;
+ try {
+ versionElement = createVersionElement(helper, situation);
- StateImpl initialState = (StateImpl) instance.getWorkflow().getInitialState();
- versionElement.setAttribute(STATE_ATTRIBUTE, initialState.getId());
+ StateImpl initialState = (StateImpl) this.instance.getWorkflow().getInitialState();
+ versionElement.setAttribute(STATE_ATTRIBUTE, initialState.getId());
+ } catch (final DOMException e) {
+ throw new WorkflowException(e);
+ }
return versionElement;
}
@@ -226,34 +275,46 @@
/**
* Advances the workflow history when a tranistion was invoked.
*
- * @param instance The workflow instance.
+ * @param _instance The workflow instance.
* @param situation The situation before the transition.
* @param event The invoked event.
* @param resultingState The resulting state.
*
* @throws WorkflowException when something went wrong.
*/
- public void transitionFired(WorkflowInstance instance, Situation situation, String event,
+ public void transitionFired(WorkflowInstance _instance, Situation situation, String event,
State resultingState) throws WorkflowException {
- try {
- this.lastState = resultingState;
- org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(getHistoryFile());
- Element root = xmlDocument.getDocumentElement();
+ try {
+ this.lastState = resultingState;
+ org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(getHistoryFile());
+ Element root = xmlDocument.getDocumentElement();
- NamespaceHelper helper = new NamespaceHelper(Workflow.NAMESPACE,
- Workflow.DEFAULT_PREFIX, xmlDocument);
+ NamespaceHelper helper = new NamespaceHelper(Workflow.NAMESPACE,
+ Workflow.DEFAULT_PREFIX, xmlDocument);
- Element versionElement = createVersionElement(helper, (StateImpl) instance
- .getCurrentState(), situation, event);
+ Element versionElement = createVersionElement(helper, (StateImpl) _instance
+ .getCurrentState(), situation, event);
- root.appendChild(versionElement);
+ root.appendChild(versionElement);
- saveVariables(helper);
+ saveVariables(helper);
- DocumentHelper.writeDocument(xmlDocument, getHistoryFile());
- } catch (Exception e) {
- throw new WorkflowException(e);
- }
+ DocumentHelper.writeDocument(xmlDocument, getHistoryFile());
+ } catch (final DOMException e) {
+ throw new WorkflowException(e);
+ } catch (final TransformerConfigurationException e) {
+ throw new WorkflowException(e);
+ } catch (final ParserConfigurationException e) {
+ throw new WorkflowException(e);
+ } catch (final SAXException e) {
+ throw new WorkflowException(e);
+ } catch (final IOException e) {
+ throw new WorkflowException(e);
+ } catch (final WorkflowException e) {
+ throw new WorkflowException(e);
+ } catch (final TransformerException e) {
+ throw new WorkflowException(e);
+ }
}
/**
@@ -261,7 +322,7 @@
* @param impl A workflow instance implementation.
*/
public void setInstance(WorkflowInstanceImpl impl) {
- instance = impl;
+ this.instance = impl;
}
/**
@@ -289,7 +350,7 @@
}
element.setAttribute(VALUE_ATTRIBUTE, Boolean.toString(value));
- } catch (TransformerException e) {
+ } catch (final TransformerException e) {
throw new WorkflowException(e);
}
}
@@ -297,11 +358,11 @@
/**
* Restores the state variables of a workflow instance.
- * @param instance The instance to restore.
+ * @param _instance The instance to restore.
* @param helper The helper that wraps the history document.
* @throws WorkflowException when something went wrong.
*/
- protected void restoreVariables(WorkflowInstanceImpl instance, NamespaceHelper helper)
+ protected void restoreVariables(WorkflowInstanceImpl _instance, NamespaceHelper helper)
throws WorkflowException {
Element parent = helper.getDocument().getDocumentElement();
@@ -310,17 +371,17 @@
for (int i = 0; i < variableElements.length; i++) {
String name = variableElements[i].getAttribute(NAME_ATTRIBUTE);
String value = variableElements[i].getAttribute(VALUE_ATTRIBUTE);
- instance.setValue(name, Boolean.valueOf(value).booleanValue());
+ _instance.setValue(name, Boolean.valueOf(value).booleanValue());
}
}
/**
* Restores the state of a workflow instance.
- * @param instance The instance to restore.
+ * @param _instance The instance to restore.
* @param helper The helper that wraps the history document.
* @throws WorkflowException when something went wrong.
*/
- protected void restoreState(WorkflowInstanceImpl instance, NamespaceHelper helper)
+ protected void restoreState(WorkflowInstanceImpl _instance, NamespaceHelper helper)
throws WorkflowException {
State state;
Element[] versionElements = helper.getChildren(helper.getDocument().getDocumentElement(),
@@ -329,9 +390,9 @@
if (versionElements.length > 0) {
Element lastElement = versionElements[versionElements.length - 1];
String stateId = lastElement.getAttribute(STATE_ATTRIBUTE);
- state = instance.getWorkflowImpl().getState(stateId);
+ state = _instance.getWorkflowImpl().getState(stateId);
} else {
- state = instance.getWorkflow().getInitialState();
+ state = _instance.getWorkflow().getInitialState();
}
this.lastState = state;
@@ -391,7 +452,7 @@
destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
sourceStream.close();
destinationStream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new WorkflowException(e);
} finally {
try {
@@ -399,7 +460,7 @@
sourceStream.close();
if (destinationStream != null)
destinationStream.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new WorkflowException(e);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/StateImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/StateImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/StateImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/StateImpl.java Tue Feb 8 10:13:39 2005
@@ -32,7 +32,7 @@
* @param stateId The state ID.
*/
protected StateImpl(String stateId) {
- id = stateId;
+ this.id = stateId;
}
private String id;
@@ -42,7 +42,7 @@
* @return A string.
*/
public String getId() {
- return id;
+ return this.id;
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/SynchronizedWorkflowInstancesImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/SynchronizedWorkflowInstancesImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/SynchronizedWorkflowInstancesImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/SynchronizedWorkflowInstancesImpl.java Tue Feb 8 10:13:39 2005
@@ -41,42 +41,54 @@
* Ctor.
*/
public SynchronizedWorkflowInstancesImpl() {
+ // do nothing
}
/**
* Ctor.
- * @param instances The set of workflow instances to synchronize.
- * @param mainInstance The main workflow instance to invoke for
+ * @param _instances The set of workflow instances to synchronize.
+ * @param _mainInstance The main workflow instance to invoke for
* non-synchronized transitions.
*/
- public SynchronizedWorkflowInstancesImpl(WorkflowInstance[] instances,
- WorkflowInstance mainInstance) {
- setInstances(instances);
- setMainInstance(mainInstance);
+ public SynchronizedWorkflowInstancesImpl(WorkflowInstance[] _instances,
+ WorkflowInstance _mainInstance) {
+ setInstances(_instances);
+ setMainInstance(_mainInstance);
}
/**
* Sets the main workflow instance.
- * @param mainInstance The main workflow instance to invoke for
+ * @param _mainInstance The main workflow instance to invoke for
* non-synchronized transitions.
*/
- public void setMainInstance(WorkflowInstance mainInstance) {
- this.mainInstance = mainInstance;
+ public void setMainInstance(WorkflowInstance _mainInstance) {
+ this.mainInstance = _mainInstance;
}
private WorkflowInstance[] instances;
private WorkflowInstance mainInstance;
- public void setInstances(WorkflowInstance[] instances) {
- this.instances = instances;
+ /**
+ * Set the workflow instances
+ * @param _instances The instances
+ */
+ public void setInstances(WorkflowInstance[] _instances) {
+ this.instances = _instances;
}
+ /**
+ * Return the workflow instances
+ * @return The instances
+ */
public WorkflowInstance[] getInstances() {
- return instances;
+ return this.instances;
}
/**
* Returns all executable events.
+ * @param situation
+ * @return
+ * @throws WorkflowException
* @see org.apache.lenya.workflow.WorkflowInstance#getExecutableEvents(org.apache.lenya.workflow.Situation)
*/
public String[] getExecutableEvents(Situation situation) throws WorkflowException {
@@ -84,17 +96,17 @@
getLogger().debug("Resolving executable events");
}
- WorkflowInstance[] instances = getInstances();
- if (instances.length == 0) {
+ WorkflowInstance[] _instances = getInstances();
+ if (_instances.length == 0) {
throw new WorkflowException("The set must contain at least one workflow instance!");
}
- String[] events = mainInstance.getExecutableEvents(situation);
+ String[] events = this.mainInstance.getExecutableEvents(situation);
Set executableEvents = new HashSet(Arrays.asList(events));
for (int i = 0; i < events.length; i++) {
String event = events[i];
- if (mainInstance.isSynchronized(event)) {
+ if (this.mainInstance.isSynchronized(event)) {
boolean canFire = true;
if (getLogger().isDebugEnabled()) {
@@ -102,10 +114,10 @@
}
boolean sameState = true;
- State currentState = mainInstance.getCurrentState();
+ State currentState = this.mainInstance.getCurrentState();
int j = 0;
- while (j < instances.length && sameState) {
- sameState = instances[j].getCurrentState().equals(currentState);
+ while (j < _instances.length && sameState) {
+ sameState = _instances[j].getCurrentState().equals(currentState);
j++;
}
if (getLogger().isDebugEnabled()) {
@@ -113,9 +125,9 @@
}
if (sameState) {
- for (int k = 0; k < instances.length; k++) {
- WorkflowInstanceImpl instance = (WorkflowInstanceImpl) instances[k];
- if (instance != mainInstance
+ for (int k = 0; k < _instances.length; k++) {
+ WorkflowInstanceImpl instance = (WorkflowInstanceImpl) _instances[k];
+ if (instance != this.mainInstance
&& !instance.getNextTransition(event).canFire(situation, instance)) {
canFire = false;
if (getLogger().isDebugEnabled()) {
@@ -146,6 +158,9 @@
/**
* Invokes an event on all documents.
+ * @param situation The situation
+ * @param event The event
+ * @throws WorkflowException if an error occurs
* @see org.apache.lenya.workflow.WorkflowInstance#invoke(org.apache.lenya.workflow.Situation,
* java.lang.String)
*/
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/TransitionImpl.java Tue Feb 8 10:13:39 2005
@@ -44,8 +44,8 @@
* @param destinationState The destination state.
*/
protected TransitionImpl(StateImpl sourceState, StateImpl destinationState) {
- source = sourceState;
- destination = destinationState;
+ this.source = sourceState;
+ this.destination = destinationState;
}
private List actions = new ArrayList();
@@ -56,7 +56,7 @@
* @return An array of actions.
*/
public Action[] getActions() {
- return (Action[]) actions.toArray(new Action[actions.size()]);
+ return (Action[]) this.actions.toArray(new Action[this.actions.size()]);
}
/**
@@ -64,7 +64,7 @@
* @param action The action.
*/
public void addAction(Action action) {
- actions.add(action);
+ this.actions.add(action);
}
private List conditions = new ArrayList();
@@ -74,7 +74,7 @@
* @return An array of conditions.
*/
public Condition[] getConditions() {
- return (Condition[]) conditions.toArray(new Condition[conditions.size()]);
+ return (Condition[]) this.conditions.toArray(new Condition[this.conditions.size()]);
}
/**
@@ -82,7 +82,7 @@
* @param condition The condition.
*/
public void addCondition(Condition condition) {
- conditions.add(condition);
+ this.conditions.add(condition);
}
private Event event;
@@ -92,7 +92,7 @@
* @return An event.
*/
public Event getEvent() {
- return event;
+ return this.event;
}
/**
@@ -100,7 +100,7 @@
* @param anEvent An event.
*/
public void setEvent(Event anEvent) {
- event = anEvent;
+ this.event = anEvent;
}
private StateImpl source;
@@ -110,7 +110,7 @@
* @return A state.
*/
public StateImpl getSource() {
- return source;
+ return this.source;
}
private StateImpl destination;
@@ -120,7 +120,7 @@
* @return A state.
*/
public StateImpl getDestination() {
- return destination;
+ return this.destination;
}
/**
@@ -131,14 +131,14 @@
* @return A boolean value.
*/
public boolean canFire(Situation situation, WorkflowInstance instance) throws WorkflowException {
- Condition[] conditions = getConditions();
+ Condition[] _conditions = getConditions();
boolean canFire = true;
int i = 0;
- while (canFire && i < conditions.length) {
- canFire = canFire && conditions[i].isComplied(situation, instance);
+ while (canFire && i < _conditions.length) {
+ canFire = canFire && _conditions[i].isComplied(situation, instance);
if (getLogger().isDebugEnabled()) {
- getLogger().debug("Condition [" + conditions[i] + "] returns [" + canFire + "]");
+ getLogger().debug("Condition [" + _conditions[i] + "] returns [" + canFire + "]");
}
i++;
}
@@ -150,34 +150,35 @@
* @see java.lang.Object#toString()
*/
public String toString() {
- String string = getEvent().getName() + " [";
- Condition[] conditions = getConditions();
+ StringBuffer buf = new StringBuffer();
+ buf.append(getEvent().getName() + " [");
+ Condition[] _conditions = getConditions();
- for (int i = 0; i < conditions.length; i++) {
+ for (int i = 0; i < _conditions.length; i++) {
if (i > 0) {
- string += ", ";
+ buf.append(", ");
}
- string += conditions[i].toString();
+ buf.append(_conditions[i].toString());
}
- string += "]";
+ buf.append("]");
- Action[] actions = getActions();
+ Action[] _actions = getActions();
- if (actions.length > 0) {
- string += " / ";
+ if (_actions.length > 0) {
+ buf.append(" / ");
- for (int i = 0; i < actions.length; i++) {
+ for (int i = 0; i < _actions.length; i++) {
if (i > 0) {
- string += ", ";
+ buf.append(", ");
}
- string += actions[i].toString();
+ buf.append(_actions[i].toString());
}
}
- return string;
+ return buf.toString();
}
/**
@@ -185,15 +186,15 @@
* @return A boolean value.
*/
public boolean isSynchronized() {
- return isSynchronized;
+ return this.isSynchronized;
}
/**
* Sets if this transition is synchronized.
- * @param isSynchronized A boolean value.
+ * @param _isSynchronized A boolean value.
*/
- protected void setSynchronized(boolean isSynchronized) {
- this.isSynchronized = isSynchronized;
+ protected void setSynchronized(boolean _isSynchronized) {
+ this.isSynchronized = _isSynchronized;
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/Version.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/Version.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/Version.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/Version.java Tue Feb 8 10:13:39 2005
@@ -35,7 +35,7 @@
* @return An event.
*/
public Event getEvent() {
- return event;
+ return this.event;
}
/**
@@ -43,17 +43,17 @@
* @return A state.
*/
public State getState() {
- return state;
+ return this.state;
}
/**
* Ctor.
- * @param event The event that caused the version change.
- * @param state The destination state.
+ * @param _event The event that caused the version change.
+ * @param _state The destination state.
*/
- public Version(Event event, State state) {
- this.event = event;
- this.state = state;
+ public Version(Event _event, State _state) {
+ this.event = _event;
+ this.state = _state;
}
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowBuilder.java Tue Feb 8 10:13:39 2005
@@ -20,12 +20,9 @@
package org.apache.lenya.workflow.impl;
import java.io.File;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
@@ -38,7 +35,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
/**
* Utility class to build a workflow schema from a file.
@@ -79,13 +75,9 @@
* @param name The workflow name.
* @param document The XML document.
* @return A workflow implementation.
- * @throws ParserConfigurationException when something went wrong.
- * @throws SAXException when something went wrong.
- * @throws IOException when something went wrong.
* @throws WorkflowException when something went wrong.
*/
- protected WorkflowImpl buildWorkflow(String name, Document document) throws ParserConfigurationException,
- SAXException, IOException, WorkflowException {
+ protected WorkflowImpl buildWorkflow(String name, Document document) throws WorkflowException {
Element root = document.getDocumentElement();
StateImpl initialState = null;
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowImpl.java Tue Feb 8 10:13:39 2005
@@ -36,13 +36,13 @@
/**
* Creates a new instance of WorkflowImpl.
- * @param name The name.
- * @param initialState the initial state of the workflow.
+ * @param _name The name.
+ * @param _initialState the initial state of the workflow.
*/
- protected WorkflowImpl(String name, StateImpl initialState) {
- this.initialState = initialState;
- this.name = name;
- addState(initialState);
+ protected WorkflowImpl(String _name, StateImpl _initialState) {
+ this.initialState = _initialState;
+ this.name = _name;
+ addState(_initialState);
}
private State initialState;
@@ -54,7 +54,7 @@
*
*/
public State getInitialState() {
- return initialState;
+ return this.initialState;
}
private Set transitions = new HashSet();
@@ -65,7 +65,7 @@
* @param state A state.
*/
private void addState(StateImpl state) {
- states.put(state.getId(), state);
+ this.states.put(state.getId(), state);
}
/**
@@ -73,7 +73,7 @@
* @param transition The transition.
*/
protected void addTransition(TransitionImpl transition) {
- transitions.add(transition);
+ this.transitions.add(transition);
addState(transition.getSource());
addState(transition.getDestination());
}
@@ -83,7 +83,7 @@
* @return An array of transitions.
*/
protected TransitionImpl[] getTransitions() {
- return (TransitionImpl[]) transitions.toArray(new TransitionImpl[transitions.size()]);
+ return (TransitionImpl[]) this.transitions.toArray(new TransitionImpl[this.transitions.size()]);
}
/**
@@ -104,11 +104,11 @@
*/
public Transition[] getLeavingTransitions(State state) {
Set leavingTransitions = new HashSet();
- TransitionImpl[] transitions = getTransitions();
+ TransitionImpl[] _transitions = getTransitions();
- for (int i = 0; i < transitions.length; i++) {
- if (transitions[i].getSource() == state) {
- leavingTransitions.add(transitions[i]);
+ for (int i = 0; i < _transitions.length; i++) {
+ if (_transitions[i].getSource() == state) {
+ leavingTransitions.add(_transitions[i]);
}
}
@@ -122,7 +122,7 @@
* otherwise.
*/
protected boolean containsState(State state) {
- return states.containsValue(state);
+ return this.states.containsValue(state);
}
/**
@@ -130,21 +130,21 @@
* @return An array of states.
*/
protected StateImpl[] getStates() {
- return (StateImpl[]) states.values().toArray(new StateImpl[states.size()]);
+ return (StateImpl[]) this.states.values().toArray(new StateImpl[this.states.size()]);
}
/**
* Returns the state with a certain name.
- * @param name The state name.
+ * @param _name The state name.
* @return A state.
* @throws WorkflowException when the state does not exist.
*/
- protected StateImpl getState(String name) throws WorkflowException {
- if (!states.containsKey(name)) {
- throw new WorkflowException("Workflow does not contain the state '" + name + "'!");
+ protected StateImpl getState(String _name) throws WorkflowException {
+ if (!this.states.containsKey(_name)) {
+ throw new WorkflowException("Workflow does not contain the state '" + _name + "'!");
}
- return (StateImpl) states.get(name);
+ return (StateImpl) this.states.get(_name);
}
private Map events = new HashMap();
@@ -154,21 +154,21 @@
* @param event An event.
*/
protected void addEvent(EventImpl event) {
- events.put(event.getName(), event);
+ this.events.put(event.getName(), event);
}
/**
* Returns the event for a certain event name.
- * @param name A string.
+ * @param _name A string.
* @return The event with this name.
* @throws WorkflowException when no event with the given name exists.
*/
- public EventImpl getEvent(String name) throws WorkflowException {
- if (!events.containsKey(name)) {
- throw new WorkflowException("Workflow does not contain the event '" + name + "'!");
+ public EventImpl getEvent(String _name) throws WorkflowException {
+ if (!this.events.containsKey(_name)) {
+ throw new WorkflowException("Workflow does not contain the event '" + _name + "'!");
}
- return (EventImpl) events.get(name);
+ return (EventImpl) this.events.get(_name);
}
private Map variables = new HashMap();
@@ -178,21 +178,21 @@
* @param variable A variable.
*/
protected void addVariable(BooleanVariableImpl variable) {
- variables.put(variable.getName(), variable);
+ this.variables.put(variable.getName(), variable);
}
/**
* Returns the variable for a certain name.
- * @param name The name of the variable.
+ * @param _name The name of the variable.
* @return A variable.
* @throws WorkflowException if no variable with the given name exists.
*/
- public BooleanVariableImpl getVariable(String name) throws WorkflowException {
- if (!variables.containsKey(name)) {
- throw new WorkflowException("Workflow does not contain the variable '" + name + "'!");
+ public BooleanVariableImpl getVariable(String _name) throws WorkflowException {
+ if (!this.variables.containsKey(_name)) {
+ throw new WorkflowException("Workflow does not contain the variable '" + _name + "'!");
}
- return (BooleanVariableImpl) variables.get(name);
+ return (BooleanVariableImpl) this.variables.get(_name);
}
/**
@@ -200,7 +200,7 @@
* @return An array of variables.
*/
protected BooleanVariableImpl[] getVariables() {
- return (BooleanVariableImpl[]) variables.values().toArray(new BooleanVariableImpl[variables
+ return (BooleanVariableImpl[]) this.variables.values().toArray(new BooleanVariableImpl[this.variables
.size()]);
}
@@ -208,10 +208,10 @@
* @see org.apache.lenya.workflow.Workflow#getVariableNames()
*/
public String[] getVariableNames() {
- BooleanVariableImpl[] variables = getVariables();
- String[] names = new String[variables.length];
+ BooleanVariableImpl[] _variables = getVariables();
+ String[] names = new String[_variables.length];
for (int i = 0; i < names.length; i++) {
- names[i] = variables[i].getName();
+ names[i] = _variables[i].getName();
}
return names;
}
Modified: lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/workflow/impl/WorkflowInstanceImpl.java Tue Feb 8 10:13:39 2005
@@ -48,10 +48,10 @@
/**
* Creates a new instance of WorkflowInstanceImpl.
- * @param workflow The workflow implementation to use.
+ * @param _workflow The workflow implementation to use.
*/
- protected WorkflowInstanceImpl(WorkflowImpl workflow) {
- this.workflow = workflow;
+ protected WorkflowInstanceImpl(WorkflowImpl _workflow) {
+ this.workflow = _workflow;
initVariableInstances();
}
@@ -94,7 +94,7 @@
* @return A workflow object.
*/
protected WorkflowImpl getWorkflowImpl() {
- return workflow;
+ return this.workflow;
}
/**
@@ -238,14 +238,14 @@
* Initializes the variable instances in the initial state.
*/
protected void initVariableInstances() {
- variableInstances.clear();
+ this.variableInstances.clear();
BooleanVariable[] variables = getWorkflowImpl().getVariables();
for (int i = 0; i < variables.length; i++) {
BooleanVariableInstance instance = new BooleanVariableInstanceImpl();
instance.setValue(variables[i].getInitialValue());
- variableInstances.put(variables[i], instance);
+ this.variableInstances.put(variables[i], instance);
}
}
@@ -301,8 +301,8 @@
* @see org.apache.lenya.workflow.WorkflowInstance#addWorkflowListener(org.apache.lenya.workflow.WorkflowListener)
*/
public void addWorkflowListener(WorkflowListener listener) {
- if (!listeners.contains(listener)) {
- listeners.add(listener);
+ if (!this.listeners.contains(listener)) {
+ this.listeners.add(listener);
}
}
@@ -310,7 +310,7 @@
* @see org.apache.lenya.workflow.WorkflowInstance#removeWorkflowListener(org.apache.lenya.workflow.WorkflowListener)
*/
public void removeWorkflowListener(WorkflowListener listener) {
- listeners.remove(listener);
+ this.listeners.remove(listener);
}
/**
Modified: lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/DocumentHelper.java Tue Feb 8 10:13:39 2005
@@ -56,7 +56,6 @@
public class DocumentHelper {
/**
* Creates a non-validating and namespace-aware DocumentBuilder.
- *
* @return A new DocumentBuilder object.
* @throws ParserConfigurationException if an error occurs
*/
@@ -73,16 +72,13 @@
/**
* Creates a document. A xmlns:prefix="namespaceUri" attribute is added to
* the document element.
- *
* @param namespaceUri The namespace URL of the root element.
* @param qualifiedName The qualified name of the root element.
* @param documentType The type of document to be created or null. When doctype is not null,
* its Node.ownerDocument attribute is set to the document being created.
* @return A new Document object.
- *
* @throws DOMException if an error occurs
* @throws ParserConfigurationException if an error occurs
- *
* @see org.w3c.dom.DOMImplementation#createDocument(String, String, DocumentType)
*/
public static Document createDocument(String namespaceUri, String qualifiedName,
@@ -108,7 +104,6 @@
* Reads a document from a file.
* @return A document.
* @param file The file to load the document from.
- *
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
@@ -123,7 +118,6 @@
* Reads a document from a URL.
* @return A document.
* @param url The URL to load the document from.
- *
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
@@ -138,7 +132,6 @@
* Reads a document from a URI.
* @return A document.
* @param uri The URI to load the document from.
- *
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
@@ -153,7 +146,6 @@
* Reads a document from a string.
* @return A document.
* @param string The string to load the document from.
- *
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
@@ -168,7 +160,6 @@
* Reads a document from an input stream.
* @return A document.
* @param stream The input stream to load the document from.
- *
* @throws ParserConfigurationException if an error occurs
* @throws SAXException if an error occurs
* @throws IOException if an error occurs
@@ -181,10 +172,8 @@
/**
* Writes a document to a file. A new file is created if it does not exist.
- *
* @param document The document to save.
* @param file The file to save the document to.
- *
* @throws IOException if an error occurs
* @throws TransformerConfigurationException if an error occurs
* @throws TransformerException if an error occurs
@@ -201,16 +190,13 @@
/**
* Writes a document to a writer.
- *
* @param document The document to write.
* @param writer The writer to write the document to.
- *
- * @throws IOException if an error occurs
* @throws TransformerConfigurationException if an error occurs
* @throws TransformerException if an error occurs
*/
public static void writeDocument(Document document, Writer writer)
- throws TransformerConfigurationException, TransformerException, IOException {
+ throws TransformerConfigurationException, TransformerException {
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(writer);
getTransformer(document.getDoctype()).transform(source, result);
@@ -218,10 +204,8 @@
/**
* Get the tranformer.
- *
* @param documentType the document type
* @return a transformer
- *
* @throws TransformerConfigurationException if an error occurs
*/
protected static Transformer getTransformer(DocumentType documentType)
@@ -241,15 +225,11 @@
/**
* Creates a document type.
- *
* @param qualifiedName The qualified name of the document type.
* @param publicId The public identifier.
* @param systemId The system identifier.
- *
* @return the document type
- *
* @throws ParserConfigurationException if an error occurs
- *
* @see org.w3c.dom.DOMImplementation#createDocumentType(java.lang.String, java.lang.String, java.lang.String)
*/
public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId)
@@ -273,11 +253,9 @@
/**
* Returns the first child element of an element that belongs to a certain namespace
* and has a certain local name or <code>null</code> if none exists.
- *
* @param element The parent element.
* @param namespaceUri The namespace that the childen must belong to.
* @param localName The local name of the children.
- *
* @return The child element or <code>null</code> if none exists.
*/
public static Element getFirstChild(Element element, String namespaceUri, String localName) {
@@ -285,9 +263,8 @@
if (children.length > 0) {
return children[0];
- } else {
- return null;
}
+ return null;
}
/**
@@ -310,10 +287,8 @@
/**
* Returns all child elements of an element that belong to a certain namespace.
- *
* @param element The parent element.
* @param namespaceUri The namespace that the childen must belong to.
- *
* @return The child elements.
*/
public static Element[] getChildren(Element element, String namespaceUri) {
@@ -323,11 +298,9 @@
/**
* Returns all child elements of an element that belong to a certain namespace
* and have a certain local name.
- *
* @param element The parent element.
* @param namespaceUri The namespace that the childen must belong to.
* @param localName The local name of the children.
- *
* @return The child elements.
*/
public static Element[] getChildren(Element element, String namespaceUri, String localName) {
@@ -366,7 +339,6 @@
/**
* Replaces all child nodes of an element by a single text node.
- *
* @param element The element.
* @param text The text to insert.
*/
@@ -385,10 +357,8 @@
/**
* Returns all following sibling elements of an element that belong to a certain namespace.
- *
* @param element The parent element.
* @param namespaceUri The namespace that the childen must belong to.
- *
* @return The following sibling elements.
*/
public static Element[] getNextSiblings(Element element, String namespaceUri) {
@@ -398,11 +368,9 @@
/**
* Returns all following sibling elements of an element that belong to a certain namespace.
* and have a certain local name.
- *
* @param element The parent element.
* @param namespaceUri The namespace that the childen must belong to.
* @param localName The local name of the children.
- *
* @return The following sibling elements.
*/
public static Element[] getNextSiblings(Element element, String namespaceUri, String localName) {
Modified: lenya/trunk/src/java/org/apache/lenya/xml/NamespaceHelper.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/xml/NamespaceHelper.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/NamespaceHelper.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/NamespaceHelper.java Tue Feb 8 10:13:39 2005
@@ -29,7 +29,7 @@
/**
* A NamespaceHelper object simplifies the creation of elements in a certain
* namespace. All elements are owned by a document that is passed to the
- * {@link #NamespaceHelper(Document, String, String)} constructor or created
+ * {@link #NamespaceHelper(String, String, Document)} constructor or created
* using the {@link #NamespaceHelper(String, String, String)} constructor.
*/
public class NamespaceHelper {
@@ -40,15 +40,14 @@
/**
* Creates a new instance of NamespaceHelper using an existing document. The
* document is not affected. If you omit the prefix, the default namespace is used.
- *
- * @param document The document.
- * @param namespaceUri The namespace URI.
- * @param prefix The namespace prefix.
- */
- public NamespaceHelper(String namespaceUri, String prefix, Document document) {
- this.namespaceUri = namespaceUri;
- this.prefix = prefix;
- this.document = document;
+ * @param _document The document.
+ * @param _namespaceUri The namespace URI.
+ * @param _prefix The namespace prefix.
+ */
+ public NamespaceHelper(String _namespaceUri, String _prefix, Document _document) {
+ this.namespaceUri = _namespaceUri;
+ this.prefix = _prefix;
+ this.document = _document;
}
/**
@@ -63,70 +62,62 @@
* <svg:svg xmlns:svg="http://www.w3.org/2000/svg"><br/>
* </svg:svg>
* </p>
- *
* @param localName The local name of the document element.
- * @param namespaceUri The namespace URI.
- * @param prefix The namespace prefix.
- *
+ * @param _namespaceUri The namespace URI.
+ * @param _prefix The namespace prefix.
* @throws ParserConfigurationException if an error occured
*/
- public NamespaceHelper(String namespaceUri, String prefix, String localName)
+ public NamespaceHelper(String _namespaceUri, String _prefix, String localName)
throws ParserConfigurationException {
- this.namespaceUri = namespaceUri;
- this.prefix = prefix;
+ this.namespaceUri = _namespaceUri;
+ this.prefix = _prefix;
setDocument(DocumentHelper.createDocument(getNamespaceURI(), getQualifiedName(localName),
null));
}
/**
* Sets the document of this NamespaceHelper.
- *
- * @param document the document
+ * @param _document the document
*/
- protected void setDocument(Document document) {
- this.document = document;
+ protected void setDocument(Document _document) {
+ this.document = _document;
}
/**
* Returns the document that is used to create elements.
- *
* @return A document object.
*/
public Document getDocument() {
- return document;
+ return this.document;
}
/**
* Returns the namespace URI of this NamespaceHelper.
- *
* @return The namespace URI.
*/
public String getNamespaceURI() {
- return namespaceUri;
+ return this.namespaceUri;
}
/**
* Returns the namespace prefix that is used to create elements.
- *
* @return The namespace prefix.
*/
public String getPrefix() {
- return prefix;
+ return this.prefix;
}
/**
* Returns the qualified name for a local name using the prefix of this
* NamespaceHelper.
- *
* @param localName The local name.
* @return The qualified name, i.e. prefix:localName.
*/
public String getQualifiedName(String localName) {
if (getPrefix().equals("")) {
return localName;
- } else {
- return getPrefix() + ":" + localName;
}
+ return getPrefix() + ":" + localName;
}
/**
@@ -137,7 +128,6 @@
* <p>
* <code>createElement("text")</code>: <code><prefix:text/><code>.
* </p>
- *
* @param localName The local name of the element.
* @return A new element.
*/
@@ -154,7 +144,6 @@
* <code>createElement("text", "Hello World!")</code>:
* <code><prefix:text>Hello World!</prefix:text></code>.
* </p>
- *
* @param localName The local name of the element.
* @param text The text for the text node inside the element.
* @return A new element containing a text node.
@@ -170,9 +159,7 @@
/**
* Returns all children of an element in the namespace
* of this NamespaceHelper.
- *
* @param element The parent element.
- *
* @return the children.
*/
public Element[] getChildren(Element element) {
@@ -182,10 +169,8 @@
/**
* Returns all children of an element with a local name in the namespace
* of this NamespaceHelper.
- *
* @param element The parent element.
* @param localName The local name of the children to return.
- *
* @return the children.
*/
public Element[] getChildren(Element element, String localName) {
@@ -195,10 +180,8 @@
/**
* Returns the first childr of an element with a local name in the namespace
* of this NamespaceHelper or <code>null</code> if none exists.
- *
* @param element The parent element.
* @param localName The local name of the children to return.
- *
* @return the first child.
*/
public Element getFirstChild(Element element, String localName) {
@@ -208,10 +191,8 @@
/**
* Returns the next siblings of an element with a local name in the namespace
* of this NamespaceHelper or <code>null</code> if none exists.
- *
* @param element The parent element.
* @param localName The local name of the children to return.
- *
* @return the next siblings.
*/
public Element[] getNextSiblings(Element element, String localName) {
Modified: lenya/trunk/src/java/org/apache/lenya/xml/RelaxNG.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/xml/RelaxNG.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/RelaxNG.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/RelaxNG.java Tue Feb 8 10:13:39 2005
@@ -35,16 +35,17 @@
import com.thaiopensource.validate.auto.AutoSchemaReader;
import com.thaiopensource.xml.sax.ErrorHandlerImpl;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
/**
* Validate XML Document with RELAX NG Schema
*/
public class RelaxNG {
- static Category log = Category.getInstance(RelaxNG.class);
+ private static final Logger log = Logger.getLogger(RelaxNG.class);
/**
- *
+ * Command line interface
+ * @param args Command line args
*/
public static void main(String[] args) {
if (args.length == 0) {
@@ -59,8 +60,8 @@
} else {
System.out.println("Document not valid: " + message);
}
- } catch (Exception e) {
- System.err.println("" + e);
+ } catch (IOException e) {
+ log.error("" +e.toString());
}
}
@@ -69,9 +70,9 @@
* @param schema The schema file.
* @param xml The XML file.
* @return A string. FIXME: what does this mean?
- * @throws Exception if an error occurs.
+ * @throws IOException if an error occurs.
*/
- public static String validate(File schema, File xml) throws Exception {
+ public static String validate(File schema, File xml) throws IOException {
InputSource schemaInputSource = ValidationDriver.uriOrFileInputSource(schema
.getAbsolutePath());
@@ -85,27 +86,34 @@
* @param schemaInputSource The schema input source.
* @param xmlInputSource The XML input source.
* @return A string.
- * @throws Exception if an error occurs.
+ * @throws IOException if an error occurs.
*/
public static String validate(InputSource schemaInputSource, InputSource xmlInputSource)
- throws Exception {
- PropertyMapBuilder properties = new PropertyMapBuilder();
- ByteArrayOutputStream error = new ByteArrayOutputStream();
- ErrorHandlerImpl eh = new ErrorHandlerImpl(
- new BufferedWriter(new OutputStreamWriter(error)));
- ValidateProperty.ERROR_HANDLER.put(properties, eh);
- SchemaReader schemaReader = new AutoSchemaReader();
- ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
- if (driver.loadSchema(schemaInputSource)) {
- if (driver.validate(xmlInputSource)) {
- log.debug("" + error);
- return null;
- } else {
- log.error("" + error);
- return "" + error;
+ throws IOException {
+ ByteArrayOutputStream error;
+ try {
+ PropertyMapBuilder properties = new PropertyMapBuilder();
+ error = new ByteArrayOutputStream();
+ ErrorHandlerImpl eh = new ErrorHandlerImpl(
+ new BufferedWriter(new OutputStreamWriter(error)));
+ ValidateProperty.ERROR_HANDLER.put(properties, eh);
+ SchemaReader schemaReader = new AutoSchemaReader();
+ ValidationDriver driver = new ValidationDriver(properties.toPropertyMap(), schemaReader);
+ if (driver.loadSchema(schemaInputSource)) {
+ if (driver.validate(xmlInputSource)) {
+ log.debug("" + error);
+ return null;
+ }
+ log.error("" + error);
+ return "" + error;
}
- } else {
- throw new Exception("Could not load schema!\n" + error);
+ throw new IOException("Could not load schema!\n" + error);
+ } catch (final SAXException e) {
+ log.error("" +e.toString());
+ throw new IOException("Could not load schema!\n" + e);
+ } catch (final IOException e) {
+ log.error("" +e.toString());
+ throw new IOException("Could not load schema!\n" + e);
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/xml/XLink.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/xml/XLink.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/XLink.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/XLink.java Tue Feb 8 10:13:39 2005
@@ -20,67 +20,96 @@
package org.apache.lenya.xml;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
+/**
+ * Helper class for XLinks
+ */
public class XLink {
+ /**
+ * <code>type</code> The Xlink type
+ */
public String type = null;
+ /**
+ * <code>href</code> The XLink href
+ */
public String href = null;
+ /**
+ * <code>show</code> The value of the show attribute
+ */
public String show = null;
+ /**
+ * <code>name</code> The Xlink name
+ */
public String name = null;
+ /**
+ * <code>element</code> The Xlink element
+ */
public Element element = null;
-
+ /**
+ * <code>XLINK_NAMESPACE</code> The XLink namespace
+ */
public static final String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
+ /**
+ * <code>ATTRIBUTE_HREF</code> The href attribte
+ */
public static final String ATTRIBUTE_HREF = "href";
+ /**
+ * <code>ATTRIBUTE_SHOW</code> The show attribute
+ */
public static final String ATTRIBUTE_SHOW = "show";
+ /**
+ * <code>ATTRIBUTE_TYPE</code> The type attribute
+ */
public static final String ATTRIBUTE_TYPE = "type";
/**
- *
+ * Constructor
*/
public XLink() {
- type = "simple";
- show = "undefined";
+ this.type = "simple";
+ this.show = "undefined";
}
/**
- *
+ * Constructor
+ * @param _element The element
*/
- public XLink(Element element) {
+ public XLink(Element _element) {
this();
- this.element = element;
+ this.element = _element;
- name = element.getNodeName();
+ this.name = _element.getNodeName();
- Attr hrefAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_HREF);
+ Attr hrefAttribute = _element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_HREF);
if (hrefAttribute != null) {
- href = hrefAttribute.getNodeValue();
+ this.href = hrefAttribute.getNodeValue();
}
- Attr typeAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_TYPE);
+ Attr typeAttribute = _element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_TYPE);
if (typeAttribute != null) {
- type = typeAttribute.getNodeValue();
+ this.type = typeAttribute.getNodeValue();
}
- Attr showAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_SHOW);
+ Attr showAttribute = _element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_SHOW);
if (showAttribute != null) {
- show = showAttribute.getNodeValue();
+ this.show = showAttribute.getNodeValue();
}
}
-
/**
- *
+ * Returns a printout of the XLink values
+ * @return The printout
*/
public String toString() {
return "XLink: type=\""
- + type
+ + this.type
+ "\", href=\""
- + href
+ + this.href
+ "\", show=\""
- + show
+ + this.show
+ "\", name=\""
- + name
+ + this.name
+ "\"";
}
}
Modified: lenya/trunk/src/java/org/apache/lenya/xml/XPath.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/xml/XPath.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/xml/XPath.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/xml/XPath.java Tue Feb 8 10:13:39 2005
@@ -23,82 +23,87 @@
import org.w3c.dom.Node;
+/**
+ * Helper class for XPath operations
+ */
public class XPath {
String xpath = null;
String[] parts = null;
/**
- *
+ * Constructor
+ * @param _xpath The Xpath
*/
- public XPath(String xpath) {
- this.xpath = xpath;
+ public XPath(String _xpath) {
+ this.xpath = _xpath;
- StringTokenizer st = new StringTokenizer(xpath, "/");
+ StringTokenizer st = new StringTokenizer(_xpath, "/");
int length = st.countTokens();
- parts = new String[length];
+ this.parts = new String[length];
for (int i = 0; i < length; i++) {
- parts[i] = st.nextToken();
+ this.parts[i] = st.nextToken();
}
}
/**
- *
+ * Get the parent path
+ * @return The parent path
*/
public XPath getParent() {
- String parentXPath = "";
+ StringBuffer buf = new StringBuffer();
- for (int i = 0; i < (parts.length - 1); i++) {
- parentXPath = parentXPath + "/" + parts[i];
+ for (int i = 0; i < (this.parts.length - 1); i++) {
+ buf.append("/" + this.parts[i]);
}
- return new XPath(parentXPath);
+ return new XPath(buf.toString());
}
/**
- *
+ * Get the type of a node. Only supports attribute and element nodes
+ * @return The node type
*/
public short getType() {
- if (parts[parts.length - 1].indexOf("@") == 0) {
+ if (this.parts[this.parts.length - 1].indexOf("@") == 0) {
return Node.ATTRIBUTE_NODE;
}
-
return Node.ELEMENT_NODE;
}
/**
- *
+ * Return a string representation of the XPath
+ * @return The Xpath
*/
public String toString() {
- return xpath;
+ return this.xpath;
}
/**
- *
+ * Get the name
+ * @return The name
*/
public String getName() {
if (getType() == Node.ATTRIBUTE_NODE) {
- return parts[parts.length - 1].substring(1);
+ return this.parts[this.parts.length - 1].substring(1);
}
-
- return parts[parts.length - 1];
+ return this.parts[this.parts.length - 1];
}
/**
- * Describe 'getName' method here.
- *
- * @return a value of type 'String'
+ * Return the name of the element
+ * @return the name of the element
*/
public String getElementName() {
if (getType() == Node.ATTRIBUTE_NODE) {
- return parts[parts.length - 2];
+ return this.parts[this.parts.length - 2];
}
-
- return parts[parts.length - 1];
+ return this.parts[this.parts.length - 1];
}
/**
- *
+ * Get the name without predicates
+ * @return The name without predicates
*/
public String getNameWithoutPredicates() {
return removePredicates(getName());
@@ -106,6 +111,8 @@
/**
* Remove predicates (square brackets), http://www.w3.org/TR/xpath
+ * @param s The string to remove predicates from
+ * @return The string without predicates
*/
public String removePredicates(String s) {
int index = s.indexOf("[");
Modified: lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/file/FileGroupTest.java Tue Feb 8 10:13:39 2005
@@ -32,9 +32,17 @@
import org.apache.lenya.cms.PublicationHelper;
import org.xml.sax.SAXException;
+/**
+ * Test for file-based groups
+ */
public class FileGroupTest extends AccessControlTest {
/**
+ * <code>GROUP_ID</code> The group id
+ */
+ public static final String GROUP_ID = "testGroup";
+
+ /**
* Constructor for FileGroupTest.
* @param arg0 command line args
*/
@@ -43,9 +51,9 @@
}
/**
- * DOCUMENT ME!
+ * The command line interface
*
- * @param args DOCUMENT ME!
+ * @param args The command line args
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
@@ -53,12 +61,12 @@
}
/**
- * DOCUMENT ME!
+ * Runs the test
*
- * @throws AccessControlException DOCUMENT ME!
- * @throws ConfigurationException DOCUMENT ME!
- * @throws SAXException DOCUMENT ME!
- * @throws IOException DOCUMENT ME!
+ * @throws AccessControlException if an AC error occurs
+ * @throws ConfigurationException if an error with the configuration occurs
+ * @throws SAXException if a parsing error occurs
+ * @throws IOException if an IO error occurs
*/
final public void testFileGroup()
throws AccessControlException, ConfigurationException, SAXException, IOException {
@@ -83,8 +91,6 @@
assertTrue(newGroup.getId().equals(GROUP_ID));
}
-
- public static final String GROUP_ID = "testGroup";
/**
* Test getGroup
Modified: lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/file/FileUserTest.java Tue Feb 8 10:13:39 2005
@@ -48,9 +48,9 @@
}
/**
- * DOCUMENT ME!
+ * The main method
*
- * @param args DOCUMENT ME!
+ * @param args command line args
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
@@ -66,21 +66,21 @@
}
/**
- * DOCUMENT ME!
+ * Get all Groups
*
- * @return DOCUMENT ME!
+ * @return A map of the groups
*/
final public Map getGroups() {
- return groups;
+ return this.groups;
}
/**
* Create and save a user
*
- * @param userName DOCUMENT ME!
- * @param fullName DOCUMENT ME!
- * @param email DOCUMENT ME!
- * @param password DOCUMENT ME!
+ * @param userName The user name
+ * @param fullName The full name
+ * @param email The email
+ * @param password The password
*
* @return a <code>FileUser</code>
*
@@ -107,8 +107,8 @@
adminGroup.save();
user.save();
- FileUserManager manager = getUserManager();
- manager.add(user);
+ FileUserManager _manager = getUserManager();
+ _manager.add(user);
return user;
}
@@ -120,9 +120,9 @@
*/
protected FileUserManager getUserManager() throws AccessControlException {
UserType[] userTypes = { FileAccreditableManager.getDefaultUserType() };
- FileUserManager manager = FileUserManager.instance(getAccreditablesDirectory(), userTypes,
+ FileUserManager _manager = FileUserManager.instance(getAccreditablesDirectory(), userTypes,
getLogEnabledLogger());
- return manager;
+ return _manager;
}
/**
@@ -135,8 +135,8 @@
* @throws AccessControlException if an error occurs
*/
final public FileUser loadUser(String userName) throws AccessControlException {
- FileUserManager manager = getUserManager();
- return (FileUser) manager.getUser(userName);
+ FileUserManager _manager = getUserManager();
+ return (FileUser) _manager.getUser(userName);
}
/**
@@ -215,13 +215,13 @@
final public void testDelete() throws AccessControlException {
String id = "albert";
FileUser user = createAndSaveUser(id, "Albert Einstein", "albert@physics.org", "secret");
- FileUserManager manager = getUserManager();
- assertNotNull(manager);
+ FileUserManager _manager = getUserManager();
+ assertNotNull(_manager);
- assertNotNull(manager.getUser(id));
+ assertNotNull(_manager.getUser(id));
user.delete();
- manager.remove(user);
- assertNull(manager.getUser(id));
+ _manager.remove(user);
+ assertNull(_manager.getUser(id));
}
/**
@@ -234,10 +234,10 @@
FileUser user = createAndSaveUser("mickey", "Mickey Mouse", "mickey@mouse.com", password);
assertTrue(user.authenticate(password));
- FileUserManager manager = getUserManager();
- assertNotNull(manager);
+ FileUserManager _manager = getUserManager();
+ assertNotNull(_manager);
- User lenya = manager.getUser("lenya");
+ User lenya = _manager.getUser("lenya");
assertNotNull(lenya);
assertTrue(lenya.authenticate("levi"));
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControlTest.java Tue Feb 8 10:13:39 2005
@@ -57,7 +57,7 @@
* @return An access controller.
*/
public DefaultAccessController getAccessController() {
- return accessController;
+ return this.accessController;
}
protected static final String URL = "/test/authoring/index.html";
@@ -72,51 +72,49 @@
super.setUp();
- accessControllerResolverSelector = (ComponentSelector) manager
+ this.accessControllerResolverSelector = (ComponentSelector) this.manager
.lookup(AccessControllerResolver.ROLE + "Selector");
- assertNotNull(accessControllerResolverSelector);
+ assertNotNull(this.accessControllerResolverSelector);
- accessControllerResolver = (AccessControllerResolver) accessControllerResolverSelector
+ this.accessControllerResolver = (AccessControllerResolver) this.accessControllerResolverSelector
.select(AccessControllerResolver.DEFAULT_RESOLVER);
- assertNotNull(accessControllerResolver);
+ assertNotNull(this.accessControllerResolver);
getLogger().info(
- "Using access controller resolver: [" + accessControllerResolver.getClass() + "]");
+ "Using access controller resolver: [" + this.accessControllerResolver.getClass() + "]");
- accessController = (DefaultAccessController) ((PublicationAccessControllerResolver) accessControllerResolver)
+ this.accessController = (DefaultAccessController) ((PublicationAccessControllerResolver) this.accessControllerResolver)
.resolveAccessController(URL);
- assertNotNull(accessController);
- getLogger().info("Resolved access controller: [" + accessController.getClass() + "]");
+ assertNotNull(this.accessController);
+ getLogger().info("Resolved access controller: [" + this.accessController.getClass() + "]");
File servletContext = PublicationHelper.getPublication().getServletContext();
- ((FilePolicyManager) accessController.getPolicyManager())
+ ((FilePolicyManager) this.accessController.getPolicyManager())
.setPoliciesDirectory(servletContext);
- accreditablesDirectory = new File(PublicationHelper.getPublication().getDirectory(),
+ this.accreditablesDirectory = new File(PublicationHelper.getPublication().getDirectory(),
"config/ac/passwd".replace('/', File.separatorChar));
- ((FileAccreditableManager) accessController.getAccreditableManager())
- .setConfigurationDirectory(accreditablesDirectory);
+ ((FileAccreditableManager) this.accessController.getAccreditableManager())
+ .setConfigurationDirectory(this.accreditablesDirectory);
}
/**
* The teardown method for JUnit
- *
- * @exception Exception Description of Exception
- * @since
+ * @exception Exception if an error occurs
*/
public void tearDown() throws Exception {
super.tearDown();
- if (accessControllerResolverSelector != null) {
- if (accessControllerResolver != null) {
- if (accessController != null) {
- accessControllerResolver.release(accessController);
+ if (this.accessControllerResolverSelector != null) {
+ if (this.accessControllerResolver != null) {
+ if (this.accessController != null) {
+ this.accessControllerResolver.release(this.accessController);
}
- accessControllerResolverSelector.release(accessControllerResolver);
+ this.accessControllerResolverSelector.release(this.accessControllerResolver);
}
- manager.release(accessControllerResolver);
+ this.manager.release(this.accessControllerResolver);
}
}
@@ -160,7 +158,7 @@
* @return A file.
*/
protected File getAccreditablesDirectory() {
- return accreditablesDirectory;
+ return this.accreditablesDirectory;
}
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java Tue Feb 8 10:13:39 2005
@@ -15,15 +15,17 @@
*
*/
-/* $Id: AccessControllerTest.java,v 1.2 2004/03/04 15:40:19 egli Exp $ */
+/* $Id$ */
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
-import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.cms.PublicationHelper;
+/**
+ * Access controller test
+ */
public class AccessControllerTest extends AccessControlTest {
/**
@@ -44,9 +46,8 @@
/**
* The test.
- * @throws AccessControlException when something went wrong.
*/
- public void testAccessController() throws AccessControlException {
+ public void testAccessController() {
assertNotNull(getAccessController());
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java Tue Feb 8 10:13:39 2005
@@ -23,6 +23,9 @@
import org.apache.lenya.cms.ExcaliburTest;
import org.apache.lenya.cms.PublicationHelper;
+/**
+ * Test class for the Accreditable Manager
+ */
public class AccreditableManagerTest extends ExcaliburTest {
/**
@@ -58,10 +61,10 @@
super.setUp();
String role = AccreditableManager.ROLE + "Selector";
- selector = (ComponentSelector) manager.lookup(role);
+ this.selector = (ComponentSelector) this.manager.lookup(role);
- accreditableManager = (AccreditableManager) selector.select(HINT);
- assertNotNull("AccreditableManager is null", accreditableManager);
+ this.accreditableManager = (AccreditableManager) this.selector.select(HINT);
+ assertNotNull("AccreditableManager is null", this.accreditableManager);
}
/**
@@ -69,10 +72,9 @@
* @throws AccessControlException when something went wrong.
*/
public void testAccreditableManager() throws AccessControlException {
- assertNotNull(accreditableManager.getUserManager());
- assertNotNull(accreditableManager.getGroupManager());
- assertNotNull(accreditableManager.getRoleManager());
-
+ assertNotNull(this.accreditableManager.getUserManager());
+ assertNotNull(this.accreditableManager.getGroupManager());
+ assertNotNull(this.accreditableManager.getRoleManager());
}
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java Tue Feb 8 10:13:39 2005
@@ -26,7 +26,7 @@
/**
* Group manager test.
*
- * @version $Id:$
+ * @version $Id$
*/
public class GroupManagerTest extends AccessControlTest {
@@ -39,9 +39,9 @@
}
/**
- * DOCUMENT ME!
+ * Command line interface
*
- * @param args DOCUMENT ME!
+ * @param args command line args
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
@@ -49,19 +49,18 @@
}
/**
- * DOCUMENT ME!
- *
- * @throws AccessControlException DOCUMENT ME!
+ * The test
+ * @throws AccessControlException if an error occurs
*/
public final void testInstance() throws AccessControlException {
- FileGroupManager manager = null;
+ FileGroupManager _manager = null;
File configDir = getAccreditablesDirectory();
- manager = FileGroupManager.instance(configDir, getLogEnabledLogger());
- assertNotNull(manager);
+ _manager = FileGroupManager.instance(configDir, getLogEnabledLogger());
+ assertNotNull(_manager);
FileGroupManager anotherManager = null;
anotherManager = FileGroupManager.instance(configDir, getLogEnabledLogger());
assertNotNull(anotherManager);
- assertEquals(manager, anotherManager);
+ assertEquals(_manager, anotherManager);
}
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/IdentityTest.java Tue Feb 8 10:13:39 2005
@@ -22,9 +22,17 @@
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.PublicationHelper;
+/**
+ * Tests the identity
+ */
public class IdentityTest extends AccessControlTest {
/**
+ * <code>USER_ID</code> The user id to test
+ */
+ public static final String USER_ID = "lenya";
+
+ /**
* Ctor.
* @param test The test.
*/
@@ -41,8 +49,6 @@
TestRunner.run(IdentityTest.class);
}
- public static final String USER_ID = "lenya";
-
/**
* Tests the identity.
*
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java Tue Feb 8 10:13:39 2005
@@ -138,10 +138,10 @@
*/
final public LDAPUser loadUser(String userName) throws AccessControlException {
UserType[] userTypes = { FileAccreditableManager.getDefaultUserType() };
- FileUserManager manager = FileUserManager.instance(getAccreditablesDirectory(), userTypes,
+ FileUserManager _manager = FileUserManager.instance(getAccreditablesDirectory(), userTypes,
getLogEnabledLogger());
- return (LDAPUser) manager.getUser(userName);
+ return (LDAPUser) _manager.getUser(userName);
}
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java Tue Feb 8 10:13:39 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: PolicyManagerTest.java,v 1.2 2004/03/04 15:40:19 egli Exp $ */
+/* $Id$ */
package org.apache.lenya.ac.impl;
@@ -26,11 +26,13 @@
import org.apache.lenya.ac.PolicyManager;
import org.apache.lenya.cms.PublicationHelper;
+/**
+ * Test for the Policy Manager
+ */
public class PolicyManagerTest extends AccessControlTest {
/**
* Create an instance of PolicyManagerTest
- *
* @param test a test
*/
public PolicyManagerTest(String test) {
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/PolicyTest.java Tue Feb 8 10:13:39 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: PolicyTest.java,v 1.3 2004/03/04 15:40:19 egli Exp $ */
+/* $Id$ */
package org.apache.lenya.ac.impl;
@@ -31,9 +31,9 @@
import org.apache.lenya.cms.PublicationHelper;
/**
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
+ * Policy Test
+ *
+ * */
public class PolicyTest extends AccessControlTest {
/**
* Executes this test.
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java Tue Feb 8 10:13:39 2005
@@ -26,7 +26,7 @@
/**
* Role manager test.
*
- * @version $Id:$
+ * @version $Id$
*/
public class RoleManagerTest extends AccessControlTest {
/**
@@ -38,9 +38,8 @@
}
/**
- * DOCUMENT ME!
- *
- * @param args DOCUMENT ME!
+ * Command line interface
+ * @param args Command line args
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
@@ -48,69 +47,67 @@
}
/**
- * DOCUMENT ME!
- *
- * @throws AccessControlException DOCUMENT ME!
+ * Run the test
+ * @throws AccessControlException if an error occurs
*/
final public void testInstance() throws AccessControlException {
File configDir = getAccreditablesDirectory();
- FileRoleManager manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
- assertNotNull(manager);
+ FileRoleManager _manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
+ assertNotNull(_manager);
FileRoleManager anotherManager = FileRoleManager.instance(configDir, getLogEnabledLogger());
assertNotNull(anotherManager);
- assertEquals(manager, anotherManager);
+ assertEquals(_manager, anotherManager);
}
/**
- * DOCUMENT ME!
+ * Test getRoles()
*/
final public void testGetRoles() {
+ // do nothing
}
/**
* Test add(Role)
- *
* @throws AccessControlException if an error occurs
*/
final public void testAddRole() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String name = "test";
- FileRoleManager manager = null;
- manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
- assertNotNull(manager);
- Role role = new FileRole(manager.getConfigurationDirectory(), name);
- manager.add(role);
+ FileRoleManager _manager = null;
+ _manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
+ assertNotNull(_manager);
+ Role role = new FileRole(_manager.getConfigurationDirectory(), name);
+ _manager.add(role);
- assertTrue(manager.getRoles().length > 0);
+ assertTrue(_manager.getRoles().length > 0);
}
/**
* Test for void remove(Role)
* @throws AccessControlException if an error occurs.
- *
*/
final public void testRemoveRole() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String name = "test2";
Role role = new FileRole(configDir, name);
- FileRoleManager manager = null;
+ FileRoleManager _manager = null;
try {
- manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
+ _manager = FileRoleManager.instance(configDir, getLogEnabledLogger());
} catch (AccessControlException e) {
e.printStackTrace();
}
- assertNotNull(manager);
+ assertNotNull(_manager);
- Role[] roles = manager.getRoles();
+ Role[] roles = _manager.getRoles();
int roleCountBefore = roles.length;
- manager.add(role);
- manager.remove(role);
+ _manager.add(role);
+ _manager.remove(role);
- roles = manager.getRoles();
+ roles = _manager.getRoles();
int roleCountAfter = roles.length;
assertEquals(roleCountBefore, roleCountAfter);
Modified: lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java?view=diff&r1=152681&r2=152682
==============================================================================
--- lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java (original)
+++ lenya/trunk/src/test/org/apache/lenya/ac/impl/UserManagerTest.java Tue Feb 8 10:13:39 2005
@@ -47,9 +47,8 @@
}
/**
- * DOCUMENT ME!
- *
- * @param args DOCUMENT ME!
+ * Command line interface
+ * @param args Command line args
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
@@ -57,7 +56,6 @@
}
/**
- * (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
@@ -65,22 +63,20 @@
}
/**
- * DOCUMENT ME!
- *
- * @throws AccessControlException DOCUMENT ME!
+ * Run the test
+ * @throws AccessControlException if an error occurs
*/
final public void testInstance() throws AccessControlException {
File configDir = getAccreditablesDirectory();
UserType[] userTypes = { FileAccreditableManager.getDefaultUserType() };
- FileUserManager manager = FileUserManager.instance(configDir, userTypes,
+ FileUserManager _manager = FileUserManager.instance(configDir, userTypes,
getLogEnabledLogger());
- assertNotNull(manager);
+ assertNotNull(_manager);
}
/**
- * DOCUMENT ME!
- *
- * @throws AccessControlException DOCUMENT ME!
+ * Load the configuration for the test
+ * @throws AccessControlException if an error occurs
*/
final public void testLoadConfig() throws AccessControlException {
File configDir = getAccreditablesDirectory();
@@ -131,9 +127,8 @@
}
/**
- * DOCUMENT ME!
- *
- * @throws AccessControlException DOCUMENT ME!
+ * Test getUser()
+ * @throws AccessControlException if an error occurs
*/
final public void testGetUser() throws AccessControlException {
File configDir = getAccreditablesDirectory();
@@ -141,12 +136,12 @@
FileUser user = new FileUser(configDir, userName, "Alice in Wonderland",
"alice@wonderland.com", "secret");
UserType[] userTypes = { FileAccreditableManager.getDefaultUserType() };
- FileUserManager manager = FileUserManager.instance(configDir, userTypes,
+ FileUserManager _manager = FileUserManager.instance(configDir, userTypes,
getLogEnabledLogger());
- assertNotNull(manager);
- manager.add(user);
+ assertNotNull(_manager);
+ _manager.add(user);
- User otherUser = manager.getUser(userName);
+ User otherUser = _manager.getUser(userName);
assertEquals(user, otherUser);
assertEquals(user.getDescription(), otherUser.getDescription());
assertEquals(user.getEmail(), otherUser.getEmail());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org