2002-08-04 18:00:11 +00:00
|
|
|
/** GSWComponentRequestHandler.m - <title>GSWeb: Class GSWComponentRequestHandler</title>
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
Copyright (C) 1999-2003 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
|
|
Date: Feb 1999
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
<license>
|
2000-01-22 12:49:49 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-08-04 18:00:11 +00:00
|
|
|
</license>
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-03-21 14:32:57 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
RCS_ID("$Id$")
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2003-01-22 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/Makefile.postamble:
o use $(LN_S) -f in install-WO-headers
o added $(MKDIRS) $(GNUSTEP_HEADERS)/$(GSWExtensions_wo_HEADER_FILES_INSTALL_DIR);
* GSWExtensionsGSW.framework/Makefile.postamble: use $(LN_S) -f in install-WO-headers
2003-01-20 David Ayers <d.ayers@inode.at>
* Makefile.postamble
o added support for make gswnames=(gsw,wo,all) (corrected
typo)
o reinserted support for $(INSTALL_ROOT_DIR)
* config.h.in
o added HAVE_GDL2
* configure
o added support for --with-gswnames=(gsw,wo,all)
o set LIBWRAP during configure
o added config.mak.in as configurable file
* configure.ac
o (see configure)
* config.mak: removed (replaced by config.mak.in)
* config.mak.in: new file
o added support for make gswnames=(gsw,wo,all)
* gsweb.make.in
o add GSANTLR as auxiliary lib
o add gsweb libs to AUXILIARY_GSW_LIBS
o include correct extensions for GSW/WO-libs
* gsweb_wo.make: new file
* GSWeb/GSWConfig.h
o changed support for GSWEB_WONAMES
o conditionally import file GSWWOCompatiblity
here instead of in GSWeb.h
* GSWeb/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o removed reference to unused files:
GSWeb.m, GSWWOCompatibility.m
o added references to new files:
GSWExtenstions.h, GSWExtWOCompatibility.h
o added support to create WO header files
* GSWeb/Makefile.postamble
o changed support to install WO header files according to
make gswnames=(gsw,wo,all)
o remove Makefile.preamble during distclean
* GSWeb/Makefile.preamble.in
o fixed typo
* GSWeb/GSWeb.h
o moved GSW/WO-Name-mapping to GSWWOCompatibility.h
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWeb/GSWeb.m: removed
* GSWeb/GSWWOCompatibility.h
o changed GSWEB_WONAMES handling
o removed hybrid namespace WO subclasses
o moved & reorganized GSW/WO-Name-mapping from GSWeb.h
o inlucluded missing GSW/WO-Name-mappings
* GSWeb/GSWWOCompatibility.m: removed
* GSWeb/*.m
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWeb/GSWApplication.m
o remove special GSW/WO handling of WOApp
* GSWeb/WebObject/WO*: removed
* GSWeb/WebObject/WebObjects
o replaced inclusions of
<GSWeb/file.h> with "file.h"
* GSWExtensions/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o added references to new files:
GSWExtenstions.h, GSWExtWOCompatibility.h
o added support to create WO header files
* GSWExtensions/Makefile.preamble
o let gnustep make figure whether to link agains debug libs
o added support for make gswnames=(gsw,wo,all)
* GSWExtensions/Makefile.postamble
o changed support to install WO header files according to
make gswnames=(gsw,wo,all)
* GSWExtensions/*.m
o replaced inclusions of
<GSWeb/GSWeb.h> with "GSWExtWOCompatibility.h"
o replaces inclusions of
<GSWExtensions/file.h> with "file.h"
* GSWExtensions/GSWExtensions.h: new file
* GSWExtensions/WOExtensions.h: new file
* GSWExtensions/GSWExtWOCompatibility.h: new file
* GSWExtensionsGSW/GNUMakefile
o added support for make gswnames=(gsw,wo,all)
o ensure each lib gets built with its own object files
o removed deactivated framework extension determination code
o added references to new file GSWExtGSWWOCompatibility.h
o added support to create WO header files
* GSWExtensionsGSW/Makefile.pramble
o let gnustep make figure whether to link agains debug libs
o added support for make gswnames=(gsw,wo,all)
o removed GSWExtensions from ADDITIONAL_LIB_DIRS
* GSWExtensionsGSW/*.m
o replaced inclusions of
<GSWeb/GSWeb.h> with "GSWExtGSWWOCompatibility.h"
* GSWExtensions/GSWExtGSWWOCompatibility.h: new file
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@15675 72102866-910b-0410-8b05-ffd578937521
2003-01-22 12:24:26 +00:00
|
|
|
#include "GSWeb.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWComponentRequestHandler
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-11-18 11:14:55 +00:00
|
|
|
/** Handle request aRequest and return the response
|
|
|
|
This lock application
|
|
|
|
**/
|
2003-06-25 15:21:21 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWResponse*)handleRequest:(GSWRequest*)aRequest
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWResponse* response=nil;
|
|
|
|
GSWApplication* application=[GSWApplication application];
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
[application lockRequestHandling];
|
|
|
|
response=[self lockedHandleRequest:aRequest];
|
|
|
|
if (!response)
|
2000-08-25 10:36:16 +00:00
|
|
|
{
|
2002-11-18 11:14:55 +00:00
|
|
|
response=[GSWResponse responseWithMessage:@"Component Handle request failed. No Response"
|
2002-08-04 18:00:11 +00:00
|
|
|
inContext:nil
|
|
|
|
forRequest:aRequest];
|
|
|
|
[response _finalizeInContext:nil]; //DO Call _finalizeInContext: !
|
2000-08-25 10:36:16 +00:00
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
[application unlockRequestHandling];
|
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return response;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-11-18 11:14:55 +00:00
|
|
|
/** Handle request aRequest and return the response
|
|
|
|
Application should be locked before this
|
|
|
|
**/
|
2003-06-25 15:21:21 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWResponse*)lockedHandleRequest:(GSWRequest*)aRequest
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-10-28 19:57:10 +00:00
|
|
|
//GSWStatisticsStore* statisticsStore=nil;
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWApplication* application=[GSWApplication application];
|
|
|
|
GSWContext* aContext=nil;
|
|
|
|
GSWResponse* response=nil;
|
|
|
|
NSDictionary* requestHandlerValues=nil;
|
|
|
|
BOOL exceptionRaised=NO;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
NS_DURING
|
2002-11-18 11:14:55 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
requestHandlerValues=[GSWComponentRequestHandler _requestHandlerValuesForRequest:aRequest];
|
2000-08-25 10:36:16 +00:00
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
NS_HANDLER
|
2000-08-25 10:36:16 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
exceptionRaised=YES;
|
2000-08-25 10:36:16 +00:00
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
2002-08-04 18:00:11 +00:00
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In -lockedHandleRequest:");
|
2000-08-25 10:36:16 +00:00
|
|
|
LOGException(@"exception=%@",localException);
|
2002-08-04 18:00:11 +00:00
|
|
|
[application awake];
|
|
|
|
response=[application handleException:localException
|
|
|
|
inContext:nil];
|
|
|
|
[application sleep];
|
|
|
|
[response _finalizeInContext:aContext];//DO Call _finalizeInContext: !
|
|
|
|
NSAssert(!response || [response isFinalizeInContextHasBeenCalled],@"_finalizeInContext not called for GSWResponse");
|
2000-08-25 10:36:16 +00:00
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
NS_ENDHANDLER;
|
2002-08-04 18:00:11 +00:00
|
|
|
if (!exceptionRaised)
|
2000-08-25 10:36:16 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
NSString* senderID=nil;
|
|
|
|
NSString* requestContextID=nil;
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
|
2002-10-28 19:57:10 +00:00
|
|
|
//statisticsStore=[[GSWApplication application]statisticsStore];
|
|
|
|
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
|
|
|
|
//[statisticsStore _applicationWillHandleComponentActionRequest];
|
2003-06-25 15:21:21 +00:00
|
|
|
|
|
|
|
aContext=[[GSWApplication application]createContextForRequest:aRequest];
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
|
2003-06-25 15:21:21 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
|
|
|
|
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
|
|
|
[aContext _setSenderID:senderID];
|
2003-06-25 15:21:21 +00:00
|
|
|
|
|
|
|
requestContextID=[requestHandlerValues objectForKey:GSWKey_ContextID[GSWebNamingConv]];
|
|
|
|
NSDebugMLLog(@"requests",@"AA requestContextID=%@",requestContextID);
|
|
|
|
[aContext _setRequestContextID:requestContextID];
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
[application _setContext:aContext];
|
|
|
|
//====>
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[application awake];
|
|
|
|
response=[self lockedDispatchWithPreparedApplication:application
|
|
|
|
inContext:aContext
|
|
|
|
elements:requestHandlerValues];
|
|
|
|
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
exceptionRaised=YES;
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In lockedDispatchWithPreparedApplication");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
response=[application handleException:localException
|
|
|
|
inContext:aContext];
|
|
|
|
[application sleep];
|
|
|
|
[response _finalizeInContext:aContext]; //DO Call _finalizeInContext: !
|
|
|
|
NSAssert(!response || [response isFinalizeInContextHasBeenCalled],
|
|
|
|
@"_finalizeInContext not called for GSWResponse");
|
|
|
|
};
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
if (!exceptionRaised)
|
|
|
|
{
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[application sleep];
|
|
|
|
[response _finalizeInContext:aContext];//LAST //CLEAN
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In [application sleep] or [response _finalizeInContext:aContext]");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
response=[application handleException:localException
|
|
|
|
inContext:nil];
|
|
|
|
[response _finalizeInContext:aContext]; //DO Call _finalizeInContext: !
|
|
|
|
NSAssert(!response || [response isFinalizeInContextHasBeenCalled],
|
|
|
|
@"_finalizeInContext not called for GSWResponse");
|
|
|
|
};
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
};
|
|
|
|
//<===========
|
|
|
|
};
|
|
|
|
|
|
|
|
[application _setContext:nil];
|
2002-10-28 19:57:10 +00:00
|
|
|
//statisticsStore=[[GSWApplication application] statisticsStore];
|
|
|
|
//[statisticsStore _applicationDidHandleComponentActionRequest];
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return response;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWResponse*)lockedDispatchWithPreparedApplication:(GSWApplication*)application
|
|
|
|
inContext:(GSWContext*)aContext
|
|
|
|
elements:(NSDictionary*)elements
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWResponse* response=nil;
|
|
|
|
GSWResponse* errorResponse=nil;
|
|
|
|
GSWSession* session=nil;
|
|
|
|
NSString* sessionID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
|
|
|
NS_DURING
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
|
|
|
sessionID=[elements objectForKey:GSWKey_SessionID[GSWebNamingConv]];
|
|
|
|
NSDebugMLLog(@"requests",@"sessionID=%@",sessionID);
|
|
|
|
if (sessionID)
|
|
|
|
{
|
|
|
|
session=[application restoreSessionWithID:sessionID
|
|
|
|
inContext:aContext];
|
|
|
|
if (!session)
|
|
|
|
{
|
|
|
|
// check for refuseNewSessions
|
|
|
|
errorResponse=[application handleSessionRestorationErrorInContext:aContext];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// check for refuseNewSessions
|
|
|
|
session=[application _initializeSessionInContext:aContext];
|
2002-11-18 11:14:55 +00:00
|
|
|
NSDebugMLLog(@"requests",@"session=%@",session);
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
NS_HANDLER
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"in session create/restore");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
errorResponse=[application handleException:localException
|
|
|
|
inContext:aContext];
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
NS_ENDHANDLER;
|
2002-08-04 18:00:11 +00:00
|
|
|
if (!response && !errorResponse)
|
|
|
|
{
|
|
|
|
if (session)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"requests",@"session=%@",session);
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
response=[self lockedDispatchWithPreparedSession:session
|
|
|
|
inContext:aContext
|
|
|
|
elements:elements];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"in lockedDispatchWithPreparedSession");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
errorResponse=[application handleException:localException
|
|
|
|
inContext:aContext];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
//======LAST //CLEAN
|
|
|
|
if (response || errorResponse)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
|
|
|
NSDebugMLLog(@"requests",@"errorResponse=%@",errorResponse);
|
|
|
|
RETAIN(response);
|
|
|
|
[aContext _putAwakeComponentsToSleep];
|
|
|
|
[application saveSessionForContext:aContext];
|
|
|
|
NSDebugMLLog(@"requests",@"session=%@",session);
|
|
|
|
NSDebugMLLog(@"requests",@"sessionCount=%u",[session retainCount]);
|
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
|
|
|
AUTORELEASE(response);
|
|
|
|
};
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return response ? response : errorResponse;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWResponse*)lockedDispatchWithPreparedSession:(GSWSession*)aSession
|
|
|
|
inContext:(GSWContext*)aContext
|
|
|
|
elements:(NSDictionary*)elements
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWResponse* errorResponse=nil;
|
|
|
|
GSWResponse* response=nil;
|
|
|
|
GSWComponent* page=nil;
|
|
|
|
BOOL storesIDsInCookies=NO;
|
|
|
|
NSString* contextID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
|
|
|
|
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
|
|
|
|
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
|
|
|
|
|
|
|
|
storesIDsInCookies=[aSession storesIDsInCookies]; //For What ?
|
|
|
|
NSDebugMLLog(@"requests",@"storesIDsInCookies=%s",(storesIDsInCookies ? "YES" : "NO"));
|
|
|
|
|
2003-01-19 15:33:07 +00:00
|
|
|
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];//use aContext requestContextID instead ?
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
|
|
|
|
|
|
|
|
if (contextID) // ??
|
|
|
|
{
|
|
|
|
NSAssert([contextID length]>0,@"contextID empty");
|
|
|
|
page=[self lockedRestorePageForContextID:contextID
|
|
|
|
inSession:aSession];
|
|
|
|
//??
|
|
|
|
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
|
|
|
|
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
|
|
|
|
NSDebugMLLog(@"requests",@"page=%@",page);
|
|
|
|
if (!page)
|
|
|
|
{
|
|
|
|
GSWApplication* application=[aSession application];
|
|
|
|
errorResponse=[application handlePageRestorationErrorInContext:aContext];
|
|
|
|
};
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
else
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
|
|
|
NSString* pageName=[elements objectForKey:GSWKey_PageName[GSWebNamingConv]];
|
|
|
|
NSException* exception=nil;
|
|
|
|
NSDebugMLLog(@"requests",@"pageName=%@",pageName);
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
page=[[GSWApplication application] pageWithName:pageName
|
|
|
|
inContext:aContext];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In pageWithName");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
ASSIGN(exception,localException);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
if (!page)
|
|
|
|
{
|
|
|
|
errorResponse=[[GSWApplication application] handleException:exception
|
|
|
|
inContext:aContext];
|
|
|
|
};
|
|
|
|
DESTROY(exception);
|
|
|
|
};
|
|
|
|
if (!response && !errorResponse && page)
|
|
|
|
{
|
|
|
|
[aContext _setPageElement:page];
|
|
|
|
response=[self lockedDispatchWithPreparedPage:page
|
|
|
|
inSession:aSession
|
|
|
|
inContext:aContext
|
|
|
|
elements:elements];
|
|
|
|
};
|
|
|
|
if (response)
|
|
|
|
{
|
|
|
|
BOOL isPageRefreshOnBacktrackEnabled=[[GSWApplication application] isPageRefreshOnBacktrackEnabled];
|
|
|
|
//TODO method adds a header to the HTTP response. This header sets the expiration date for an HTML page to the date and time of the creation of the page. Later, when the browser checks its cache for this page, it finds that the page is no longer valid and so refetches it by resubmitting the request URL to the WebObjects application.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
[aSession _saveCurrentPage];
|
2000-12-03 00:00:18 +00:00
|
|
|
#if 0
|
2002-08-04 18:00:11 +00:00
|
|
|
if (!contextID) // ??
|
|
|
|
{
|
|
|
|
if (![aSession storesIDsInCookies])//??
|
|
|
|
[aSession clearCookieFromResponse:response];
|
|
|
|
};
|
2000-12-03 00:00:18 +00:00
|
|
|
#endif
|
2002-08-04 18:00:11 +00:00
|
|
|
};
|
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return response ? response : errorResponse;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWResponse*)lockedDispatchWithPreparedPage:(GSWComponent*)aComponent
|
|
|
|
inSession:(GSWSession*)aSession
|
|
|
|
inContext:(GSWContext*)aContext
|
|
|
|
elements:(NSDictionary*)elements
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWRequest* request=nil;
|
|
|
|
GSWResponse* response=nil;
|
|
|
|
GSWResponse* errorResponse=nil;
|
|
|
|
NSString* senderID=nil;
|
|
|
|
NSString* contextID=nil;
|
|
|
|
NSString* httpVersion=nil;
|
2003-03-21 14:32:57 +00:00
|
|
|
GSWComponent* page=nil;
|
|
|
|
GSWComponent* responsePage=nil;
|
2002-08-04 18:00:11 +00:00
|
|
|
BOOL isFromClientComponent=NO;
|
|
|
|
BOOL hasFormValues=NO;
|
|
|
|
GSWContext* responseContext=nil;
|
|
|
|
GSWComponent* responsePageElement=nil;
|
|
|
|
GSWRequest* responseRequest=nil;
|
2003-06-25 15:21:21 +00:00
|
|
|
NSString* matchingContextID=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
LOGObjectFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"requests",@"aComponent=%@",aComponent);
|
|
|
|
|
|
|
|
request=[aContext request];
|
|
|
|
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];
|
|
|
|
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
|
|
|
|
|
2003-02-01 19:07:25 +00:00
|
|
|
response=[GSWApp createResponseInContext:aContext];
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
|
|
|
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
|
|
|
|
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
|
|
|
|
|
|
|
|
senderID=[aContext senderID];
|
|
|
|
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
|
2003-06-25 15:21:21 +00:00
|
|
|
NSDebugMLLog(@"requests",@"AA request=%@",request);
|
|
|
|
|
|
|
|
matchingContextID=[aSession _contextIDMatchingIDsInContext:aContext];
|
|
|
|
NSDebugMLLog(@"requests",@"matchingContextID=%@",matchingContextID);
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
httpVersion=[request httpVersion];
|
|
|
|
[response setHTTPVersion:httpVersion];
|
2003-05-14 08:30:22 +00:00
|
|
|
[response setAcceptedEncodings:[request browserAcceptedEncodings]];
|
2002-08-04 18:00:11 +00:00
|
|
|
[response setHeader:@"text/html"
|
|
|
|
forKey:@"content-type"];
|
|
|
|
[aContext _setResponse:response];
|
2003-06-25 15:21:21 +00:00
|
|
|
|
|
|
|
if (matchingContextID)
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
page = [self lockedRestorePageForContextID:matchingContextID
|
|
|
|
inSession:aSession];
|
|
|
|
[aContext _setPageElement:page];
|
|
|
|
[[GSWApplication application] appendToResponse:response
|
2002-08-04 18:00:11 +00:00
|
|
|
inContext:aContext];
|
2003-06-25 15:21:21 +00:00
|
|
|
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[aContext elementID]);
|
2003-06-25 15:21:21 +00:00
|
|
|
}
|
|
|
|
else
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
page=[aContext page];
|
|
|
|
if (contextID)//??
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
hasFormValues=[request _hasFormValues];
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
[aContext _setPageChanged:NO];
|
|
|
|
isFromClientComponent=[request isFromClientComponent];
|
|
|
|
//??
|
|
|
|
[aContext _setPageReplaced:NO];
|
|
|
|
isFromClientComponent=[request isFromClientComponent];
|
2002-08-04 18:00:11 +00:00
|
|
|
};
|
2003-06-25 15:21:21 +00:00
|
|
|
if (hasFormValues)
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
NSDebugMLLog(@"requests",@"Before takeValues [aContext elementID]=%@",
|
|
|
|
[aContext elementID]);
|
2002-08-04 18:00:11 +00:00
|
|
|
NSAssert([[aContext elementID] length]==0,
|
2003-06-25 15:21:21 +00:00
|
|
|
@"1 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
[[GSWApplication application] takeValuesFromRequest:request
|
|
|
|
inContext:aContext];
|
|
|
|
NSDebugMLLog(@"requests",@"After takeValues[aContext elementID]=%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[aContext elementID]);
|
2003-06-25 15:21:21 +00:00
|
|
|
if (![[aContext elementID] length]==0)
|
|
|
|
{
|
|
|
|
LOGSeriousError0(@"2 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
[aContext deleteAllElementIDComponents];//NDFN
|
|
|
|
};
|
|
|
|
[aContext _setPageChanged:NO];//???
|
|
|
|
isFromClientComponent=[request isFromClientComponent];
|
|
|
|
[aContext _setPageReplaced:NO];
|
|
|
|
};
|
|
|
|
if (senderID) //??
|
|
|
|
{
|
|
|
|
BOOL pageChanged=NO;
|
|
|
|
NSException* exception=nil;
|
|
|
|
NSDebugMLLog(@"requests",@"Before invokeAction [aContext elementID]=%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[aContext elementID]);
|
|
|
|
NSAssert([[aContext elementID] length]==0,
|
2003-06-25 15:21:21 +00:00
|
|
|
@"3 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
// Exception catching here ?
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
responsePage=(GSWComponent*)[[GSWApplication application] invokeActionForRequest:request
|
|
|
|
inContext:aContext];
|
|
|
|
NSDebugMLLog(@"requests",@"After invokeAction [aContext elementID]=%@",[aContext elementID]);
|
|
|
|
NSAssert([[aContext elementID] length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException0(@"exception in invokeActionForRequest");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
|
|
|
@"In invokeActionForRequest component=%@ of Class %@",
|
|
|
|
[aComponent name],
|
|
|
|
[aComponent class]);
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
ASSIGN(exception,localException);
|
|
|
|
if (!responsePage)
|
|
|
|
{
|
|
|
|
errorResponse=[[GSWApplication application] handleException:exception
|
|
|
|
inContext:aContext];
|
|
|
|
};
|
|
|
|
DESTROY(exception);
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
// [aContext deleteAllElementIDComponents];//NDFN
|
|
|
|
NSDebugMLLog(@"requests",@"responsePage=%@",responsePage);
|
|
|
|
if (errorResponse)
|
|
|
|
{
|
|
|
|
response=errorResponse;
|
|
|
|
responseContext=aContext;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!responsePage)
|
|
|
|
responsePage=page;
|
|
|
|
|
|
|
|
responseContext=[(GSWComponent*)responsePage context];//So what ?
|
|
|
|
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
|
|
|
[responseContext _setPageReplaced:NO];
|
|
|
|
responsePageElement=(GSWComponent*)[responseContext _pageElement];
|
|
|
|
NSDebugMLLog(@"requests",@"responsePageElement=%@",responsePageElement);
|
|
|
|
pageChanged=(responsePage!=responsePageElement);
|
|
|
|
[responseContext _setPageChanged:pageChanged];//??
|
|
|
|
if (pageChanged)
|
|
|
|
{
|
|
|
|
[responseContext _setPageElement:responsePage];
|
|
|
|
};
|
|
|
|
responseRequest=[responseContext request];//SoWhat ?
|
|
|
|
[responseRequest isFromClientComponent];//SoWhat
|
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
2003-06-25 15:21:21 +00:00
|
|
|
else
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2003-06-25 15:21:21 +00:00
|
|
|
responseContext=aContext;
|
|
|
|
responsePageElement=page;
|
|
|
|
responsePage=aComponent;
|
|
|
|
responseRequest=request;
|
|
|
|
};
|
|
|
|
if (!errorResponse)
|
|
|
|
{
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"requests",@"response before appendToResponse=%@",response);
|
|
|
|
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
|
|
|
|
NSAssert([[aContext elementID] length]==0,
|
|
|
|
@"5 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
NSDebugMLLog(@"requests",@"Before appendToResponse [aContext elementID]=%@",
|
|
|
|
[aContext elementID]);
|
|
|
|
[[GSWApplication application] appendToResponse:response
|
|
|
|
inContext:responseContext];
|
|
|
|
NSDebugMLLog(@"requests",@"After appendToResponse [aContext elementID]=%@",
|
|
|
|
[aContext elementID]);
|
|
|
|
NSAssert([[aContext elementID] length]==0,
|
|
|
|
@"6 lockedDispatchWithPreparedPage elementID length>0");
|
|
|
|
responseRequest=[responseContext request];//SoWhat ?
|
|
|
|
//Not used [responseRequest isFromClientComponent];//SoWhat
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
|
|
|
@"In appendToResponse page=%@ of Class %@",
|
|
|
|
[page name],
|
|
|
|
[page class]);
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
NSDebugMLLog(@"requests",@"context=%@",aContext);
|
|
|
|
errorResponse=[[GSWApplication application] handleException:localException
|
|
|
|
inContext:aContext];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
};
|
|
|
|
NSDebugMLLog(@"requests",@"response=%@",response);
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGObjectFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return errorResponse ? errorResponse : response;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(GSWComponent*)lockedRestorePageForContextID:(NSString*)aContextID
|
|
|
|
inSession:(GSWSession*)aSession
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
GSWComponent* page=[aSession restorePageForContextID:aContextID];
|
|
|
|
return page;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWComponentRequestHandler (GSWRequestHandlerClassA)
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
+(id)handler
|
|
|
|
{
|
|
|
|
return [[GSWComponentRequestHandler new] autorelease];
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
+(NSDictionary*)_requestHandlerValuesForRequest:(GSWRequest*)aRequest
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDictionary* values=nil;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGClassFnStart();
|
2000-08-25 10:36:16 +00:00
|
|
|
NS_DURING
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
values=[aRequest uriOrFormOrCookiesElements];
|
2003-01-19 15:33:07 +00:00
|
|
|
NSDebugMLLog(@"requests",@"values=%@",values);
|
2000-08-25 10:36:16 +00:00
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGException(@"%@ (%@)",
|
|
|
|
localException,
|
|
|
|
[localException reason]);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In +_requestHandlerValuesForRequest:");
|
|
|
|
LOGException(@"exception=%@",localException);
|
|
|
|
[localException raise];
|
|
|
|
};
|
|
|
|
NS_ENDHANDLER;
|
2000-01-22 12:49:49 +00:00
|
|
|
LOGClassFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return values;
|
2000-01-22 12:49:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|