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 ju...@apache.org on 2002/05/14 16:16:08 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util PropertySearchSetProperty.java

juergen     02/05/14 07:16:08

  Added:       src/webdav/server/org/apache/slide/webdav/util
                        PropertySearchSetProperty.java
  Log:
  added principal-search-report and principal-search-property-set report
  
  Revision  Changes    Path
  1.1                  jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertySearchSetProperty.java
  
  Index: PropertySearchSetProperty.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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]
   *
   * SearchPropertySet.java
   *
   * @author eckehard.hermann@softwareag.com
   */
  
  package org.apache.slide.webdav.util;
  import java.util.HashMap;
  import java.util.Collection;
  import java.util.Iterator;
  
  public class PropertySearchSetProperty {
      
      private static HashMap propertyMap = null;
      
      private String property = null;
      
      private String description = null;
      
      private String namespace = null;
      
      /**
       * Returns an iterator over the principal-search-property-set.
       *
       * @return   iterator over the principal-search-property-set
       */
      public static Iterator getPropertySetIterator(){
          if (propertyMap == null) {
              loadProperties();
          }
          Collection values = propertyMap.values();
          return values.iterator();
      }
      
      private PropertySearchSetProperty (String prop, String namesp, String desc) {
          property = prop;
          description = desc;
          namespace = namesp;
      }
      
      /** loads the principal-search-properties-set
       */
      private static void loadProperties () {
          String propSet = AclConstants.C_PRINCIPAL_SEARCH_PROPERTY_SET;
          int index = 0;
          int doubleIndex = 0;
          int trippleIndex = 0;
          String currentProp = null;
          String currentTripple = null;
          String currentDesc = null;
          String namespace = null;
          propertyMap = new HashMap();
          int len = AclConstants.C_PRINCIPAL_SEARCH_PROPERTY_SET.length();
          while ((index != -1) && (index != (len-1))) {
              index = propSet.indexOf(AclConstants.C_SEARCH_PROPERTY_SET_SEPERATOR);
              if (index == -1) {
                  currentTripple = propSet;
              } else {
                  currentTripple = propSet.substring(0, index);
                  propSet = propSet.substring(index+1);
              }
              
              if ((len > 0) && (!(propSet.equals(AclConstants.C_SEARCH_PROPERTY_SET_SEPERATOR)))) {
                  trippleIndex = currentTripple.indexOf(",");
                  if (trippleIndex == -1) {
                      currentProp = currentTripple;
                      namespace = WebdavConstants.DEFAULT_NAMESPACE;
                      currentDesc = "";
                  }else {
                      String currentDouble = currentTripple.substring(trippleIndex+1);
                      currentProp = currentTripple.substring(0,trippleIndex);
                      doubleIndex = currentDouble.indexOf(",");
                      if (doubleIndex == -1) {
                          namespace = currentDouble;
                          currentDesc = "";
                      }else {
                          namespace = currentDouble.substring(0,doubleIndex);
                          currentDesc = currentDouble.substring(doubleIndex+1);
                      }
                  }
                  String key = new String(currentProp + namespace);
                  propertyMap.put(key,(new PropertySearchSetProperty(currentProp,namespace,currentDesc)));
                  len = propSet.length();
              }
          }
      }
      
      /** Verifies if the property is in the search-property-set
       *
       * @return true if property is found, false else
       */
      public static boolean inSearchPropertySet(String property, String namespace) {
          if (propertyMap == null) {
              loadProperties();
          }
          String space;
          if (namespace == null) {
              space = WebdavConstants.DEFAULT_NAMESPACE;
          } else {
              space = namespace;
          }
          return propertyMap.containsKey(property + space);
      }
      
      /** returns the property name of this property
       *
       * @return property name
       */
      public String getPropertyName() {
          return property;
      }
  
      /** returns the namespace of this property
       *
       * @return property namspace
       */
      public String getNamespace() {
          return namespace;
      }
      
      /** returns the description of this property
       *
       * @return property description
       */
      public String getDescription () {
          return description;
      }
  }
  
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>