Skip to content

UNOMI-888: Javadoc and API cleanup for import/export router extension#756

Open
sergehuber wants to merge 12 commits into
UNOMI-879-unified-crud-shellfrom
UNOMI-888-import-export-javadoc
Open

UNOMI-888: Javadoc and API cleanup for import/export router extension#756
sergehuber wants to merge 12 commits into
UNOMI-879-unified-crud-shellfrom
UNOMI-888-import-export-javadoc

Conversation

@sergehuber
Copy link
Copy Markdown
Contributor

@sergehuber sergehuber commented May 6, 2026

Stacked PR (merge order)

Role Branch
Base (merge into) UNOMI-879-unified-crud-shell
Head (this PR) UNOMI-888-import-export-javadoc

This PR is stacked: merge into UNOMI-879-unified-crud-shell first (after #755 is merged there, or once that line is rebased).


Summary

JIRA: UNOMI-888

Improves public documentation for the profile import/export router (extensions/router/router-api, extensions/router/router-core) by replacing placeholder comments with substantive Javadoc on the facade, configuration types, services, processors, route builders, aggregation strategies, and related API types.

Includes a few small behavioral/API corrections found while documenting.

What changed

Documentation

  • IRouterCamelContext: Facade-level description and method-level Javadoc for route lifecycle operations.
  • ImportExportConfiguration, ProfileToImport, BadProfileDataFormatException, import/export service interfaces: Expanded and clarified docs (including consistent wording for shared import/export configuration).
  • RouterCamelContext, processors, route builders, aggregation strategies, CollectProfileBean: Class and member documentation aligned with actual responsibilities.

Small fixes (non-doc)

  • IRouterCamelContext: Add Object getCamelContext() so API consumers are not forced to depend on Camel types at compile time (implementations may still return the concrete Camel context).
  • RouterCamelContext: setTracing(boolean) now honors the argument (previously always enabled tracing); @Override + {@inheritDoc} on interface methods.
  • ImportExportConfiguration#setColumnSeparator: Null-check the parameter (consistent with setLineSeparator).
  • LineSplitFailureHandler: @Override on process(Exchange).

Verification

  • Local build successful
  • Integration tests successful

(Fill in the exact Maven commands you ran, e.g. router modules compile / full itests.)

Scope

  • 24 files under extensions/router/ (commit 51aa61c9f).

Add and expand Javadoc across router-api and router-core: IRouterCamelContext
facade, ImportExportConfiguration and services, ProfileToImport, route builders,
processors, aggregation strategies, and related exceptions.

Also include small behavioral and API fixes discovered during documentation:
- IRouterCamelContext: document methods and add getCamelContext() returning Object
  to avoid a compile-time Camel dependency for API consumers
- RouterCamelContext: honor setTracing(boolean) (previously always enabled tracing);
  add @OverRide and {@inheritdoc} for interface methods
- ImportExportConfiguration: fix setColumnSeparator to null-check the parameter,
  consistent with setLineSeparator
- LineSplitFailureHandler: add @OverRide on process(Exchange)

Replaces placeholder 'Created by' class comments with module-oriented descriptions.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands Javadoc across the router import/export API and core implementation while making a few small API/behavior adjustments around Camel context access, tracing, and separator handling.

Changes:

  • Replaces placeholder comments with detailed Javadoc for router APIs, processors, route builders, aggregation strategies, and beans.
  • Adds IRouterCamelContext#getCamelContext() and updates RouterCamelContext accordingly.
  • Fixes RouterCamelContext#setTracing(boolean) to honor its argument and updates ImportExportConfiguration#setColumnSeparator null handling.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 21 comments.

Show a summary per file
File Description
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/strategy/StringLinesAggregationStrategy.java Documents string aggregation behavior for export lines.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/strategy/ArrayListAggregationStrategy.java Documents list aggregation behavior for import results.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/RouterAbstractRouteBuilder.java Documents shared router route-builder configuration and endpoint creation.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportToUnomiRouteBuilder.java Documents final import-to-storage route setup.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportOneShotRouteBuilder.java Documents one-shot file import route setup.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileImportFromSourceRouteBuilder.java Documents recurrent import source route setup.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileExportProducerRouteBuilder.java Documents export producer route setup.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/route/ProfileExportCollectRouteBuilder.java Documents export collection route setup.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/UnomiStorageProcessor.java Documents imported profile persistence processing.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java Documents CSV line parsing into profiles.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitFailureHandler.java Documents import line failure handling and adds @Override.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineBuildProcessor.java Documents profile-to-CSV-line processing.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/ImportRouteCompletionProcessor.java Documents import completion statistics and status updates.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/ImportConfigByFileNameProcessor.java Documents one-shot config lookup by filename.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/ExportRouteCompletionProcessor.java Documents export completion status/history updates.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java Documents router Camel context lifecycle and updates tracing/context API implementation.
extensions/router/router-core/src/main/java/org/apache/unomi/router/core/bean/CollectProfileBean.java Documents segment-based profile collection.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ProfileImportService.java Documents profile import service responsibilities.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ProfileExportService.java Documents profile export service responsibilities.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java Documents import/export configuration service operations.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/ProfileToImport.java Documents import-specific profile fields and merge/delete flags.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java Documents router Camel facade and adds context accessor.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/ImportExportConfiguration.java Cleans imports, expands configuration docs, and fixes column-separator null handling.
extensions/router/router-api/src/main/java/org/apache/unomi/router/api/exceptions/BadProfileDataFormatException.java Documents bad profile data format exception constructors and usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +102 to 116
/**
* Checks if existing profiles should be overwritten during import.
* When true, all properties of existing profiles will be overwritten with imported data.
*
* @return true if existing profiles should be overwritten, false for selective updates
*/
public boolean isOverwriteExistingProfiles() {
return this.overwriteExistingProfiles;
}

/**
* Sets the overwriteExistingProfiles flag.
* @param overwriteExistingProfiles flag used to specify if we want to overwrite existing profiles
* Sets whether existing profiles should be completely overwritten during import.
*
* @param overwriteExistingProfiles true to overwrite all properties, false for selective updates
*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — agreed. Updated isOverwriteExistingProfiles() / setter Javadoc to match ProfileImportServiceImpl: when true and propertiesToOverwrite is non-empty, only listed properties are updated; otherwise the full properties map is replaced.

*
* <p>Configuration properties include:
* <ul>
* <li>name - unique identifier for the configuration</li>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Class-level docs now distinguish itemId (persisted identifier used by router services and routes) from name (display label only).

Comment on lines 123 to 134
/**
* Retrieves the config type of the import configuration
* @return the config type of the import configuration
* Retrieves the configuration type (for example import vs export semantics used by the router).
*
* @return the config type of this configuration
*/
public String getConfigType() { return this.configType; }

/**
* Sets the config type of the import configuration
* @param configType the config type of the import configuration
* Sets the configuration type.
*
* @param configType the config type for this configuration
*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. getConfigType() / setConfigType() Javadoc now documents scheduling mode (recurrent / oneshot via RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_*), not import vs export.

*/
public void setColumnSeparator(String columnSeparator) {
if(this.columnSeparator !=null) {
if (columnSeparator != null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. setColumnSeparator() now rejects empty or multi-character values with IllegalArgumentException, consistent with import (charAt(0)) and export usage.

* </ul>
* </p>
*
* @see org.apache.unomi.router.core.context.RouterCamelContext
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the @see to RouterCamelContext so router-api Javadoc stays implementation-neutral and does not reference router-core.

Comment on lines +45 to +51
* <p>Implementation considerations:
* <ul>
* <li>Must handle profile merging strategies</li>
* <li>Should implement proper error handling</li>
* <li>Must maintain data consistency</li>
* <li>Should handle property type conversions</li>
* </ul>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated implementation considerations: property type conversion happens upstream (e.g. LineSplitProcessor); this service merges/deletes/saves prepared profiles only.

Comment on lines +20 to +22
* Exception thrown when profile data cannot be properly parsed or formatted during import/export operations.
* This exception indicates issues with the structure or content of profile data that prevent it from being
* properly processed by the Unomi router.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrowed class Javadoc to import line processing only; export paths do not throw or handle this exception.

* <li>Sets up import and export routes</li>
* <li>Handles route configuration updates</li>
* <li>Manages route lifecycle (start/stop/update)</li>
* <li>Provides monitoring through event notifications</li>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "monitoring through event notifications" from the feature list. The class does not publish router events today (fireEvent is unused).

private Integer configsRefreshInterval = 1000;
private ScheduledFuture<?> scheduledFuture;

/** Event topic fired when a router configuration or route is removed (reserved for integrations). */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented EVENT_ID_REMOVE as a reserved topic identifier for future use — not published by the current implementation. We kept constants as placeholders rather than implementing emission in this PR.

* - Formatting profiles according to export configuration
* - Generating the export content
*
* @param exportConfiguration the configuration specifying export parameters and format
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated extractProfilesBySegment Javadoc to mention that implementations query profiles, build CSV content, append an execution record, and persist the updated export configuration — not a pure read/format helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants