libs-gsweb/GSWeb.framework/GSWComponentRequestHandler.m
Manuel Guesdon cf6ed0b5cb 2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWGNUmakefile:
		o removed NSObject+IVarAccess+PerformSel.*
	* GSWeb.framework/GSWConstants.m:
		o fix GSWHTTPHeader_Response_HeaderLineEnd: remove space at the begining
		o use RCS_ID
	* GSWeb.framework/Adaptors/common/GSWHTTPResponse.c:
		o fix status in GSWHTTPResponse_New()
	* GSWAdaptors/Apache/mod_gsweb.c:
		o fixes bad returned status
		o traces
	* GSWeb.framework/GSWTemplateParserANTLR.m:
		o removed logs
		o fixes for warnings
		o use RCS_ID
	* GSWeb.framework/GSWApplication.m:
		o use RCS_ID
		o added logs
		o new method to begin rewrite exception handling
	* GSWeb.framework/GSWRequest.m:
		o logs
		o fix in -_getFormValuesFromMultipartFormData to handle more than one value per name
		o use RCS_ID
		o -fix bad types in uriElementForKey:
	* GSWeb.framework/GSWConditional.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWHTMLStaticElement.m:
		o added asserts
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWComponentReference.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWActiveImage.m:
		o added asserts
	* GSWeb.framework/GSWComponentContent.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWForm.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWHTMLDynamicElement.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWHTMLURLValuedElement.m:
		o use RCS_ID
		o added asserts
	* GSWeb.framework/GSWRepetition.m:
		o added asserts
		o use RCS_ID
	* GSWeb.framework/GSWExtensions.framework/GNUmakefile:
		o added GSWPageRestorationErrorPage.gswc
	* GSWeb.framework/GSWFileUploadComponent.m:
		o use RCS_ID
	* GSWeb.framework/GSWImage.m:
		o Don't output nil height/width
		o fix: get component before using !
		o use RCS_ID
	* GSWeb.framework/GSWElementIDString.m:
		o in -initWithCoder: retain _string
		o use RCS_ID
	* GSWeb.framework/GSWElementIDString.h:
		o cleaned
	* config.h.in:
		o define RCS_ID like in GDL2
	* GSWeb.framework/GSWDirectActionRequestHandler.[hm]:
		o added +additionalRequestPathArrayFromRequest:
		o enable directAction with additional path components
		o use RCS_ID
	* GSWeb.framework/GSWDirectAction.[hm]:
		o added -additionalRequestPathArray
		o use RCS_ID
	* GSWeb.framework/GSWeb.h:
		o include GSCategories.h
	* GSWeb.framework/GSWDebug.m:
		o use RCS_ID
	* GSWeb.framework/GSWPageDefParserExt.m:
		o use RCS_ID
	* GSWeb.framework/GSWPageDefElement.m:
		o use RCS_ID
	* GSWeb.framework/GSWDeployedBundle.m:
		o use RCS_ID
	* GSWeb.framework/GSWProjectBundle.m:
		o use RCS_ID
	* GSWeb.framework/GSWStats.m:
		o use RCS_ID
	* GSWeb.framework/GSWBundle.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWTemplateParser.m::
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWTemplateParserXML.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWComponent.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWDisplayGroup.m:
		o clean warnings
		o fix -validateValue:forKey: call
		o use RCS_ID
	* GSWeb.framework/GSWHTMLParserExt.m:
		o use RCS_ID
	* GSWeb.framework/GSWAssociation.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWResourceManager.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWSession.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWMultiKeyDictionary.m:
		o use RCS_ID
	* GSWeb.framework/GSWResponse.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWStatisticsStore.m:
		o clean warnings
	* GSWeb.framework/GSWAdaptor.m:
		o use RCS_ID
	* GSWeb.framework/GSWGeometricRegion.[hm]:
		o types change
		o use RCS_ID
	* GSWeb.framework/GSWActiveImage.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWBody.m:
		o use RCS_ID
	* GSWeb.framework/GSWTextField.m:
		o use RCS_ID
	* GSWeb.framework/GSWSubmitButton.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWHTMLBareString.m:
		o use RCS_ID
	* GSWeb.framework/GSWHTMLComment.m:
		o use RCS_ID
	* GSWeb.framework/GSWApplet.m:
		o use RCS_ID
	* GSWeb.framework/GSWBrowser.m:
		o use RCS_ID
	* GSWeb.framework/GSWCheckBoxList.m:
		o use RCS_ID
	* GSWeb.framework/GSWEmbeddedObject.m:
		o use RCS_ID
	* GSWeb.framework/GSWFrame.m:
		o use RCS_ID
	* GSWeb.framework/GSWGenericContainer.m:
		o use RCS_ID
	* GSWeb.framework/GSWGenericElement.m:
		o use RCS_ID
	* GSWeb.framework/GSWHyperlink.m:
		o use RCS_ID
		o clean warnings
	* GSWeb.framework/GSWImageButton.m:
		o use RCS_ID
		o clean warnings
	* GSWeb.framework/GSWJavaScript.m:
		o use RCS_ID
	* GSWeb.framework/GSWNestedList.m:
		o use RCS_ID
	* GSWeb.framework/GSWParam.m:
		o use RCS_ID
	* GSWeb.framework/GSWPasswordField.m:
		o use RCS_ID
	* GSWeb.framework/GSWPopUpButton.m:
		o use RCS_ID
	* GSWeb.framework/GSWRadioButtonList.m:
		o use RCS_ID
	* GSWeb.framework/GSWResetButton.m:
		o use RCS_ID
	* GSWeb.framework/GSWSwitchComponent.m:
		o use RCS_ID
	* GSWeb.framework/GSWVBScript.m:
		o use RCS_ID
	* GSWeb.framework/GSWString.m:
		o use RCS_ID
	* GSWeb.framework/GSWText.m:
		o use RCS_ID
	* GSWeb.framework/GSWCookie.m:
		o use RCS_ID
	* GSWeb.framework/GSWRequestHandler.m:
		o use RCS_ID
	* GSWeb.framework/GSWMailDelivery.m:
		o use RCS_ID
	* GSWeb.framework/GSWComponentRequestHandler.m:
		o use RCS_ID
		o clean warnings
	* GSWeb.framework/GSWKeyValueAssociation.m:
		o use RCS_ID
	* GSWeb.framework/GSWHTMLStaticGroup.m:
		o use RCS_ID
	* GSWeb.framework/GSWConstantValueAssociation.m:
		o use RCS_ID
	* GSWeb.framework/GSWDynamicURLString.m:
		o use RCS_ID
	* GSWeb.framework/GSWBindingNameAssociation.m:
		o use RCS_ID
	* GSWeb.framework/GSWBindingNameAssociation.[hm]
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWURLValuedElementData.m:
		o clean warnings
		o use RCS_ID
	* GSWeb.framework/GSWToggle.m:
		o use RCS_ID
	* GSWeb.framework/GSWFileUpload.m:
		o use RCS_ID
	* GSWeb.framework/GSWResourceURL.m:
		o use RCS_ID
	* GSWeb.framework/GSWProcFS.m:
		o use RCS_ID
	* GSWeb.framework/GSWActionURL.m:
		o use RCS_ID
	* GSWeb.framework/GSWContext.m:
		o use RCS_ID
	* GSWeb.framework/GSWDefaultAdaptorThread.m:
		o use RCS_ID
	* GSWeb.framework/GSWDynamicElement.m:
		o use RCS_ID
	* GSWeb.framework/GSWeb.m:
		o use RCS_ID
	* GSWeb.framework/GSWElement.m:
		o use RCS_ID
	* GSWeb.framework/GSWResourceRequestHandler.m:
		o use RCS_ID
	* GSWeb.framework/GSWServerSessionStore.m:
		o use RCS_ID
	* GSWeb.framework/GSWSessionStore.m:
		o use RCS_ID
	* GSWeb.framework/GSWSessionTimeOut.m:
		o use RCS_ID
	* GSWeb.framework/GSWSessionTimeOutManager.m:
		o use RCS_ID
	* GSWeb.framework/GSWTransactionRecord.m:
		o use RCS_ID
	* GSWeb.framework/GSWUtils.m:
		o use RCS_ID
	* GSWeb.framework/GSWWOCompatibility.m:
		o use RCS_ID
	* GSWeb.framework/NSString+HTML.m:
		o use RCS_ID
	* GSWeb.framework/NSString+Trimming.m:
		o use RCS_ID


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@16216 72102866-910b-0410-8b05-ffd578937521
2003-03-21 14:32:57 +00:00

