You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2003/10/14 08:37:57 UTC

cvs commit: jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/test jetspeed.properties

taylor      2003/10/13 23:37:57

  Modified:    .        maven.xml
               cps/test/rewriter test-001-output.html
               portal/src/webapp/WEB-INF/conf jetspeed.properties
               portal/src/webapp/WEB-INF/conf/test jetspeed.properties
  Added:       portal/src/java/org/apache/jetspeed/services/capability
                        CapabilityService.java
               portal/src/java/org/apache/jetspeed/services/capability/impl
                        CapabilityServiceImpl.java
  Log:
  Capability Service started
  
  Revision  Changes    Path
  1.7       +3 -0      jakarta-jetspeed-2/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/maven.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- maven.xml	7 Oct 2003 19:17:48 -0000	1.6
  +++ maven.xml	14 Oct 2003 06:37:56 -0000	1.7
  @@ -95,6 +95,9 @@
                  banner="Build and Install the Demo application WAR"
                  postProcessing="false"
                  ignoreFailures="false"/>
  +
  +    <attainGoal name= "catalina:base-shared"/> 
  +    <attainGoal name= "catalina:shared"/> 
     
     </goal>
     <goal name="catalina:shared"
  
  
  
  1.7       +6 -6      jakarta-jetspeed-2/cps/test/rewriter/test-001-output.html
  
  Index: test-001-output.html
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/test/rewriter/test-001-output.html,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- test-001-output.html	7 Oct 2003 19:17:49 -0000	1.6
  +++ test-001-output.html	14 Oct 2003 06:37:56 -0000	1.7
  @@ -1,10 +1,10 @@
   <p>
   This is a test</p>
  -<a name="1" target="_BLANK" href="http://www.bluesunrise.com/suffix">keep this</a>
  - <a name="2" target="_BLANK" href="http://www.rewriter.com/stuff/junk/stuffedjunk.html/suffix">junk</a>
  - <a name="3" target="_BLANK" href="http://www.rewriter.com/stuff/junk/stuffedjunk.html/suffix">junk2</a>
  - <a name="4" href="javascript:whatever()">script</a>
  - <a name="5" href="mailto:david@bluesunrise.com">script</a>
  - <a name="6" href="#INTERNAL">internal</a>
  +<a href="http://www.bluesunrise.com/suffix" target="_BLANK" name="1">keep this</a>
  + <a href="http://www.rewriter.com/stuff/junk/stuffedjunk.html/suffix" target="_BLANK" name="2">junk</a>
  + <a href="http://www.rewriter.com/stuff/junk/stuffedjunk.html/suffix" target="_BLANK" name="3">junk2</a>
  + <a href="javascript:whatever()" name="4">script</a>
  + <a href="mailto:david@bluesunrise.com" name="5">script</a>
  + <a href="#INTERNAL" name="6">internal</a>
   
   
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/capability/CapabilityService.java
  
  Index: CapabilityService.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" 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",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  package org.apache.jetspeed.services.capability;
  
  import org.apache.jetspeed.capability.CapabilityMap;
  import org.apache.jetspeed.cps.CommonService;
  
  /**
   * CapabilityService
   *
   * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
   * @version $Id: CapabilityService.java,v 1.1 2003/10/14 06:37:56 taylor Exp $
   */
  public interface CapabilityService extends CommonService
  {
      /** The name of this service */
      public String SERVICE_NAME = "capability";
      
      public CapabilityMap getCapabilityMap(String userAgent);
      
      
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/capability/impl/CapabilityServiceImpl.java
  
  Index: CapabilityServiceImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" 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",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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/>.
   */
  package org.apache.jetspeed.services.capability.impl;
  
  import java.util.Collection;
  import java.util.Iterator;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.fulcrum.InitializationException;
  import org.apache.jetspeed.capability.CapabilityMap;
  import org.apache.jetspeed.cps.BaseCommonService;
  import org.apache.jetspeed.cps.CPSInitializationException;
  import org.apache.jetspeed.cps.CommonPortletServices;
  import org.apache.jetspeed.om.registry.ClientEntry;
  import org.apache.jetspeed.om.registry.impl.ClientEntryImpl;
  import org.apache.jetspeed.persistence.PersistencePlugin;
  import org.apache.jetspeed.persistence.PersistenceService;
  import org.apache.jetspeed.services.capability.CapabilityService;
  import org.apache.regexp.RE;
  
  /**
   * CapabilityServiceImpl
   *
   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
   * @version $Id: CapabilityServiceImpl.java,v 1.1 2003/10/14 06:37:57 taylor Exp $
   */
  public class CapabilityServiceImpl
      extends BaseCommonService
      implements CapabilityService
  {
      private PersistencePlugin plugin;
  
      private PersistencePlugin originalPlugin;
  
      private String originalAlias;
  
      private static final Log log = LogFactory.getLog(CapabilityServiceImpl.class);
      
      public static final String DEFAULT_AGENT = "Mozilla/4.0";
  
      public static final String AGENT_XML = "agentxml/1.0";
      
      private Collection clients = null;
      
      private Class clientClass;
      
      
      /* (non-Javadoc)
       * @see org.apache.fulcrum.Service#init()
       */
      public void init() throws InitializationException
      {
          if (!isInitialized())
          {
              PersistenceService ps = (PersistenceService)CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
              String pluginName = getConfiguration().getString("persistence.plugin.name", "jetspeed");
  
              plugin = ps.getPersistencePlugin(pluginName);
  
              String className = getConfiguration().getString("client.impl", null);
              
              if (null == className)
              {
                  throw new CPSInitializationException("Factory class properties not found in configuration.");
              }
              
              try
              {
                  clientClass = createClass(className);
              }
              catch (ClassNotFoundException e)
              {
                  throw new CPSInitializationException("Could not preload client implementation class.", e);
              }
              
              setInit(true);
          }
      }
      
      /**
       * @param className
       * @return
       * @throws ClassNotFoundException
       */
      private Class createClass(String className)
      throws ClassNotFoundException
      {
          return Class.forName(className);
      }
      
      
      /* (non-Javadoc)
       * @see org.apache.jetspeed.services.capability.CapabilityService#getCapabilityMap(java.lang.String)
       */
      public CapabilityMap getCapabilityMap(String userAgent)
      {
          CapabilityMap map = null;
  
          if (userAgent == null)
          {
              userAgent = DEFAULT_AGENT;
          }
  
          ClientEntry entry = findClient(userAgent);
  
          if (entry == null)
          {
              if (userAgent.equals(DEFAULT_AGENT))
              {
                  log.error("CapabilityMap: Default agent not found in Client Registry !");
              }
              else
              {
                  if (log.isDebugEnabled())
                  {
                      log.debug("CapabilityMap: useragent "+ userAgent + "unknown, falling back to default");
                  }
                  // LEFT OFF HERE: map = getDefaultCapabilityMap();
              }
          }
          else
          {
              // LEFT OFF HERE: map = new BaseCapabilityMap(userAgent, entry);
          }
  
  
          if (log.isDebugEnabled())
          {
              log.debug("CapabilityMap: User-agent: " + userAgent + " mapped to " + map);
          }
  
          return map;
      }
      
      /**
       * Returns the client which matches the given useragent string.
       *
       * @param useragent     the useragent to match
       * @return the found client or null if the user-agent does not match any
       *  defined client
       */
      public ClientEntry findClient(String userAgent)
      {
          ClientEntry clientEntry = null;
          Iterator clients = getClients();
  
          if (log.isDebugEnabled())
          {
              log.debug( "ClientRegistry: Looking for client with useragent :" + userAgent );
          }
  
          while (clients.hasNext())
          {
              ClientEntry client = (ClientEntry)clients.next();
              if (client.getUseragentpattern() != null)
              {
                  try
                  {
                      RE r = new RE(client.getUseragentpattern());
                      r.setMatchFlags(RE.MATCH_CASEINDEPENDENT);
  
                      if (r.match(userAgent))
                      {
  
                          if (log.isDebugEnabled())
                          {
                              log.debug( "ClientRegistry: " + userAgent + " matches " + client.getUseragentpattern() );
                          }
  
                          return client;
                      }
                      else
                      {
                          if ( log.isDebugEnabled() )
                          {
                              log.debug( "ClientRegistry: " + userAgent + " does not match " + client.getUseragentpattern() );
                          }
                      }
                  }
                  catch (org.apache.regexp.RESyntaxException e)
                  {
                      String message = "ClientRegistryService: UserAgentPattern not valid : " 
                                          + client.getUseragentpattern() + " : " + e.getMessage();
                      log.error( message, e );
                  }
              }
          }
  
          return clientEntry;
      }
      
  
      /**
       * @return
       */
      public Iterator getClients()
      {
          if (null == clients)
          {
              this.clients = plugin.getExtent(ClientEntryImpl.class);
          }
          
          return this.clients.iterator();
      }
  }
  
  
  
  1.7       +8 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties
  
  Index: jetspeed.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jetspeed.properties	8 Oct 2003 04:36:39 -0000	1.6
  +++ jetspeed.properties	14 Oct 2003 06:37:57 -0000	1.7
  @@ -128,6 +128,13 @@
   services.PortletRegistry.earlyInit = true
   
   # -------------------------------------------------------------------
  +#  C A P A B I L I T Y 
  +# -------------------------------------------------------------------
  +services.capability.classname = org.apache.jetspeed.services.capability.impl.CapabilityServiceImpl
  +services.capability.earlyInit = true
  +services.capability.client.impl = org.apache.jetspeed.om.registry.impl.ClientEntryImpl
  +
  +# -------------------------------------------------------------------
   #  P S M L  M A N A G E R
   # -------------------------------------------------------------------
   # Select your PSML Manager service by uncommenting it. 
  
  
  
  1.5       +7 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/test/jetspeed.properties
  
  Index: jetspeed.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/test/jetspeed.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jetspeed.properties	13 Aug 2003 21:32:04 -0000	1.4
  +++ jetspeed.properties	14 Oct 2003 06:37:57 -0000	1.5
  @@ -13,6 +13,12 @@
   services.PortletRegistry.persistence.plugin.name=jetspeed-test
   
   # -------------------------------------------------------------------
  +#  C A P A B I L I T Y 
  +# -------------------------------------------------------------------
  +# Use the persistence plugin that points to the test system
  +services.capability.persistence.plugin.name=jetspeed-test
  +
  +# -------------------------------------------------------------------
   #  P S M L 
   # -------------------------------------------------------------------
   services.PsmlManager.root=./test/testdata/psml
  
  
  

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