ozeigermann    2005/02/11 17:58:58

  Modified:    wck/src/org/apache/slide/simple/store
                        WebdavStoreAdapter.java
  Log:
  Fixed namespace issues
  
  Revision  Changes    Path
  1.5       +27 -10    
jakarta-slide/wck/src/org/apache/slide/simple/store/WebdavStoreAdapter.java
  
  Index: WebdavStoreAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/wck/src/org/apache/slide/simple/store/WebdavStoreAdapter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebdavStoreAdapter.java   9 Feb 2005 19:16:28 -0000       1.4
  +++ WebdavStoreAdapter.java   12 Feb 2005 01:58:58 -0000      1.5
  @@ -69,6 +69,20 @@
   
       protected static ThreadLocal credentials = new ThreadLocal();
   
  +    protected static String getNamespacedPropertyName(String namespace, 
String propertyName) {
  +        String result;
  +        if (namespace == null) {
  +            result = propertyName;
  +        } else {
  +            if (namespace.endsWith(":")) {
  +                result = namespace + propertyName;
  +            } else {
  +                result = namespace + ":" + propertyName;
  +            }
  +        }
  +        return result;
  +    }
  +
       protected Hashtable parameters;
   
       protected String callBackFactoryClassName;
  @@ -634,8 +648,6 @@
               } else {
                   NodeRevisionDescriptor descriptor = new 
NodeRevisionDescriptor(new NodeRevisionNumber(1, 0),
                           NodeRevisionDescriptors.MAIN_BRANCH, new Vector(), 
new ArrayList());
  -                // override default collection as we will set this later
  -                
descriptor.removeProperty(NodeRevisionDescriptor.RESOURCE_TYPE);
                   if (objectExistsInStore(uri)) {
                       try {
   
  @@ -653,7 +665,7 @@
                                   String effectiveName = (String) 
entry.getKey();
                                   String name = effectiveName;
                                   String ns = null;
  -                                int colonPos = effectiveName.indexOf(':');
  +                                int colonPos = 
effectiveName.lastIndexOf(':');
                                   if (colonPos > 0 && colonPos < 
effectiveName.length()) {
                                       name = effectiveName.substring(colonPos 
+ 1);
                                       ns = effectiveName.substring(0, colonPos 
+ 1);
  @@ -676,6 +688,7 @@
                               
descriptor.setResourceType(NodeRevisionDescriptor.COLLECTION_TYPE);
                               descriptor.setContentLength(0);
                           } else {
  +                            
descriptor.removeProperty(NodeRevisionDescriptor.RESOURCE_TYPE);
                               long length = 
store.getResourceLength(uri.toString());
                               if (length != -1) {
                                   descriptor.setContentLength(length);
  @@ -740,7 +753,7 @@
                           NodeProperty property = (NodeProperty) 
updated.nextElement();
                           String name = property.getName();
                           String ns = property.getNamespace();
  -                        String effectiveName = 
revisionDescriptor.getNamespacedPropertyName(ns, name);
  +                        String effectiveName = getNamespacedPropertyName(ns, 
name);
                           String value = property.getValue().toString();
                           String type = property.getType();
                           // XXX we do not use the type as it rarely contains
  @@ -752,8 +765,12 @@
                       while (removed.hasMoreElements()) {
                           NodeProperty property = (NodeProperty) 
removed.nextElement();
                           String name = property.getName();
  +                        
  +                        // we might have set that before
  +                        if 
(name.equals(NodeRevisionDescriptor.RESOURCE_TYPE)) continue;
  +
                           String ns = property.getNamespace();
  -                        String effectiveName = 
revisionDescriptor.getNamespacedPropertyName(ns, name);
  +                        String effectiveName = getNamespacedPropertyName(ns, 
name);
                           singlePropStore.removeProperty(uri.toString(), name);
                       }
                   } else if (bulkPropStore != null) {
  @@ -763,7 +780,7 @@
                           NodeProperty property = (NodeProperty) 
enum.nextElement();
                           String name = property.getName();
                           String ns = property.getNamespace();
  -                        String effectiveName = 
revisionDescriptor.getNamespacedPropertyName(ns, name);
  +                        String effectiveName = getNamespacedPropertyName(ns, 
name);
                           String value = property.getValue().toString();
                           String type = property.getType();
                           // XXX we do not use the type as it rarely contains
  
  
  

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

Reply via email to