Interface ImportExportDelegate<R>
- Type Parameters:
R- The resource config type, matching the owningResourceTypeMeta
- All Known Implementing Classes:
DefaultImportExportDelegate
.gwex files). Each ResourceTypeMeta returns a delegate from ResourceTypeMeta.getImportExportDelegate().
The delegate controls the data — parsing resources from the ZIP, what gets written
during export, how resources are prepared and ordered during import, and what post-push work
happens. The ImportExportManager controls the mechanics — conflict resolution
(create vs modify), ChangeOperation construction, user choices (skip, rename, overwrite),
collection remapping, and session management.
Full Lifecycle
- Upload: Manager walks the ZIP, identifies resource type paths, calls
parseImport(List, ResourceReader)— the delegate decodes resources and returnsImportExportDelegate.ResourceEntrys. The manager uses these to build the interactive manifest (parseability, conflicts, dependencies). - Export: Manager calls
onExport(List, ResourceWriter)— the delegate writes resource files and additional data to the ZIP. - Apply: Manager resolves user choices (skip, rename, remap), then calls
prepareImport(List, ImportContext, ResourceReader)— the delegate can reorder, transform, or read additional data. The manager constructsChangeOperations and pushes. - Post-apply: Manager calls
afterImport(List, ImportContext, ResourceReader)— the delegate performs post-push work (e.g., restoring persisted tag values).
Usage Options
- Do nothing —
getImportExportDelegate()returnsDefaultImportExportDelegateby default. Standard resource file copy/push behavior. - Extend default + add extra data — Extend
DefaultImportExportDelegate, callsuper, then write/read additional associated data (e.g., memory tag values). - Replace entirely — Implement
ImportExportDelegatefrom scratch for resource types with completely custom storage, decoding, or ordering requirements. - Exclude from import/export — Return
nullfromgetImportExportDelegate()to skip this resource type entirely. It won't appear in the export tree and will be ignored during import parsing.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA resource entry bundling the resource, its decoded configuration, and the collection it belongs to (or is being imported into).static final recordPairs aResourcePathwith the collection it was found in within the.gwexZIP. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidafterImport(List<ImportExportDelegate.ResourceEntry<R>> resources, ImportContext context, ResourceReader reader) Called after the manager has pushed all resources of this type and theCompletableFuturehas completed (subsystem listeners fired, resources initialized).voidonExport(List<ImportExportDelegate.ResourceEntry<R>> resources, ResourceWriter writer) Called during export with all resources of this type selected for export.parseImport(List<ImportExportDelegate.ResourceImportPath> resourcePaths, ResourceReader reader) Parse resources of this type from the.gwexZIP.default List<ImportExportDelegate.ResourceEntry<R>> prepareImport(List<ImportExportDelegate.ResourceEntry<R>> resources, ImportContext context, ResourceReader reader) Called during import before the manager pushes resources.
-
Method Details
-
onExport
void onExport(List<ImportExportDelegate.ResourceEntry<R>> resources, ResourceWriter writer) throws IOException Called during export with all resources of this type selected for export. The delegate writes all necessary data for these resources into the.gwexfile.- Parameters:
resources- all resources of this type selected for export, with decoded configs and collection nameswriter- provides methods for writing resource files and additional data to the.gwexZIP- Throws:
IOException
-
parseImport
List<ImportExportDelegate.ResourceEntry<R>> parseImport(List<ImportExportDelegate.ResourceImportPath> resourcePaths, ResourceReader reader) throws IOException Parse resources of this type from the.gwexZIP. Called at upload time (before any user interaction). The delegate owns all decoding — it reads the raw resource files from the ZIP via the reader and decodes them using whatever codec or logic it needs.The returned
ImportExportDelegate.ResourceEntrys are used by the manager to build the interactive manifest (parseability status, conflict detection, dependency warnings). If a resource cannot be parsed, the delegate should not include it in the returned list — the manager will mark it as non-importable.- Parameters:
resourcePaths- the resource paths identified in the.gwexZIP for this type, paired with their collection namesreader- provides methods for reading resource files from the ZIP- Returns:
- the parsed resource entries with decoded configs
- Throws:
IOException
-
prepareImport
default List<ImportExportDelegate.ResourceEntry<R>> prepareImport(List<ImportExportDelegate.ResourceEntry<R>> resources, ImportContext context, ResourceReader reader) throws IOException Called during import before the manager pushes resources. The delegate can reorder resources, read additional data from the.gwex, and transform resource data.By the time this method is called, the manager has already applied user choices: skipped resources are excluded and renamed resources have their new name. Each resource still carries the collection it was exported from — the manager rewrites collections on the returned list, so a delegate cannot see or influence where a remapped resource lands.
The returned list determines the order resources are pushed. The manager handles constructing the correct
ChangeOperation(create vs modify) for each resource based on current gateway state.- Parameters:
resources- all resources of this type being imported, with decoded configs and their source collection namescontext- metadata from the.gwex'sexportinfo.jsonreader- provides methods for reading resource files and additional data from the.gwexZIP- Returns:
- the (possibly reordered or modified) list of resources to push
- Throws:
IOException
-
afterImport
default void afterImport(List<ImportExportDelegate.ResourceEntry<R>> resources, ImportContext context, ResourceReader reader) throws IOException Called after the manager has pushed all resources of this type and theCompletableFuturehas completed (subsystem listeners fired, resources initialized). Use this for post-push work that requires the resources to be live.The default implementation is a no-op.
- Parameters:
resources- the resources that were imported (same list returned fromprepareImport(List, ImportContext, ResourceReader))context- metadata from the.gwex'sexportinfo.jsonreader- provides methods for reading resource files and additional data from the.gwexZIP- Throws:
IOException
-