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))
/* 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)),
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)
*/
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);
};