return baseURL;
}
-NSString *SoObjectRootURLInContext(WOContext *_ctx, id self /* logger */, BOOL withAppPart) {
+NSString *SoObjectRootURLInContext
+ (WOContext *_ctx, id self /* logger */, BOOL withAppPart)
+{
+ // TODO: it would be best if we would return relative URLs here, but
+ // _some_ places (like the ZideStore subscription page) actually
+ // need absolute URLs.
/*
Note: Evolution doesn't correctly transfer the "Host:" header, it
misses the port argument :-(
-
+
Note: this is called by SoObjectWebDAVDispatcher.m.
*/
// TODO: this should be a WOContext method?
rq = [_ctx request];
port = [[rq headerForKey:@"x-webobjects-server-port"] intValue];
- /* TODO: how to handle Evolution bug which sends invalid port ? */
+ /* this is actually a bug in Apache */
if (port == 0) {
static BOOL didWarn = NO;
if (!didWarn) {
- [self warnWithFormat:@"(%s:%i): got an empty port, probably buggy "
- @"SOAP host header!",
+ [self warnWithFormat:@"(%s:%i): got an empty port from Apache!",
__PRETTY_FUNCTION__, __LINE__];
didWarn = YES;
}
- port = 23000;
+ port = 80;
}
ms = [[NSMutableString alloc] initWithCapacity:128];
else if ((tmp = [rq headerForKey:@"x-webobjects-server-url"]) != nil) {
/* sometimes the URL is just wrong! (suggests port 80) */
if ([tmp hasSuffix:@":0"] && [tmp length] > 2) { // TODO: bad bad bad
- [self logWithFormat:@"WARNING(%s): got incorrect URL from Apache: '%@'",
+ [self warnWithFormat:@"%s: got incorrect URL from Apache: '%@'",
__PRETTY_FUNCTION__, tmp];
tmp = [tmp substringToIndex:([tmp length] - 2)];
}
else if ([tmp hasSuffix:@":443"] && [tmp hasPrefix:@"http://"]) {
/* see OGo bug #1435, Debian Apache hack */
- [self logWithFormat:@"WARNING(%s): got 'http' protocol but 443 port, "
+ [self warnWithFormat:@"%s: got 'http' protocol but 443 port, "
@"assuming Debian/Apache bug (OGo #1435): '%@'",
__PRETTY_FUNCTION__, tmp];
tmp = [tmp substringWithRange:NSMakeRange(4, [tmp length] - 4 - 4)];
}
- (NSString *)baseURLForContext:(WOContext *)_ctx {
- extern NSString *SoObjectRootURLInContext(WOContext *_ctx, id logobj, BOOL withAppPart);
+ extern NSString *SoObjectRootURLInContext
+ (WOContext *_ctx, id logobj, BOOL withAppPart);
NSString *rootURL;
rootURL = SoObjectRootURLInContext(_ctx, self, NO);
sm = [_ctx soSecurityManager];
e = [sm validatePermission:
- ([pathInfo length] > 0)
+ [pathInfo isNotEmpty]
? SoPerm_AddDocumentsImagesAndFiles
: SoPerm_ChangeImagesAndFiles
onObject:self->object
/* perform */
- if ([pathInfo length] > 0) {
+ if ([pathInfo isNotEmpty]) {
/* check whether all the parent collections are available */
// TODO: we might also want to check for a 'create' permission
if ([pathInfo rangeOfString:@"/"].length > 0) {
NSString *pathInfo;
pathInfo = [_ctx pathInfo];
- if ([pathInfo length] == 0) {
+ if (![pathInfo isNotEmpty]) {
/* MKCOL target already exists ... */
WOResponse *r;
depth = [rq headerForKey:@"depth"];
uri = [rq uri];
- if ([depth length] == 0) depth = @"infinity";
+ if (![depth isNotEmpty]) depth = @"infinity";
- if ([[rq content] length] > 0) {
+ if ([[rq content] isNotEmpty]) {
[self lockParser:davsax];
{
[xmlParser parseFromSource:[rq content]];
"A client may choose not to submit a request body. An empty PROPFIND
request body MUST be treated as a request for the names and values of
all properties."
- TODO: means, an empty request is to be treated as allprop?
+ TODO: means, an empty request is to be handled as <allprop/>?
*/
propNames = nil;
findAll = YES;
if ([s hasSuffix:@"/"]) s = [s substringToIndex:([s length] - 1)];
if ([s hasPrefix:@"_"]) s = [s substringFromIndex:1];
- ids = ([s length] == 0)
- ? (NSArray *)[NSArray array]
- : [s componentsSeparatedByString:@"_"];
+ ids = [s isNotEmpty]
+ ? [s componentsSeparatedByString:@"_"]
+ : (NSArray *)[NSArray array];
// TODO: should use -stringByUnescapingURL on IDs (not required for ints)
/* check permissions */
sm = [_ctx soSecurityManager];
- e = [sm validatePermission:([pathInfo length] > 0)
+ e = [sm validatePermission:[pathInfo isNotEmpty]
? SoPerm_AddDocumentsImagesAndFiles
: SoPerm_ChangeImagesAndFiles
onObject:self->object
/* check for conflicts */
- if ([pathInfo length] > 0) {
+ if ([pathInfo isNotEmpty]) {
/* check whether all the parent collections are available */
if ([pathInfo rangeOfString:@"/"].length > 0) {
return [self httpException:409 /* Conflict */
/* check whether the object supports patching */
- if ([pathInfo length] > 0) {
+ if ([pathInfo isNotEmpty]) {
if (![self->object respondsToSelector:
@selector(davCreateObject:properties:inContext:)]) {
[self debugWithFormat:@"cannot create new object via DAV on %@",
reason:@"got no properties in PROPPATCH !"];
}
- if ([pathInfo length] > 0) {
+ if ([pathInfo isNotEmpty]) {
/* a create object cannot delete props ... */
- if ([delProps count] > 0) {
+ if ([delProps isNotEmpty]) {
if (![self allowDeletePropertiesOnNewObjectInContext:_ctx]) {
[self logWithFormat:@"shall delete props in new object '%@': %@",
pathInfo, delProps];
/* TODO: check proper permission prior attempting a move */
absDestURL = [[_ctx request] headerForKey:@"destination"];
- if ([absDestURL length] == 0) {
+ if (![absDestURL isNotEmpty]) {
return [self httpException:400 /* Bad Request */
reason:
@"the destination WebDAV header was missing "
return error;
}
- return ([newName length] > 0)
+ return [newName isNotEmpty]
? [NSNumber numberWithBool:201 /* Created */]
: [NSNumber numberWithBool:204 /* No Content */];
}
return error;
}
- return ([newName length] > 0)
+ return [newName isNotEmpty]
? [NSNumber numberWithBool:201 /* Created */]
: [NSNumber numberWithBool:204 /* No Content */];
}
return [_ctx response];
}
+ // TODO: whats that? VERY bad, maybe use -baseURLForContext:?
baseURL = [NSString stringWithFormat:@"http://%@%@",
[[_ctx request] headerForKey:@"host"],
[[_ctx request] uri]];
}
subscriptionID = [rq headerForKey:@"subscription-id"];
- if ([subscriptionID length] == 0) {
+ if (![subscriptionID isNotEmpty]) {
return [self httpException:400 /* Bad Request */
reason:@"did not find subscription-id header in POLL"];
}
/* first check, whether it's an existing subscription to be renewed */
- if ([subscriptionID length] > 0) {
+ if ([subscriptionID isNotEmpty]) {
NSString *newId;
if ((newId = [sm renewSubscription:subscriptionID onURL:url]) == nil) {
}
subscriptionID = [rq headerForKey:@"subscription-id"];
- if ([subscriptionID length] == 0) {
+ if (![subscriptionID isNotEmpty]) {
return [self httpException:400 /* Bad Request */
reason:@"missing subscription id !"];
}
[r setStatus:200];
return r;
}
- else {
- return [self httpException:400 /* Bad Request */
- reason:@"unsubscribe failed (invalid or old id ?)"];
- }
+
+ return [self httpException:400 /* Bad Request */
+ reason:@"unsubscribe failed (invalid or old id ?)"];
}
/* Exchange bulk methods */
rq = [_ctx request];
depth = [rq headerForKey:@"depth"];
- if ([depth length] == 0) depth = @"infinity";
+ if (![depth isNotEmpty]) depth = @"infinity";
[self lockParser:davsax];
{
propNames = [propNames autorelease];
targets = [targets autorelease];
- if ([targets count] == 0)
+ if (![targets isNotEmpty])
return [NSArray array];
/* check query all properties */