570 lines
21 KiB
Objective-C

/** GSWComponentRequestHandler.m - <title>GSWeb: Class GSWComponentRequestHandler</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
This file is part of the GNUstep Web Library.
<license>
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.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include "GSWeb.h"
//====================================================================
@implementation GSWComponentRequestHandler
//--------------------------------------------------------------------
/** Handle request aRequest and return the response
This lock application
**/
-(GSWResponse*)handleRequest:(GSWRequest*)aRequest
{
//OK
GSWResponse* response=nil;
GSWApplication* application=[GSWApplication application];
LOGObjectFnStart();
[application lockRequestHandling];
response=[self lockedHandleRequest:aRequest];
if (!response)
{
response=[GSWResponse responseWithMessage:@"Component Handle request failed. No Response"
inContext:nil
forRequest:aRequest];
[response _finalizeInContext:nil]; //DO Call _finalizeInContext: !
};
[application unlockRequestHandling];
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response;
};
//--------------------------------------------------------------------
/** Handle request aRequest and return the response
Application should be locked before this
**/
-(GSWResponse*)lockedHandleRequest:(GSWRequest*)aRequest
{
//OK
//GSWStatisticsStore* statisticsStore=nil;
GSWApplication* application=[GSWApplication application];
GSWContext* aContext=nil;
GSWResponse* response=nil;
NSDictionary* requestHandlerValues=nil;
NSString* senderID=nil;
BOOL exceptionRaised=NO;
LOGObjectFnStart();
NS_DURING
{
requestHandlerValues=[GSWComponentRequestHandler _requestHandlerValuesForRequest:aRequest];
}
NS_HANDLER
{
exceptionRaised=YES;
LOGException(@"%@ (%@)",
localException,
[localException reason]);
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"In -lockedHandleRequest:");
LOGException(@"exception=%@",localException);
[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");
};
NS_ENDHANDLER;
if (!exceptionRaised)
{
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
//statisticsStore=[[GSWApplication application]statisticsStore];
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
//[statisticsStore _applicationWillHandleComponentActionRequest];
aContext=[GSWContext contextWithRequest:aRequest];
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
[aContext _setSenderID:senderID];
[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];
//statisticsStore=[[GSWApplication application] statisticsStore];
//[statisticsStore _applicationDidHandleComponentActionRequest];
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response;
};
//--------------------------------------------------------------------
-(GSWResponse*)lockedDispatchWithPreparedApplication:(GSWApplication*)application
inContext:(GSWContext*)aContext
elements:(NSDictionary*)elements
{
//OK
GSWResponse* response=nil;
GSWResponse* errorResponse=nil;
GSWSession* session=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
NS_DURING
{
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];
NSDebugMLLog(@"requests",@"session=%@",session);
}
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"in session create/restore");
LOGException(@"exception=%@",localException);
errorResponse=[application handleException:localException
inContext:aContext];
}
NS_ENDHANDLER;
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);
};
LOGObjectFnStop();
return response ? response : errorResponse;
};
//--------------------------------------------------------------------
-(GSWResponse*)lockedDispatchWithPreparedSession:(GSWSession*)aSession
inContext:(GSWContext*)aContext
elements:(NSDictionary*)elements
{
//OK
GSWResponse* errorResponse=nil;
GSWResponse* response=nil;
GSWComponent* page=nil;
BOOL storesIDsInCookies=NO;
NSString* contextID=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
storesIDsInCookies=[aSession storesIDsInCookies]; //For What ?
NSDebugMLLog(@"requests",@"storesIDsInCookies=%s",(storesIDsInCookies ? "YES" : "NO"));
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];//use aContext requestContextID instead ?
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];
};
}
else
{
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.
[aSession _saveCurrentPage];
#if 0
if (!contextID) // ??
{
if (![aSession storesIDsInCookies])//??
[aSession clearCookieFromResponse:response];
};
#endif
};
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response ? response : errorResponse;
};
//--------------------------------------------------------------------
-(GSWResponse*)lockedDispatchWithPreparedPage:(GSWComponent*)aComponent
inSession:(GSWSession*)aSession
inContext:(GSWContext*)aContext
elements:(NSDictionary*)elements
{
//OK
GSWRequest* request=nil;
GSWResponse* response=nil;
GSWResponse* errorResponse=nil;
NSString* senderID=nil;
NSString* contextID=nil;
NSString* httpVersion=nil;
GSWComponent* page=nil;
GSWComponent* responsePage=nil;
BOOL isFromClientComponent=NO;
BOOL hasFormValues=NO;
GSWContext* responseContext=nil;
GSWComponent* responsePageElement=nil;
GSWRequest* responseRequest=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"aComponent=%@",aComponent);
request=[aContext request];
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
response=[GSWApp createResponseInContext:aContext];
NSDebugMLLog(@"requests",@"response=%@",response);
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=[aContext senderID];
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
//TODO
{
GSWContext* matchedContext=[aSession _contextIDMatchingContextID:contextID
requestSenderID:senderID];
}
httpVersion=[request httpVersion];
[response setHTTPVersion:httpVersion];
[response setHeader:@"text/html"
forKey:@"content-type"];
[aContext _setResponse:response];
page=[aContext page];
if (contextID)//??
{
hasFormValues=[request _hasFormValues];
}
else
{
[aContext _setPageChanged:NO];
isFromClientComponent=[request isFromClientComponent];
//??
[aContext _setPageReplaced:NO];
isFromClientComponent=[request isFromClientComponent];
};
if (hasFormValues)
{
NSDebugMLLog(@"requests",@"Before takeValues [aContext elementID]=%@",
[aContext elementID]);
NSAssert([[aContext elementID] length]==0,
@"1 lockedDispatchWithPreparedPage elementID length>0");
[[GSWApplication application] takeValuesFromRequest:request
inContext:aContext];
NSDebugMLLog(@"requests",@"After takeValues[aContext elementID]=%@",
[aContext elementID]);
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]=%@",
[aContext elementID]);
NSAssert([[aContext elementID] length]==0,
@"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
};
}
else
{
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;
};
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return errorResponse ? errorResponse : response;
};
//--------------------------------------------------------------------
-(GSWComponent*)lockedRestorePageForContextID:(NSString*)aContextID
inSession:(GSWSession*)aSession
{
//OK
GSWComponent* page=[aSession restorePageForContextID:aContextID];
return page;
};
@end
//====================================================================
@implementation GSWComponentRequestHandler (GSWRequestHandlerClassA)
//--------------------------------------------------------------------
+(id)handler
{
return [[GSWComponentRequestHandler new] autorelease];
};
//--------------------------------------------------------------------
+(NSDictionary*)_requestHandlerValuesForRequest:(GSWRequest*)aRequest
{
//OK
NSDictionary* values=nil;
LOGClassFnStart();
NS_DURING
{
values=[aRequest uriOrFormOrCookiesElements];
NSDebugMLLog(@"requests",@"values=%@",values);
}
NS_HANDLER
{
LOGException(@"%@ (%@)",
localException,
[localException reason]);
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In +_requestHandlerValuesForRequest:");
LOGException(@"exception=%@",localException);
[localException raise];
};
NS_ENDHANDLER;
LOGClassFnStop();
return values;
};
@end