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/24 16:00:37 UTC

cvs commit: jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/store Cache.java

dflorey     2004/05/24 07:00:37

  Modified:    proposals/projector/src/java/org/apache/slide/projector/engine
                        ProjectorClassLoader.java ResultConfiguration.java
               proposals/projector/src/java/org/apache/slide/projector/processor
                        URL.java CachedContent.java Link.java
               proposals/projector/src/java/org/apache/slide/projector/application
                        ApplicationManager.java
               proposals/projector/src/java/org/apache/slide/projector/processor/form
                        FormGenerator.java
  Added:       proposals/projector/src/java/org/apache/slide/projector
                        SystemContext.java HttpContext.java
               proposals/projector/src/java/org/apache/slide/projector/processor/xml
                        XSLTransformer.java XPathQuery.java
               proposals/projector/src/java/org/apache/slide/projector/processor/tree
                        Sitemap.java
               proposals/projector/src/java/org/apache/slide/projector/processor/security
                        Login.java
               proposals/projector/src/java/org/apache/slide/projector/store
                        Cache.java
  Removed:     proposals/projector/src/java/org/apache/slide/projector/engine
                        SystemContext.java HttpContext.java Cache.java
               proposals/projector/src/java/org/apache/slide/projector/processor
                        Sitemap.java XSLTransformer.java Login.java
               proposals/projector/src/java/org/apache/slide/projector/processor/query
                        XPathQuery.java
  Log:
  Refactoring
  
  Revision  Changes    Path
  1.2       +1 -0      jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ProjectorClassLoader.java
  
  Index: ProjectorClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/engine/ProjectorClassLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProjectorClassLoader.java	24 May 2004 13:33:13 -0000	1.1
  +++ ProjectorClassLoader.java	24 May 2004 14:00:36 -0000	1.2
  @@ -1,5 +1,6 @@
   package org.apache.slide.projector.engine;
   
  +import org.apache.slide.projector.*;
   import org.apache.slide.projector.Constants;
   import org.apache.slide.projector.Context;
   import org.apache.slide.projector.URI;
  
  
  
  1.3       +1 -0      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResultConfiguration.java	5 May 2004 09:58:08 -0000	1.2
  +++ ResultConfiguration.java	24 May 2004 14:00:36 -0000	1.3
  @@ -1,5 +1,6 @@
   package org.apache.slide.projector.engine;
   
  +import org.apache.slide.projector.*;
   import org.apache.slide.projector.Context;
   import org.apache.slide.projector.Resource;
   import org.apache.slide.projector.Result;
  
  
  
  1.3       +1 -1      jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/URL.java
  
  Index: URL.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/URL.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- URL.java	17 May 2004 15:22:03 -0000	1.2
  +++ URL.java	24 May 2004 14:00:36 -0000	1.3
  @@ -1,13 +1,13 @@
   package org.apache.slide.projector.processor;
   
   import org.apache.slide.projector.Context;
  +import org.apache.slide.projector.HttpContext;
   import org.apache.slide.projector.ProcessException;
   import org.apache.slide.projector.Resource;
   import org.apache.slide.projector.descriptor.ParameterDescriptor;
   import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
   import org.apache.slide.projector.descriptor.StringValueDescriptor;
   import org.apache.slide.projector.engine.ContentType;
  -import org.apache.slide.projector.engine.HttpContext;
   import org.apache.slide.projector.i18n.DefaultMessage;
   import org.apache.slide.projector.i18n.ErrorMessage;
   import org.apache.slide.projector.i18n.ParameterMessage;
  
  
  
  1.3       +1 -2      jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/CachedContent.java
  
  Index: CachedContent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/CachedContent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CachedContent.java	17 May 2004 15:22:03 -0000	1.2
  +++ CachedContent.java	24 May 2004 14:00:36 -0000	1.3
  @@ -4,7 +4,6 @@
   import org.apache.slide.projector.connector.ConnectorFactory;
   import org.apache.slide.projector.connector.Subscriber;
   import org.apache.slide.projector.descriptor.*;
  -import org.apache.slide.projector.engine.HttpContext;
   import org.apache.slide.projector.engine.ProcessorManager;
   import org.apache.slide.projector.engine.Scheduler;
   import org.apache.slide.projector.expression.EventExpression;
  
  
  
  1.2       +1 -1      jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/Link.java
  
  Index: Link.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/Link.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Link.java	3 May 2004 14:20:24 -0000	1.1
  +++ Link.java	24 May 2004 14:00:36 -0000	1.2
  @@ -6,6 +6,7 @@
   
   import org.apache.slide.projector.Constants;
   import org.apache.slide.projector.Context;
  +import org.apache.slide.projector.HttpContext;
   import org.apache.slide.projector.ProcessException;
   import org.apache.slide.projector.Processor;
   import org.apache.slide.projector.Resource;
  @@ -18,7 +19,6 @@
   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.engine.HttpContext;
   import org.apache.slide.projector.engine.Process;
   import org.apache.slide.projector.i18n.ErrorMessage;
   import org.apache.slide.projector.i18n.ParameterMessage;
  
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/SystemContext.java
  
  Index: SystemContext.java
  ===================================================================
  package org.apache.slide.projector;
  
  import java.io.IOException;
  
  import org.apache.commons.httpclient.Credentials;
  import org.apache.slide.projector.store.*;
  import org.apache.slide.projector.store.ProcessStore;
  import org.apache.slide.projector.store.RepositoryStore;
  
  public class SystemContext extends AbstractContext {
  	private final static String BOOKMARK = "_bookmark_";
  	private final static String FORM_MAP = "_form_map_";
  	
      private Cache contextStore = new Cache();
  	private RepositoryStore repositoryStore = new RepositoryStore(this);
      private ProcessStore transientProcessStore = new ProcessStore(Cache.getInstance());
      private ProcessStore persistentProcessStore = new ProcessStore(repositoryStore);
  
      public Store getStore(int store) {
          switch ( store ) {
              case Store.CACHE : {
                  return Cache.getInstance();
              }
              case Store.CONTEXT : {
                  return contextStore;
              }
              case Store.REPOSITORY : {
                  return repositoryStore;
              }
              case Store.TRANSIENT_PROCESS : {
                  return transientProcessStore;
              }
              case Store.PERSISTENT_PROCESS : {
                  return persistentProcessStore;
              }
          }
          return null;
      }
  
      public Credentials getCredentials() {
          return Constants.CREDENTIALS;
      }
  
      public void setProcessId(String processId) {
      	transientProcessStore.setProcessId(processId);
      	persistentProcessStore.setProcessId(processId);
      }
      
      public String getProcessId() {
      	return transientProcessStore.getProcessId();
      }
  
      public void setBookmark(URI processor) throws IOException {
      	transientProcessStore.put(BOOKMARK, processor);
      }
      
      public URI getBookmark() throws IOException {
      	return (URI)transientProcessStore.get(BOOKMARK);
      }
  }
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/HttpContext.java
  
  Index: HttpContext.java
  ===================================================================
  package org.apache.slide.projector;
  
  import org.apache.commons.httpclient.Credentials;
  import org.apache.slide.projector.resource.StreamableResource;
  import org.apache.slide.projector.store.*;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  public class HttpContext extends SystemContext {
      private final static String CREDENTIALS = "credentials";
  
      private StreamableResource resource;
      private SessionStore sessionStore;
      private RequestAttributeStore requestAttributeStore;
      private RequestParameterStore requestParameterStore;
      private RequestHeaderStore requestHeaderStore;
      private CookieStore cookieStore;
      private FormStore formStore;
      private String contextPath;
  
      public HttpContext(HttpServletRequest request, HttpServletResponse response) {
          this.contextPath = request.getContextPath()+Constants.PROCESS_SERVLET_PATH;
          sessionStore = new SessionStore(request);
          formStore = new FormStore(this, sessionStore);
          requestAttributeStore = new RequestAttributeStore(request);
          requestParameterStore = new RequestParameterStore(request);
          requestHeaderStore = new RequestHeaderStore(request);
          cookieStore = new CookieStore(request, response);
      }
  
      public void setCredentials(Credentials credentials) {
          sessionStore.put(CREDENTIALS, credentials);
      }
  
      public Credentials getCredentials() {
          Credentials credentials = (Credentials)sessionStore.get(CREDENTIALS);
          if ( credentials == null ) {
              credentials = Constants.CREDENTIALS;            
          }
          return credentials;
      }
  
      public Store getStore(int store) {
          switch ( store ) {
              case Store.SESSION : {
                  return sessionStore;
              }
              case Store.REQUEST_PARAMETER : {
                  return requestParameterStore;
              }
              case Store.REQUEST_ATTRIBUTE : {
                  return requestAttributeStore;
              }
              case Store.REQUEST_HEADER : {
                  return requestHeaderStore;
              }
              case Store.COOKIE : {
                  return cookieStore;
              }
              case Store.CACHE : {
                  return Cache.getInstance();
              }
              case Store.FORM : {
                  return formStore;
              }
          }
          return super.getStore(store);
      }
  
      public String getContextPath() {
          return contextPath;
      }
  
      public void setPresentableResource(StreamableResource resource) {
          this.resource = resource;
      }
  
      public StreamableResource getPresentableResource() {
          return resource;
      }
  }
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/xml/XSLTransformer.java
  
  Index: XSLTransformer.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/xml/XSLTransformer.java,v 1.1 2004/05/24 14:00:37 dflorey Exp $
   * $Revision: 1.1 $
   * $Date: 2004/05/24 14:00:37 $
   *
   * ====================================================================
   *
   * 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.xml;
  
  import org.apache.slide.projector.ConfigurableProcessor;
  import org.apache.slide.projector.ConfigurationException;
  import org.apache.slide.projector.Context;
  import org.apache.slide.projector.Resource;
  import org.apache.slide.projector.descriptor.ParameterDescriptor;
  import org.apache.slide.projector.descriptor.ResourceValueDescriptor;
  import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
  import org.apache.slide.projector.i18n.DefaultMessage;
  import org.apache.slide.projector.i18n.ErrorMessage;
  import org.apache.slide.projector.i18n.ParameterMessage;
  import org.apache.slide.projector.processor.SimpleProcessor;
  import org.apache.slide.projector.resource.DocumentResource;
  import org.apache.slide.projector.resource.StreamableResource;
  import org.jdom.Document;
  import org.jdom.transform.JDOMResult;
  import org.jdom.transform.JDOMSource;
  
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerConfigurationException;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.stream.StreamSource;
  import java.io.IOException;
  
  /**
   * @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
   * @version $Revision: 1.1 $
   */
  
  public class XSLTransformer extends SimpleProcessor implements ConfigurableProcessor {
      private Transformer transformer;
  
      public Resource process(Resource input, Context context) throws Exception {
          Document document = ((DocumentResource)input).getDocument();
          JDOMResult result = new JDOMResult();
          transformer.transform(new JDOMSource(document), result);
          return new DocumentResource(result.getDocument());
      }
  
      public ParameterDescriptor getParameterDescriptor() {
          return new ParameterDescriptor(INPUT, new ParameterMessage("xslTransformer/parameter/input"), new ResourceValueDescriptor("text/xml"));
      }
  
      public ResultEntryDescriptor getResultEntryDescriptor() {
          return new ResultEntryDescriptor(OUTPUT, new DefaultMessage("xslTransformer/result/output"), "text/xml", true);
      }
  
      public void configure(StreamableResource config) throws ConfigurationException {
          try {
              transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(config.getInputStream()));
          } catch (TransformerConfigurationException e) {
              throw new ConfigurationException(new ErrorMessage("xslTransformer/creationgFailed"), e);
          } catch (IOException e) {
              throw new ConfigurationException(new ErrorMessage("xslTransformer/ioException"), e);
          }
      }
  }
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/xml/XPathQuery.java
  
  Index: XPathQuery.java
  ===================================================================
  package org.apache.slide.projector.processor.xml;
  
  import org.apache.slide.projector.*;
  import org.apache.slide.projector.descriptor.ParameterDescriptor;
  import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
  import org.apache.slide.projector.descriptor.StringValueDescriptor;
  import org.apache.slide.projector.engine.ContentType;
  import org.apache.slide.projector.i18n.DefaultMessage;
  import org.apache.slide.projector.i18n.ErrorMessage;
  import org.apache.slide.projector.i18n.ParameterMessage;
  import org.apache.slide.projector.processor.SimpleProcessor;
  import org.apache.slide.projector.resource.*;
  import org.jdom.*;
  import org.jdom.xpath.XPath;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
   * @version $Revision: 1.1 $
   */
  
  public class XPathQuery extends SimpleProcessor implements ConfigurableProcessor {
      private Element rootElement;
  
      public Resource process(Resource input, Context context) throws Exception {
          XPath xPath = XPath.newInstance(((StringResource)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()));
              }
              Resource[] array = new Resource[resources.size()];
              return new ArrayResource((Resource [])resources.toArray(array));
          } else {
              return createResourceFromNode(nodeList.get(0));
          }
      }
  
      public ParameterDescriptor getParameterDescriptor() {
          return new ParameterDescriptor(INPUT, new ParameterMessage("xPathQuery/parameter/input"), new StringValueDescriptor());
      }
  
      public ResultEntryDescriptor getResultEntryDescriptor() {
          return new ResultEntryDescriptor(OUTPUT, new DefaultMessage("xPathQuery/result/output"), ContentType.DYNAMIC, true);
      }
  
      public void configure(StreamableResource config) throws ConfigurationException {
          if ( config instanceof XMLResource ) {
              rootElement = ((XMLResource)config).getRootElement();
          } else {
              throw new ConfigurationException(new ErrorMessage("xpathQuery/xmlResourceRequired"));
          }
      }
  
      private Resource createResourceFromNode(Object node) throws ProcessException {
          if ( node instanceof Element ) {
              return new ElementResource((Element)node);
          } else if ( node instanceof Attribute ) {
              return new StringResource(((Attribute)node).getValue());
          } else if ( node instanceof Text ) {
              return new StringResource(((Text)node).getText());
          } else if ( node instanceof Comment ) {
              return new StringResource(((Comment)node).getText());
          } else if ( node instanceof CDATA ) {
              return new StringResource(((CDATA)node).toString());
          } else if ( node instanceof ProcessingInstruction ) {
              return new StringResource(((ProcessingInstruction)node).getData());
          }
          throw new ProcessException(new ErrorMessage("unconvertableJDomNode"));
      }
  }
  
  
  1.2       +0 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationManager.java	24 May 2004 13:52:44 -0000	1.1
  +++ ApplicationManager.java	24 May 2004 14:00:37 -0000	1.2
  @@ -11,7 +11,6 @@
   import org.apache.slide.projector.descriptor.ValueDescriptorManager;
   import org.apache.slide.projector.engine.ProcessorManager;
   import org.apache.slide.projector.engine.ProjectorClassLoader;
  -import org.apache.slide.projector.engine.SystemContext;
   import org.apache.slide.projector.i18n.MessageManager;
   import org.apache.slide.projector.resource.ArrayResource;
   import org.apache.slide.projector.resource.StreamableResource;
  
  
  
  1.8       +1 -2      jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/FormGenerator.java
  
  Index: FormGenerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/form/FormGenerator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FormGenerator.java	17 May 2004 15:22:03 -0000	1.7
  +++ FormGenerator.java	24 May 2004 14:00:37 -0000	1.8
  @@ -3,7 +3,6 @@
   import org.apache.slide.projector.*;
   import org.apache.slide.projector.descriptor.*;
   import org.apache.slide.projector.engine.Process;
  -import org.apache.slide.projector.engine.HttpContext;
   import org.apache.slide.projector.engine.ProcessorManager;
   import org.apache.slide.projector.i18n.DefaultMessage;
   import org.apache.slide.projector.i18n.ErrorMessage;
  
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/tree/Sitemap.java
  
  Index: Sitemap.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/tree/Sitemap.java,v 1.1 2004/05/24 14:00:37 dflorey Exp $
   * $Revision: 1.1 $
   * $Date: 2004/05/24 14:00:37 $
   *
   * ====================================================================
   *
   * 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.tree;
  
  import de.zeigermann.xml.simpleImporter.DefaultSimpleImportHandler;
  import de.zeigermann.xml.simpleImporter.SimpleImporter;
  import de.zeigermann.xml.simpleImporter.SimplePath;
  import org.apache.slide.projector.*;
  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.i18n.DefaultMessage;
  import org.apache.slide.projector.processor.SimpleProcessor;
  import org.apache.slide.projector.resource.ArrayResource;
  import org.apache.slide.projector.resource.StreamableResource;
  import org.apache.slide.projector.resource.StringResource;
  import org.xml.sax.InputSource;
  import org.xml.sax.helpers.AttributesImpl;
  
  import java.io.InputStream;
  import java.util.*;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  /**
   * The Sitemap class
   * 
   * @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
   */
  public class Sitemap implements ConfigurableProcessor {
      private static Logger logger = Logger.getLogger(Sitemap.class.getName());
  
      private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[0];
      private static ResultDescriptor resultDescriptors;
  
      private static Result result = new Result(StateDescriptor.OK);
  
      public void configure(StreamableResource config) throws ConfigurationException {
          try {
              InputStream configuration = config.getInputStream();
              SimpleImporter importer = new SimpleImporter();
              ConfigurationHandler handler = new ConfigurationHandler();
              importer.addSimpleImportHandler(handler);
              importer.parse(new InputSource(configuration));
              Page rootPage = handler.getRootPage();
              List resources = new ArrayList();
              buildArray(resources, rootPage);
              Resource[] array = new Resource[resources.size()];
              ArrayResource arrayResource = new ArrayResource((Resource [])resources.toArray(array));
              result.addResultEntry(SimpleProcessor.OUTPUT, arrayResource);
              resultDescriptors = new ResultDescriptor(
                      new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR },
                      new ResultEntryDescriptor[] {
                          new ResultEntryDescriptor(SimpleProcessor.OUTPUT, new DefaultMessage("sitemap/output"), ArrayResource.CONTENT_TYPE, false)
                      });
          } catch (Exception exception) {
              logger.log(Level.SEVERE, "Error while parsing sitemap configuration", exception);
          }
      }
  
      private void buildArray(List resources, Page page) {
          for ( Iterator j = page.getChildren().iterator(); j.hasNext(); ) {
              Page child = (Page)j.next();
              if ( child.getId() != null ) {
                  resources.add(new StringResource(child.getId()));
              }
              if ( child.getChildren().size() > 0 ) {
                  List childrenResources = new ArrayList();
                  buildArray(childrenResources, child);
                  Resource[] array = new Resource[childrenResources.size()];
                  ArrayResource arrayResource = new ArrayResource((Resource [])childrenResources.toArray(array));
                  resources.add(arrayResource);
              }
          }
      }
  
      public Result process(Map parameter, Context context) throws Exception {
          return result;
      }
  
      public ParameterDescriptor[] getParameterDescriptors() {
          return parameterDescriptors;
      }
  
      public ResultDescriptor getResultDescriptor() {
          return resultDescriptors;
      }
  
      class Page {
          private List children = new ArrayList();
          private String id;
  
          public Page(String id) {
              this.id = id;
          }
  
          public String getId() {
              return id;
          }
  
          public void addChild(Page page) {
              children.add(page);
          }
  
          public List getChildren() {
              return children;
          }
      }
  
      class ConfigurationHandler extends DefaultSimpleImportHandler {
          private Stack pageStack = new Stack();
          private Page rootPage;
  
          public Page getRootPage() {
              return rootPage;
          }
  
          public void startElement(SimplePath path, String name, AttributesImpl attributes, String leadingCDdata) {
              if ( path.matches("page") ) {
                  String id = attributes.getValue(org.apache.slide.projector.processor.tree.TreeRenderer.ID);
                  Page page = new Page(id);
                  Page parentPage = (Page)pageStack.peek();
                  parentPage.addChild(page);
                  pageStack.push(page);
              } else if ( path.matches("sitemap" ) ) {
                  Page page = new Page(null);
                  pageStack.push(page);
                  rootPage = page;
              }
          }
  
          public void endElement(SimplePath path, String name) {
              if ( path.matches("page") ) {
                  pageStack.pop();
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/processor/security/Login.java
  
  Index: Login.java
  ===================================================================
  package org.apache.slide.projector.processor.security;
  
  import org.apache.slide.projector.descriptor.*;
  import org.apache.slide.projector.i18n.DefaultMessage;
  import org.apache.slide.projector.i18n.ErrorMessage;
  import org.apache.slide.projector.i18n.ParameterMessage;
  import org.apache.slide.projector.Information;
  import org.apache.slide.projector.*;
  import org.apache.slide.projector.resource.StringResource;
  
  import java.util.Map;
  
  /**
   * @author <a href="mailto:dflorey@c1-fse.de">Daniel Florey</a>
   * @version $Revision: 1.1 $
   */
  
  public class Login implements Processor {
      private final static String USERNAME = "username";
      private final static String PASSWORD = "password";
      private final static String INTERESTS = "interests";
  
      private final static String LOGIN_OK = "loginOk";
      private final static String LOGIN_FAILED = "loginFailed";
      public final static String ERRORS = "errors";
  
      public Result process(Map parameter, Context context) throws Exception {
          String username = parameter.get(USERNAME).toString();
          String password = parameter.get(PASSWORD).toString();
          if ( username.equals("Daniel") && password.equals("test") ) {
              return new Result(LOGIN_OK);
          }
          context.addInformation(new Information(Information.ERROR, new ErrorMessage("login/invalidLogin"), new String[] { USERNAME, PASSWORD }));
          if ( password.equals("aaaa") ) {
              context.addInformation(new Information(Information.ERROR, new ErrorMessage("login/invalidPassword"), new String[] { PASSWORD }));
          }
          return new Result(LOGIN_FAILED);
      }
  
      public ParameterDescriptor[] getParameterDescriptors() {
          return new ParameterDescriptor[] {
              new ParameterDescriptor(USERNAME, new ParameterMessage("login/user"), new StringValueDescriptor(), new StringResource("Daniel")),
              new ParameterDescriptor(PASSWORD, new ParameterMessage("login/password"), new StringValueDescriptor(4,12)),
              new ParameterDescriptor(INTERESTS, new ParameterMessage("person/interests"), new ArrayValueDescriptor(new StringValueDescriptor(new String[] { "sport", "musik", "fernsehen", "tanzen", "springen", "schreien"})))
          };
      }
  
      public ResultDescriptor getResultDescriptor() {
          return new ResultDescriptor(new StateDescriptor[] {
             new StateDescriptor(LOGIN_OK, new DefaultMessage("login/state/ok")),
             new StateDescriptor(LOGIN_FAILED, new DefaultMessage("login/state/failed"))
          });
      }
  }
  
  
  1.1                  jakarta-slide/proposals/projector/src/java/org/apache/slide/projector/store/Cache.java
  
  Index: Cache.java
  ===================================================================
  package org.apache.slide.projector.store;
  
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.slide.projector.store.*;
  
  public class Cache extends AbstractStore {
      private static Cache cache = new Cache();
  
      public static Cache getInstance() {
          return cache;
      }
  
      private Map map = new HashMap();
  
      public void put(String key, Object value) throws IOException {
          map.put(key, value);
      }
  
      public Object get(String key) throws IOException {
          return map.get(key);
      }
  
      public void dispose(String key) throws IOException {
          map.remove(key);
      }
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org