mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-29 09:00:31 +00:00
fix(dav): render DAV exceptions as XML
This commit is contained in:
@@ -445,8 +445,8 @@
|
||||
[self logWithFormat:
|
||||
@"TODO: copy not implemented:\n target: %@\n new name: %@",
|
||||
_target, _name];
|
||||
return [NSException exceptionWithHTTPStatus:405 /* not allowed */
|
||||
reason:@"this object cannot be copied via WebDAV"];
|
||||
return [NSException exceptionWithDAVStatus: 405 /* not allowed */
|
||||
reason: @"this object cannot be copied via WebDAV"];
|
||||
}
|
||||
|
||||
/* acls */
|
||||
|
||||
@@ -483,13 +483,13 @@ static NSArray *childRecordFields = nil;
|
||||
error = nil;
|
||||
}
|
||||
NS_HANDLER
|
||||
error = [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"Existing name"];
|
||||
error = [NSException exceptionWithDAVStatus: 409
|
||||
reason: @"Existing name"];
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"Empty string"];
|
||||
error = [NSException exceptionWithDAVStatus: 403
|
||||
reason: @"Empty string"];
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -593,8 +593,8 @@ static NSArray *childRecordFields = nil;
|
||||
[self displayName];
|
||||
|
||||
if ([nameInContainer isEqualToString: @"personal"])
|
||||
error = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"folder 'personal' cannot be deleted"];
|
||||
error = [self exceptionWithHTTPStatus: 403
|
||||
reason: @"folder 'personal' cannot be deleted"];
|
||||
else
|
||||
error = [[self folderManager] deleteFolderAtPath: ocsPath];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
Copyright (C) 2006-2015 Inverse inc.
|
||||
Copyright (C) 2006-2022 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
@@ -174,6 +174,10 @@
|
||||
|
||||
- (NSString *) labelForKey: (NSString *) key;
|
||||
|
||||
- (id) exceptionWithHTTPStatus: (unsigned short) theStatus;
|
||||
- (id) exceptionWithHTTPStatus: (unsigned short) theStatus
|
||||
reason: (NSString *) theReason;
|
||||
|
||||
/* description */
|
||||
|
||||
- (void) appendAttributesToDescription:(NSMutableString *)_ms;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* SOGoObject.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
* Copyright (C) 2006-2015 Inverse inc.
|
||||
* Copyright (C) 2006-2022 Inverse inc.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -1594,4 +1594,23 @@
|
||||
return [self labelForKey: key inContext: context];
|
||||
}
|
||||
|
||||
- (id) exceptionWithHTTPStatus: (unsigned short) theStatus
|
||||
{
|
||||
if ([[context request] handledByDefaultHandler])
|
||||
return [NSException exceptionWithHTTPStatus: theStatus];
|
||||
else
|
||||
return [NSException exceptionWithDAVStatus: theStatus];
|
||||
}
|
||||
|
||||
- (id) exceptionWithHTTPStatus: (unsigned short) theStatus
|
||||
reason: (NSString *) theReason
|
||||
{
|
||||
if ([[context request] handledByDefaultHandler])
|
||||
return [NSException exceptionWithHTTPStatus: theStatus
|
||||
reason: theReason];
|
||||
else
|
||||
return [NSException exceptionWithDAVStatus: theStatus
|
||||
reason: theReason];
|
||||
}
|
||||
|
||||
@end /* SOGoObject */
|
||||
|
||||
@@ -392,8 +392,8 @@ static SoSecurityManager *sm = nil;
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"The new folder could not be created"];
|
||||
error = [self exceptionWithHTTPStatus: 400
|
||||
reason: @"The new folder could not be created"];
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -491,7 +491,7 @@ static SoSecurityManager *sm = nil;
|
||||
if (error)
|
||||
{
|
||||
[self errorWithFormat: @"a database error occured: %@", [error reason]];
|
||||
obj = [NSException exceptionWithHTTPStatus: 503];
|
||||
obj = [self exceptionWithHTTPStatus: 503];
|
||||
}
|
||||
else
|
||||
obj = [subscribedSubFolders objectForKey: name];
|
||||
@@ -511,7 +511,7 @@ static SoSecurityManager *sm = nil;
|
||||
if (error)
|
||||
{
|
||||
[self errorWithFormat: @"a database error occured: %@", [error reason]];
|
||||
obj = [NSException exceptionWithHTTPStatus: 503];
|
||||
obj = [self exceptionWithHTTPStatus: 503];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -638,7 +638,7 @@ static SoSecurityManager *sm = nil;
|
||||
if (error)
|
||||
{
|
||||
[self errorWithFormat: @"a database error occured: %@", [error reason]];
|
||||
return [NSException exceptionWithHTTPStatus: 503];
|
||||
return [NSException exceptionWithDAVStatus: 503];
|
||||
}
|
||||
|
||||
// We assume "personal" exists. In fact, if it doesn't, something
|
||||
@@ -671,7 +671,7 @@ static SoSecurityManager *sm = nil;
|
||||
|
||||
if (!supported)
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 403];
|
||||
return [NSException exceptionWithDAVStatus: 403];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@
|
||||
// inContainer: self];
|
||||
|
||||
if (!obj)
|
||||
obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */];
|
||||
obj = [self exceptionWithHTTPStatus: 404 /* Not Found */];
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
||||
Reference in New Issue
Block a user