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';", "part 'props.g.dart';",
'', '',
...generateClass( ...generateClass(
'WebDavPropfindProp', 'WebDavPropWithoutValues',
'prop', 'prop',
'namespaceDav', 'namespaceDav',
findProps, 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. /// See http://www.webdav.org/specs/rfc2518.html#METHOD_PROPFIND for more information.
Future<WebDavMultistatus> propfind( Future<WebDavMultistatus> propfind(
final String path, { final String path, {
final WebDavPropfindProp? prop, final WebDavPropWithoutValues? prop,
final String? depth, final String? depth,
}) async { }) async {
assert(depth == null || ['0', '1', 'infinity'].contains(depth), 'Depth has to be 0, 1 or infinity'); 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( data: Stream.value(
Uint8List.fromList( Uint8List.fromList(
utf8.encode( 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( Future<WebDavMultistatus> report(
final String path, final String path,
final WebDavOcFilterRules filterRules, { final WebDavOcFilterRules filterRules, {
final WebDavPropfindProp? prop, final WebDavPropWithoutValues? prop,
}) async => }) async =>
_parseResponse( _parseResponse(
await _send( await _send(
@ -256,7 +256,7 @@ class WebDavClient {
utf8.encode( utf8.encode(
WebDavOcFilterFiles( WebDavOcFilterFiles(
filterRules: filterRules, filterRules: filterRules,
prop: prop ?? WebDavPropfindProp(), // coverage:ignore-line prop: prop ?? WebDavPropWithoutValues(), // coverage:ignore-line
).toXmlElement(namespaces: namespaces).toXmlString(), ).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.XmlSerializable(createMixin: true)
@annotation.XmlRootElement(name: 'prop', namespace: namespaceDav) @annotation.XmlRootElement(name: 'prop', namespace: namespaceDav)
class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin { class WebDavPropWithoutValues with _$WebDavPropWithoutValuesXmlSerializableMixin {
WebDavPropfindProp({ WebDavPropWithoutValues({
this.davgetlastmodified, this.davgetlastmodified,
this.davgetetag, this.davgetetag,
this.davgetcontenttype, this.davgetcontenttype,
@ -38,7 +38,7 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin {
this.ocmsharepermissions, this.ocmsharepermissions,
}); });
WebDavPropfindProp.fromBools({ WebDavPropWithoutValues.fromBools({
final bool davgetlastmodified = false, final bool davgetlastmodified = false,
final bool davgetetag = false, final bool davgetetag = false,
final bool davgetcontenttype = false, final bool davgetcontenttype = false,
@ -94,7 +94,8 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin {
ocssharepermissions = ocssharepermissions ? [null] : null, ocssharepermissions = ocssharepermissions ? [null] : null,
ocmsharepermissions = ocmsharepermissions ? [null] : null; ocmsharepermissions = ocmsharepermissions ? [null] : null;
factory WebDavPropfindProp.fromXmlElement(final XmlElement element) => _$WebDavPropfindPropFromXmlElement(element); factory WebDavPropWithoutValues.fromXmlElement(final XmlElement element) =>
_$WebDavPropWithoutValuesFromXmlElement(element);
@annotation.XmlElement( @annotation.XmlElement(
name: 'getlastmodified', name: 'getlastmodified',

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

@ -6,7 +6,7 @@ part of 'props.dart';
// XmlSerializableGenerator // XmlSerializableGenerator
// ************************************************************************** // **************************************************************************
void _$WebDavPropfindPropBuildXmlChildren(WebDavPropfindProp instance, XmlBuilder builder, void _$WebDavPropWithoutValuesBuildXmlChildren(WebDavPropWithoutValues instance, XmlBuilder builder,
{Map<String, String> namespaces = const {}}) { {Map<String, String> namespaces = const {}}) {
final davgetlastmodified = instance.davgetlastmodified; final davgetlastmodified = instance.davgetlastmodified;
final davgetlastmodifiedSerialized = 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 {}}) { {Map<String, String> namespaces = const {}}) {
builder.element('prop', namespace: 'DAV:', namespaces: namespaces, nest: () { builder.element('prop', namespace: 'DAV:', namespaces: namespaces, nest: () {
instance.buildXmlChildren(builder, namespaces: namespaces); instance.buildXmlChildren(builder, namespaces: namespaces);
}); });
} }
WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) { WebDavPropWithoutValues _$WebDavPropWithoutValuesFromXmlElement(XmlElement element) {
final davgetlastmodified = final davgetlastmodified =
element.getElements('getlastmodified', namespace: 'DAV:')?.map((e) => e.getText()).whereType<String>(); element.getElements('getlastmodified', namespace: 'DAV:')?.map((e) => e.getText()).whereType<String>();
final davgetetag = element.getElements('getetag', 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') .getElements('share-permissions', namespace: 'http://open-cloud-mesh.org/ns')
?.map((e) => e.getText()) ?.map((e) => e.getText())
.whereType<String>(); .whereType<String>();
return WebDavPropfindProp( return WebDavPropWithoutValues(
davgetlastmodified: davgetlastmodified?.toList(), davgetlastmodified: davgetlastmodified?.toList(),
davgetetag: davgetetag?.toList(), davgetetag: davgetetag?.toList(),
davgetcontenttype: davgetcontenttype?.toList(), davgetcontenttype: davgetcontenttype?.toList(),
@ -431,13 +431,13 @@ WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) {
ocmsharepermissions: ocmsharepermissions?.toList()); ocmsharepermissions: ocmsharepermissions?.toList());
} }
List<XmlAttribute> _$WebDavPropfindPropToXmlAttributes(WebDavPropfindProp instance, List<XmlAttribute> _$WebDavPropWithoutValuesToXmlAttributes(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) { {Map<String, String?> namespaces = const {}}) {
final attributes = <XmlAttribute>[]; final attributes = <XmlAttribute>[];
return attributes; return attributes;
} }
List<XmlNode> _$WebDavPropfindPropToXmlChildren(WebDavPropfindProp instance, List<XmlNode> _$WebDavPropWithoutValuesToXmlChildren(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) { {Map<String, String?> namespaces = const {}}) {
final children = <XmlNode>[]; final children = <XmlNode>[];
final davgetlastmodified = instance.davgetlastmodified; final davgetlastmodified = instance.davgetlastmodified;
@ -638,28 +638,29 @@ List<XmlNode> _$WebDavPropfindPropToXmlChildren(WebDavPropfindProp instance,
return children; return children;
} }
XmlElement _$WebDavPropfindPropToXmlElement(WebDavPropfindProp instance, {Map<String, String?> namespaces = const {}}) { XmlElement _$WebDavPropWithoutValuesToXmlElement(WebDavPropWithoutValues instance,
{Map<String, String?> namespaces = const {}}) {
return XmlElement( return XmlElement(
XmlName('prop', namespaces['DAV:']), XmlName('prop', namespaces['DAV:']),
[...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)],
instance.toXmlChildren(namespaces: namespaces)); instance.toXmlChildren(namespaces: namespaces));
} }
mixin _$WebDavPropfindPropXmlSerializableMixin { mixin _$WebDavPropWithoutValuesXmlSerializableMixin {
void buildXmlChildren(XmlBuilder builder, {Map<String, String> namespaces = const {}}) => 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 {}}) => 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 {}}) => 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 {}}) => 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 {}}) => 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, 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) @annotation.XmlElement(name: 'prop', namespace: namespaceDav)
final WebDavPropfindProp prop; final WebDavPropWithoutValues prop;
} }
@annotation.XmlSerializable(createMixin: true) @annotation.XmlSerializable(createMixin: true)
@ -119,7 +119,7 @@ class WebDavOcFilterFiles with _$WebDavOcFilterFilesXmlSerializableMixin {
final WebDavOcFilterRules filterRules; final WebDavOcFilterRules filterRules;
@annotation.XmlElement(name: 'prop', namespace: namespaceDav) @annotation.XmlElement(name: 'prop', namespace: namespaceDav)
final WebDavPropfindProp prop; final WebDavPropWithoutValues prop;
} }
@annotation.XmlSerializable(createMixin: true) @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) { WebDavPropfind _$WebDavPropfindFromXmlElement(XmlElement element) {
final prop = element.getElement('prop', namespace: 'DAV:')!; final prop = element.getElement('prop', namespace: 'DAV:')!;
return WebDavPropfind(prop: WebDavPropfindProp.fromXmlElement(prop)); return WebDavPropfind(prop: WebDavPropWithoutValues.fromXmlElement(prop));
} }
List<XmlAttribute> _$WebDavPropfindToXmlAttributes(WebDavPropfind instance, 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 filterRules = element.getElement('filter-rules', namespace: 'http://owncloud.org/ns')!;
final prop = element.getElement('prop', namespace: 'DAV:')!; final prop = element.getElement('prop', namespace: 'DAV:')!;
return WebDavOcFilterFiles( return WebDavOcFilterFiles(
filterRules: WebDavOcFilterRules.fromXmlElement(filterRules), prop: WebDavPropfindProp.fromXmlElement(prop)); filterRules: WebDavOcFilterRules.fromXmlElement(filterRules), prop: WebDavPropWithoutValues.fromXmlElement(prop));
} }
List<XmlAttribute> _$WebDavOcFilterFilesToXmlAttributes(WebDavOcFilterFiles instance, List<XmlAttribute> _$WebDavOcFilterFilesToXmlAttributes(WebDavOcFilterFiles instance,

14
packages/nextcloud/test/webdav_test.dart

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

Loading…
Cancel
Save