diff --git a/ChangeLog b/ChangeLog index ef45ef7ef..8c42b75d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-12-13 Wolfgang Sourdeau + * UI/SOGoUI/UIxComponent.m ([UIxComponent -responseWithStatus:status]) + ([UIxComponent -responseWithStatus:statusandString:contentString]) + ([UIxComponent -responseWithStatus:statusandJSONRepresentation:contentObject]) + ([UIxComponent -responseWith204]): new utility methods. + + * UI/Common/WODirectAction+SOGo.m ([WODirectAction -responseWithStatus:statusandString:contentString]) + ([WODirectAction + -responseWithStatus:statusandJSONRepresentation:contentObject]): + new utility methods. + * SoObjects/SOGo/NSScanner+BSJSONAdditions.m ([NSScanner -scanJSONStringDelimiterString]): new category module taken from BSJSONAdditions 1.3. diff --git a/UI/Common/WODirectAction+SOGo.h b/UI/Common/WODirectAction+SOGo.h index aa518c6d6..70b098c77 100644 --- a/UI/Common/WODirectAction+SOGo.h +++ b/UI/Common/WODirectAction+SOGo.h @@ -31,6 +31,10 @@ @interface WODirectAction (SOGoExtension) - (WOResponse *) responseWithStatus: (unsigned int) status; +- (WOResponse *) responseWithStatus: (unsigned int) status + andString: (NSString *) contentString; +- (WOResponse *) responseWithStatus: (unsigned int) status + andJSONRepresentation: (NSObject *) contentObject; - (WOResponse *) responseWith204; - (WOResponse *) redirectToLocation: (NSString *) newLocation; diff --git a/UI/Common/WODirectAction+SOGo.m b/UI/Common/WODirectAction+SOGo.m index 6c1c3adfa..e1f31afca 100644 --- a/UI/Common/WODirectAction+SOGo.m +++ b/UI/Common/WODirectAction+SOGo.m @@ -25,6 +25,7 @@ #import #import +#import #import #import @@ -42,6 +43,24 @@ return response; } +- (WOResponse *) responseWithStatus: (unsigned int) status + andString: (NSString *) contentString +{ + WOResponse *response; + + response = [self responseWithStatus: status]; + [response appendContentString: contentString]; + + return response; +} + +- (WOResponse *) responseWithStatus: (unsigned int) status + andJSONRepresentation: (NSObject *) contentObject; +{ + return [self responseWithStatus: status + andString: [contentObject jsonRepresentation]]; +} + - (WOResponse *) responseWith204 { return [self responseWithStatus: 204]; diff --git a/UI/SOGoUI/UIxComponent.h b/UI/SOGoUI/UIxComponent.h index f0c019083..5897f3aa7 100644 --- a/UI/SOGoUI/UIxComponent.h +++ b/UI/SOGoUI/UIxComponent.h @@ -95,7 +95,13 @@ - (WOResourceManager *) pageResourceManager; - (NSString *) urlForResourceFilename: (NSString *) filename; +- (WOResponse *) responseWithStatus: (unsigned int) status; +- (WOResponse *) responseWithStatus: (unsigned int) status + andString: (NSString *) contentString; +- (WOResponse *) responseWithStatus: (unsigned int) status + andJSONRepresentation: (NSObject *) contentObject; - (WOResponse *) responseWith204; +- (WOResponse *) redirectToLocation: (NSString *) newLocation; /* Debugging */ - (BOOL)isUIxDebugEnabled; diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 50e6bf253..2444791ab 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -36,6 +36,7 @@ #import #import +#import #import #import #import @@ -584,12 +585,45 @@ static BOOL uixDebugEnabled = NO; return url; } -- (WOResponse *) responseWith204 +- (WOResponse *) responseWithStatus: (unsigned int) status { WOResponse *response; response = [context response]; - [response setStatus: 204]; + [response setStatus: status]; + + return response; +} + +- (WOResponse *) responseWithStatus: (unsigned int) status + andString: (NSString *) contentString +{ + WOResponse *response; + + response = [self responseWithStatus: status]; + [response appendContentString: contentString]; + + return response; +} + +- (WOResponse *) responseWithStatus: (unsigned int) status + andJSONRepresentation: (NSObject *) contentObject; +{ + return [self responseWithStatus: status + andString: [contentObject jsonRepresentation]]; +} + +- (WOResponse *) responseWith204 +{ + return [self responseWithStatus: 204]; +} + +- (WOResponse *) redirectToLocation: (NSString *) newLocation +{ + WOResponse *response; + + response = [self responseWithStatus: 302]; + [response setHeader: newLocation forKey: @"location"]; return response; }