]> granicus.if.org Git - apache/commitdiff
*) add activity handling: OPTIONS and MKACTIVITY
authorGreg Stein <gstein@apache.org>
Mon, 5 Feb 2001 12:34:39 +0000 (12:34 +0000)
committerGreg Stein <gstein@apache.org>
Mon, 5 Feb 2001 12:34:39 +0000 (12:34 +0000)
*) 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

modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h

index 9e71897bf2122cf45e83d8ded066f9a17b09eb34..06dd4bf3270ad62ab64c8be476383cfae9af539b 100644 (file)
@@ -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,
+                            "<DAV:resource-must-be-null/>");
+       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)
index 22902c9cf76f16c884df55aabe49219689fcba88..a73f12901a6a8433c496c3f869c272cafa95f57e 100644 (file)
@@ -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);
 };