Commit Graph
329 Commits
Author SHA1 Message Date
pnoker a620afb087 build(deps): upgrade spring-ai to 2.0.0 ga and drop milestone repository 2026-06-23 19:34:21 +08:00
pnoker 46f8243c07 test(driver): add postgresql testcontainers integration test for jdbc io
Add the first driver integration test: spins a real PostgreSQL container and
verifies the shared JDBC read path returns stored values and that the write
path binds the point value as a parameter — a SQL-injection payload is stored
verbatim and cannot drop the table, confirming the parameterised-write fix
end-to-end. Set the Failsafe classesDirectory so integration tests run against
the plain compiled classes instead of the Spring Boot repackaged fat jar.
2026-06-22 18:49:49 +08:00
pnoker c2c9a690a4 fix(common): correctly convert PEM certificates and keys in X509Util
Replace the unsafe (T) cast of PemReader.readPemObject() — which threw
ClassCastException at runtime — with explicit conversion: X.509 certs via
CertificateFactory and private keys (PKCS#1/PKCS#8, encrypted or plain) via
BouncyCastle's PEMParser. Add the bcpkix dependency and unit tests covering
the encrypted-key path used by MQTT TLS.
2026-06-22 16:09:50 +08:00
pnoker 51a3847205 feat(openapi): wire up springdoc OpenAPI docs and fix security chain loading
Make the REST API documentation actually reachable end-to-end:

- Upgrade springdoc to 3.0.3 (Spring Boot 4 / Spring Framework 7 compatible)
  and pin swagger-core 2.2.47 to resolve the Spring AI conflict.
- Register SpringDocConfig and WebFluxSecurityConfig as @AutoConfiguration so
  they load (they sit in io.github.pnoker.common.config, which centers do not
  component-scan); add the global OpenAPI info + X-Auth security schemes.
- Add per-module GroupedOpenApi beans (auth/manager/data/agentic) and gateway
  aggregation routes + swagger-ui.urls for a single federated Swagger UI.
- Fix the security chain: guard WebFluxSecurityConfig off the gateway, supply a
  permissive default PermissionProvider, register the @perm bean, and correct
  the token-path whitelist (base-path is stripped before the chain).
- Whitelist doc paths; disable docs in the production profile.
- Register swagger-ui webjar resources (default static mappings are disabled).
2026-06-09 15:49:54 +08:00
pnoker a07d3f29ea feat(doc): add springdoc-openapi infrastructure
- Add springdoc-openapi 2.8.6 to parent POM dependency management
- Add springdoc-openapi-starter-webflux-ui to dc3-common-web
- Add springdoc-openapi-starter-common to facade, dal, repository modules
- Add SpringDocConfig with IoT DC3 API metadata (title, contact, license)
2026-06-08 17:00:00 +08:00
pnoker f58e8dd52f chore(deps): upgrade Spring AI to 2.0.0-M8 and migrate tool API
- Bump spring-ai.version from 2.0.0-M6 to 2.0.0-M8
- Migrate ChatClientConfig: suppressToolCallStreaming() → streamToolCallResponses(false)
- Migrate AgenticPromptBuilder: toolContext() → tools(toolSpec → toolSpec.context())
  and toolCallbacks() → tools(toolSpec → toolSpec.callbacks())
2026-06-08 16:02:00 +08:00
pnoker 6884022dc9 chore(pom): bump dependency versions
- surefire / failsafe / jacoco: 3.5.2 → 3.5.6 / 0.8.12 → 0.8.15
- graalvm native: 1.1.0 → 1.1.1
- jaxb: 4.0.8 → 4.0.9
- jna: 5.18.1 → 5.19.0
- tools.jackson: 3.1.3 → 3.1.4
- maven-dependency-plugin: 3.10.0 → 3.11.0
2026-06-07 01:11:18 +08:00
pnoker 5730f7c137 feat: update pom version 2026-06-06 13:00:39 +08:00
pnoker b5ef7a8501 fix(pom): clean up dependency management and plugin configuration
- Replace obsolete nexus-staging-maven-plugin with central-publishing-
  maven-plugin in dc3-api and dc3-common
- Remove 20 redundant version declarations from dc3-coverage dependencies
- Fix snmp4j version from non-existent 3.8.3 to available 3.7.4
2026-06-06 00:40:18 +08:00
pnoker 26f6e91a64 feat(driver): add 17 protocol drivers to extend IoT connectivity coverage
## Common Foundation
- dc3-common-sql: AbstractJdbcDriverCustomService base class with HikariCP
  pool management and JDBC template methods

## Serial & General-Purpose (3)
- Serial: RS232/RS485/RS422 with configurable frame parsing (CRC16/XOR)
- HTTP: REST Client using Spring WebClient with JSON path extraction
- TCP/UDP Raw: generic socket driver with pluggable frame protocol

## Database Drivers (4)
- MySQL, PostgreSQL, Oracle (SID/ServiceName), SQL Server

## IoT & Wireless Protocols (3)
- LwM2M: Eclipse Leshan 2.0.0-M14 with CoAP server and device observation
- Zigbee: Z-Smart Systems 1.4.16.1 with Telegesis dongle support
- BLE: Sputnikdev Bluetooth Manager 1.5.3 with TinyB transport

## Building Automation & Smart Metering (2)
- BACnet IP: BACnet4J 6.0.1 with ReadProperty/WriteProperty support
- DLMS/COSEM: Gurux DLMS 4.0.79 for smart metering (TCP/Serial transport)

## Industrial & Power Protocols (4)
- IEC 104: OpenMUC j60870 1.7.2 for power telecontrol
- SNMP: SNMP4J 3.7.4 for network device monitoring
- EtherNet/IP: CIP Data Table Read/Write for Rockwell AB PLCs
- FINS: Omron PLC memory area read/write over TCP

## Automotive & Fieldbus (1)
- CAN Bus: SocketCAN interface with standard/extended frame support

## Build
- Register all 17 driver modules and dc3-common-sql in parent POMs
- Add version properties and dependencyManagement entries
2026-06-02 09:54:13 +08:00
Vickey 29f1594072 feat(driver): add Mitsubishi Melsec MC and SL651 hydrological telemetry drivers
feat: new driver modules
- dc3-driver-melsec: Mitsubishi Melsec MC (1E/3E/4E frame) driver via iot-communication
- dc3-driver-sl651: SL651-2014 hydrological telemetry server-side driver via iot-communication
- Bump iot-communication from 1.5.4 to 1.5.6 in dc3-driver-plcs7
- Relocate ias-releases repository from root pom.xml to dc3-driver/pom.xml

fix: code review fixes across driver implementations
- PlcS7PointVariable: only include bit offset in address when bit access and offset > 0
- OpcDaDriverCustomServiceImpl: disconnect server on device delete/update
- OpcUaDriverCustomServiceImpl: disconnect client on device delete/update
- ModbusTcpDriverCustomServiceImpl: remove duplicate FLOAT case in write value switch

refactor: eliminate magic numbers, consolidate statics, and normalize log formatting
- NettyServerHandler: replace magic numbers with named constants
- OpcUaDriverCustomServiceImpl: replace magic timeout numbers with named constants
- ModbusFactory: consolidate static block into private static final field
- VirtualDriverCustomServiceImpl: replace new Random() with ThreadLocalRandom
- KeyLoader: reorder fields so statics precede instance fields
- Normalize log format from string concat to {} placeholders across multiple drivers
- MqttDriverCustomServiceImpl: downgrade QoS fallback log warn→debug
- Remove unused imports
2026-05-26 10:00:00 +08:00
Vickey 27bcf1383b fix: address code review — security, thread safety, performance, and null safety
Security (CRITICAL):
- KeyUtil: read JWT signing key from DC3_SECURITY_KEY env/property
- UserPasswordServiceImpl: read default password from DC3_SECURITY_DEFAULT_PASSWORD env
- KeyLoader: read OPC-UA keystore password from OPCUA_KEYSTORE_PASSWORD env
- WebFilterConfig: return 401 on malformed X-Auth-User header
- AlgorithmConstant: document deprecated hardcoded constants

Thread safety (HIGH):
- Fix TOCTOU races in 4 driver connectors (computeIfAbsent)
- Fix PlcS7 lock leak, OpcUa connect timeout (5s)
- CoapClientManager: synchronize setURI to prevent URI race
- PointValueJob, MqttScheduleJob: add @DisallowConcurrentExecution
- SystemHealthServiceImpl: preserve interrupt flag
- WindowSampleBuffer: local AtomicInteger → int

Performance (MEDIUM):
- EntityStateExpiryScanner: batch alarm saves (saveBatch)
- ImportDeviceServiceImpl: batch config saves
- ResourceRegistrySyncServiceImpl: batch-load nodes, eliminate N+1 COUNTs
- DriverSenderServiceImpl: debug-gate hot-path logging
- PointServiceImpl: stream().count() → size()

Null safety (LOW):
- RegexUtil: null guards on isName/isPhone/isMail/isPassword/isHost
- HostUtil: null-check getNetworkInterfaces() return
- TimeUtil: log parse failures instead of silent null

Infrastructure:
- Add spring-boot-starter-cache + @EnableCaching CacheConfig
- Replace embedded modbus4j/plc-s7 jars with external Maven dependencies
- Add dc3-driver-modbus-rtu module
2026-05-26 08:40:25 +08:00
Vickey 918b3d5e8e feat: update pom version to 2026.5.22 2026-05-26 00:30:11 +08:00
Vickey fd3af64634 feat: add layered architecture diagram and reposition project narrative
- Add IoT DC3 layered architecture diagram (SVG + HTML viewer)
  with Application / Management / Data / Driver layers,
  Security & Load and Platform & System sidebars,
  Data→Driver connection flows, and color-coded sections
- Reposition README descriptions across all languages (en, zh, ja, vi)
  and pom.xml to AI-ready narrative: "Connects devices, collects
  data organized for AI, and orchestrates the closed loop"
- Add README.ai.md with Chinese multi-paragraph AI narrative
  and closed-loop flowchart
- Optimize package.json metadata (name, license, scripts)
2026-05-24 13:35:57 +08:00
pnoker 9007cbc22c style: apply consistent code formatting across all modules and docs 2026-05-22 00:24:22 +08:00
pnoker 5a3ab1440a test: improve backend test coverage governance 2026-05-19 18:19:12 +08:00
pnoker 7f5da1a0f8 chore: bump version to 2026.5.18 across all modules 2026-05-18 00:24:22 +08:00
pnoker 737caa178c build: update root pom and banner version to 2026.5.17 2026-05-17 19:04:31 +08:00
pnoker 019daf62ce feat: do someting test and code review 2026-05-16 00:56:04 +08:00
pnoker 67f1f7c2c0 build(agentic): upgrade Spring AI from 2.0.0-M5 to 2.0.0-M6
Bump spring-ai-bom in root and agentic module POMs. API is fully
compatible — no code changes required. Full project build and 89
agentic module tests pass.
2026-05-15 01:53:21 +08:00
pnoker 9123b480f4 test(e2e): stabilize infrastructure harness 2026-05-14 21:29:08 +08:00
pnoker ade8579369 fix(test-infra): propagate test bom into dc3-common dependency management
Maven dependencyManagement does not flow across the iot-dc3 root reactor
into dc3-common because dc3-common inherits from the externally
published dc3-parent. As a result, dc3-common-test could not resolve
JUnit 5 / Testcontainers / Instancio dependencies and dc3-e2e could not
resolve dc3-common-test itself.

Mirror the relevant slice of test-toolchain version management into
dc3-common/pom.xml (junit-bom + testcontainers-bom imports plus pinned
versions for AssertJ, Awaitility, Instancio, REST-assured and WireMock)
and add the missing dc3-common-test version entry to the iot-dc3 root
dependencyManagement so the e2e module can import it.

Verified locally with mvn -B clean compile -pl dc3-common/dc3-common-test -am,
which now resolves all 9 source files and produces
dc3-common-test-2026.5.5.jar.
2026-05-13 13:17:55 +08:00
Vickey c47e5f0a37 test(infra): add coverage and end-to-end aggregator modules
Introduce two reactor modules that exist purely to host repository-wide
test concerns:

- dc3-coverage (packaging=pom) runs jacoco:report-aggregate against all
  contributing modules and applies a tree-wide jacoco:check rule. The
  aggregator excludes generated sources, deployable Application classes,
  POJO entity packages and the third-party modbus4j sero utilities so
  the percentage stays anchored on real business logic. Coverage gates
  start at 0% and tighten in later stages as more tests land.
- dc3-e2e (packaging=jar) reserves a place for the docker-compose driven
  end-to-end suite delivered in stage S8. Unit and integration phases
  are skipped by default and only the e2e profile turns them on.

Both modules are wired into the root reactor.
2026-05-13 13:02:26 +08:00
Vickey a3e95968bc test(infra): wire test bom and plugins in root pom
Centralise test toolchain wiring at the iot-dc3 root pom so child modules
do not need to repeat versions or plugin definitions:

- Import the JUnit 5 and Testcontainers BOMs and pin AssertJ, Awaitility,
  Instancio, REST-assured and WireMock versions.
- Add Surefire 3.5.2 and Failsafe 3.5.2 plugin management with the
  expected include patterns (*Test.java for unit, *IT.java for
  integration) plus argLine wiring for the Jacoco agents.
- Add Jacoco 0.8.12 plugin management with both unit and integration
  agent + report executions; integration coverage lands in jacoco-it.exec
  while unit coverage stays in jacoco.exec.
- Surface skip.unit.tests and skip.integration.tests properties so CI and
  Makefile targets can flip phases without rewriting plugin configuration.

The new plugins are enabled at this layer; subsequent commits add the
aggregator coverage module that reads both .exec files and the workflows
that exercise them.
2026-05-13 11:14:21 +08:00
pnoker 1bc0b74d4d style: reorganize POM dependencies with consistent category comments
Group dependencies in each module POM using a standard category order:
Spring Boot → Spring Cloud → gRPC → Data Access → Messaging → IoT → AI
→ Serialization → Utility → Security → Observability → DC3 API → DC3 Common

DC3 Common dependencies sorted alphabetically within their group.
2026-05-08 00:28:44 +08:00
pnoker 844c89ddce chore: remove duplicate java.version property (inherited from dc3-parent) 2026-05-07 23:59:02 +08:00
pnoker e47299a327 chore: remove format and format-check targets from Makefile 2026-05-07 23:55:32 +08:00
pnoker eefe411bd7 chore(build): upgrade spring-javaformat to 0.0.47 and add Checkstyle integration
- Add maven-checkstyle-plugin with spring-javaformat-checkstyle rules
- Add custom checkstyle.xml excluding overly strict rules for existing codebase
- Exclude third-party driver code (serotonin, openscada, nodave) from checks
- Configure plugins in dc3-common and dc3-api POMs for full module coverage
- Add .springjavaformatconfig placeholder
2026-05-07 16:46:17 +08:00
pnoker 293bc1a0c2 fix(build): remove requireEncoding rule incompatible with Maven 3.x
requireEncoding requires Maven 4.0+ runtime; drop it until the project
migrates to Maven 4.
2026-05-07 13:12:23 +08:00
pnoker 95b7e1ffa3 chore(build): add enforcer plugin and Spring Java Format validation
- maven-enforcer-plugin: require JDK >= 21, Maven >= 3.9.0, UTF-8 encoding
- spring-javaformat-maven-plugin 0.0.43: validate code style at build time
2026-05-07 13:10:44 +08:00
pnoker dea8482001 feat(agentic): add AI agentic center with Spring AI tool-calling
Introduce dc3-common-agentic (skill registry, tool sets for auth/manager/data,
chat client) and dc3-center-agentic (deployable service). Register Spring AI BOM,
add gateway route /api/v3/agentic/**, and configure OpenAI env vars.
2026-05-07 00:09:38 +08:00
pnoker 95c40b2387 chore: bump version to 2026.5.5
Roll every pom, per-module README, Spring banner, and @version /
@since javadoc tag from 2026.4.30 to the new 2026.5.5 release line.
2026-05-05 00:56:09 +08:00
pnoker da5c02efd6 refactor: restructure facade module to aggregator pom, split local into auth/manager submodules
- Move dc3-common-facade-api, dc3-common-facade-grpc, dc3-common-facade-local
  under new dc3-common-facade aggregator pom
- Split dc3-common-facade-local into dc3-common-facade-local-auth and
  dc3-common-facade-local-manager for cleaner dependency scoping
- Update root pom.xml and dc3-common/pom.xml dependency management
- Update dc3-center-auth to use dc3-common-facade-local-auth
- Update dc3-center-single facade-local dependency type to pom
2026-05-01 00:48:50 +08:00
Vickey fb9ee53781 feat: auto-register center API endpoints to auth resource tables
Adds a startup-time registrar that scans the local WebFlux handler mappings
of each center service and reconciles the discovered endpoints against
dc3_api and dc3_resource (insert-if-missing, update-if-drifted, soft-delete-
if-orphaned), so the permission model is no longer hand-maintained.

Wiring:
- dc3-common-resource-registrar (new module): scanner, diff runner, Spring
  Boot AutoConfiguration. Activates on ApplicationReadyEvent.
- dc3-common-facade-api: ResourceRegistryFacade + BOs define a transport-
  neutral sync contract.
- dc3-common-facade-local / dc3-common-facade-grpc: two implementations
  selected via dc3.facade.mode. center-auth/single use local; manager/data
  call auth via gRPC.
- dc3-common-auth: biz-side ResourceRegistrySyncService performs the three-
  way diff inside a transaction guarded by pg_advisory_xact_lock(hashtext
  (serviceName)); exposes ResourceRegistryApi gRPC server.
- dc3-api-auth: new resource_registry.proto contract.
- ApiDO/BO/VO/Query gain a serviceName field so each service's endpoints
  can be located with a single indexed lookup.

Deployment-visible changes:
- api_code format is the human-readable serviceName:METHOD:/path
- dc3_resource.resource_code format is api:serviceName:METHOD:/path
  (prefixed namespace reserved for future resource types)
- center-auth application.yml sets dc3.facade.mode=local
- 4 center pom.xml files pull in the registrar (auth also gets facade-local)
2026-04-30 21:40:45 +08:00
Vickey 200beeaa71 chore: update version to 2026.4.30 in multiple files 2026-04-30 16:06:30 +08:00
pnoker b0176bd9a1 fix: downgrade JDK version from 25 to 21 in Dockerfile and related configurations 2026-04-29 16:26:24 +08:00
pnoker d09647c780 fix: update Mybatis and Dynamic Datasource dependencies to version 4, remove Redis exporter from docker-compose files 2026-04-29 16:01:11 +08:00
pnoker c5a9feeeb9 feat: add .env file for Docker Compose configuration and update usage instructions 2026-04-29 10:27:57 +08:00
pnoker fddf7bb60e feat(facade): introduce facade layer for cross-service calls
Adds three new modules that let business code call center services
through protocol-neutral interfaces instead of @GrpcClient stubs:

- dc3-common-facade-api: Device/Driver/Point + Tenant/User/UserLogin/Token
  facade interfaces plus facade-owned BO/Query/Page types
- dc3-common-facade-local: in-process implementations backed by the
  auth/manager services; zero serialization cost in single deployments
- dc3-common-facade-grpc: gRPC implementations holding BlockingStubs;
  default mode for distributed deployments

Implementation selection is driven by dc3.facade.mode={local|grpc} via
@ConditionalOnProperty, with grpc as the matchIfMissing default. Wire-up
for dc3-center-single (dc3.facade.mode=local + facade-local dependency)
is included so the single-deployment mode is runnable out of the box.
2026-04-27 19:46:15 +08:00
pnoker ea17c86387 chore: update version to 2026.4.19 across all modules and adjust branch settings in codeql.yml 2026-04-19 13:45:21 +08:00
pnoker e38b5e6b64 refactor: optimize root, dc3-common and dc3-api pom.xml
- Consolidate 19+ individual DC3 module version properties into single <dc3.version>
- Remove redundant <scope>compile</scope> from DC3 Api dependencyManagement entries
- Reorder elements: modules before properties, profiles after dependencyManagement
- Fix <scm> connection/developerConnection to use scm:git: protocol prefix
- Fix <inceptionYear> from range '2016-2022' to correct single year '2016'
2026-04-18 01:15:20 +08:00
pnoker e57793ec5f chore: bump version to 2026.4.18.3 and optimize pom.xml dependencies
- Bump all module versions from 2025.11.1 to 2026.4.18.3
- Remove orphaned dc3-common-influx dependency and property from root pom.xml
- Standardize dependency comment style in dc3-common/pom.xml
- Merge gRPC dependency groups into single section in dc3-common-api
- Restructure Spring Integration MQTT and Eclipse Paho groups in dc3-common-mqtt
- Fix incorrect comment 'DC3 Common Exception' to 'DC3 Common Related' in dc3-common-postgres
- Add missing blank line before </dependencies> in dc3-common-driver
- Remove stray blank line in root pom.xml dependencyManagement
2026-04-18 01:05:30 +08:00
Vickey 0adff1532b refactor: replace deprecated EnvironmentPostProcessor imports and update JsonMapper references 2026-02-11 11:56:52 +08:00
Vickey 0e419bab05 feat: update pom 2025-11-11 13:22:24 +08:00
zzi666 518d2a8b7d refactor: update Java docs, README files, and Protobuf comments for consistent language and formatting 2025-10-24 16:51:40 +08:00
zzi666 989a931c2f fix: standardize comment language in POM files 2025-10-24 15:45:02 +08:00
Vickey a9e8d05631 feat: update version 2025-10-05 17:16:37 +08:00
Vickey 7302107c56 chore: bump all module versions to 2025.9.2 2025-09-11 17:02:24 +08:00
Vickey 2051d42847 refactor(common): remove hutool dependency and replace usages with native utilities 2025-09-11 14:57:02 +08:00
Vickey 8cc7365293 build: bump all module versions to 2025.6.6 and update compose image tags 2025-08-26 22:38:53 +08:00