Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add @type annotations when serializing SocialActivity data In preparation for creating a generic transfer extension, set the `@type` field when serializing `SocialActivity*` objects. * Implement basic GenericImporter for SOCIAL_POSTS Adds a generic `Importer` for SOCIAL_POSTS. The importer passes the social data straight through, and is built to be extensible to other data types. * Implement basic GenericFileImporter for BLOBS Extends the `GenericImporter` from the previous commit to support data with both JSON metadata and file data. As an example of usage, provide an implementation for `BLOBS` data. * Add README with draft docs for generic importers * Configure GenericFileImporter for MEDIA * Configure GenericImporter for CALENDAR * Extract generic BLOBS serializer to separate module Extracts the logic for serializing BLOBS data to a separate module. Adds tests for the serializer. Adds a generic wrapper around the payload, which will wrap all other types after they undergo the same refactoring. * Extract generic SOCIAL_POSTS exporter to separate module Extracts the SOCIAL_POSTS generic importer serialization logic to a separate module. Also adds tests, and wraps the payload in GenericPayload, like with BLOBS that was done in the previous commit. * Extract generic CALENDAR exporter to separate module Extracts the CALENDAR generic importer serialization logic to a separate module. Also adds tests, and wraps the payload in GenericPayload, like with other data types in previous commits. * Extract generic MEDIA exporter to separate module Extracts the MEDIA generic importer serialization logic to a separate module. Also adds tests, and wraps the payload in GenericPayload, like with other data types in previous commits. * Move CachedDownloadableItem to BlobbySerializer Moves `CachedDownloadableItem` to the `BlobbySerializer` file, since that's the only place it's used. * Serialize dates to strings in tests * Preserve typing information of JSON payloads In previous commits the type information of exported data was being lost at serialization time. This change delays converting to JSON representation until the time when data is sent on the wire, allowing type information to be preserved as long as possible and to avoid double-serialization of the data. The exported data have a union of possible types (the MediaSerializer, for example, generates a list of MediaAlbums, VideoModels, and PhotoModels), but unfortunately Java doesn't support proper union types. A solution to this is to create an empty `ExportData` interface for each serializer and have the possible subtypes 'implement' the empty interface, then using the `ExportData` interface as a type bound. This makes Media and Calendar serializers more verbose as we're having to duplicate the underlying models, but it gives us a layer of separation between the model and the serialized data, allowing them to evolve independently, and guaranteeing that changes to the model will require a corresponding change in the serializer, reducing the chance of the serializer interface being broken. * Use custom schema for media GenericImporter serialization Since we've added a layer between generic importer serializers and the underlying models to better preserve type information, make use of this by using a custom schema for media items. This lets us be a) use consistent schemas for Photos and Videos b) use TZ-aware date-times (although we have to assume the underlying Date is UTC when copying the model) * Tidy up TypeNames of top-level schemas Simplifies the `@type` annotations of exported data. Might be worth doing this for nested types too, although some of them are directly using Models defined by DTP. * Configure endpoint and supported verticals for generic importers Expands the `TransferServiceConfig` object to allow arbitraty data in a `serviceConfig` field, to be later parsed by `TransferExtension`s at initialization time. Extends `GenericTransferExtension` to read from `serviceConfig` to configure itself for the import service being targeted. Also allows `TransferExtension`s to declare support for services through a `supportsService` method, turning Service->Extension mappings from one-to-one to many-to-one, meaning `GenericTransferExtension` can be configured to support multiple services. For now the configuration is fairly barebones; a list of supported verticals (wrapped in an object to allow future support for vertical-level configuration), the base of the API endpoint, and the service name. * Support OAuth Authorization Code-based auth for generic importers * Tidy up MediaSerializer Tidies up the MediaSerializer class, and reverts some now-unnecessary changes to the core DTP models. * Tidy up BlobbySerializer Improves the serialization of Blobby data. * Add tests for GenericImporter * Simplify GenericFileImporter Refactors GenericImporter to make GenericFileImporter simpler, and to remove some duplication in the two classes. * Set mimetype in GenericFileImporter * Tidy up old test code There was a manual test being used during development that was replaced by unit tests. * Flatten BlobbySerializer File data File data had inherited some structure from when it was based on `BlobbyStorageContainerResource`. Since refactoring to a standalone schema, there's no need to have this structure, so simplify the schema by flattening it. * Add schemas to README docs * Correct OAuth doc * Add configuration docs * Remove test generic extension config file * Document GenericPayload wrapper * Rename ContainerMapper to ContainerSerializer This makes the naming more consistent with e.g. MediaSerializer * Expand documentation Based on review feedback, expand on the documentation. - Include a high-level overview of job lifecyle - Add details on data rates - Clarify the ordering behaviour - Add reference to OAuth RFC - 201 -> 20x for success codes - Remove implementation details for OAuth flow It's documented more thoroughly elsewhere and we should encourage use of a framework or third-party authorization server. * Fix 'favourite' typo * Remove extra import * Use set for vertical config storage Also use `Set.contains` to check for vertical support.
- Loading branch information