From: Greg Stein Date: Mon, 5 Feb 2001 12:34:39 +0000 (+0000) Subject: *) add activity handling: OPTIONS and MKACTIVITY X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16f160c45e1418ac22899fce733f8be708409610;p=apache *) add activity handling: OPTIONS and MKACTIVITY *) fix HTTP status code in MKWORKSPACE handling *) add can_be_activity and make_activity hooks to dav_hooks_vsn git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87980 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index 9e71897bf2..06dd4bf327 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -1672,6 +1672,10 @@ static int dav_method_options(request_rec *r) if (vsn_hooks->can_be_workspace != NULL && (*vsn_hooks->can_be_workspace)(resource)) apr_table_addn(methods, "MKWORKSPACE", ""); + + if (vsn_hooks->can_be_activity != NULL + && (*vsn_hooks->can_be_activity)(resource)) + apr_table_addn(methods, "MKACTIVITY", ""); } else if (!resource->versioned) { if ((*vsn_hooks->versionable)(resource)) @@ -3930,7 +3934,7 @@ static int dav_method_make_workspace(request_rec *r) /* attempt to create the workspace */ if ((err = (*vsn_hooks->make_workspace)(resource, doc)) != NULL) { - err = dav_push_error(r->pool, HTTP_CONFLICT, 0, + err = dav_push_error(r->pool, err->status, 0, apr_psprintf(r->pool, "Could not create workspace %s.", ap_escape_html(r->pool, r->uri)), @@ -3947,8 +3951,57 @@ static int dav_method_make_workspace(request_rec *r) static int dav_method_make_activity(request_rec *r) { - /* ### */ - return HTTP_METHOD_NOT_ALLOWED; + dav_resource *resource; + const dav_hooks_vsn *vsn_hooks = DAV_GET_HOOKS_VSN(r); + dav_error *err; + int result; + + /* if no versioning provider, or the provider does not support activities, + * decline the request + */ + if (vsn_hooks == NULL || vsn_hooks->make_activity == NULL) + return DECLINED; + + /* ask repository module to resolve the resource */ + err = dav_get_resource(r, 0 /*target_allowed*/, NULL, &resource); + if (err != NULL) + return dav_handle_err(r, err, NULL); + + /* MKACTIVITY does not have a defined request body. */ + if ((result = ap_discard_request_body(r)) != OK) { + return result; + } + + /* Check request preconditions */ + + /* ### need a general mechanism for reporting precondition violations + * ### (should be returning XML document for 403/409 responses) + */ + + /* resource must not already exist */ + if (resource->exists) { + err = dav_new_error(r->pool, HTTP_CONFLICT, 0, + ""); + return dav_handle_err(r, err, NULL); + } + + /* ### what about locking? */ + + /* attempt to create the activity */ + if ((err = (*vsn_hooks->make_activity)(resource)) != NULL) { + err = dav_push_error(r->pool, err->status, 0, + apr_psprintf(r->pool, + "Could not create activity %s.", + ap_escape_html(r->pool, r->uri)), + err); + return dav_handle_err(r, err, NULL); + } + + /* set the Cache-Control header, per the spec */ + apr_table_setn(r->headers_out, "Cache-Control", "no-cache"); + + /* return an appropriate response (HTTP_CREATED) */ + return dav_created(r, resource->uri, "Activity", 0 /*replaced*/); } static int dav_method_baseline_control(request_rec *r) diff --git a/modules/dav/main/mod_dav.h b/modules/dav/main/mod_dav.h index 22902c9cf7..a73f12901a 100644 --- a/modules/dav/main/mod_dav.h +++ b/modules/dav/main/mod_dav.h @@ -2063,6 +2063,28 @@ struct dav_hooks_vsn */ dav_error * (*make_workspace)(dav_resource *resource, ap_xml_doc *doc); + + /* + ** Determine whether a null resource can be created as an activity. + ** The provider may restrict activities to certain locations. + ** Returns 0 if the resource cannot be an activity. + ** + ** This hook is optional; if the provider does not support activities, + ** it should be set to NULL. + */ + int (*can_be_activity)(const dav_resource *resource); + + /* + ** Create an activity resource. The resource must not already + ** exist. + ** + ** If activity creation is succesful, the state of the resource + ** object is updated appropriately. + ** + ** This hook is optional; if the provider does not support activities, + ** it should be set to NULL. + */ + dav_error * (*make_activity)(dav_resource *resource); };