Browse Source

refactor(nextcloud): Rename WebDAV prop without values

pull/520/head
jld3103 1 year ago
parent
commit
f6d785bcd6
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 2
      packages/nextcloud/bin/generate_props.dart
  2. 8
      packages/nextcloud/lib/src/webdav/client.dart
  3. 9
      packages/nextcloud/lib/src/webdav/props.dart
  4. 27
      packages/nextcloud/lib/src/webdav/props.g.dart
  5. 4
      packages/nextcloud/lib/src/webdav/webdav.dart
  6. 4
      packages/nextcloud/lib/src/webdav/webdav.g.dart
  7. 14
      packages/nextcloud/test/webdav_test.dart

2
packages/nextcloud/bin/generate_props.dart

@ -29,7 +29,7 @@ void main() {
"part 'props.g.dart';",
'',
...generateClass(
'WebDavPropfindProp',
'WebDavPropWithoutValues',
'prop',
'namespaceDav',
findProps,

8
packages/nextcloud/lib/src/webdav/client.dart

@ -204,7 +204,7 @@ class WebDavClient {
/// See http://www.webdav.org/specs/rfc2518.html#METHOD_PROPFIND for more information.
Future<WebDavMultistatus> propfind(
final String path, {
final WebDavPropfindProp? prop,
final WebDavPropWithoutValues? prop,
final String? depth,
}) async {
assert(depth == null || ['0', '1', 'infinity'].contains(depth), 'Depth has to be 0, 1 or infinity');
@ -215,7 +215,7 @@ class WebDavClient {
data: Stream.value(
Uint8List.fromList(
utf8.encode(
WebDavPropfind(prop: prop ?? WebDavPropfindProp()).toXmlElement(namespaces: namespaces).toXmlString(),
WebDavPropfind(prop: prop ?? WebDavPropWithoutValues()).toXmlElement(namespaces: namespaces).toXmlString(),
),
),
),
@ -244,7 +244,7 @@ class WebDavClient {
Future<WebDavMultistatus> report(
final String path,
final WebDavOcFilterRules filterRules, {
final WebDavPropfindProp? prop,
final WebDavPropWithoutValues? prop,
}) async =>
_parseResponse(
await _send(
@ -256,7 +256,7 @@ class WebDavClient {
utf8.encode(
WebDavOcFilterFiles(
filterRules: filterRules,
prop: prop ?? WebDavPropfindProp(), // coverage:ignore-line
prop: prop ?? WebDavPropWithoutValues(), // coverage:ignore-line
).toXmlElement(namespaces: namespaces).toXmlString(),
),
),

9
packages/nextcloud/lib/src/webdav/props.dart

@ -7,8 +7,8 @@ part 'props.g.dart';
@annotation.XmlSerializable(createMixin: true)
@annotation.XmlRootElement(name: 'prop', namespace: namespaceDav)
class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin {
WebDavPropfindProp({
class WebDavPropWithoutValues with _$WebDavPropWithoutValuesXmlSerializableMixin {
WebDavPropWithoutValues({
this.davgetlastmodified,
this.davgetetag,
this.davgetcontenttype,
@ -38,7 +38,7 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin {
this.ocmsharepermissions,
});
WebDavPropfindProp.fromBools({
WebDavPropWithoutValues.fromBools({
final bool davgetlastmodified = false,
final bool davgetetag = false,
final bool davgetcontenttype = false,
@ -94,7 +94,8 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin {
ocssharepermissions = ocssharepermissions ? [null] : null,
ocmsharepermissions = ocmsharepermissions ? [null] : null;
factory WebDavPropfindProp.fromXmlElement(final XmlElement element) => _$WebDavPropfindPropFromXmlElement(element);
factory WebDavPropWithoutValues.fromXmlElement(final XmlElement element) =>
_$WebDavPropWithoutValuesFromXmlElement(element);
@annotation.XmlElement(
name: 'getlastmodified',

27
packages/nextcloud/lib/src/webdav/props.g.dart

@ -6,7 +6,7 @@ part of 'props.dart';
// XmlSerializableGenerator
// **************************************************************************
void _$WebDavPropfindPropBuildXmlChildren(WebDavPropfindProp instance, XmlBuilder builder,
void _$WebDavPropWithoutValuesBuildXmlChildren(WebDavPropWithoutValues instance, XmlBuilder builder,
{Map<String, String> namespaces = const {}}) {
final davgetlastmodified = instance.davgetlastmodified;
final davgetlastmodifiedSerialized = davgetlastmodified;
@ -308,14 +308,14 @@ void _$WebDavPropfindPropBuildXmlChildren(WebDavPropfindProp instance, XmlBuilde
}
}
void _$WebDavPropfindPropBuildXmlElement(WebDavPropfindProp instance, XmlBuilder builder,
void _$WebDavPropWithoutValuesBuildXmlElement(WebDavPropWithoutValues instance, XmlBuilder builder,
{Map<String, String> namespaces = const {}}) {
builder.element('prop', namespace: 'DAV:', namespaces: namespaces, nest: () {
instance.buildXmlChildren(builder, namespaces: namespaces);
});
}
WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) {
WebDavPropWithoutValues _$WebDavPropWithoutValuesFromXmlElement(XmlElement element) {
final davgetlastmodified =
element.getElements('getlastmodified', namespace: 'DAV:')?.map((e) => e.getText()).whereType<String>();
final davgetetag = element.getElements('getetag', namespace: 'DAV:')?.map((e) => e.getText()).whereType<String>();
@ -401,7 +401,7 @@ WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) {
.getElements('share-permissions', namespace: 'http://open-cloud-mesh.org/ns')
?.map((e) => e.getText())
.whereType<String>();
return WebDavPropfindProp(
return WebDavPropWithoutValues(
davgetlastmodified: davgetlastmodified?.toList(),
davgetetag: davgetetag?.toList(),
davgetcontenttype: davgetcontenttype?.toList(),
@ -431,13 +431,13 @@ WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) {
ocmsharepermissions: ocmsharepermissions?.toList());
}
List<XmlAttribute> _$WebDavPropfindPropToXmlAttributes(WebDavPropfindProp instance,
List<XmlAttribute> _$WebDavPropWithoutValuesToXmlAttributes(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) {
final attributes = <XmlAttribute>[];
return attributes;
}
List<XmlNode> _$WebDavPropfindPropToXmlChildren(WebDavPropfindProp instance,
List<XmlNode> _$WebDavPropWithoutValuesToXmlChildren(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) {
final children = <XmlNode>[];
final davgetlastmodified = instance.davgetlastmodified;
@ -638,28 +638,29 @@ List<XmlNode> _$WebDavPropfindPropToXmlChildren(WebDavPropfindProp instance,
return children;
}
XmlElement _$WebDavPropfindPropToXmlElement(WebDavPropfindProp instance, {Map<String, String?> namespaces = const {}}) {
XmlElement _$WebDavPropWithoutValuesToXmlElement(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) {
return XmlElement(
XmlName('prop', namespaces['DAV:']),
[...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)],
instance.toXmlChildren(namespaces: namespaces));
}
mixin _$WebDavPropfindPropXmlSerializableMixin {
mixin _$WebDavPropWithoutValuesXmlSerializableMixin {
void buildXmlChildren(XmlBuilder builder, {Map<String, String> namespaces = const {}}) =>
_$WebDavPropfindPropBuildXmlChildren(this as WebDavPropfindProp, builder, namespaces: namespaces);
_$WebDavPropWithoutValuesBuildXmlChildren(this as WebDavPropWithoutValues, builder, namespaces: namespaces);
void buildXmlElement(XmlBuilder builder, {Map<String, String> namespaces = const {}}) =>
_$WebDavPropfindPropBuildXmlElement(this as WebDavPropfindProp, builder, namespaces: namespaces);
_$WebDavPropWithoutValuesBuildXmlElement(this as WebDavPropWithoutValues, builder, namespaces: namespaces);
List<XmlAttribute> toXmlAttributes({Map<String, String?> namespaces = const {}}) =>
_$WebDavPropfindPropToXmlAttributes(this as WebDavPropfindProp, namespaces: namespaces);
_$WebDavPropWithoutValuesToXmlAttributes(this as WebDavPropWithoutValues, namespaces: namespaces);
List<XmlNode> toXmlChildren({Map<String, String?> namespaces = const {}}) =>
_$WebDavPropfindPropToXmlChildren(this as WebDavPropfindProp, namespaces: namespaces);
_$WebDavPropWithoutValuesToXmlChildren(this as WebDavPropWithoutValues, namespaces: namespaces);
XmlElement toXmlElement({Map<String, String?> namespaces = const {}}) =>
_$WebDavPropfindPropToXmlElement(this as WebDavPropfindProp, namespaces: namespaces);
_$WebDavPropWithoutValuesToXmlElement(this as WebDavPropWithoutValues, namespaces: namespaces);
}
void _$WebDavPropBuildXmlChildren(WebDavProp instance, XmlBuilder builder,

4
packages/nextcloud/lib/src/webdav/webdav.dart

@ -104,7 +104,7 @@ class WebDavPropfind with _$WebDavPropfindXmlSerializableMixin {
});
@annotation.XmlElement(name: 'prop', namespace: namespaceDav)
final WebDavPropfindProp prop;
final WebDavPropWithoutValues prop;
}
@annotation.XmlSerializable(createMixin: true)
@ -119,7 +119,7 @@ class WebDavOcFilterFiles with _$WebDavOcFilterFilesXmlSerializableMixin {
final WebDavOcFilterRules filterRules;
@annotation.XmlElement(name: 'prop', namespace: namespaceDav)
final WebDavPropfindProp prop;
final WebDavPropWithoutValues prop;
}
@annotation.XmlSerializable(createMixin: true)

4
packages/nextcloud/lib/src/webdav/webdav.g.dart

@ -356,7 +356,7 @@ void _$WebDavPropfindBuildXmlElement(WebDavPropfind instance, XmlBuilder builder
WebDavPropfind _$WebDavPropfindFromXmlElement(XmlElement element) {
final prop = element.getElement('prop', namespace: 'DAV:')!;
return WebDavPropfind(prop: WebDavPropfindProp.fromXmlElement(prop));
return WebDavPropfind(prop: WebDavPropWithoutValues.fromXmlElement(prop));
}
List<XmlAttribute> _$WebDavPropfindToXmlAttributes(WebDavPropfind instance,
@ -424,7 +424,7 @@ WebDavOcFilterFiles _$WebDavOcFilterFilesFromXmlElement(XmlElement element) {
final filterRules = element.getElement('filter-rules', namespace: 'http://owncloud.org/ns')!;
final prop = element.getElement('prop', namespace: 'DAV:')!;
return WebDavOcFilterFiles(
filterRules: WebDavOcFilterRules.fromXmlElement(filterRules), prop: WebDavPropfindProp.fromXmlElement(prop));
filterRules: WebDavOcFilterRules.fromXmlElement(filterRules), prop: WebDavPropWithoutValues.fromXmlElement(prop));
}
List<XmlAttribute> _$WebDavOcFilterFilesToXmlAttributes(WebDavOcFilterFiles instance,

14
packages/nextcloud/test/webdav_test.dart

@ -32,7 +32,7 @@ void main() {
test('List directory', () async {
final responses = (await client.webdav.propfind(
'/',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
nchaspreview: true,
davgetcontenttype: true,
davgetlastmodified: true,
@ -75,7 +75,7 @@ void main() {
final responses = (await client.webdav.propfind(
'/',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
ocsize: true,
),
))
@ -106,7 +106,7 @@ void main() {
final props = (await client.webdav.propfind(
'/',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
davgetlastmodified: true,
nccreationtime: true,
),
@ -207,7 +207,7 @@ void main() {
test('Get file props', () async {
final response = (await client.webdav.propfind(
'Nextcloud.png',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
davgetlastmodified: true,
davgetetag: true,
davgetcontenttype: true,
@ -294,7 +294,7 @@ void main() {
final response = (await client.webdav.propfind(
'test',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
davgetcontenttype: true,
davgetlastmodified: true,
davresourcetype: true,
@ -334,7 +334,7 @@ void main() {
WebDavOcFilterRules(
ocfavorite: 1,
),
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
ocid: true,
ocfavorite: true,
),
@ -365,7 +365,7 @@ void main() {
final props = (await client.webdav.propfind(
'test.txt',
prop: WebDavPropfindProp.fromBools(
prop: WebDavPropWithoutValues.fromBools(
ocfavorite: true,
nccreationtime: true,
ncuploadtime: true,

Loading…
Cancel
Save