2002-08-04 18:00:11 +00:00
|
|
|
/** GSWComponentRequestHandler.m - <title>GSWeb: Class GSWComponentRequestHandler</title>
|
|
|
|
|
2004-12-31 14:33:16 +00:00
|
|
|
Copyright (C) 1999-2004 Free Software Foundation, Inc.
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
Written by: David Wetzel <dave@turbocat.de>
|
|
|
|
Date: Mar 2008
|
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"
|
2008-03-30 22:10:20 +00:00
|
|
|
#include "GSWPrivate.h"
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWComponentRequestHandler
|
|
|
|
|
2003-06-25 15:21:21 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
// note: we are NOT looking at [WORequest _lookForIDsInCookiesFirst] since it is always NO -- dw
|
2007-04-13 18:32:02 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
- (NSDictionary*) requestHandlerValuesForRequest:(GSWRequest *) aRequest
|
|
|
|
{
|
|
|
|
NSMutableDictionary * aDictionary = [NSMutableDictionary dictionary];
|
|
|
|
NSArray * pathArray = [aRequest requestHandlerPathArray];
|
|
|
|
NSString * lastObject = nil;
|
|
|
|
NSString * penultElement = nil;
|
|
|
|
NSString * aSessionID = nil;
|
|
|
|
NSString * aContextID = nil;
|
|
|
|
NSString * aSenderID = nil;
|
|
|
|
NSMutableString * pageName = nil;
|
|
|
|
NSString * sessionIdKey = [GSWApp sessionIdKey];
|
|
|
|
int p = 0;
|
|
|
|
int count = 0;
|
|
|
|
int length = 0;
|
|
|
|
int pageNameLocation = 0;
|
|
|
|
int pageNameLength = 0;
|
|
|
|
|
|
|
|
if ((pathArray))
|
|
|
|
{
|
|
|
|
count = [pathArray count];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count != 0)
|
|
|
|
{
|
|
|
|
lastObject = [pathArray lastObject];
|
|
|
|
if(count > 1)
|
2000-08-25 10:36:16 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
penultElement = [pathArray objectAtIndex:count - 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (length = [lastObject length]; ((p < length) && (isdigit([lastObject characterAtIndex:p]) != 0)); p++) { }
|
|
|
|
|
|
|
|
if ((p < length) && ([lastObject characterAtIndex:p] == '.')) {
|
|
|
|
aContextID = [lastObject substringToIndex:p];
|
|
|
|
p++;
|
|
|
|
aSenderID = [lastObject substringFromIndex:p];
|
|
|
|
|
|
|
|
if ((penultElement != nil) && ([penultElement hasSuffix:GSWPagePSuffix[GSWebNamingConv]])) {
|
|
|
|
if (GSWebNamingConv == 1) {
|
|
|
|
pageNameLength = count - 2; // .wo
|
|
|
|
} else {
|
|
|
|
pageNameLength = count - 4; // .gswc
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (penultElement != nil) {
|
|
|
|
aSessionID = penultElement;
|
|
|
|
pageNameLength = count - 2; // TODO:check if that works with GSWNAMES.
|
|
|
|
} else {
|
|
|
|
pageNameLength = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aContextID != nil)
|
|
|
|
{
|
|
|
|
[aDictionary setObject:aContextID forKey:GSWKey_ContextID[GSWebNamingConv]]; // wocid
|
|
|
|
[aDictionary setObject:aSenderID forKey:GSWKey_ElementID[GSWebNamingConv]]; // woeid
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ([lastObject hasSuffix:GSWPagePSuffix[GSWebNamingConv]]) {
|
|
|
|
pageNameLength = count;
|
|
|
|
} else {
|
|
|
|
aSessionID = lastObject;
|
|
|
|
pageNameLength = count - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pageNameLength != 0) {
|
|
|
|
if (pageNameLength == 1) {
|
|
|
|
pageName = [pathArray objectAtIndex:0];
|
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
pageName = [[NSMutableString alloc] initWithCapacity:256];
|
|
|
|
[pageName autorelease];
|
|
|
|
|
|
|
|
for (i = pageNameLocation; i < pageNameLength - pageNameLocation; i++) {
|
|
|
|
[pageName appendString:[pathArray objectAtIndex:i]];
|
|
|
|
[pageName appendString:@"/"];
|
|
|
|
}
|
|
|
|
[pageName appendString:[pathArray objectAtIndex:i]];
|
|
|
|
}
|
|
|
|
if ([pageName hasSuffix:GSWPagePSuffix[GSWebNamingConv]]) {
|
|
|
|
if (GSWebNamingConv == 1) {
|
|
|
|
pageName = (NSMutableString*) [pageName substringToIndex:[pageName length] - 3]; // .wo
|
|
|
|
} else {
|
|
|
|
pageName = (NSMutableString*) [pageName substringToIndex:[pageName length] - 5]; // .gswc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[aDictionary setObject:pageName
|
|
|
|
forKey:GSWKey_PageName[GSWebNamingConv]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aSessionID == nil) {
|
|
|
|
aSessionID = [aRequest stringFormValueForKey:sessionIdKey];
|
|
|
|
|
|
|
|
if(aSessionID == nil) {
|
|
|
|
aSessionID = [aRequest cookieValueForKey:sessionIdKey];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ([GSWApp shouldRestoreSessionOnCleanEntry:aRequest]) {
|
|
|
|
aSessionID = [aRequest cookieValueForKey:sessionIdKey];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((aSessionID != nil) && ([aSessionID length] > 0)) {
|
|
|
|
[aDictionary setObject:aSessionID forKey:sessionIdKey];
|
|
|
|
}
|
|
|
|
return aDictionary;
|
|
|
|
}
|
2003-06-25 15:21:21 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWResponse * _dispatchWithPreparedPage(GSWComponent * aPage, GSWSession * aSession, GSWContext * aContext, NSDictionary * someElements)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWRequest * aRequest = [aContext request];
|
|
|
|
GSWApplication * anApplication = GSWApp;
|
|
|
|
GSWResponse * aResponse = [anApplication createResponseInContext:aContext];
|
|
|
|
NSString * aSenderID = [aContext senderID];
|
|
|
|
NSString * oldContextID = [aSession _contextIDMatchingIDsInContext:aContext];
|
|
|
|
BOOL didPageChange = NO;
|
|
|
|
|
|
|
|
[aResponse setHTTPVersion:[aRequest httpVersion]];
|
|
|
|
[aResponse setHeader:@"text/html"
|
|
|
|
forKey:@"content-type"];
|
|
|
|
[aContext _setResponse:aResponse];
|
|
|
|
|
|
|
|
if (oldContextID == nil) {
|
|
|
|
if ((aSenderID != nil) && ([aRequest _hasFormValues])) {
|
|
|
|
[anApplication takeValuesFromRequest:aRequest inContext:aContext];
|
2000-08-25 10:36:16 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
[aContext _setPageChanged:NO];
|
|
|
|
|
|
|
|
if (aSenderID != nil) {
|
|
|
|
GSWElement * anActionResults = [anApplication invokeActionForRequest:aRequest inContext:aContext];
|
|
|
|
|
|
|
|
if ((anActionResults == nil) || ([anActionResults isKindOfClass: [GSWComponent class]])) {
|
|
|
|
GSWComponent * aResultComponent = (GSWComponent*) anActionResults;
|
|
|
|
|
|
|
|
if ((aResultComponent != nil) && ([aResultComponent context] != aContext)) {
|
|
|
|
[aResultComponent _awakeInContext:aContext];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((aResultComponent != nil) && (aResultComponent != [aContext _pageElement])) {
|
|
|
|
didPageChange = YES;
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
|
|
|
|
[aContext _setPageChanged:didPageChange];
|
2007-04-13 18:32:02 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
if (didPageChange) {
|
|
|
|
[aContext _setPageElement:aResultComponent];
|
|
|
|
}
|
|
|
|
} else {
|
2008-08-20 20:32:10 +00:00
|
|
|
// CHECKME: extend the GSWElement protocol? -- dw
|
|
|
|
GSWResponse * theResponse = [(GSWComponent*)anActionResults generateResponse];
|
2008-03-30 22:10:20 +00:00
|
|
|
return theResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GSWComponent * responsePage = [aSession restorePageForContextID:oldContextID];
|
|
|
|
[aContext _setPageElement:responsePage];
|
|
|
|
}
|
|
|
|
|
|
|
|
[anApplication appendToResponse:aResponse inContext: aContext];
|
|
|
|
|
|
|
|
return aResponse;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWResponse * _dispatchWithPreparedSession(GSWSession * aSession, GSWContext * aContext, NSDictionary * someElements)
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWComponent * aPage = nil;
|
|
|
|
GSWResponse * aResponse = nil;
|
|
|
|
NSString * aPageName = [someElements objectForKey:GSWKey_PageName[GSWebNamingConv]]; // "wopage"
|
|
|
|
NSString * oldContextID = [aContext _requestContextID];
|
|
|
|
GSWApplication * anApplication = GSWApp;
|
|
|
|
NSString * sessionIdKey = [anApplication sessionIdKey];
|
|
|
|
NSString * oldSessionID = [someElements objectForKey:sessionIdKey];
|
|
|
|
BOOL clearIDsInCookies = NO;
|
|
|
|
BOOL storesIDsInCookies = [aSession storesIDsInCookies];
|
|
|
|
|
|
|
|
if ((oldSessionID == nil) || (oldContextID == nil)) {
|
|
|
|
if ((aPageName == nil) && (!storesIDsInCookies))
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWRequest * request = [aContext request];
|
|
|
|
NSString * cookieHeader = [request headerForKey:GSWHTTPHeader_Cookie]; //"cookie"
|
|
|
|
if ((cookieHeader != nil) && ([cookieHeader length] > 0)) {
|
|
|
|
NSDictionary * cookieDict = [request cookieValues];
|
|
|
|
|
|
|
|
if (([cookieDict objectForKey:sessionIdKey] != nil) ||
|
|
|
|
([cookieDict objectForKey:[anApplication instanceIdKey]] != nil)) {
|
|
|
|
clearIDsInCookies = YES;
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
}
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
aPage = [anApplication pageWithName:aPageName inContext:aContext];
|
|
|
|
} else {
|
|
|
|
aPage = [aSession restorePageForContextID:oldContextID];
|
|
|
|
|
|
|
|
if (aPage == nil) {
|
|
|
|
if ([anApplication _isPageRecreationEnabled]) {
|
|
|
|
aPage = [anApplication pageWithName:aPageName inContext: aContext];
|
|
|
|
} else {
|
|
|
|
return [anApplication handlePageRestorationErrorInContext:aContext];
|
|
|
|
}
|
2002-08-04 18:00:11 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[aContext _setPageElement:aPage];
|
|
|
|
aResponse = _dispatchWithPreparedPage(aPage, aSession, aContext, someElements);
|
2002-08-04 18:00:11 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
if ([anApplication isPageRefreshOnBacktrackEnabled]) {
|
|
|
|
[aResponse disableClientCaching];
|
|
|
|
}
|
|
|
|
|
|
|
|
[aSession _saveCurrentPage];
|
|
|
|
|
|
|
|
if ((clearIDsInCookies) && (!storesIDsInCookies)) {
|
|
|
|
[aSession _clearCookieFromResponse:aResponse];
|
|
|
|
}
|
|
|
|
|
|
|
|
return aResponse;
|
|
|
|
}
|
2002-08-04 18:00:11 +00:00
|
|
|
|
2007-04-13 18:32:02 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWResponse * _dispatchWithPreparedApplication(GSWApplication *app, GSWContext * aContext, NSDictionary * requestHandlerDict)
|
|
|
|
{
|
|
|
|
GSWSession * session = nil;
|
|
|
|
GSWResponse * response = nil;
|
|
|
|
NSString * sessionID;
|
|
|
|
|
|
|
|
sessionID = [requestHandlerDict objectForKey:GSWKey_SessionID[GSWebNamingConv]]; //@"wosid"
|
|
|
|
if ((!sessionID)) {
|
|
|
|
session = [app _initializeSessionInContext:aContext];
|
2008-06-11 14:50:27 +00:00
|
|
|
if (session == nil) {
|
|
|
|
response = [app handleSessionCreationErrorInContext:aContext];
|
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
} else {
|
|
|
|
session = [app restoreSessionWithID:sessionID inContext:aContext];
|
2008-06-11 14:50:27 +00:00
|
|
|
if (session == nil) {
|
|
|
|
response = [app handleSessionRestorationErrorInContext:aContext];
|
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
}
|
|
|
|
|
2008-06-11 14:50:27 +00:00
|
|
|
if (response == nil) {
|
2008-03-30 22:10:20 +00:00
|
|
|
response = _dispatchWithPreparedSession(session, aContext, requestHandlerDict);
|
|
|
|
}
|
|
|
|
|
|
|
|
[aContext _putAwakeComponentsToSleep];
|
|
|
|
[app saveSessionForContext:aContext];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
- (GSWResponse*) _handleRequest:(GSWRequest*) aRequest
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWContext * aContext = nil;
|
|
|
|
NSDictionary * requestHandlerValues;
|
|
|
|
NSString * aSessionID;
|
|
|
|
NSString * aSenderID;
|
|
|
|
NSString * oldContextID;
|
|
|
|
GSWStatisticsStore * aStatisticsStore;
|
|
|
|
GSWResponse * aResponse;
|
|
|
|
GSWApplication * app = GSWApp; // is there any reason not to use the global var? -- dw
|
|
|
|
|
|
|
|
requestHandlerValues = [self requestHandlerValuesForRequest:aRequest];
|
|
|
|
aSessionID = [requestHandlerValues objectForKey:[app sessionIdKey]];
|
|
|
|
|
|
|
|
if ((aSessionID == nil) && [app isRefusingNewSessions])
|
|
|
|
{
|
|
|
|
NSString * newLocationURL = [app _newLocationForRequest:aRequest];
|
|
|
|
NSString * msgString = [NSString stringWithFormat:@"Sorry, your request could not immediately be processed. Please try this URL: <a href=\"%@\">%@</a>",
|
|
|
|
newLocationURL, newLocationURL];
|
|
|
|
|
|
|
|
aResponse = [app createResponseInContext:nil];
|
|
|
|
[aResponse _redirectResponse:newLocationURL contentString:msgString];
|
|
|
|
[aResponse _finalizeInContext:nil];
|
|
|
|
|
|
|
|
return aResponse;
|
|
|
|
}
|
|
|
|
|
|
|
|
aSenderID = [requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
|
|
|
|
oldContextID = [requestHandlerValues objectForKey:GSWKey_ContextID[GSWebNamingConv]];
|
|
|
|
|
|
|
|
if ((aStatisticsStore = [app statisticsStore]))
|
|
|
|
{
|
|
|
|
[aStatisticsStore applicationWillHandleComponentActionRequest];
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DURING {
|
|
|
|
aContext = [app createContextForRequest:aRequest];
|
|
|
|
[aContext _setRequestContextID:oldContextID];
|
|
|
|
[aContext _setSenderID:aSenderID];
|
|
|
|
|
|
|
|
[app awake];
|
|
|
|
aResponse = _dispatchWithPreparedApplication(app, aContext, requestHandlerValues);
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:DidHandleRequestNotification
|
|
|
|
object:aContext];
|
|
|
|
|
|
|
|
[app sleep];
|
|
|
|
} NS_HANDLER {
|
|
|
|
GSWSession * aSession = nil;
|
|
|
|
|
|
|
|
NSLog(@"%s: Exception occurred while handling request:%@", __PRETTY_FUNCTION__, [localException reason]);
|
|
|
|
|
|
|
|
if(aContext == nil)
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
aContext = [app createContextForRequest:aRequest];
|
|
|
|
} else {
|
|
|
|
[aContext _putAwakeComponentsToSleep];
|
2003-06-25 15:21:21 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
|
|
|
|
aSession = [aContext _session];
|
|
|
|
aResponse = [app handleException:localException
|
|
|
|
inContext:aContext];
|
|
|
|
|
|
|
|
if (aSession) {
|
|
|
|
NS_DURING {
|
|
|
|
[app saveSessionForContext:aContext];
|
|
|
|
[app sleep];
|
|
|
|
} NS_HANDLER {
|
|
|
|
NSLog(@"WOApplication '%@': Another Exception occurred while trying to clean the application :%@", [app name], [localException reason]);
|
|
|
|
} NS_ENDHANDLER;
|
|
|
|
}
|
|
|
|
|
|
|
|
} NS_ENDHANDLER;
|
|
|
|
|
|
|
|
if ((aContext) && ([aContext _session]))
|
|
|
|
{
|
|
|
|
[app saveSessionForContext:aContext];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((aResponse))
|
|
|
|
{
|
|
|
|
[aResponse _finalizeInContext:aContext];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((aStatisticsStore))
|
|
|
|
{
|
|
|
|
GSWComponent * aPage = [aContext page];
|
|
|
|
NSString * pageName = nil;
|
|
|
|
|
|
|
|
if ((aPage))
|
2002-08-04 18:00:11 +00:00
|
|
|
{
|
2008-03-30 22:10:20 +00:00
|
|
|
pageName = [aPage name];
|
|
|
|
}
|
|
|
|
[aStatisticsStore applicationDidHandleComponentActionRequestWithPageNamed:pageName];
|
|
|
|
}
|
|
|
|
return aResponse;
|
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
/** Handle request aRequest and return the response
|
|
|
|
This may lock the application
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
-(GSWResponse*)handleRequest:(GSWRequest*)aRequest
|
2000-01-22 12:49:49 +00:00
|
|
|
{
|
|
|
|
//OK
|
2008-03-30 22:10:20 +00:00
|
|
|
GSWResponse* response=nil;
|
|
|
|
NSLock * lock;
|
2007-04-13 18:32:02 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
lock = [GSWApp requestHandlingLock];
|
|
|
|
|
|
|
|
if (lock) {
|
|
|
|
SYNCHRONIZED(lock) {
|
|
|
|
response = [self _handleRequest:aRequest];
|
2000-08-25 10:36:16 +00:00
|
|
|
}
|
2008-03-30 22:10:20 +00:00
|
|
|
END_SYNCHRONIZED;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// no locking
|
|
|
|
response = [self _handleRequest:aRequest];
|
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
2007-04-13 18:32:02 +00:00
|
|
|
|
2008-03-30 22:10:20 +00:00
|
|
|
// do we need this? -- dw
|
2008-08-20 20:32:10 +00:00
|
|
|
// used in GSWApplication _componentRequestHandler
|
2008-03-30 22:10:20 +00:00
|
|
|
+(id)handler
|
|
|
|
{
|
|
|
|
return [[GSWComponentRequestHandler new] autorelease];
|
2008-08-20 20:32:10 +00:00
|
|
|
}
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|