mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-17 07:33:57 +00:00
fix(dav): render DAV exceptions as XML
This commit is contained in:
@@ -2048,7 +2048,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad color format (should be '#XXXXXXXX')."];
|
||||
|
||||
return error;
|
||||
@@ -2288,7 +2288,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
}
|
||||
}
|
||||
if (!obj)
|
||||
obj = [NSException exceptionWithHTTPStatus:404 /* Not Found */];
|
||||
obj = [self exceptionWithHTTPStatus:404 /* Not Found */];
|
||||
}
|
||||
|
||||
if (obj)
|
||||
@@ -2645,8 +2645,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
else if ([newName rangeOfString: @"transparent"].location != NSNotFound)
|
||||
[self setIncludeInFreeBusy: NO];
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Bad transparency value."];
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad transparency value."];
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -2666,8 +2666,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -2688,8 +2688,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -2710,8 +2710,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
|
||||
return error;
|
||||
}
|
||||
@@ -2732,8 +2732,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
error = nil;
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
error = [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Bad boolean value."];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -397,11 +397,9 @@ static SoSecurityManager *sm = nil;
|
||||
subfolderNames = [self toManyRelationshipKeys];
|
||||
if ([subfolderNames containsObject: newName])
|
||||
{
|
||||
content = [NSString stringWithFormat:
|
||||
@"A collection named '%@' already exists.",
|
||||
newName];
|
||||
error = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: content];
|
||||
content = [NSString stringWithFormat: @"A collection named '%@' already exists.", newName];
|
||||
error = [NSException exceptionWithDAVStatus: 403
|
||||
reason: content];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -409,7 +407,7 @@ static SoSecurityManager *sm = nil;
|
||||
davPatchedPropertiesWithTopTag: @"mkcalendar"];
|
||||
setProperties = [properties objectForKey: @"set"];
|
||||
newDisplayName = [self _fetchPropertyWithName: @"{DAV:}displayname"
|
||||
inArray: setProperties];
|
||||
inArray: setProperties];
|
||||
if (![newDisplayName length])
|
||||
newDisplayName = newName;
|
||||
error
|
||||
@@ -417,10 +415,10 @@ static SoSecurityManager *sm = nil;
|
||||
if (!error)
|
||||
{
|
||||
newFolder = [self lookupName: newName
|
||||
inContext: createContext
|
||||
acquire: NO];
|
||||
inContext: createContext
|
||||
acquire: NO];
|
||||
error = [self _applyMkCalendarProperties: setProperties
|
||||
toObject: newFolder];
|
||||
toObject: newFolder];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,9 +486,8 @@ static SoSecurityManager *sm = nil;
|
||||
[defaults synchronize];
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 403
|
||||
reason: @"invalid"
|
||||
@" classification value"];
|
||||
error = [NSException exceptionWithDAVStatus: 403
|
||||
reason: @"invalid classification value"];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@
|
||||
|
||||
[unavailableAttendees release];
|
||||
|
||||
return [NSException exceptionWithHTTPStatus:409 reason: reason];
|
||||
return [self exceptionWithHTTPStatus:409 reason: reason];
|
||||
}
|
||||
|
||||
[unavailableAttendees release];
|
||||
@@ -681,7 +681,7 @@
|
||||
[user cn], @"Cn",
|
||||
[user systemEmail], @"SystemEmail", nil];
|
||||
reason = [values keysWithFormat: [self labelForKey: @"Cannot access resource: \"%{Cn} %{SystemEmail}\""]];
|
||||
return [NSException exceptionWithHTTPStatus:409 reason: reason];
|
||||
return [self exceptionWithHTTPStatus:409 reason: reason];
|
||||
}
|
||||
|
||||
fb = [SOGoFreeBusyObject objectWithName: @"freebusy.ifb" inContainer: [user homeFolderInContext: context]];
|
||||
@@ -806,8 +806,8 @@
|
||||
|
||||
info = [NSDictionary dictionaryWithObject: reason forKey: @"reject"];
|
||||
|
||||
return [NSException exceptionWithHTTPStatus: 409
|
||||
reason: [info jsonRepresentation]];
|
||||
return [self exceptionWithHTTPStatus: 409
|
||||
reason: [info jsonRepresentation]];
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -857,8 +857,8 @@
|
||||
[info setObject: conflicts forKey: @"conflicts"];
|
||||
|
||||
// We immediately raise an exception, without processing the possible other attendees.
|
||||
return [NSException exceptionWithHTTPStatus: 409
|
||||
reason: [info jsonRepresentation]];
|
||||
return [self exceptionWithHTTPStatus: 409
|
||||
reason: [info jsonRepresentation]];
|
||||
}
|
||||
} // if ([fbInfo count]) ...
|
||||
else if (currentAttendee && [user isResource])
|
||||
@@ -1668,19 +1668,19 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
if (delegatedUid)
|
||||
delegatedUser = [SOGoUser userWithLogin: delegatedUid];
|
||||
if (delegatedUser != nil && [event userIsOrganizer: delegatedUser])
|
||||
ex = [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is organizer"];
|
||||
ex = [self exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is organizer"];
|
||||
if ([event isAttendee: [[delegate email] rfc822Email]])
|
||||
ex = [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is a participant"];
|
||||
ex = [self exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is a participant"];
|
||||
else {
|
||||
NSDictionary *dict;
|
||||
domain = [[context activeUser] domain];
|
||||
dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: [[delegate email] rfc822Email]
|
||||
inDomain: domain];
|
||||
if (dict && [[dict objectForKey: @"isGroup"] boolValue])
|
||||
ex = [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is a group"];
|
||||
ex = [self exceptionWithHTTPStatus: 409
|
||||
reason: @"delegate is a group"];
|
||||
}
|
||||
}
|
||||
if (ex == nil)
|
||||
@@ -1719,12 +1719,12 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
}
|
||||
}
|
||||
else
|
||||
ex = [NSException exceptionWithHTTPStatus: 404 // Not Found
|
||||
reason: @"user does not participate in this calendar event"];
|
||||
ex = [self exceptionWithHTTPStatus: 404 // Not Found
|
||||
reason: @"user does not participate in this calendar event"];
|
||||
}
|
||||
else
|
||||
ex = [NSException exceptionWithHTTPStatus: 500 // Server Error
|
||||
reason: @"unable to parse event record"];
|
||||
ex = [self exceptionWithHTTPStatus: 500 // Server Error
|
||||
reason: @"unable to parse event record"];
|
||||
|
||||
return ex;
|
||||
}
|
||||
@@ -2138,8 +2138,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
// TODO: send out a no-uid-conflict (DAV:href) xml element (rfc4791 section 5.3.2.1)
|
||||
if ([container resourceNameForEventUID: eventUID])
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 409
|
||||
reason: [NSString stringWithFormat: @"Event UID already in use. (%@)", eventUID]];
|
||||
return [self exceptionWithHTTPStatus: 409
|
||||
reason: [NSString stringWithFormat: @"Event UID already in use. (%@)", eventUID]];
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2355,8 +2355,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
|
||||
if (![roles containsObject: @"ComponentModifier"] && ![[context activeUser] isSuperUser])
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"Not allowed to perform this action. Wrong SENT-BY being used regarding access rights on organizer's calendar."];
|
||||
return [self exceptionWithHTTPStatus: 409
|
||||
reason: @"Not allowed to perform this action. Wrong SENT-BY being used regarding access rights on organizer's calendar."];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2410,8 +2410,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
// We first check of the sequences are alright. We don't accept attendees
|
||||
// accepting "old" invitations. If that's the case, we return a 409
|
||||
if ([[newEvent sequence] intValue] < [[oldEvent sequence] intValue])
|
||||
return [NSException exceptionWithHTTPStatus: 409
|
||||
reason: @"sequences don't match"];
|
||||
return [self exceptionWithHTTPStatus: 409
|
||||
reason: @"sequences don't match"];
|
||||
|
||||
// Remove the RSVP attribute, as an action from the attendee
|
||||
// was actually performed, and this confuses iCal (bug #1850)
|
||||
@@ -2503,8 +2503,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
// with a 400 error code.
|
||||
if (!rqCalendar)
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Unable to parse event."];
|
||||
return [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Unable to parse event."];
|
||||
}
|
||||
|
||||
if (![self isNew])
|
||||
|
||||
@@ -145,8 +145,8 @@
|
||||
// with a 400 error code.
|
||||
if (!rqCalendar)
|
||||
{
|
||||
return [NSException exceptionWithHTTPStatus: 400
|
||||
reason: @"Unable to parse task."];
|
||||
return [NSException exceptionWithDAVStatus: 400
|
||||
reason: @"Unable to parse task."];
|
||||
}
|
||||
|
||||
[self adjustClassificationInRequestCalendar: rqCalendar];
|
||||
|
||||
@@ -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