dflorey     2004/06/02 06:58:53

  Modified:    proposals/projector/src/java/org/apache/slide/projector/processor/xml
                        XPathQuery.java
               proposals/projector/src/java/org/apache/slide/projector/engine
                        ResultConfiguration.java Process.java
                        ParameterConfiguration.java
               proposals/projector/src/java/org/apache/slide/projector
                        Store.java
               proposals/projector/src/java/org/apache/slide/projector/connector/webdav
                        WebdavConnector.java
               proposals/projector/src/java/org/apache/slide/projector/application
                        ApplicationManager.java
  Added:       proposals/projector/src/java/org/apache/slide/projector/processor/query
                        ResultResolver.java
  Log:
  Improved DASLQuery-handling and fixed some bugs in the real core...
  
  Revision  Changes    Path
  1.3       +28 -24    
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/xml/XPathQuery.java
  
  Index: XPathQuery.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/xml/XPathQuery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XPathQuery.java   1 Jun 2004 07:49:58 -0000       1.2
  +++ XPathQuery.java   2 Jun 2004 13:58:53 -0000       1.3
  @@ -28,16 +28,7 @@
       public Value process(Value input, Context context) throws Exception {
           XPath xPath = XPath.newInstance(((StringValue)input).toString());
           List nodeList = xPath.selectNodes(rootElement);
  -        if ( nodeList.size() > 1 ) {
  -            List resources = new ArrayList();
  -            for ( Iterator i = nodeList.iterator(); i.hasNext(); ) {
  -                resources.add(createResourceFromNode(i.next()));
  -            }
  -            Value[] array = new Value[resources.size()];
  -            return new ArrayValue((Value [])resources.toArray(array));
  -        } else {
  -            return createResourceFromNode(nodeList.get(0));
  -        }
  +        return createValueFromNodeList(nodeList);
       }
   
       public ParameterDescriptor getParameterDescriptor() {
  @@ -56,19 +47,32 @@
           }
       }
   
  -    private Value createResourceFromNode(Object node) throws ProcessException {
  -        if ( node instanceof Element ) {
  -            return new ElementValue((Element)node);
  -        } else if ( node instanceof Attribute ) {
  -            return new StringValue(((Attribute)node).getValue());
  -        } else if ( node instanceof Text ) {
  -            return new StringValue(((Text)node).getText());
  -        } else if ( node instanceof Comment ) {
  -            return new StringValue(((Comment)node).getText());
  -        } else if ( node instanceof CDATA ) {
  -            return new StringValue(((CDATA)node).toString());
  -        } else if ( node instanceof ProcessingInstruction ) {
  -            return new StringValue(((ProcessingInstruction)node).getData());
  +    public static Value createValueFromNodeList(List nodeList) throws 
ProcessException {
  +     if ( nodeList.size() > 1 ) {
  +             List resources = new ArrayList();
  +             for ( Iterator i = nodeList.iterator(); i.hasNext(); ) {
  +                     resources.add(createValueFromNode(i.next()));
  +             }
  +             Value[] array = new Value[resources.size()];
  +             return new ArrayValue((Value [])resources.toArray(array));
  +     } else {
  +             return createValueFromNode(nodeList.get(0));
  +     }
  +    }
  +    
  +    public static Value createValueFromNode(Object node) throws ProcessException {
  +     if ( node instanceof Element ) {
  +             return new ElementValue((Element)node);
  +     } else if ( node instanceof Attribute ) {
  +             return new StringValue(((Attribute)node).getValue());
  +     } else if ( node instanceof Text ) {
  +             return new StringValue(((Text)node).getText());
  +     } else if ( node instanceof Comment ) {
  +             return new StringValue(((Comment)node).getText());
  +     } else if ( node instanceof CDATA ) {
  +             return new StringValue(((CDATA)node).toString());
  +     } else if ( node instanceof ProcessingInstruction ) {
  +             return new StringValue(((ProcessingInstruction)node).getData());
           }
           throw new ProcessException(new ErrorMessage("unconvertableJDomNode"));
       }
  
  
  
  1.5       +26 -6     
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ResultConfiguration.java
  
  Index: ResultConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ResultConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ResultConfiguration.java  1 Jun 2004 07:49:54 -0000       1.4
  +++ ResultConfiguration.java  2 Jun 2004 13:58:53 -0000       1.5
  @@ -4,6 +4,7 @@
   import org.apache.slide.projector.Context;
   import org.apache.slide.projector.Result;
   import org.apache.slide.projector.Store;
  +import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
   import org.apache.slide.projector.util.StoreHelper;
   import org.apache.slide.projector.value.MapValue;
   import org.apache.slide.projector.value.StreamableValue;
  @@ -56,8 +57,9 @@
           return name;
       }
   
  -    protected void storeValue(Value value, Result result, Context context) {
  -        if (presentable ) {
  +    protected void storeValue(Value value, Store stepStore, Result result, 
ResultEntryDescriptor[] resultEntryDescriptors, Context context) {
  +     // FIXME: Throw process exception instead of severe logging
  +     if (presentable ) {
               if ( value instanceof StreamableValue ) {
                   if ( context instanceof HttpContext ) {
                       
((HttpContext)context).setPresentableResource((StreamableValue)value);
  @@ -68,11 +70,29 @@
                   logger.log(Level.SEVERE, "Only resources of type StreamableResource 
can be presented!");
               }
           }
  -        if ( store == Store.NONE ) {
  -        } else if ( store == Store.OUTPUT ) {
  -            result.addResultEntry(key, value);
  +        Store resultStore = stepStore;
  +        if ( store == Store.OUTPUT ) {
  +             // check if result is defined
  +             boolean resultDefined = false;
  +             for ( int i = 0; i < resultEntryDescriptors.length; i++ ) {
  +                     if ( resultEntryDescriptors[i].getName().equals(key) ) {
  +                             // check if result matches description
  +                             if ( 
ContentType.matches(resultEntryDescriptors[i].getContentType(), 
value.getContentType()) ) {
  +                                     result.addResultEntry(key, value);
  +                                     resultDefined = true;
  +                                     break;
  +                             } else {
  +                        logger.log(Level.SEVERE, "Storing result with key '"+key+"' 
failed, because content type of generated result is '"+value.getContentType()+"' and 
does not match defined content type '"+resultEntryDescriptors[i].getContentType()+"'");
  +                             }
  +                     }
  +             }
  +             if ( !resultDefined ) {
  +                logger.log(Level.SEVERE, "Storing result failed, because result 
with key '"+key+"' is not defined in processor description!");
  +             }
           } else {
  -            Store resultStore = context.getStore(store);
  +            if ( store != Store.NONE ) {
  +             resultStore = context.getStore(store);
  +            }
               if ( resultStore == null ) {
                   logger.log(Level.SEVERE, "Storing result with key '"+key+"' failed, 
because store '"+Store.stores[store]+"' in not available in context '"+context+"'");
               } else {
  
  
  
  1.9       +19 -17    
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Process.java
  
  Index: Process.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/Process.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Process.java      1 Jun 2004 14:48:42 -0000       1.8
  +++ Process.java      2 Jun 2004 13:58:53 -0000       1.9
  @@ -62,7 +62,7 @@
                        this.parameterDescriptors = (ParameterDescriptor 
[])parameterDescriptors.toArray(new ParameterDescriptor[parameterDescriptors.size()]);
                        List outputResults = 
XPath.newInstance("/process/description/output/result").selectNodes(rootElement);
                        List resultEntryDescriptors = new ArrayList();
  -                     for ( Iterator i = inputParamters.iterator(); i.hasNext(); ) {
  +                     for ( Iterator i = outputResults.iterator(); i.hasNext(); ) {
                                Element outputResult = (Element)i.next();
                                String name = outputResult.getAttributeValue("name");
                                String description = 
outputResult.getAttributeValue("description");
  @@ -126,18 +126,20 @@
        
        public Result process(Map parameter, Context context) throws Exception {
                URI processorUri = 
ProcessorManager.getInstance().getProcessorDescriptor(this).getUri(); 
  -             context.setProcess(processorUri);
  -             String nextStep = getStep(firstStep, context);
  -             Result result = null;
  -             Step step;
  +             context.setProcess(processorUri);                               // 
Remember current process in context 
  +             String nextStep = getStep(firstStep, context);  // Lookup the first 
step of this process
  +             Store stepStore = new Cache();                                  // 
This store is used to allow stack-like result/parameter delivery between steps  
  +             Result result = new Result(OK);                                 // The 
result of this process processor
  +             Result stepResult = null;                                       // The 
result of the last executed step
  +             Step step;                                                             
                 // The current step
                do {
                        logger.log(Level.INFO, "Processing step: " + nextStep);
  -                     context.setStep(nextStep);
  +                     context.setStep(nextStep);                                     
 // Remember current step in context
                        step = (Step)steps.get(nextStep);
                        if (step == null) throw new ProcessException(new 
ErrorMessage("stepNotFound", new String[]{nextStep}));
                        Processor processor = 
ProcessorManager.getInstance().getProcessor(step.getProcessorURI());
                        try {
  -                             Map processorParameters = loadParameters(step, 
processor, parameter, result, context);
  +                             Map processorParameters = loadParameters(step, 
processor, parameter, stepStore, context);
                                if ( processor instanceof EnvironmentConsumer ) {
                                        
checkRequirements((EnvironmentConsumer)processor, context);
                                }
  @@ -145,12 +147,12 @@
                                try {
                                        if (step.getExpression() == null ) {
                                                // no expression set, so invoke 
processor
  -                                             result = 
processor.process(processorParameters, context);
  -                                             saveResults(step, result, context);
  +                                             stepResult = 
processor.process(processorParameters, context);
  +                                             saveResults(step, stepResult, 
stepStore, result, getResultDescriptor().getResultEntryDescriptors(), context);
                                        } else {
                                                // expression set, so schedule this 
processor as job
                                                
Scheduler.getInstance().addJob(step.getExpression(), step.getProcessorURI(), 
processorParameters, step.repeat(), step.isPersistent());
  -                                             result = new Result(OK);
  +                                             stepResult = new Result(OK);
                                        }
                                        nextStep = routeState(step, result.getState());
                                } catch (Exception e) {
  @@ -160,7 +162,8 @@
                                throw new ValidationException(new 
ErrorMessage("validationFailed", new Object[] { step.getProcessorURI(), nextStep }), 
exception);
                        }
                } while (nextStep != null);
  -             return generateResult(getState(step, result.getState()), result);
  +             result.setState(getState(step, stepResult.getState()));
  +             return result;
        }
        
        public ParameterDescriptor[] getParameterDescriptors() {
  @@ -246,7 +249,7 @@
                return key;
        }
        
  -     static Map loadParameters(Step step, Processor processor, Map parameter, 
Result previousResult, Context context) throws Exception {
  +     static Map loadParameters(Step step, Processor processor, Map parameter, Store 
stepStore, Context context) throws Exception {
                // Collect parameters for this processor
                Map parameters = new HashMap();
                ParameterDescriptor[] parameterDescriptors = 
processor.getParameterDescriptors();
  @@ -263,7 +266,7 @@
                                }
                        } else if ( parameterConfiguration != null ) {
                                try {
  -                                     Value validatedValue = 
parameterConfiguration.getValidatedValue(parameterDescriptor, parameter, 
previousResult, context);
  +                                     Value validatedValue = 
parameterConfiguration.getValidatedValue(parameterDescriptor, parameter, stepStore, 
context);
                                        parameters.put(parameterDescriptor.getName(), 
validatedValue);
                                } catch ( ValidationException exception ) {
                                        throw new ProcessException(new 
ErrorMessage("invalidParameter", new String[]{parameterDescriptor.getName()}), 
exception);
  @@ -273,14 +276,13 @@
                return parameters;
        }
        
  -     private static void saveResults(Step step, Result result, Context context) {
  +     private static void saveResults(Step step, Result stepResult, Store stepStore, 
Result result, ResultEntryDescriptor[] resultEntryDescriptors, Context context) {
                // save results by using result configuration
  -             
                for (Iterator i = 
step.getResultConfigurations().entrySet().iterator(); i.hasNext();) {
                        Map.Entry entry = (Map.Entry)i.next();
                        String resultName = (String)entry.getKey();
  -                     Value resultValue = 
(Value)result.getResultEntries().get(resultName);
  -                     
((ResultConfiguration)entry.getValue()).storeValue(resultValue, result, context);
  +                     Value resultValue = 
(Value)stepResult.getResultEntries().get(resultName);
  +                     
((ResultConfiguration)entry.getValue()).storeValue(resultValue, stepStore, result, 
resultEntryDescriptors, context);
                }
        }
        
  
  
  
  1.5       +11 -11    
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ParameterConfiguration.java
  
  Index: ParameterConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ParameterConfiguration.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParameterConfiguration.java       1 Jun 2004 07:49:54 -0000       1.4
  +++ ParameterConfiguration.java       2 Jun 2004 13:58:53 -0000       1.5
  @@ -55,8 +55,8 @@
           this.configuration = configuration;
       }
   
  -    public Value getValidatedValue(ParameterDescriptor descriptor, Map parameter, 
Result result, Context context) throws ProcessException, IOException {
  -        Object evaluatedValue = configuration.getEvaluatedValue(parameter, result, 
context);
  +    public Value getValidatedValue(ParameterDescriptor descriptor, Map parameter, 
Store stepStore, Context context) throws ProcessException, IOException {
  +        Object evaluatedValue = configuration.getEvaluatedValue(parameter, 
stepStore, context);
           if ( evaluatedValue == null && !descriptor.isRequired() ) {
               return descriptor.getDefaultValue();
           } else {
  @@ -67,7 +67,7 @@
       public interface Configuration {
        public void configure(Element element);
        
  -     public Object getEvaluatedValue(Map parameter, Result result, Context context) 
throws ProcessException, IOException;
  +     public Object getEvaluatedValue(Map parameter, Store stepStore, Context 
context) throws ProcessException, IOException;
       }
   
       public abstract class EnclosingConfiguration implements Configuration {
  @@ -97,10 +97,10 @@
               return (Configuration[])elements.toArray(configurations);
           }
   
  -        public Object getEvaluatedValue(Map parameter, Result result, Context 
context) throws ProcessException, IOException {
  +        public Object getEvaluatedValue(Map parameter, Store stepStore, Context 
context) throws ProcessException, IOException {
               List array = new ArrayList();
               for ( Iterator i = elements.iterator(); i.hasNext(); ) {
  -                Object evaluatedValue = 
((Configuration)i.next()).getEvaluatedValue(parameter, result, context);
  +                Object evaluatedValue = 
((Configuration)i.next()).getEvaluatedValue(parameter, stepStore, context);
                   array.add(evaluatedValue);
               }
               return array;
  @@ -119,11 +119,11 @@
               return (Configuration[])entries.toArray(configurations);
           }
   
  -        public Object getEvaluatedValue(Map parameter, Result result, Context 
context) throws ProcessException, IOException {
  +        public Object getEvaluatedValue(Map parameter, Store stepStore, Context 
context) throws ProcessException, IOException {
               Map map = new HashMap();
               for ( Iterator i = entries.iterator(); i.hasNext(); ) {
                   MapEntryConfiguration entry = (MapEntryConfiguration)i.next();
  -                map.put(entry.getKey(), entry.getEvaluatedValue(parameter, result, 
context));
  +                map.put(entry.getKey(), entry.getEvaluatedValue(parameter, 
stepStore, context));
               }
               return map;
           }
  @@ -146,8 +146,8 @@
               return new Configuration[] { configuration };
           }
   
  -        public Object getEvaluatedValue(Map parameter, Result result, Context 
context) throws ProcessException, IOException {
  -            return configuration.getEvaluatedValue(parameter, result, context);
  +        public Object getEvaluatedValue(Map parameter, Store stepStore, Context 
context) throws ProcessException, IOException {
  +            return configuration.getEvaluatedValue(parameter, stepStore, context);
           }
   
           public String getKey() {
  @@ -175,12 +175,12 @@
               processorUri = ( processor == null ? null : new URIValue(processor) );
           }            
   
  -        public Object getEvaluatedValue(Map parameter, Result result, Context 
context) throws ProcessException, IOException {
  +        public Object getEvaluatedValue(Map parameter, Store stepStore, Context 
context) throws ProcessException, IOException {
               Object value = getValue();
               if (isStoreUsed()) {
                   String key = Process.evaluateKey(storeKey, context);
                   if ( getStore() == Store.NONE ) {
  -                    if (result != null) value = result.getResultEntries().get(key);
  +                    value = stepStore.get(key);
                   } else if ( getStore() == Store.INPUT ) {
                       value = parameter.get(key);
                   } else {
  
  
  
  1.3       +1 -1      
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/Store.java
  
  Index: Store.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/Store.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Store.java        6 May 2004 12:54:11 -0000       1.2
  +++ Store.java        2 Jun 2004 13:58:53 -0000       1.3
  @@ -4,7 +4,7 @@
   
   public interface Store {
       public final static int NONE = -1;
  -    public final static int REQUEST_PARAMETER = 0; // Reqeust parameter (can only 
be of type String)
  +    public final static int REQUEST_PARAMETER = 0; // Reqeust parameter (can only 
be of type String or String[])
       public final static int REQUEST_ATTRIBUTE = 1; // Request attribute
       public final static int REQUEST_HEADER = 2;
       public final static int SESSION = 3;
  
  
  
  1.8       +16 -5     
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/connector/webdav/WebdavConnector.java
  
  Index: WebdavConnector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/connector/webdav/WebdavConnector.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebdavConnector.java      1 Jun 2004 16:13:10 -0000       1.7
  +++ WebdavConnector.java      2 Jun 2004 13:58:53 -0000       1.8
  @@ -141,19 +141,30 @@
           searchMethod.setDoAuthentication(true);
           HttpState httpState = new HttpState();
           httpState.setCredentials(null, Constants.REPOSITORY_HOST, credentials);
  -        searchMethod.execute(httpState, new 
HttpConnection(Constants.REPOSITORY_HOST, Constants.REPOSITORY_PORT, 
Constants.REPOSITORY_PROTOCOL));
  -        List resources = new ArrayList();
  +        int state = searchMethod.execute(httpState, new 
HttpConnection(Constants.REPOSITORY_HOST, Constants.REPOSITORY_PORT, 
Constants.REPOSITORY_PROTOCOL));
  +        if ( state != HttpStatus.SC_MULTI_STATUS ) {
  +            throw new IOException("Received status code "+state+" when doing SEARCH 
with query="+query);
  +        }
  +        List values = new ArrayList();
           for ( Enumeration e = searchMethod.getAllResponseURLs(); 
e.hasMoreElements(); ) {
  +            Map searchResults = new HashMap(); 
               String uri = (String)e.nextElement();
  +             for ( Enumeration pe = searchMethod.getResponseProperties(uri); 
pe.hasMoreElements(); ) {
  +                 Property property = (Property)pe.nextElement();
  +                             searchResults.put(property.getLocalName(), 
property.getPropertyAsString());
  +             }
                        if ( uri.indexOf(Constants.REPOSITORY_DOMAIN) > 0  ) {
                                uri = 
uri.substring(uri.indexOf(Constants.REPOSITORY_DOMAIN));
                        }
  -           Value resource = getResource(new URIValue(uri), credentials);
  +                     searchResults.put("uri", uri);
  +                                     /*
  +                     Value resource = getResource(new URIValue(uri), credentials);
               if ( resource != null ) {
                   resources.add(resource);
               }
  +            */
  +                     values.add(new MapValue(searchResults));
           }
  -        Value[] resourceArray = new Value[resources.size()];
  -        return (Value [])resources.toArray(resourceArray);
  +        return (Value [])values.toArray(new Value[values.size()]);
       }
   }
  
  
  
  1.1                  
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/query/ResultResolver.java
  
  Index: ResultResolver.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * 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.
   *
   */
  package org.apache.slide.projector.processor.query;
  
  import java.util.ArrayList;
  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.Processor;
  import org.apache.slide.projector.Result;
  import org.apache.slide.projector.URI;
  import org.apache.slide.projector.connector.ConnectorFactory;
  import org.apache.slide.projector.descriptor.ArrayValueDescriptor;
  import org.apache.slide.projector.descriptor.BooleanValueDescriptor;
  import org.apache.slide.projector.descriptor.MapValueDescriptor;
  import org.apache.slide.projector.descriptor.ParameterDescriptor;
  import org.apache.slide.projector.descriptor.ResultDescriptor;
  import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
  import org.apache.slide.projector.descriptor.StateDescriptor;
  import org.apache.slide.projector.descriptor.StringValueDescriptor;
  import org.apache.slide.projector.descriptor.URIValueDescriptor;
  import org.apache.slide.projector.i18n.DefaultMessage;
  import org.apache.slide.projector.i18n.ParameterMessage;
  import org.apache.slide.projector.processor.SimpleProcessor;
  import org.apache.slide.projector.processor.xml.XPathQuery;
  import org.apache.slide.projector.value.ArrayValue;
  import org.apache.slide.projector.value.BooleanValue;
  import org.apache.slide.projector.value.DocumentValue;
  import org.apache.slide.projector.value.MapValue;
  import org.apache.slide.projector.value.MultipleStreamableValue;
  import org.apache.slide.projector.value.NullValue;
  import org.apache.slide.projector.value.StreamableValue;
  import org.apache.slide.projector.value.Value;
  import org.jdom.xpath.XPath;
  
  /**
   * @author dflorey
   */
  public class ResultResolver implements Processor {
        private final static String URI_ENTRY = "uri";
        private final static String INSTRUCTIONS = "instructions";
        private final static String INCLUDE_CONTENT = "includeContent";
        private final static String CONTENT_ENTRY = "content";
  
        private final static ParameterDescriptor[] parameterDescriptors = 
                new ParameterDescriptor[] {
                        new ParameterDescriptor(
                                        SimpleProcessor.INPUT, 
                                        new 
ParameterMessage("resultResolver/paramter/input"), 
                                        new ArrayValueDescriptor(new 
MapValueDescriptor(
                                                        new 
ParameterDescriptor(URI_ENTRY, 
                                                        new 
ParameterMessage("resultResolver/parameter/input/uri"), 
                                                        new URIValueDescriptor())))),
                        new ParameterDescriptor(
                                        INSTRUCTIONS, 
                                        new 
ParameterMessage("resultResolver/paramter/instructions"), 
                                        new MapValueDescriptor(new 
ParameterDescriptor(MapValueDescriptor.ALL, 
                                                                        new 
ParameterMessage("resultResolver/parameter/instruction/instruction"), 
                                                                        new 
StringValueDescriptor())), NullValue.NULL),
                        new ParameterDescriptor(
                                        INCLUDE_CONTENT, 
                                        new 
ParameterMessage("resultResolver/paramter/include-content"), 
                                        new BooleanValueDescriptor(), 
BooleanValue.TRUE)
        };
        
        private final static ResultDescriptor resultDescriptor = 
                new ResultDescriptor(new StateDescriptor[] { 
StateDescriptor.OK_DESCRIPTOR },
                                new ResultEntryDescriptor[] {
                                new ResultEntryDescriptor(SimpleProcessor.OUTPUT, 
                                                new 
DefaultMessage("resultResolver/result/output"),
                                                ArrayValue.CONTENT_TYPE, false) });
        
        public Result process(Map parameter, Context context) throws Exception {
                Value []values = 
((ArrayValue)parameter.get(SimpleProcessor.INPUT)).getArray();
                boolean includeContent = 
((BooleanValue)parameter.get(INCLUDE_CONTENT)).booleanValue();
                Value instructions = (Value)parameter.get(INSTRUCTIONS);
                List arrayEntries = new ArrayList();
                for ( int i = 0; i < values.length; i++ ) {
                        Map map = ((MapValue)values[i]).getMap();
                        Map resultMap = new HashMap();
                        resultMap.putAll(map);
                        URI uri = (URI)map.get(URI_ENTRY);
                        Value content = 
ConnectorFactory.getConnector().getResource(uri, context.getCredentials()); 
                        if ( instructions instanceof MapValue ) {
                                if ( includeContent ) {
                                        content = new 
MultipleStreamableValue((StreamableValue) content);
                                }
                                DocumentValue documentValue = new 
DocumentValue((StreamableValue)content);
                                Map instructionMap = ((MapValue)instructions).getMap();
                                for ( Iterator j = 
instructionMap.entrySet().iterator(); j.hasNext(); ) {
                                        Map.Entry entry = (Map.Entry)j.next();
                                        String key = (String) entry.getKey();
                                XPath xPath = 
XPath.newInstance(entry.getValue().toString());
                                List nodeList = 
xPath.selectNodes(documentValue.getRootElement());
                                resultMap.put(key, 
XPathQuery.createValueFromNodeList(nodeList));
                                }
                        }
                        if ( includeContent ) {
                                resultMap.put(CONTENT_ENTRY, content);
                        }
                        arrayEntries.add(new MapValue(resultMap));
                }
                return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, new 
ArrayValue((Value [])arrayEntries.toArray(new Value[arrayEntries.size()])));
        }
        
        public ParameterDescriptor[] getParameterDescriptors() {
                return parameterDescriptors;
        }
  
        public ResultDescriptor getResultDescriptor() {
                return resultDescriptor;
        }
  }
  
  
  1.5       +1 -1      
jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java
  
  Index: ApplicationManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/application/ApplicationManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ApplicationManager.java   1 Jun 2004 16:13:10 -0000       1.4
  +++ ApplicationManager.java   2 Jun 2004 13:58:53 -0000       1.5
  @@ -71,7 +71,7 @@
                        if ( !applicationUri.endsWith("/") ) {
                                applicationUri = applicationUri + "/";
                        }
  -                     if ( applicationUri.indexOf(Constants.REPOSITORY_DOMAIN) > 0  
) {
  +                     if ( applicationUri.indexOf(Constants.REPOSITORY_DOMAIN) != -1 
 ) {
                                applicationUri = 
applicationUri.substring(applicationUri.indexOf(Constants.REPOSITORY_DOMAIN)+Constants.REPOSITORY_DOMAIN.length());
                        }
                        if ( !installedApplications.containsKey(applicationUri) ) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to