You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by df...@apache.org on 2004/05/17 11:07:07 UTC
cvs commit: jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/query XPathQuery.java
dflorey 2004/05/17 02:07:07
Modified: proposals/projector/src/java/org/apache/slide/projector/processor/query
XPathQuery.java
Added: proposals/projector/src/java/org/apache/slide/projector/processor/form
Test.java
Removed: proposals/projector/src/java/org/apache/slide/projector/engine
Test.java
Log:
Revision Changes Path
1.1 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/Test.java
Index: Test.java
===================================================================
package org.apache.slide.projector.processor.form;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.slide.projector.Context;
import org.apache.slide.projector.Information;
import org.apache.slide.projector.Processor;
import org.apache.slide.projector.Resource;
import org.apache.slide.projector.Result;
import org.apache.slide.projector.Store;
import org.apache.slide.projector.URI;
import org.apache.slide.projector.descriptor.ParameterDescriptor;
import org.apache.slide.projector.descriptor.ResultDescriptor;
import org.apache.slide.projector.descriptor.URIValueDescriptor;
import org.apache.slide.projector.engine.HttpContext;
import org.apache.slide.projector.engine.Process;
import org.apache.slide.projector.engine.ProcessorManager;
import org.apache.slide.projector.engine.HttpContext.FormStore;
import org.apache.slide.projector.i18n.ParameterMessage;
import org.apache.slide.projector.resource.BooleanResource;
import org.apache.slide.projector.resource.MapResource;
import org.apache.slide.projector.resource.NullResource;
import org.apache.slide.projector.resource.StringResource;
import org.apache.slide.projector.resource.URIResource;
import org.apache.slide.projector.util.ProcessorHelper;
public class Test implements Processor {
private final static URI FORM_PROCESSOR = new URIResource("/formGenerator");
private final static URI RESULT_RENDERER = new URIResource("/result");
private final static String PROCESSOR = "processor";
private final static String FORM_STEP = "form";
private final static String PROCESS_STEP = "process";
private final static String RESULT_STEP = "result";
private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[] {
new ParameterDescriptor(PROCESSOR, new ParameterMessage("test/parameter/processor"), new URIValueDescriptor(), NullResource.NULL),
};
public Result process(Map parameter, Context context) throws Exception {
context.setBookmark(ProcessorManager.getInstance().getURI(this));
Resource uri = (Resource)parameter.get(PROCESSOR);
if ( uri == null || uri == NullResource.NULL ) {
uri = (URI)context.getStore(Store.SESSION).get(PROCESSOR);
}
context.setProcess((URI)uri);
context.getStore(Store.SESSION).put(PROCESSOR, uri);
Resource stepResource = (Resource)context.getStore(Store.FORM).get(Process.STEP);
String step;
if ( stepResource == null ) {
step = FORM_STEP;
} else {
step = stepResource.toString();
}
context.setStep(step);
Processor formProcessor = ProcessorManager.getInstance().getProcessor(FORM_PROCESSOR);
Processor resultRenderer = ProcessorManager.getInstance().getProcessor(RESULT_RENDERER);
Processor processor = ProcessorManager.getInstance().getProcessor((URI)uri);
parameter.put(Control.ACTION, uri);
parameter.put(ControlComposer.LOCALE, ProcessorManager.getInstance().process(ProcessorManager.LOCALE_RESOLVER, context.getStore(Store.REQUEST_HEADER).get("accept-language"), context));
parameter.put(FormGenerator.TARGET_STEP, PROCESS_STEP);
Result result = null;
if ( step.equals(FORM_STEP) ) {
result = formProcessor.process(parameter, context);
} else if ( step.equals(PROCESS_STEP) ) {
parameter.putAll(((MapResource)((HttpContext.FormStore)context.getStore(Store.FORM)).getDomain()).getMap());
ProcessorHelper.validate(processor.getParameterDescriptors(), parameter, context);
Result processorResult = processor.process(parameter, context);
if ( hasErrors(context.getInformations()) ) {
context.setStep(FORM_STEP);
((HttpContext.FormStore)context.getStore(Store.FORM)).put(ControlComposer.VALIDATE, BooleanResource.TRUE);
result = formProcessor.process(parameter, context);
} else {
Map resultParameters = new HashMap();
resultParameters.put("state", new StringResource(processorResult.getState()));
ProcessorHelper.validate(resultRenderer.getParameterDescriptors(), resultParameters, context);
result = resultRenderer.process(resultParameters, context);
((HttpContext.FormStore)context.getStore(Store.FORM)).clear();
}
} else {
((HttpContext.FormStore)context.getStore(Store.FORM)).clear();
return Result.OK;
}
return result;
}
protected boolean hasErrors(List informations) {
for ( Iterator i = informations.iterator(); i.hasNext(); ) {
Information info = (Information)i.next();
if ( info.getSeverity() == Information.ERROR ) {
return true;
}
}
return false;
}
public ParameterDescriptor[] getParameterDescriptors() {
return parameterDescriptors;
}
public ResultDescriptor getResultDescriptor() {
return null;
}
}
1.2 +1 -64 jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/query/XPathQuery.java
Index: XPathQuery.java
===================================================================
RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/query/XPathQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XPathQuery.java 3 May 2004 14:20:27 -0000 1.1
+++ XPathQuery.java 17 May 2004 09:07:07 -0000 1.2
@@ -1,66 +1,3 @@
-/*
- * $Header$
- * $Revision$
- * $Date$
- *
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Slide", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * [Additional notices, if required by prior licensing conditions]
- *
- */
-
package org.apache.slide.projector.processor.query;
import org.apache.slide.projector.*;
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org