Skip to content

Commit 08ef10a

Browse files
Removed HttpHandler to new library and added structured logging implementation (#121)
The HttpHandler are now at https://github.com/cuioss/cui-http
1 parent 4c05e8b commit 08ef10a

50 files changed

Lines changed: 444 additions & 2064 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/LogMessages.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
= Log Messages for cui-java-tools
2+
:toc: left
3+
:toclevels: 2
4+
5+
== Overview
6+
7+
All messages follow the format: [Module-Prefix]-[identifier]: [message]
8+
9+
Module Prefix: `CUI_TOOLS`
10+
11+
This document catalogs all structured log messages used in the cui-java-tools module. Each message has a unique identifier within its severity level range and is documented with its component, template, and usage description.
12+
13+
== INFO Level (001-099)
14+
15+
[cols="1,1,2,2", options="header"]
16+
|===
17+
|ID |Component |Message |Description
18+
|CUI_TOOLS-1 |IO |Unable to resolve '%s' from classpath |Logged when a resource cannot be resolved from the classpath. Parameter: resource path
19+
|===
20+
21+
== WARN Level (100-199)
22+
23+
[cols="1,1,2,2", options="header"]
24+
|===
25+
|ID |Component |Message |Description
26+
|CUI_TOOLS-100 |IO |Unable to resolve real path for '%s', due to '%s'. Returning absolutePath. |Logged when real path resolution fails and the system falls back to absolute path. Parameters: path, error message
27+
|CUI_TOOLS-101 |IO |File or Directory %s is not accessible, reason: %s |Logged when a file or directory accessibility check fails. Parameters: path, reason (e.g., "Not Writable", "Not Existing", "Not a directory")
28+
|CUI_TOOLS-102 |REFLECT |Reading from field '%s' with accessible='%s' and parameter='%s' could not complete |Logged when reflection-based field reading fails. Parameters: field, accessible flag, source object
29+
|CUI_TOOLS-103 |REFLECT |Unable to determine wrapper type for '%s' |Logged when wrapper type determination fails for a primitive type. Parameter: type name
30+
|CUI_TOOLS-104 |REFLECT |Unable to determine generic-type for '%s' |Logged when generic type extraction fails for a given type. Parameter: type
31+
|===
32+
33+
== ERROR Level (200-299)
34+
35+
[cols="1,1,2,2", options="header"]
36+
|===
37+
|ID |Component |Message |Description
38+
|CUI_TOOLS-200 |IO |Unable to compare path_a='%s' and path_b='%s' |Logged when path comparison via Files.isSameFile() fails due to IOException. Parameters: first path, second path
39+
|CUI_TOOLS-201 |IO |Retrieving the current dir failed |Logged when retrieving the current directory fails during external file path resolution
40+
|CUI_TOOLS-202 |PROPERTY |Failed to read property '%s' from bean of type '%s' |Logged when property reading via reflection fails. Parameters: property name, bean type
41+
|CUI_TOOLS-203 |PROPERTY |Failed to write property '%s' to bean of type '%s' |Logged when property writing via reflection fails. Parameters: property name, bean type
42+
|===
43+
44+
== Component Mapping
45+
46+
* *IO*: `de.cuioss.tools.io.*` - File I/O, path operations, and classpath loading
47+
* *REFLECT*: `de.cuioss.tools.reflect.*` - Reflection utilities and field/type operations
48+
* *PROPERTY*: `de.cuioss.tools.property.*` - Bean property access and manipulation
49+
50+
== Notes
51+
52+
* DEBUG and TRACE level messages are not documented here as they use direct logging without LogRecords
53+
* All messages use '%s' for parameter placeholders
54+
* Exception parameters always come first in the logging method call, followed by the formatted message

doc/ai-rules.md

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ When conflicting information exists, AI systems must follow this priority order:
3232

3333
These rules govern ALL development activities:
3434

35-
### 🚨 PRE-1.0 PROJECT RULE (HIGHEST PRIORITY)
36-
**This project is PRE-1.0 and therefore:**
37-
- **NEVER deprecate code** - Remove it directly if not needed
38-
- **NEVER add transitional comments** like "TODO: Remove in v2.0"
39-
- **NEVER enforce backward compatibility** - Make breaking changes freely
40-
- **NEVER add @Deprecated annotations** - Delete unnecessary code immediately
41-
- **Clean APIs aggressively** - Remove unused methods, classes, and patterns
42-
- **Focus on final API design** - Design for post-1.0 stability, not pre-1.0 transitions
43-
4435
### General Process Rules
4536
1. **If in doubt, ask the user** - Never make assumptions
4637
2. **Always research topics** - Use available tools (WebSearch, WebFetch, etc.) to find the most recent best practices
@@ -78,26 +69,18 @@ Before any code implementation:
7869
### Pre-Commit Checklist
7970
Execute in sequence before ANY commit:
8071

81-
1. **Quality Verification**: `./mvnw -Ppre-commit clean verify -DskipTests`
72+
1. **Quality Verification**: `./mvnw -Ppre-commit clean verify`
8273
- Fix ALL errors and warnings (mandatory)
74+
- Some recipes may add markers: Either fix them, or suppress them with proper justification. Never commit the markers.
8375
- Address code quality, formatting, and linting issues
8476

85-
2. **Final Verification**: `./mvnw clean install`
86-
- Must complete without errors or warnings
87-
- All tests must pass
88-
- Tasks are complete ONLY after this succeeds
89-
90-
3. **Run Integration Tests**: `./mvnw clean verify -Pintegration-tests -pl cui-jwt-quarkus-parent/cui-jwt-quarkus-integration-tests`
91-
- Ensure all integration tests pass
92-
- Verify against the latest standards
93-
94-
4. **Documentation**: Ensure all changes are documented
77+
2. **Documentation**: Ensure all changes are documented
9578
- Update Javadoc for public APIs
9679
- Update AsciiDoc documentation if necessary
9780

98-
5. **Documentation**: Update if changes affect APIs, features, or configuration
81+
3. **Documentation**: Update if changes affect APIs, features, or configuration
9982

100-
6. **Commit Message**: Follow Git Commit Standards
83+
4. **Commit Message**: Follow Git Commit Standards
10184

10285
### Quality Requirements
10386
- New code requires appropriate test coverage
@@ -108,10 +91,9 @@ Execute in sequence before ANY commit:
10891
## Build Commands Template
10992
Common Maven commands for CUI projects:
11093
- Build project: `./mvnw clean install`
111-
- Build Single Module: `./mvnw clean install -pl <module-name>`
11294
- Run tests: `./mvnw test`
11395
- Run single test: `./mvnw test -Dtest=ClassName#methodName`
114-
- Clean-Up Code: `./mvnw -Ppre-commit clean install -DskipTests` -> Check the console after running the command and fix all errors and warnings, verify until they are all corrected
96+
- Clean-Up Code: `./mvnw -Ppre-commit clean install` -> Check the console after running the command and fix all errors and warnings, verify until they are all corrected
11597

11698
## Standards Overview
11799
**Base Reference**: `{STANDARDS_BASE_URL}/standards`
@@ -154,11 +136,19 @@ Common Maven commands for CUI projects:
154136
- Avoid premature optimization
155137
- See Lombok Usage section for annotation patterns
156138

139+
### JSpecify Null-Handling
140+
**Reference**: `{STANDARDS_BASE_URL}/standards/java/java-code-standards.adoc#null-safety-and-api-design`
141+
- Use `@Nullable` for fields, parameters, and returns that may be null
142+
- Use `@NonNull` for explicit non-null guarantees
143+
- Default assumption is non-null unless marked `@Nullable`
144+
- Apply `@NullMarked` at package level for consistent null-safety
145+
- Validate null constraints at API boundaries
146+
- Prefer Optional over nullable return types where appropriate
147+
157148
### Lombok Usage
158149
**Reference**: `{STANDARDS_BASE_URL}/standards/java/java-code-standards.adoc`
159150
- Use `@Builder` for complex object creation
160151
- Use `@Value` for immutable objects
161-
- Use `@NonNull` for required parameters
162152
- Use `@ToString` and `@EqualsAndHashCode` for value objects
163153
- Use `@UtilityClass` for utility classes
164154
- Make proper use of `lombok.config` settings
@@ -236,44 +226,6 @@ Common Maven commands for CUI projects:
236226
- Use `{@link}` for references to classes, methods, and fields
237227
- Document Builder classes with complete usage examples
238228

239-
## CDI and Quarkus Standards
240-
**References**:
241-
- CDI Development Patterns: `{STANDARDS_BASE_URL}/standards/cdi-quarkus`
242-
- Quarkus Testing Standards: `{STANDARDS_BASE_URL}/standards/cdi-quarkus/testing-standards.adoc`
243-
- Container Standards: `{STANDARDS_BASE_URL}/standards/cdi-quarkus/container-standards.adoc`
244-
- Use constructor injection (mandatory over field injection)
245-
- Single constructor rule: No `@Inject` needed for single constructors
246-
- Use `final` fields for injected dependencies
247-
- Use `@ApplicationScoped` for stateless services
248-
- Use `@QuarkusTest` for CDI context testing
249-
- Use `@QuarkusIntegrationTest` for packaged app testing
250-
- Container: Use Quarkus distroless base image (91.9MB)
251-
- HTTPS required for all integration tests
252-
- OWASP Docker Top 10 compliance mandatory
253-
254-
## CSS Standards
255-
**Reference**: `{STANDARDS_BASE_URL}/standards/css`
256-
- Use CSS custom properties (variables) for theming
257-
- Follow BEM methodology for class naming
258-
- Use Stylelint for code quality enforcement
259-
- Use Prettier for consistent formatting
260-
- Mobile-first responsive design approach
261-
- Semantic HTML with accessible CSS patterns
262-
- Performance optimization: minimize CSS bundle size
263-
- Support for modern browsers (last 2 versions)
264-
265-
## JavaScript Standards
266-
**Reference**: `{STANDARDS_BASE_URL}/standards/javascript`
267-
- Use ES6+ modern JavaScript features
268-
- Use ESLint with strict configuration
269-
- Use Prettier for code formatting
270-
- Use Jest for unit testing framework
271-
- Follow functional programming patterns when appropriate
272-
- Use JSDoc for comprehensive documentation
273-
- Use Lit components for web components (Quarkus DevUI context)
274-
- Maven integration via frontend-maven-plugin
275-
- Cypress for E2E testing
276-
277229
### General Documentation Standards
278230
- Use AsciiDoc format with `.adoc` extension
279231
- Include proper document header with TOC and section numbering

pom.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>de.cuioss</groupId>
88
<artifactId>cui-java-parent</artifactId>
9-
<version>1.1.4</version>
9+
<version>1.2.1</version>
1010
<relativePath />
1111
</parent>
1212

@@ -86,5 +86,22 @@
8686
<artifactId>jakarta.annotation-api</artifactId>
8787
<scope>provided</scope>
8888
</dependency>
89+
<dependency>
90+
<groupId>org.jspecify</groupId>
91+
<artifactId>jspecify</artifactId>
92+
</dependency>
8993
</dependencies>
94+
95+
<build>
96+
<plugins>
97+
<!-- Configure Surefire to run tests on classpath to bypass JPMS module restrictions -->
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-surefire-plugin</artifactId>
101+
<configuration>
102+
<useModulePath>false</useModulePath>
103+
</configuration>
104+
</plugin>
105+
</plugins>
106+
</build>
90107
</project>
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*
2+
* Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package de.cuioss.tools;
17+
18+
import de.cuioss.tools.logging.LogRecord;
19+
import de.cuioss.tools.logging.LogRecordModel;
20+
import lombok.experimental.UtilityClass;
21+
22+
/**
23+
* Centralized log messages for the cui-java-tools module.
24+
* Follows the DSL-Style Constants Pattern for organizing log messages by severity level.
25+
*
26+
* <h2>Message Identifier Ranges</h2>
27+
* <ul>
28+
* <li>001-099: INFO level</li>
29+
* <li>100-199: WARN level</li>
30+
* <li>200-299: ERROR level</li>
31+
* <li>300-399: FATAL level</li>
32+
* </ul>
33+
*
34+
* <h2>Usage Examples</h2>
35+
* <pre>
36+
* import static de.cuioss.tools.ToolsLogMessages.INFO;
37+
* import static de.cuioss.tools.ToolsLogMessages.WARN;
38+
* import static de.cuioss.tools.ToolsLogMessages.ERROR;
39+
*
40+
* // INFO level
41+
* LOGGER.info(INFO.CLASSPATH_RESOLUTION_FAILED.format(path));
42+
*
43+
* // WARN level with exception
44+
* LOGGER.warn(e, WARN.REAL_PATH_RESOLUTION_FAILED.format(path, e.getMessage()));
45+
*
46+
* // ERROR level
47+
* LOGGER.error(e, ERROR.PATH_COMPARISON_FAILED.format(path1, path2));
48+
* </pre>
49+
*
50+
* @author Oliver Wolff
51+
* @see de.cuioss.tools.logging.LogRecord
52+
* @see de.cuioss.tools.logging.LogRecordModel
53+
*/
54+
@UtilityClass
55+
public final class ToolsLogMessages {
56+
57+
/** Module prefix for all log messages */
58+
public static final String PREFIX = "CUI_TOOLS";
59+
60+
/**
61+
* INFO level log messages (001-099).
62+
* Used for informational messages that highlight the progress of the application.
63+
*/
64+
@UtilityClass
65+
public static final class INFO {
66+
67+
/**
68+
* Logged when a resource cannot be resolved from the classpath.
69+
* Parameters: path
70+
*/
71+
public static final LogRecord CLASSPATH_RESOLUTION_FAILED = LogRecordModel.builder()
72+
.template("Unable to resolve '%s' from classpath")
73+
.prefix(PREFIX)
74+
.identifier(1)
75+
.build();
76+
}
77+
78+
/**
79+
* WARN level log messages (100-199).
80+
* Used for potentially harmful situations that warrant attention.
81+
*/
82+
@UtilityClass
83+
public static final class WARN {
84+
85+
/**
86+
* Logged when real path resolution fails and falls back to absolute path.
87+
* Parameters: path, error message
88+
*/
89+
public static final LogRecord REAL_PATH_RESOLUTION_FAILED = LogRecordModel.builder()
90+
.template("Unable to resolve real path for '%s', due to '%s'. Returning absolutePath.")
91+
.prefix(PREFIX)
92+
.identifier(100)
93+
.build();
94+
95+
/**
96+
* Logged when a file or directory is not accessible.
97+
* Parameters: path, reason
98+
*/
99+
public static final LogRecord PATH_NOT_ACCESSIBLE = LogRecordModel.builder()
100+
.template("File or Directory %s is not accessible, reason: %s")
101+
.prefix(PREFIX)
102+
.identifier(101)
103+
.build();
104+
105+
/**
106+
* Logged when field reading via reflection fails.
107+
* Parameters: field, accessible flag, source object
108+
*/
109+
public static final LogRecord FIELD_READ_FAILED = LogRecordModel.builder()
110+
.template("Reading from field '%s' with accessible='%s' and parameter='%s' could not complete")
111+
.prefix(PREFIX)
112+
.identifier(102)
113+
.build();
114+
115+
/**
116+
* Logged when wrapper type determination fails.
117+
* Parameters: type name
118+
*/
119+
public static final LogRecord WRAPPER_TYPE_DETERMINATION_FAILED = LogRecordModel.builder()
120+
.template("Unable to determine wrapper type for '%s'")
121+
.prefix(PREFIX)
122+
.identifier(103)
123+
.build();
124+
125+
/**
126+
* Logged when generic type extraction fails.
127+
* Parameters: type
128+
*/
129+
public static final LogRecord GENERIC_TYPE_DETERMINATION_FAILED = LogRecordModel.builder()
130+
.template("Unable to determine generic-type for '%s'")
131+
.prefix(PREFIX)
132+
.identifier(104)
133+
.build();
134+
}
135+
136+
/**
137+
* ERROR level log messages (200-299).
138+
* Used for error events that might still allow the application to continue running.
139+
*/
140+
@UtilityClass
141+
public static final class ERROR {
142+
143+
/**
144+
* Logged when path comparison fails.
145+
* Parameters: path1, path2
146+
*/
147+
public static final LogRecord PATH_COMPARISON_FAILED = LogRecordModel.builder()
148+
.template("Unable to compare path_a='%s' and path_b='%s'")
149+
.prefix(PREFIX)
150+
.identifier(200)
151+
.build();
152+
153+
/**
154+
* Logged when retrieving the current directory fails.
155+
* Parameters: none
156+
*/
157+
public static final LogRecord CURRENT_DIR_RETRIEVAL_FAILED = LogRecordModel.builder()
158+
.template("Retrieving the current dir failed")
159+
.prefix(PREFIX)
160+
.identifier(201)
161+
.build();
162+
163+
/**
164+
* Logged when property reading fails.
165+
* Parameters: property name, bean type
166+
*/
167+
public static final LogRecord PROPERTY_READ_FAILED = LogRecordModel.builder()
168+
.template("Failed to read property '%s' from bean of type '%s'")
169+
.prefix(PREFIX)
170+
.identifier(202)
171+
.build();
172+
173+
/**
174+
* Logged when property writing fails.
175+
* Parameters: property name, bean type
176+
*/
177+
public static final LogRecord PROPERTY_WRITE_FAILED = LogRecordModel.builder()
178+
.template("Failed to write property '%s' to bean of type '%s'")
179+
.prefix(PREFIX)
180+
.identifier(203)
181+
.build();
182+
}
183+
}

0 commit comments

Comments
 (0)