]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOMessage+XML.m
fixed duplicate -awake
[sope] / sope-appserver / NGObjWeb / WOMessage+XML.m
index ac0eff52f8e52fb437fed9d3d777ff53c8ea0642..7e51f5a261a65db1ec3c4acd37d16167419ccd01 100644 (file)
@@ -1,27 +1,25 @@
 /*
-  Copyright (C) 2000-2003 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
 
-  This file is part of OGo
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE is free software; you can redistribute it and/or modify it under
   the terms of the GNU Lesser General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
 
-  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with OGo; see the file COPYING.  If not, write to the
+  License along with SOPE; see the file COPYING.  If not, write to the
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
-// $Id$
 
 #include <NGObjWeb/WOMessage.h>
-//#include <DOM/EDOM.h>
 #include "common.h"
 
 @interface NSObject(DOMXML)
   NSData *data;
   id     dom;
   
-  if ((dom = [[self userInfo] objectForKey:@"WODOMContent"]) == nil) {
+  if ((dom = self->domCache) == nil) {
     [self setContent:nil];
     return;
   }
   
-  outputter = [[NSClassFromString(@"DOMXMLOutputter") alloc] init];
-  AUTORELEASE(outputter);
-
+  outputter =
+    [[[NSClassFromString(@"DOMXMLOutputter") alloc] init] autorelease];
+  
   ms = [NSMutableString stringWithCapacity:2048];
   [outputter outputDocument:dom to:ms];
-    
+  
   data = [ms dataUsingEncoding:NSUTF8StringEncoding];
 
   [self setContent:data];
 }
 
 - (void)setContentDOMDocument:(id)_dom {
-  if (_dom == nil) {
-    if ((_dom = [[self userInfo] objectForKey:@"WODOMContent"])) {
-      NSMutableDictionary *ui;
-
-      ui = [[self userInfo] mutableCopy];
-      [ui removeObjectForKey:@"WODOMContent"];
-      [self setUserInfo:ui];
-      RELEASE(ui); ui = nil;
-    }
-    [self _rebuildDOMDataContent];
-    return;
-  }
-  else {
-    NSMutableDictionary *ui;
-    
-    /* cache DOM structure in userInfo */
-    ui = [[self userInfo] mutableCopy];
-    if (ui == nil) ui = [[NSMutableDictionary alloc] initWithCapacity:2];
-    [ui setObject:_dom forKey:@"WODOMContent"];
-    [self setUserInfo:ui];
-    RELEASE(ui); ui = nil;
-
-    [self _rebuildDOMDataContent];
-  }
+  ASSIGN(self->domCache, _dom);
+  [self _rebuildDOMDataContent];
 }
 
 - (void)appendContentDOMDocumentFragment:(id)_domfrag {
   NSData *data;
   id dom;
   
-  if ((dom = [[self userInfo] objectForKey:@"WODOMContent"]))
+  if ((dom = self->domCache) != nil)
     return dom;
   
-  if ((data = [self content])) {
+  if ((data = [self content]) != nil) {
     id builder;
     
     builder = [[[NSClassFromString(@"DOMSaxBuilder") alloc] init] autorelease];
-    
     dom = [[builder buildFromData:data] retain];
   }
   
-  /* cache DOM structure in userInfo */
-  if (dom) {
-    NSMutableDictionary *ui;
-    
-    ui = [[self userInfo] mutableCopy];
-    if (ui == nil) ui = [[NSMutableDictionary alloc] initWithCapacity:2];
-    [ui setObject:dom forKey:@"WODOMContent"];
-    [self setUserInfo:ui];
-    RELEASE(ui); ui = nil;
+  /* cache DOM structure */
+  if (dom != nil) {
+    ASSIGN(self->domCache, dom);
   }
   return dom;
 }