tilia-dav 3.1.0.pre.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.database.travis.yml +6 -0
- data/.gitignore +25 -0
- data/.rubocop.yml +35 -0
- data/.simplecov +4 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.sabre.md +2084 -0
- data/CONTRIBUTING.md +25 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +103 -0
- data/LICENSE +27 -0
- data/LICENSE.sabre +27 -0
- data/README.md +40 -0
- data/Rakefile +18 -0
- data/database.sample.yml +6 -0
- data/examples/minimal.rb +25 -0
- data/lib/tilia/cal_dav.rb +27 -0
- data/lib/tilia/cal_dav/backend.rb +17 -0
- data/lib/tilia/cal_dav/backend/abstract_backend.rb +194 -0
- data/lib/tilia/cal_dav/backend/backend_interface.rb +250 -0
- data/lib/tilia/cal_dav/backend/notification_support.rb +38 -0
- data/lib/tilia/cal_dav/backend/scheduling_support.rb +57 -0
- data/lib/tilia/cal_dav/backend/sequel.rb +1118 -0
- data/lib/tilia/cal_dav/backend/sharing_support.rb +239 -0
- data/lib/tilia/cal_dav/backend/subscription_support.rb +79 -0
- data/lib/tilia/cal_dav/backend/sync_support.rb +75 -0
- data/lib/tilia/cal_dav/calendar.rb +426 -0
- data/lib/tilia/cal_dav/calendar_home.rb +335 -0
- data/lib/tilia/cal_dav/calendar_object.rb +219 -0
- data/lib/tilia/cal_dav/calendar_query_validator.rb +294 -0
- data/lib/tilia/cal_dav/calendar_root.rb +57 -0
- data/lib/tilia/cal_dav/exception.rb +7 -0
- data/lib/tilia/cal_dav/exception/invalid_component_type.rb +21 -0
- data/lib/tilia/cal_dav/i_calendar.rb +11 -0
- data/lib/tilia/cal_dav/i_calendar_object.rb +13 -0
- data/lib/tilia/cal_dav/i_calendar_object_container.rb +32 -0
- data/lib/tilia/cal_dav/i_shareable_calendar.rb +40 -0
- data/lib/tilia/cal_dav/i_shared_calendar.rb +28 -0
- data/lib/tilia/cal_dav/ics_export_plugin.rb +327 -0
- data/lib/tilia/cal_dav/notifications.rb +12 -0
- data/lib/tilia/cal_dav/notifications/collection.rb +131 -0
- data/lib/tilia/cal_dav/notifications/i_collection.rb +17 -0
- data/lib/tilia/cal_dav/notifications/i_node.rb +30 -0
- data/lib/tilia/cal_dav/notifications/node.rb +142 -0
- data/lib/tilia/cal_dav/notifications/plugin.rb +138 -0
- data/lib/tilia/cal_dav/plugin.rb +891 -0
- data/lib/tilia/cal_dav/principal.rb +12 -0
- data/lib/tilia/cal_dav/principal/collection.rb +21 -0
- data/lib/tilia/cal_dav/principal/i_proxy_read.rb +13 -0
- data/lib/tilia/cal_dav/principal/i_proxy_write.rb +13 -0
- data/lib/tilia/cal_dav/principal/proxy_read.rb +127 -0
- data/lib/tilia/cal_dav/principal/proxy_write.rb +127 -0
- data/lib/tilia/cal_dav/principal/user.rb +96 -0
- data/lib/tilia/cal_dav/schedule.rb +14 -0
- data/lib/tilia/cal_dav/schedule/i_inbox.rb +12 -0
- data/lib/tilia/cal_dav/schedule/i_mip_plugin.rb +156 -0
- data/lib/tilia/cal_dav/schedule/i_outbox.rb +12 -0
- data/lib/tilia/cal_dav/schedule/i_scheduling_object.rb +10 -0
- data/lib/tilia/cal_dav/schedule/inbox.rb +211 -0
- data/lib/tilia/cal_dav/schedule/outbox.rb +143 -0
- data/lib/tilia/cal_dav/schedule/plugin.rb +851 -0
- data/lib/tilia/cal_dav/schedule/scheduling_object.rb +126 -0
- data/lib/tilia/cal_dav/shareable_calendar.rb +54 -0
- data/lib/tilia/cal_dav/shared_calendar.rb +120 -0
- data/lib/tilia/cal_dav/sharing_plugin.rb +359 -0
- data/lib/tilia/cal_dav/subscriptions.rb +9 -0
- data/lib/tilia/cal_dav/subscriptions/i_subscription.rb +37 -0
- data/lib/tilia/cal_dav/subscriptions/plugin.rb +83 -0
- data/lib/tilia/cal_dav/subscriptions/subscription.rb +205 -0
- data/lib/tilia/cal_dav/xml.rb +10 -0
- data/lib/tilia/cal_dav/xml/filter.rb +12 -0
- data/lib/tilia/cal_dav/xml/filter/calendar_data.rb +64 -0
- data/lib/tilia/cal_dav/xml/filter/comp_filter.rb +79 -0
- data/lib/tilia/cal_dav/xml/filter/param_filter.rb +66 -0
- data/lib/tilia/cal_dav/xml/filter/prop_filter.rb +80 -0
- data/lib/tilia/cal_dav/xml/notification.rb +13 -0
- data/lib/tilia/cal_dav/xml/notification/invite.rb +253 -0
- data/lib/tilia/cal_dav/xml/notification/invite_reply.rb +167 -0
- data/lib/tilia/cal_dav/xml/notification/notification_interface.rb +41 -0
- data/lib/tilia/cal_dav/xml/notification/system_status.rb +139 -0
- data/lib/tilia/cal_dav/xml/property.rb +15 -0
- data/lib/tilia/cal_dav/xml/property/allowed_sharing_modes.rb +64 -0
- data/lib/tilia/cal_dav/xml/property/email_address_set.rb +60 -0
- data/lib/tilia/cal_dav/xml/property/invite.rb +207 -0
- data/lib/tilia/cal_dav/xml/property/schedule_calendar_transp.rb +108 -0
- data/lib/tilia/cal_dav/xml/property/supported_calendar_component_set.rb +100 -0
- data/lib/tilia/cal_dav/xml/property/supported_calendar_data.rb +50 -0
- data/lib/tilia/cal_dav/xml/property/supported_collation_set.rb +47 -0
- data/lib/tilia/cal_dav/xml/request.rb +14 -0
- data/lib/tilia/cal_dav/xml/request/calendar_multi_get_report.rb +99 -0
- data/lib/tilia/cal_dav/xml/request/calendar_query_report.rb +112 -0
- data/lib/tilia/cal_dav/xml/request/free_busy_query_report.rb +70 -0
- data/lib/tilia/cal_dav/xml/request/invite_reply.rb +110 -0
- data/lib/tilia/cal_dav/xml/request/mk_calendar.rb +67 -0
- data/lib/tilia/cal_dav/xml/request/share.rb +93 -0
- data/lib/tilia/card_dav.rb +17 -0
- data/lib/tilia/card_dav/address_book.rb +338 -0
- data/lib/tilia/card_dav/address_book_home.rb +192 -0
- data/lib/tilia/card_dav/address_book_root.rb +58 -0
- data/lib/tilia/card_dav/backend.rb +12 -0
- data/lib/tilia/card_dav/backend/abstract_backend.rb +30 -0
- data/lib/tilia/card_dav/backend/backend_interface.rb +175 -0
- data/lib/tilia/card_dav/backend/sequel.rb +476 -0
- data/lib/tilia/card_dav/backend/sync_support.rb +80 -0
- data/lib/tilia/card_dav/card.rb +193 -0
- data/lib/tilia/card_dav/i_address_book.rb +10 -0
- data/lib/tilia/card_dav/i_card.rb +11 -0
- data/lib/tilia/card_dav/i_directory.rb +14 -0
- data/lib/tilia/card_dav/plugin.rb +724 -0
- data/lib/tilia/card_dav/vcf_export_plugin.rb +122 -0
- data/lib/tilia/card_dav/xml.rb +9 -0
- data/lib/tilia/card_dav/xml/filter.rb +11 -0
- data/lib/tilia/card_dav/xml/filter/address_data.rb +50 -0
- data/lib/tilia/card_dav/xml/filter/param_filter.rb +71 -0
- data/lib/tilia/card_dav/xml/filter/prop_filter.rb +77 -0
- data/lib/tilia/card_dav/xml/property.rb +10 -0
- data/lib/tilia/card_dav/xml/property/supported_address_data.rb +67 -0
- data/lib/tilia/card_dav/xml/property/supported_collation_set.rb +38 -0
- data/lib/tilia/card_dav/xml/request.rb +10 -0
- data/lib/tilia/card_dav/xml/request/address_book_multi_get_report.rb +91 -0
- data/lib/tilia/card_dav/xml/request/address_book_query_report.rb +156 -0
- data/lib/tilia/dav.rb +94 -0
- data/lib/tilia/dav/auth.rb +8 -0
- data/lib/tilia/dav/auth/backend.rb +15 -0
- data/lib/tilia/dav/auth/backend/abstract_basic.rb +119 -0
- data/lib/tilia/dav/auth/backend/abstract_digest.rb +132 -0
- data/lib/tilia/dav/auth/backend/apache.rb +85 -0
- data/lib/tilia/dav/auth/backend/backend_interface.rb +61 -0
- data/lib/tilia/dav/auth/backend/basic_call_back.rb +46 -0
- data/lib/tilia/dav/auth/backend/file.rb +61 -0
- data/lib/tilia/dav/auth/backend/sequel.rb +46 -0
- data/lib/tilia/dav/auth/plugin.rb +157 -0
- data/lib/tilia/dav/browser.rb +12 -0
- data/lib/tilia/dav/browser/assets/favicon.ico +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/ICON-LICENSE +21 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.css +510 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.eot +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.otf +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.svg +543 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.ttf +0 -0
- data/lib/tilia/dav/browser/assets/openiconic/open-iconic.woff +0 -0
- data/lib/tilia/dav/browser/assets/sabredav.css +228 -0
- data/lib/tilia/dav/browser/assets/sabredav.png +0 -0
- data/lib/tilia/dav/browser/guess_content_type.rb +80 -0
- data/lib/tilia/dav/browser/html_output.rb +27 -0
- data/lib/tilia/dav/browser/html_output_helper.rb +86 -0
- data/lib/tilia/dav/browser/map_get_to_prop_find.rb +41 -0
- data/lib/tilia/dav/browser/plugin.rb +693 -0
- data/lib/tilia/dav/browser/prop_find_all.rb +95 -0
- data/lib/tilia/dav/client.rb +341 -0
- data/lib/tilia/dav/collection.rb +79 -0
- data/lib/tilia/dav/core_plugin.rb +824 -0
- data/lib/tilia/dav/exception.rb +59 -0
- data/lib/tilia/dav/exception/bad_request.rb +18 -0
- data/lib/tilia/dav/exception/conflict.rb +18 -0
- data/lib/tilia/dav/exception/conflicting_lock.rb +26 -0
- data/lib/tilia/dav/exception/forbidden.rb +18 -0
- data/lib/tilia/dav/exception/insufficient_storage.rb +18 -0
- data/lib/tilia/dav/exception/invalid_resource_type.rb +23 -0
- data/lib/tilia/dav/exception/invalid_sync_token.rb +26 -0
- data/lib/tilia/dav/exception/length_required.rb +18 -0
- data/lib/tilia/dav/exception/lock_token_matches_request_uri.rb +25 -0
- data/lib/tilia/dav/exception/locked.rb +48 -0
- data/lib/tilia/dav/exception/method_not_allowed.rb +29 -0
- data/lib/tilia/dav/exception/not_authenticated.rb +18 -0
- data/lib/tilia/dav/exception/not_found.rb +18 -0
- data/lib/tilia/dav/exception/not_implemented.rb +18 -0
- data/lib/tilia/dav/exception/payment_required.rb +18 -0
- data/lib/tilia/dav/exception/precondition_failed.rb +47 -0
- data/lib/tilia/dav/exception/report_not_supported.rb +21 -0
- data/lib/tilia/dav/exception/requested_range_not_satisfiable.rb +18 -0
- data/lib/tilia/dav/exception/service_unavailable.rb +18 -0
- data/lib/tilia/dav/exception/too_many_matches.rb +21 -0
- data/lib/tilia/dav/exception/unsupported_media_type.rb +18 -0
- data/lib/tilia/dav/file.rb +58 -0
- data/lib/tilia/dav/fs.rb +9 -0
- data/lib/tilia/dav/fs/directory.rb +119 -0
- data/lib/tilia/dav/fs/file.rb +69 -0
- data/lib/tilia/dav/fs/node.rb +57 -0
- data/lib/tilia/dav/fs_ext.rb +8 -0
- data/lib/tilia/dav/fs_ext/directory.rb +175 -0
- data/lib/tilia/dav/fs_ext/file.rb +118 -0
- data/lib/tilia/dav/i_collection.rb +65 -0
- data/lib/tilia/dav/i_extended_collection.rb +36 -0
- data/lib/tilia/dav/i_file.rb +70 -0
- data/lib/tilia/dav/i_move_target.rb +37 -0
- data/lib/tilia/dav/i_multi_get.rb +29 -0
- data/lib/tilia/dav/i_node.rb +33 -0
- data/lib/tilia/dav/i_properties.rb +39 -0
- data/lib/tilia/dav/i_quota.rb +19 -0
- data/lib/tilia/dav/locks.rb +9 -0
- data/lib/tilia/dav/locks/backend.rb +12 -0
- data/lib/tilia/dav/locks/backend/abstract_backend.rb +16 -0
- data/lib/tilia/dav/locks/backend/backend_interface.rb +41 -0
- data/lib/tilia/dav/locks/backend/file.rb +146 -0
- data/lib/tilia/dav/locks/backend/sequel.rb +154 -0
- data/lib/tilia/dav/locks/lock_info.rb +60 -0
- data/lib/tilia/dav/locks/plugin.rb +467 -0
- data/lib/tilia/dav/mk_col.rb +47 -0
- data/lib/tilia/dav/mount.rb +7 -0
- data/lib/tilia/dav/mount/plugin.rb +62 -0
- data/lib/tilia/dav/node.rb +36 -0
- data/lib/tilia/dav/partial_update.rb +8 -0
- data/lib/tilia/dav/partial_update/i_patch_support.rb +40 -0
- data/lib/tilia/dav/partial_update/plugin.rb +179 -0
- data/lib/tilia/dav/prop_find.rb +262 -0
- data/lib/tilia/dav/prop_patch.rb +278 -0
- data/lib/tilia/dav/property_storage.rb +8 -0
- data/lib/tilia/dav/property_storage/backend.rb +10 -0
- data/lib/tilia/dav/property_storage/backend/backend_interface.rb +69 -0
- data/lib/tilia/dav/property_storage/backend/sequel.rb +192 -0
- data/lib/tilia/dav/property_storage/plugin.rb +131 -0
- data/lib/tilia/dav/server.rb +1388 -0
- data/lib/tilia/dav/server_plugin.rb +81 -0
- data/lib/tilia/dav/simple_collection.rb +71 -0
- data/lib/tilia/dav/simple_file.rb +82 -0
- data/lib/tilia/dav/string_util.rb +68 -0
- data/lib/tilia/dav/sync.rb +8 -0
- data/lib/tilia/dav/sync/i_sync_collection.rb +80 -0
- data/lib/tilia/dav/sync/plugin.rb +225 -0
- data/lib/tilia/dav/temporary_file_filter_plugin.rb +248 -0
- data/lib/tilia/dav/tree.rb +270 -0
- data/lib/tilia/dav/uuid_util.rb +45 -0
- data/lib/tilia/dav/version.rb +9 -0
- data/lib/tilia/dav/xml.rb +11 -0
- data/lib/tilia/dav/xml/element.rb +10 -0
- data/lib/tilia/dav/xml/element/prop.rb +92 -0
- data/lib/tilia/dav/xml/element/response.rb +188 -0
- data/lib/tilia/dav/xml/property.rb +16 -0
- data/lib/tilia/dav/xml/property/complex.rb +76 -0
- data/lib/tilia/dav/xml/property/get_last_modified.rb +79 -0
- data/lib/tilia/dav/xml/property/href.rb +137 -0
- data/lib/tilia/dav/xml/property/lock_discovery.rb +89 -0
- data/lib/tilia/dav/xml/property/resource_type.rb +96 -0
- data/lib/tilia/dav/xml/property/supported_lock.rb +48 -0
- data/lib/tilia/dav/xml/property/supported_method_set.rb +101 -0
- data/lib/tilia/dav/xml/property/supported_report_set.rb +118 -0
- data/lib/tilia/dav/xml/request.rb +13 -0
- data/lib/tilia/dav/xml/request/lock.rb +67 -0
- data/lib/tilia/dav/xml/request/mk_col.rb +69 -0
- data/lib/tilia/dav/xml/request/prop_find.rb +70 -0
- data/lib/tilia/dav/xml/request/prop_patch.rb +101 -0
- data/lib/tilia/dav/xml/request/sync_collection_report.rb +102 -0
- data/lib/tilia/dav/xml/response.rb +9 -0
- data/lib/tilia/dav/xml/response/multi_status.rb +108 -0
- data/lib/tilia/dav/xml/service.rb +42 -0
- data/lib/tilia/dav_acl.rb +16 -0
- data/lib/tilia/dav_acl/abstract_principal_collection.rb +143 -0
- data/lib/tilia/dav_acl/exception.rb +11 -0
- data/lib/tilia/dav_acl/exception/ace_conflict.rb +21 -0
- data/lib/tilia/dav_acl/exception/need_privileges.rb +65 -0
- data/lib/tilia/dav_acl/exception/no_abstract.rb +21 -0
- data/lib/tilia/dav_acl/exception/not_recognized_principal.rb +21 -0
- data/lib/tilia/dav_acl/exception/not_supported_privilege.rb +21 -0
- data/lib/tilia/dav_acl/fs.rb +9 -0
- data/lib/tilia/dav_acl/fs/collection.rb +108 -0
- data/lib/tilia/dav_acl/fs/file.rb +87 -0
- data/lib/tilia/dav_acl/fs/home_collection.rb +148 -0
- data/lib/tilia/dav_acl/i_acl.rb +61 -0
- data/lib/tilia/dav_acl/i_principal.rb +63 -0
- data/lib/tilia/dav_acl/i_principal_collection.rb +52 -0
- data/lib/tilia/dav_acl/plugin.rb +1109 -0
- data/lib/tilia/dav_acl/principal.rb +213 -0
- data/lib/tilia/dav_acl/principal_backend.rb +11 -0
- data/lib/tilia/dav_acl/principal_backend/abstract_backend.rb +42 -0
- data/lib/tilia/dav_acl/principal_backend/backend_interface.rb +127 -0
- data/lib/tilia/dav_acl/principal_backend/create_principal_support.rb +27 -0
- data/lib/tilia/dav_acl/principal_backend/sequel.rb +313 -0
- data/lib/tilia/dav_acl/principal_collection.rb +117 -0
- data/lib/tilia/dav_acl/xml.rb +8 -0
- data/lib/tilia/dav_acl/xml/property.rb +13 -0
- data/lib/tilia/dav_acl/xml/property/acl.rb +222 -0
- data/lib/tilia/dav_acl/xml/property/acl_restrictions.rb +40 -0
- data/lib/tilia/dav_acl/xml/property/current_user_privilege_set.rb +125 -0
- data/lib/tilia/dav_acl/xml/property/principal.rb +149 -0
- data/lib/tilia/dav_acl/xml/property/supported_privilege_set.rb +135 -0
- data/lib/tilia/dav_acl/xml/request.rb +11 -0
- data/lib/tilia/dav_acl/xml/request/expand_property_report.rb +86 -0
- data/lib/tilia/dav_acl/xml/request/principal_property_search_report.rb +111 -0
- data/lib/tilia/dav_acl/xml/request/principal_search_property_set_report.rb +49 -0
- data/test/cal_dav/backend/abstract_sequel_test.rb +817 -0
- data/test/cal_dav/backend/abstract_test.rb +163 -0
- data/test/cal_dav/backend/mock.rb +169 -0
- data/test/cal_dav/backend/mock_scheduling.rb +84 -0
- data/test/cal_dav/backend/mock_sharing.rb +124 -0
- data/test/cal_dav/backend/mock_subscription_support.rb +123 -0
- data/test/cal_dav/backend/sequel_my_sql_test.rb +102 -0
- data/test/cal_dav/backend/sequel_sqlite_test.rb +105 -0
- data/test/cal_dav/calendar_home_notifications_test.rb +41 -0
- data/test/cal_dav/calendar_home_shared_calendars_test.rb +64 -0
- data/test/cal_dav/calendar_home_subscriptions_test.rb +67 -0
- data/test/cal_dav/calendar_home_test.rb +144 -0
- data/test/cal_dav/calendar_object_test.rb +317 -0
- data/test/cal_dav/calendar_query_v_alarm_test.rb +114 -0
- data/test/cal_dav/calendar_query_validator_test.rb +820 -0
- data/test/cal_dav/calendar_test.rb +203 -0
- data/test/cal_dav/expand_events_double_events_test.rb +94 -0
- data/test/cal_dav/expand_events_dtstar_tand_dten_dby_day_test.rb +94 -0
- data/test/cal_dav/expand_events_dtstar_tand_dtend_test.rb +100 -0
- data/test/cal_dav/expand_events_floating_time_test.rb +211 -0
- data/test/cal_dav/free_busy_report_test.rb +156 -0
- data/test/cal_dav/get_events_by_timerange_test.rb +74 -0
- data/test/cal_dav/ics_export_plugin_test.rb +638 -0
- data/test/cal_dav/issue166_test.rb +59 -0
- data/test/cal_dav/issue172_test.rb +139 -0
- data/test/cal_dav/issue203_test.rb +130 -0
- data/test/cal_dav/issue205_test.rb +89 -0
- data/test/cal_dav/issue211_test.rb +84 -0
- data/test/cal_dav/issue220_test.rb +94 -0
- data/test/cal_dav/issue228_test.rb +74 -0
- data/test/cal_dav/j_cal_transform_test.rb +244 -0
- data/test/cal_dav/notifications/collection_test.rb +67 -0
- data/test/cal_dav/notifications/node_test.rb +73 -0
- data/test/cal_dav/notifications/plugin_test.rb +144 -0
- data/test/cal_dav/plugin_test.rb +1049 -0
- data/test/cal_dav/principal/collection_test.rb +19 -0
- data/test/cal_dav/principal/proxy_read_test.rb +67 -0
- data/test/cal_dav/principal/proxy_write_test.rb +29 -0
- data/test/cal_dav/principal/user_test.rb +91 -0
- data/test/cal_dav/schedule/deliver_new_event_test.rb +81 -0
- data/test/cal_dav/schedule/free_busy_request_test.rb +565 -0
- data/test/cal_dav/schedule/i_mip/mock_plugin.rb +40 -0
- data/test/cal_dav/schedule/i_mip_plugin_test.rb +196 -0
- data/test/cal_dav/schedule/inbox_test.rb +150 -0
- data/test/cal_dav/schedule/outbox_post_test.rb +124 -0
- data/test/cal_dav/schedule/outbox_test.rb +76 -0
- data/test/cal_dav/schedule/plugin_basic_test.rb +39 -0
- data/test/cal_dav/schedule/plugin_properties_test.rb +96 -0
- data/test/cal_dav/schedule/plugin_properties_with_shared_calendar_test.rb +69 -0
- data/test/cal_dav/schedule/schedule_deliver_test.rb +605 -0
- data/test/cal_dav/schedule/scheduling_object_test.rb +327 -0
- data/test/cal_dav/shareable_calendar_test.rb +58 -0
- data/test/cal_dav/shared_calendar_test.rb +189 -0
- data/test/cal_dav/sharing_plugin_test.rb +373 -0
- data/test/cal_dav/subscriptions/create_subscription_test.rb +115 -0
- data/test/cal_dav/subscriptions/plugin_test.rb +46 -0
- data/test/cal_dav/subscriptions/subscription_test.rb +119 -0
- data/test/cal_dav/test_util.rb +164 -0
- data/test/cal_dav/validate_i_cal_test.rb +219 -0
- data/test/cal_dav/xml/notification/invite_reply_test.rb +136 -0
- data/test/cal_dav/xml/notification/invite_test.rb +225 -0
- data/test/cal_dav/xml/notification/system_status_test.rb +63 -0
- data/test/cal_dav/xml/property/allowed_sharing_modes_test.rb +34 -0
- data/test/cal_dav/xml/property/email_address_set_test.rb +35 -0
- data/test/cal_dav/xml/property/invite_test.rb +173 -0
- data/test/cal_dav/xml/property/schedule_calendar_transp_test.rb +96 -0
- data/test/cal_dav/xml/property/supported_calendar_component_set_test.rb +76 -0
- data/test/cal_dav/xml/property/supported_calendar_data_test.rb +32 -0
- data/test/cal_dav/xml/property/supported_collation_set_test.rb +33 -0
- data/test/cal_dav/xml/request/calendar_query_report_test.rb +339 -0
- data/test/cal_dav/xml/request/invite_reply_test.rb +68 -0
- data/test/cal_dav/xml/request/share_test.rb +79 -0
- data/test/card_dav/abstract_plugin_test.rb +24 -0
- data/test/card_dav/address_book_home_test.rb +128 -0
- data/test/card_dav/address_book_query_test.rb +303 -0
- data/test/card_dav/address_book_root_test.rb +26 -0
- data/test/card_dav/address_book_test.rb +166 -0
- data/test/card_dav/backend/abstract_sequel_test.rb +302 -0
- data/test/card_dav/backend/mock.rb +122 -0
- data/test/card_dav/backend/sequel_my_sql_test.rb +56 -0
- data/test/card_dav/backend/sequel_sqlite_test.rb +59 -0
- data/test/card_dav/card_test.rb +164 -0
- data/test/card_dav/i_directory_test.rb +22 -0
- data/test/card_dav/multi_get_test.rb +97 -0
- data/test/card_dav/plugin_test.rb +87 -0
- data/test/card_dav/sogo_strip_content_type_test.rb +63 -0
- data/test/card_dav/test_util.rb +51 -0
- data/test/card_dav/validate_filter_test.rb +210 -0
- data/test/card_dav/validate_v_card_test.rb +143 -0
- data/test/card_dav/vcf_export_test.rb +66 -0
- data/test/card_dav/xml/property/supported_address_data_test.rb +34 -0
- data/test/card_dav/xml/property/supported_collation_set_test.rb +34 -0
- data/test/card_dav/xml/request/address_book_query_report_test.rb +276 -0
- data/test/dav/abstract_server.rb +36 -0
- data/test/dav/auth/backend/abstract_basic_test.rb +74 -0
- data/test/dav/auth/backend/abstract_digest_test.rb +114 -0
- data/test/dav/auth/backend/abstract_sequel_test.rb +25 -0
- data/test/dav/auth/backend/apache_test.rb +60 -0
- data/test/dav/auth/backend/basic_call_back_test.rb +33 -0
- data/test/dav/auth/backend/file_test.rb +43 -0
- data/test/dav/auth/backend/mock.rb +73 -0
- data/test/dav/auth/backend/sequel_my_sql_test.rb +32 -0
- data/test/dav/auth/backend/sequel_sqlite_test.rb +21 -0
- data/test/dav/auth/plugin_test.rb +92 -0
- data/test/dav/basic_node_test.rb +143 -0
- data/test/dav/browser/guess_content_type_test.rb +44 -0
- data/test/dav/browser/map_get_to_prop_find_test.rb +37 -0
- data/test/dav/browser/plugin_test.rb +165 -0
- data/test/dav/browser/prop_find_all_test.rb +59 -0
- data/test/dav/client_mock.rb +24 -0
- data/test/dav/client_test.rb +231 -0
- data/test/dav/copy_test.rb +33 -0
- data/test/dav/exception/locked_test.rb +61 -0
- data/test/dav/exception/payment_required_test.rb +14 -0
- data/test/dav/exception/service_unavailable_test.rb +14 -0
- data/test/dav/exception/too_many_matches_test.rb +31 -0
- data/test/dav/exception_test.rb +24 -0
- data/test/dav/fs_ext/file_test.rb +72 -0
- data/test/dav/fs_ext/server_test.rb +251 -0
- data/test/dav/get_if_conditions_test.rb +299 -0
- data/test/dav/http_delete_test.rb +110 -0
- data/test/dav/http_get_test.rb +130 -0
- data/test/dav/http_head_test.rb +80 -0
- data/test/dav/http_move_test.rb +105 -0
- data/test/dav/http_prefer_parsing_test.rb +186 -0
- data/test/dav/http_put_test.rb +271 -0
- data/test/dav/issue33_test.rb +90 -0
- data/test/dav/locks/backend/abstract_test.rb +160 -0
- data/test/dav/locks/backend/file_test.rb +24 -0
- data/test/dav/locks/backend/mock.rb +82 -0
- data/test/dav/locks/backend/sequel_my_sql_test.rb +32 -0
- data/test/dav/locks/backend/sequel_test.rb +19 -0
- data/test/dav/locks/ms_word_test.rb +119 -0
- data/test/dav/locks/plugin2_test.rb +61 -0
- data/test/dav/locks/plugin_test.rb +896 -0
- data/test/dav/mock/collection.rb +113 -0
- data/test/dav/mock/file.rb +100 -0
- data/test/dav/mock/properties_collection.rb +80 -0
- data/test/dav/mock/streaming_file.rb +66 -0
- data/test/dav/mount/plugin_test.rb +48 -0
- data/test/dav/object_tree_test.rb +65 -0
- data/test/dav/partial_update/file_mock.rb +92 -0
- data/test/dav/partial_update/plugin_test.rb +125 -0
- data/test/dav/partial_update/specification_test.rb +77 -0
- data/test/dav/prop_find_test.rb +87 -0
- data/test/dav/prop_patch_test.rb +367 -0
- data/test/dav/property_storage/backend/abstract_sequel_test.rb +147 -0
- data/test/dav/property_storage/backend/mock.rb +96 -0
- data/test/dav/property_storage/backend/sequel_mysql_test.rb +32 -0
- data/test/dav/property_storage/backend/sequel_sqlite_test.rb +31 -0
- data/test/dav/property_storage/plugin_test.rb +90 -0
- data/test/dav/server_copy_move_test.rb +164 -0
- data/test/dav/server_events_test.rb +105 -0
- data/test/dav/server_mkcol_test.rb +337 -0
- data/test/dav/server_mock.rb +10 -0
- data/test/dav/server_plugin_test.rb +85 -0
- data/test/dav/server_precondition_test.rb +253 -0
- data/test/dav/server_props_infinite_depth_test.rb +144 -0
- data/test/dav/server_props_test.rb +182 -0
- data/test/dav/server_range_test.rb +262 -0
- data/test/dav/server_simple_test.rb +388 -0
- data/test/dav/server_update_properties_test.rb +93 -0
- data/test/dav/simple_file_test.rb +17 -0
- data/test/dav/string_util_test.rb +92 -0
- data/test/dav/sync/mock_sync_collection.rb +141 -0
- data/test/dav/sync/plugin_test.rb +491 -0
- data/test/dav/sync_token_property_test.rb +105 -0
- data/test/dav/temporary_file_filter_test.rb +179 -0
- data/test/dav/test_plugin.rb +24 -0
- data/test/dav/tree_test.rb +201 -0
- data/test/dav/uuid_util_test.rb +14 -0
- data/test/dav/xml/element/prop_test.rb +121 -0
- data/test/dav/xml/element/response_test.rb +202 -0
- data/test/dav/xml/property/href_test.rb +112 -0
- data/test/dav/xml/property/last_modified_test.rb +52 -0
- data/test/dav/xml/property/lock_discovery_test.rb +79 -0
- data/test/dav/xml/property/supported_method_set_test.rb +54 -0
- data/test/dav/xml/property/supported_report_set_test.rb +109 -0
- data/test/dav/xml/request/prop_find_test.rb +45 -0
- data/test/dav/xml/request/prop_patch_test.rb +47 -0
- data/test/dav/xml/request/sync_collection_test.rb +89 -0
- data/test/dav/xml/xml_tester.rb +35 -0
- data/test/dav_acl/acl_method_test.rb +299 -0
- data/test/dav_acl/allow_access_test.rb +94 -0
- data/test/dav_acl/block_access_test.rb +161 -0
- data/test/dav_acl/exception/ace_conflict_test.rb +33 -0
- data/test/dav_acl/exception/need_privileges_exception_test.rb +43 -0
- data/test/dav_acl/exception/no_abstract_test.rb +33 -0
- data/test/dav_acl/exception/not_recognized_principal_test.rb +33 -0
- data/test/dav_acl/exception/not_supported_privilege_test.rb +33 -0
- data/test/dav_acl/expand_properties_test.rb +265 -0
- data/test/dav_acl/fs/collection_test.rb +39 -0
- data/test/dav_acl/fs/file_test.rb +47 -0
- data/test/dav_acl/fs/home_collection_test.rb +82 -0
- data/test/dav_acl/mock_acl_node.rb +27 -0
- data/test/dav_acl/mock_principal.rb +27 -0
- data/test/dav_acl/plugin_admin_test.rb +60 -0
- data/test/dav_acl/plugin_properties_test.rb +346 -0
- data/test/dav_acl/plugin_update_properties_test.rb +82 -0
- data/test/dav_acl/principal_backend/abstract_sequel_test.rb +159 -0
- data/test/dav_acl/principal_backend/mock.rb +150 -0
- data/test/dav_acl/principal_backend/sequel_my_sql_test.rb +43 -0
- data/test/dav_acl/principal_backend/sequel_sqlite_test.rb +31 -0
- data/test/dav_acl/principal_collection_test.rb +44 -0
- data/test/dav_acl/principal_property_search_test.rb +354 -0
- data/test/dav_acl/principal_search_property_set_test.rb +125 -0
- data/test/dav_acl/principal_test.rb +181 -0
- data/test/dav_acl/simple_plugin_test.rb +320 -0
- data/test/dav_acl/xml/property/acl_restrictions_test.rb +28 -0
- data/test/dav_acl/xml/property/acl_test.rb +325 -0
- data/test/dav_acl/xml/property/current_user_privilege_set_test.rb +77 -0
- data/test/dav_acl/xml/property/principal_test.rb +158 -0
- data/test/dav_acl/xml/property/supported_privilege_set_test.rb +109 -0
- data/test/dav_server_test.rb +225 -0
- data/test/http/response_mock.rb +16 -0
- data/test/http/sapi_mock.rb +29 -0
- data/test/test_helper.rb +176 -0
- data/tilia-dav.gemspec +28 -0
- metadata +726 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
module Tilia
|
2
|
+
module Dav
|
3
|
+
module Browser
|
4
|
+
# This class is used by the browser plugin to trick the system in returning
|
5
|
+
# every defined property.
|
6
|
+
class PropFindAll < PropFind
|
7
|
+
# Creates the PROPFIND object
|
8
|
+
#
|
9
|
+
# @param string path
|
10
|
+
def initialize(path)
|
11
|
+
super(path, [])
|
12
|
+
end
|
13
|
+
|
14
|
+
# Handles a specific property.
|
15
|
+
#
|
16
|
+
# This method checks wether the specified property was requested in this
|
17
|
+
# PROPFIND request, and if so, it will call the callback and use the
|
18
|
+
# return value for it's value.
|
19
|
+
#
|
20
|
+
# Example:
|
21
|
+
#
|
22
|
+
# prop_find.handle('{DAV:}displayname', function {
|
23
|
+
# return 'hello'
|
24
|
+
# })
|
25
|
+
#
|
26
|
+
# Note that handle will only work the first time. If null is returned, the
|
27
|
+
# value is ignored.
|
28
|
+
#
|
29
|
+
# It's also possible to not pass a callback, but immediately pass a value
|
30
|
+
#
|
31
|
+
# @param string property_name
|
32
|
+
# @param mixed value_or_call_back
|
33
|
+
# @return void
|
34
|
+
def handle(property_name, value_or_call_back)
|
35
|
+
if value_or_call_back.is_a?(Proc) || value_or_call_back.is_a?(Method)
|
36
|
+
value = value_or_call_back.call
|
37
|
+
else
|
38
|
+
value = value_or_call_back
|
39
|
+
end
|
40
|
+
|
41
|
+
result[property_name] = [200, value] unless value.nil?
|
42
|
+
end
|
43
|
+
|
44
|
+
# Sets the value of the property
|
45
|
+
#
|
46
|
+
# If status is not supplied, the status will default to 200 for non-null
|
47
|
+
# properties, and 404 for null properties.
|
48
|
+
#
|
49
|
+
# @param string property_name
|
50
|
+
# @param mixed value
|
51
|
+
# @param int status
|
52
|
+
# @return void
|
53
|
+
def set(property_name, value, status = nil)
|
54
|
+
status = value.nil? ? 404 : 200 if status.nil?
|
55
|
+
result[property_name] = [status, value]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns the current value for a property.
|
59
|
+
#
|
60
|
+
# @param string property_name
|
61
|
+
# @return mixed
|
62
|
+
def get(property_name)
|
63
|
+
result.key?(property_name) ? result[property_name][1] : nil
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns the current status code for a property name.
|
67
|
+
#
|
68
|
+
# If the property does not appear in the list of requested properties,
|
69
|
+
# null will be returned.
|
70
|
+
#
|
71
|
+
# @param string property_name
|
72
|
+
# @return int|null
|
73
|
+
def status(property_name)
|
74
|
+
result.key?(property_name) ? result[property_name][0] : 404
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns all propertynames that have a 404 status, and thus don't have a
|
78
|
+
# value yet.
|
79
|
+
#
|
80
|
+
# @return array
|
81
|
+
def get404_properties
|
82
|
+
result = []
|
83
|
+
self.result.each do |property_name, stuff|
|
84
|
+
result << property_name if stuff[0] == 404
|
85
|
+
end
|
86
|
+
|
87
|
+
# If there's nothing in this list, we're adding one fictional item.
|
88
|
+
result << '{http://sabredav.org/ns}idk' if result.empty?
|
89
|
+
|
90
|
+
result
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
module Tilia
|
2
|
+
module Dav
|
3
|
+
# SabreDAV DAV client
|
4
|
+
#
|
5
|
+
# This client wraps around Curl to provide a convenient API to a WebDAV
|
6
|
+
# server.
|
7
|
+
#
|
8
|
+
# NOTE: This class is experimental, it's api will likely change in the future.
|
9
|
+
class Client < Http::Client
|
10
|
+
# The xml service.
|
11
|
+
#
|
12
|
+
# Uset this service to configure the property and namespace maps.
|
13
|
+
#
|
14
|
+
# @var mixed
|
15
|
+
attr_accessor :xml
|
16
|
+
|
17
|
+
# The elementMap
|
18
|
+
#
|
19
|
+
# This property is linked via reference to @xml.element_map.
|
20
|
+
# It's deprecated as of version 3.0.0, and should no longer be used.
|
21
|
+
#
|
22
|
+
# @deprecated
|
23
|
+
# @var array
|
24
|
+
attr_accessor :property_map
|
25
|
+
|
26
|
+
# Base URI
|
27
|
+
#
|
28
|
+
# This URI will be used to resolve relative urls.
|
29
|
+
#
|
30
|
+
# @var string
|
31
|
+
# RUBY: attr_accessor :base_uri
|
32
|
+
|
33
|
+
# Basic authentication
|
34
|
+
AUTH_BASIC = 1
|
35
|
+
|
36
|
+
# Digest authentication
|
37
|
+
AUTH_DIGEST = 2
|
38
|
+
|
39
|
+
# NTLM authentication
|
40
|
+
AUTH_NTLM = 4
|
41
|
+
|
42
|
+
# Identity encoding, which basically does not nothing.
|
43
|
+
ENCODING_IDENTITY = 1
|
44
|
+
|
45
|
+
# Deflate encoding
|
46
|
+
ENCODING_DEFLATE = 2
|
47
|
+
|
48
|
+
# Gzip encoding
|
49
|
+
ENCODING_GZIP = 4
|
50
|
+
|
51
|
+
# Sends all encoding headers.
|
52
|
+
ENCODING_ALL = 7
|
53
|
+
|
54
|
+
# Content-encoding
|
55
|
+
#
|
56
|
+
# @var int
|
57
|
+
# RUBY: attr_accessor :encoding
|
58
|
+
|
59
|
+
# Constructor
|
60
|
+
#
|
61
|
+
# Settings are provided through the 'settings' argument. The following
|
62
|
+
# settings are supported:
|
63
|
+
#
|
64
|
+
# * baseUri
|
65
|
+
# * userName (optional)
|
66
|
+
# * password (optional)
|
67
|
+
# * proxy (optional)
|
68
|
+
# * authType (optional)
|
69
|
+
# * encoding (optional)
|
70
|
+
#
|
71
|
+
# authType must be a bitmap, using AUTH_BASIC, AUTH_DIGEST
|
72
|
+
# and AUTH_NTLM. If you know which authentication method will be
|
73
|
+
# used, it's recommended to set it, as it will save a great deal of
|
74
|
+
# requests to 'discover' this information.
|
75
|
+
#
|
76
|
+
# Encoding is a bitmap with one of the ENCODING constants.
|
77
|
+
#
|
78
|
+
# @param array settings
|
79
|
+
def initialize(settings)
|
80
|
+
@property_map = {}
|
81
|
+
@encoding = ENCODING_IDENTITY
|
82
|
+
|
83
|
+
unless settings.key?('baseUri')
|
84
|
+
fail ArgumentError, 'A baseUri must be provided'
|
85
|
+
end
|
86
|
+
|
87
|
+
super()
|
88
|
+
|
89
|
+
@base_uri = settings['baseUri']
|
90
|
+
|
91
|
+
add_curl_setting(:proxy, settings['proxy']) if settings.key?('proxy')
|
92
|
+
|
93
|
+
if settings.key?('userName')
|
94
|
+
user_name = settings['userName']
|
95
|
+
password = settings['password'] || ''
|
96
|
+
|
97
|
+
if settings.key?('authType')
|
98
|
+
curl_type = []
|
99
|
+
curl_type << :basic if settings['authType'] & AUTH_BASIC > 0
|
100
|
+
curl_type << :digest if settings['authType'] & AUTH_DIGEST > 0
|
101
|
+
curl_type << :ntlm if settings['authType'] & AUTH_NTLM > 0
|
102
|
+
else
|
103
|
+
curl_type = [:basic, :digest]
|
104
|
+
end
|
105
|
+
|
106
|
+
add_curl_setting(:httpauth, curl_type)
|
107
|
+
add_curl_setting(:userpwd, "#{user_name}:#{password}")
|
108
|
+
end
|
109
|
+
|
110
|
+
if settings.key?('encoding')
|
111
|
+
encoding = settings['encoding']
|
112
|
+
|
113
|
+
encodings = []
|
114
|
+
encodings << 'identity' if encoding & ENCODING_IDENTITY > 0
|
115
|
+
encodings << 'deflate' if encoding & ENCODING_DEFLATE > 0
|
116
|
+
encodings << 'gzip' if encoding & ENCODING_GZIP > 0
|
117
|
+
|
118
|
+
add_curl_setting(:encoding, encodings.join(','))
|
119
|
+
end
|
120
|
+
|
121
|
+
@xml = Xml::Service.new
|
122
|
+
# BC
|
123
|
+
@property_map = @xml.element_map
|
124
|
+
end
|
125
|
+
|
126
|
+
# Does a PROPFIND request
|
127
|
+
#
|
128
|
+
# The list of requested properties must be specified as an array, in clark
|
129
|
+
# notation.
|
130
|
+
#
|
131
|
+
# The returned array will contain a list of filenames as keys, and
|
132
|
+
# properties as values.
|
133
|
+
#
|
134
|
+
# The properties array will contain the list of properties. Only properties
|
135
|
+
# that are actually returned from the server (without error) will be
|
136
|
+
# returned, anything else is discarded.
|
137
|
+
#
|
138
|
+
# Depth should be either 0 or 1. A depth of 1 will cause a request to be
|
139
|
+
# made to the server to also return all child resources.
|
140
|
+
#
|
141
|
+
# @param string url
|
142
|
+
# @param array properties
|
143
|
+
# @param int depth
|
144
|
+
# @return array
|
145
|
+
def prop_find(url, properties, depth = 0)
|
146
|
+
dom = LibXML::XML::Document.new
|
147
|
+
|
148
|
+
root = LibXML::XML::Node.new('d:propfind')
|
149
|
+
LibXML::XML::Namespace.new(root, 'd', 'DAV:')
|
150
|
+
prop = LibXML::XML::Node.new('d:prop')
|
151
|
+
|
152
|
+
properties.each do |property|
|
153
|
+
(namespace, element_name) = Tilia::Xml::Service.parse_clark_notation(property)
|
154
|
+
|
155
|
+
if namespace == 'DAV:'
|
156
|
+
element = LibXML::XML::Node.new("d:#{element_name}")
|
157
|
+
else
|
158
|
+
element = LibXML::XML::Node.new("x:#{element_name}")
|
159
|
+
LibXML::XML::Namespace.new(element, 'x', namespace)
|
160
|
+
end
|
161
|
+
|
162
|
+
prop << element
|
163
|
+
end
|
164
|
+
|
165
|
+
dom.root = root
|
166
|
+
root << prop
|
167
|
+
|
168
|
+
body = dom.to_s
|
169
|
+
|
170
|
+
url = absolute_url(url)
|
171
|
+
|
172
|
+
request = Http::Request.new(
|
173
|
+
'PROPFIND',
|
174
|
+
url,
|
175
|
+
{
|
176
|
+
'Depth' => depth,
|
177
|
+
'Content-Type' => 'application/xml'
|
178
|
+
},
|
179
|
+
body
|
180
|
+
)
|
181
|
+
|
182
|
+
response = send_request(request)
|
183
|
+
|
184
|
+
fail Exception, "HTTP error: #{response.status}" if response.status.to_i >= 400
|
185
|
+
|
186
|
+
result = parse_multi_status(response.body_as_string)
|
187
|
+
|
188
|
+
# If depth was 0, we only return the top item
|
189
|
+
if depth == 0
|
190
|
+
result = result.first.second # value of first key/value pair
|
191
|
+
return result.key?('200') ? result['200'] : {}
|
192
|
+
end
|
193
|
+
|
194
|
+
new_result = {}
|
195
|
+
result.each do |href, status_list|
|
196
|
+
new_result[href] = status_list.key?('200') ? status_list['200'] : {}
|
197
|
+
end
|
198
|
+
|
199
|
+
new_result
|
200
|
+
end
|
201
|
+
|
202
|
+
# Updates a list of properties on the server
|
203
|
+
#
|
204
|
+
# The list of properties must have clark-notation properties for the keys,
|
205
|
+
# and the actual (string) value for the value. If the value is null, an
|
206
|
+
# attempt is made to delete the property.
|
207
|
+
#
|
208
|
+
# @param string url
|
209
|
+
# @param array properties
|
210
|
+
# @return void
|
211
|
+
def prop_patch(url, properties)
|
212
|
+
prop_patch = Xml::Request::PropPatch.new
|
213
|
+
prop_patch.properties = properties
|
214
|
+
xml = @xml.write('{DAV:}propertyupdate', prop_patch)
|
215
|
+
|
216
|
+
url = absolute_url(url)
|
217
|
+
request = Http::Request.new(
|
218
|
+
'PROPPATCH',
|
219
|
+
url,
|
220
|
+
{ 'Content-Type' => 'application/xml' },
|
221
|
+
xml
|
222
|
+
)
|
223
|
+
send_request(request)
|
224
|
+
end
|
225
|
+
|
226
|
+
# Performs an HTTP options request
|
227
|
+
#
|
228
|
+
# This method returns all the features from the 'DAV:' header as an array.
|
229
|
+
# If there was no DAV header, or no contents this method will return an
|
230
|
+
# empty array.
|
231
|
+
#
|
232
|
+
# @return array
|
233
|
+
def options
|
234
|
+
request = Http::Request.new('OPTIONS', absolute_url(''))
|
235
|
+
response = send_request(request)
|
236
|
+
|
237
|
+
dav = response.header('Dav')
|
238
|
+
return [] unless dav
|
239
|
+
|
240
|
+
features = dav.split(',')
|
241
|
+
features.map(&:strip)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Performs an actual HTTP request, and returns the result.
|
245
|
+
#
|
246
|
+
# If the specified url is relative, it will be expanded based on the base
|
247
|
+
# url.
|
248
|
+
#
|
249
|
+
# The returned array contains 3 keys:
|
250
|
+
# * body - the response body
|
251
|
+
# * httpCode - a HTTP code (200, 404, etc)
|
252
|
+
# * headers - a list of response http headers. The header names have
|
253
|
+
# been lowercased.
|
254
|
+
#
|
255
|
+
# For large uploads, it's highly recommended to specify body as a stream
|
256
|
+
# resource. You can easily do this by simply passing the result of
|
257
|
+
# fopen(..., 'r').
|
258
|
+
#
|
259
|
+
# This method will throw an exception if an HTTP error was received. Any
|
260
|
+
# HTTP status code above 399 is considered an error.
|
261
|
+
#
|
262
|
+
# Note that it is no longer recommended to use this method, use the send
|
263
|
+
# method instead.
|
264
|
+
#
|
265
|
+
# @param string method
|
266
|
+
# @param string url
|
267
|
+
# @param string|resource|null body
|
268
|
+
# @param array headers
|
269
|
+
# @throws ClientException, in case a curl error occurred.
|
270
|
+
# @return array
|
271
|
+
def request(method, url = '', body = nil, headers = {})
|
272
|
+
url = absolute_url(url)
|
273
|
+
|
274
|
+
headers = {}
|
275
|
+
response.headers.each { |k, v| headers[k.downcase] = v }
|
276
|
+
|
277
|
+
response = send_request(Http::Request.new(method, url, headers, body))
|
278
|
+
{
|
279
|
+
'body' => response.body_as_string,
|
280
|
+
'statusCode' => response.status.to_i,
|
281
|
+
'headers' => headers
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
# Returns the full url based on the given url (which may be relative). All
|
286
|
+
# urls are expanded based on the base url as given by the server.
|
287
|
+
#
|
288
|
+
# @param string url
|
289
|
+
# @return string
|
290
|
+
def absolute_url(url)
|
291
|
+
# If the url starts with http:// or https://, the url is already absolute.
|
292
|
+
return url if url =~ /^http(s?):\/\//
|
293
|
+
|
294
|
+
# If the url starts with a slash, we must calculate the url based off
|
295
|
+
# the root of the base url.
|
296
|
+
if url.index('/') == 0
|
297
|
+
parts = Tilia::Uri.parse(@base_uri)
|
298
|
+
return "#{parts['scheme']}://#{parts['host']}#{parts['port'] ? ":#{parts['port']}" : ''}#{url}"
|
299
|
+
end
|
300
|
+
|
301
|
+
# Otherwise...
|
302
|
+
@base_uri + url
|
303
|
+
end
|
304
|
+
|
305
|
+
# Parses a WebDAV multistatus response body
|
306
|
+
#
|
307
|
+
# This method returns an array with the following structure
|
308
|
+
#
|
309
|
+
# [
|
310
|
+
# 'url/to/resource' => [
|
311
|
+
# '200' => [
|
312
|
+
# '{DAV:}property1' => 'value1',
|
313
|
+
# '{DAV:}property2' => 'value2',
|
314
|
+
# ],
|
315
|
+
# '404' => [
|
316
|
+
# '{DAV:}property1' => null,
|
317
|
+
# '{DAV:}property2' => null,
|
318
|
+
# ],
|
319
|
+
# ],
|
320
|
+
# 'url/to/resource2' => [
|
321
|
+
# .. etc ..
|
322
|
+
# ]
|
323
|
+
# ]
|
324
|
+
#
|
325
|
+
#
|
326
|
+
# @param string body xml body
|
327
|
+
# @return array
|
328
|
+
def parse_multi_status(body)
|
329
|
+
multistatus = @xml.expect('{DAV:}multistatus', body)
|
330
|
+
|
331
|
+
result = {}
|
332
|
+
|
333
|
+
multistatus.responses.each do |response|
|
334
|
+
result[response.href] = response.response_properties
|
335
|
+
end
|
336
|
+
|
337
|
+
result
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Tilia
|
2
|
+
module Dav
|
3
|
+
# Collection class
|
4
|
+
#
|
5
|
+
# This is a helper class, that should aid in getting collections classes setup.
|
6
|
+
# Most of its methods are implemented, and throw permission denied exceptions
|
7
|
+
class Collection < Node
|
8
|
+
include ICollection
|
9
|
+
|
10
|
+
# Returns a child object, by its name.
|
11
|
+
#
|
12
|
+
# This method makes use of the children method to grab all the child
|
13
|
+
# nodes, and compares the name.
|
14
|
+
# Generally its wise to override this, as this can usually be optimized
|
15
|
+
#
|
16
|
+
# This method must throw Sabre\DAV\Exception\NotFound if the node does not
|
17
|
+
# exist.
|
18
|
+
#
|
19
|
+
# @param string name
|
20
|
+
# @throws Exception\NotFound
|
21
|
+
# @return INode
|
22
|
+
def child(name)
|
23
|
+
children.each do |child|
|
24
|
+
return child if child.name == name
|
25
|
+
end
|
26
|
+
|
27
|
+
fail Exception::NotFound, "File not found: #{name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Checks is a child-node exists.
|
31
|
+
#
|
32
|
+
# It is generally a good idea to try and override this. Usually it can be optimized.
|
33
|
+
#
|
34
|
+
# @param string name
|
35
|
+
# @return bool
|
36
|
+
def child_exists(name)
|
37
|
+
child(name)
|
38
|
+
true
|
39
|
+
rescue Exception::NotFound => e
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates a new file in the directory
|
44
|
+
#
|
45
|
+
# Data will either be supplied as a stream resource, or in certain cases
|
46
|
+
# as a string. Keep in mind that you may have to support either.
|
47
|
+
#
|
48
|
+
# After succesful creation of the file, you may choose to return the ETag
|
49
|
+
# of the new file here.
|
50
|
+
#
|
51
|
+
# The returned ETag must be surrounded by double-quotes (The quotes should
|
52
|
+
# be part of the actual string).
|
53
|
+
#
|
54
|
+
# If you cannot accurately determine the ETag, you should not return it.
|
55
|
+
# If you don't store the file exactly as-is (you're transforming it
|
56
|
+
# somehow) you should also not return an ETag.
|
57
|
+
#
|
58
|
+
# This means that if a subsequent GET to this new file does not exactly
|
59
|
+
# return the same contents of what was submitted here, you are strongly
|
60
|
+
# recommended to omit the ETag.
|
61
|
+
#
|
62
|
+
# @param string name Name of the file
|
63
|
+
# @param resource|string data Initial payload
|
64
|
+
# @return null|string
|
65
|
+
def create_file(name, _data = nil)
|
66
|
+
fail Exception::Forbidden, "Permission denied to create file (filename #{name})"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Creates a new subdirectory
|
70
|
+
#
|
71
|
+
# @param string name
|
72
|
+
# @throws Exception\Forbidden
|
73
|
+
# @return void
|
74
|
+
def create_directory(_name)
|
75
|
+
fail Exception::Forbidden, 'Permission denied to create directory'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|