1
/* Licensed to the Apache Software Foundation (ASF) under one or more
2
* contributor license agreements. See the NOTICE file distributed with
3
* this work for additional information regarding copyright ownership.
4
* The ASF licenses this file to You under the Apache License, Version 2.0
5
* (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
#include "apr_strings.h"
24
static const dav_hooks_liveprop dav_core_hooks_liveprop;
27
** The namespace URIs that we use. There will only ever be "DAV:".
29
static const char * const dav_core_namespace_uris[] =
36
** Define each of the core properties that this provider will handle.
37
** Note that all of them are in the DAV: namespace, which has a
38
** provider-local index of 0.
40
static const dav_liveprop_spec dav_core_props[] =
42
{ 0, "comment", DAV_PROPID_comment, 1 },
43
{ 0, "creator-displayname", DAV_PROPID_creator_displayname, 1 },
44
{ 0, "displayname", DAV_PROPID_displayname, 1 },
45
{ 0, "resourcetype", DAV_PROPID_resourcetype, 0 },
46
{ 0, "source", DAV_PROPID_source, 1 },
51
static const dav_liveprop_group dav_core_liveprop_group =
54
dav_core_namespace_uris,
55
&dav_core_hooks_liveprop
58
static dav_prop_insert dav_core_insert_prop(const dav_resource *resource,
59
int propid, dav_prop_insert what,
60
apr_text_header *phdr)
64
apr_pool_t *p = resource->pool;
65
const dav_liveprop_spec *info;
70
case DAV_PROPID_resourcetype:
71
switch (resource->type) {
72
case DAV_RESOURCE_TYPE_VERSION:
73
if (resource->baselined) {
74
value = "<D:baseline/>";
78
case DAV_RESOURCE_TYPE_REGULAR:
79
case DAV_RESOURCE_TYPE_WORKING:
80
if (resource->collection) {
81
value = "<D:collection/>";
84
/* ### should we denote lock-null resources? */
86
value = ""; /* becomes: <D:resourcetype/> */
89
case DAV_RESOURCE_TYPE_HISTORY:
90
value = "<D:version-history/>";
92
case DAV_RESOURCE_TYPE_WORKSPACE:
93
value = "<D:collection/>";
95
case DAV_RESOURCE_TYPE_ACTIVITY:
96
value = "<D:activity/>";
101
return DAV_PROP_INSERT_NOTDEF;
105
case DAV_PROPID_comment:
106
case DAV_PROPID_creator_displayname:
107
case DAV_PROPID_displayname:
108
case DAV_PROPID_source:
111
** This property is known, but not defined as a liveprop. However,
112
** it may be a dead property.
114
return DAV_PROP_INSERT_NOTDEF;
117
/* assert: value != NULL */
119
/* get the information and global NS index for the property */
120
global_ns = dav_get_liveprop_info(propid, &dav_core_liveprop_group, &info);
122
/* assert: info != NULL && info->name != NULL */
124
if (what == DAV_PROP_INSERT_SUPPORTED) {
126
"<D:supported-live-property D:name=\"%s\" "
127
"D:namespace=\"%s\"/>" DEBUG_CR,
128
info->name, dav_core_namespace_uris[info->ns]);
130
else if (what == DAV_PROP_INSERT_VALUE && *value != '\0') {
131
s = apr_psprintf(p, "<lp%ld:%s>%s</lp%ld:%s>" DEBUG_CR,
132
global_ns, info->name, value, global_ns, info->name);
135
s = apr_psprintf(p, "<lp%ld:%s/>" DEBUG_CR, global_ns, info->name);
137
apr_text_append(p, phdr, s);
139
/* we inserted what was asked for */
143
static int dav_core_is_writable(const dav_resource *resource, int propid)
145
const dav_liveprop_spec *info;
147
(void) dav_get_liveprop_info(propid, &dav_core_liveprop_group, &info);
148
return info->is_writable;
151
static dav_error * dav_core_patch_validate(const dav_resource *resource,
152
const apr_xml_elem *elem,
153
int operation, void **context,
156
/* all of our writable props go in the dead prop database */
162
static const dav_hooks_liveprop dav_core_hooks_liveprop = {
163
dav_core_insert_prop,
164
dav_core_is_writable,
165
dav_core_namespace_uris,
166
dav_core_patch_validate,
167
NULL, /* patch_exec */
168
NULL, /* patch_commit */
169
NULL, /* patch_rollback */
172
DAV_DECLARE_NONSTD(int) dav_core_find_liveprop(
173
const dav_resource *resource,
174
const char *ns_uri, const char *name,
175
const dav_hooks_liveprop **hooks)
177
return dav_do_find_liveprop(ns_uri, name, &dav_core_liveprop_group, hooks);
180
DAV_DECLARE_NONSTD(void) dav_core_insert_all_liveprops(
182
const dav_resource *resource,
183
dav_prop_insert what,
184
apr_text_header *phdr)
186
(void) dav_core_insert_prop(resource, DAV_PROPID_resourcetype,
190
DAV_DECLARE_NONSTD(void) dav_core_register_uris(apr_pool_t *p)
192
/* register the namespace URIs */
193
dav_register_liveprop_group(p, &dav_core_liveprop_group);