manual check, indent ruby-mcp, balance convert-jpa fencing
This commit is contained in:
parent
fb96172b55
commit
fdda910ee0
@ -34,13 +34,16 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
### Step 2 — Properties and Configuration
|
### Step 2 — Properties and Configuration
|
||||||
|
|
||||||
- Create `src/main/resources/application-cosmos.properties`:
|
- Create `src/main/resources/application-cosmos.properties`:
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
azure.cosmos.uri=${COSMOS_URI:https://localhost:8081}
|
azure.cosmos.uri=${COSMOS_URI:https://localhost:8081}
|
||||||
azure.cosmos.database=${COSMOS_DATABASE:petclinic}
|
azure.cosmos.database=${COSMOS_DATABASE:petclinic}
|
||||||
azure.cosmos.populate-query-metrics=false
|
azure.cosmos.populate-query-metrics=false
|
||||||
azure.cosmos.enable-multiple-write-locations=false
|
azure.cosmos.enable-multiple-write-locations=false
|
||||||
```
|
```
|
||||||
|
|
||||||
- Update `src/main/resources/application.properties`:
|
- Update `src/main/resources/application.properties`:
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
spring.profiles.active=cosmos
|
spring.profiles.active=cosmos
|
||||||
```
|
```
|
||||||
@ -48,6 +51,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
### Step 3 — Configuration class with Azure Identity
|
### Step 3 — Configuration class with Azure Identity
|
||||||
|
|
||||||
- Create `src/main/java/<rootpkg>/config/CosmosConfiguration.java`:
|
- Create `src/main/java/<rootpkg>/config/CosmosConfiguration.java`:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCosmosRepositories(basePackages = "<rootpkg>")
|
@EnableCosmosRepositories(basePackages = "<rootpkg>")
|
||||||
@ -76,6 +80,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **IMPORTANT**: Use `DefaultAzureCredentialBuilder().build()` instead of key-based authentication for production security
|
- **IMPORTANT**: Use `DefaultAzureCredentialBuilder().build()` instead of key-based authentication for production security
|
||||||
|
|
||||||
### Step 4 — Entity transformation
|
### Step 4 — Entity transformation
|
||||||
@ -103,6 +108,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
- **CRITICAL - Authentication Entity Pattern**:
|
- **CRITICAL - Authentication Entity Pattern**:
|
||||||
- **For User entities with Spring Security**: Store authorities as `Set<String>` instead of `Set<Authority>` objects
|
- **For User entities with Spring Security**: Store authorities as `Set<String>` instead of `Set<Authority>` objects
|
||||||
- **Example User entity transformation**:
|
- **Example User entity transformation**:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Container(containerName = "users")
|
@Container(containerName = "users")
|
||||||
public class User {
|
public class User {
|
||||||
@ -131,6 +137,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **CRITICAL - Template Compatibility for Relationship Changes**:
|
- **CRITICAL - Template Compatibility for Relationship Changes**:
|
||||||
- **When converting relationships to ID references, preserve template access**
|
- **When converting relationships to ID references, preserve template access**
|
||||||
- **Example**: If entity had `List<Specialty> specialties` → convert to:
|
- **Example**: If entity had `List<Specialty> specialties` → convert to:
|
||||||
@ -194,6 +201,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
- **CRITICAL**: Create service classes to bridge Cosmos document storage with existing template expectations
|
- **CRITICAL**: Create service classes to bridge Cosmos document storage with existing template expectations
|
||||||
- **Purpose**: Handle relationship population and maintain template compatibility
|
- **Purpose**: Handle relationship population and maintain template compatibility
|
||||||
- **Service pattern for each entity with relationships**:
|
- **Service pattern for each entity with relationships**:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Service
|
@Service
|
||||||
public class EntityService {
|
public class EntityService {
|
||||||
@ -242,6 +250,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
### Step 6.5 — **Spring Security Integration** (CRITICAL for Authentication)
|
### Step 6.5 — **Spring Security Integration** (CRITICAL for Authentication)
|
||||||
|
|
||||||
- **UserDetailsService Integration Pattern**:
|
- **UserDetailsService Integration Pattern**:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Service
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
@ -277,6 +286,7 @@ This generalized guide applies to any JPA to Spring Data Cosmos DB conversion pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Key Authentication Requirements**:
|
- **Key Authentication Requirements**:
|
||||||
- User entity must be fully serializable (no `@JsonIgnore` on password/authorities)
|
- User entity must be fully serializable (no `@JsonIgnore` on password/authorities)
|
||||||
- Store authorities as `Set<String>` for Cosmos DB compatibility
|
- Store authorities as `Set<String>` for Cosmos DB compatibility
|
||||||
@ -329,6 +339,7 @@ private void populateRelationships(Entity entity) {
|
|||||||
### Step 7 — Data seeding
|
### Step 7 — Data seeding
|
||||||
|
|
||||||
- Create `@Component` implementing `CommandLineRunner`:
|
- Create `@Component` implementing `CommandLineRunner`:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Component
|
@Component
|
||||||
public class DataSeeder implements CommandLineRunner {
|
public class DataSeeder implements CommandLineRunner {
|
||||||
@ -344,6 +355,7 @@ private void populateRelationships(Entity entity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- **CRITICAL - BigDecimal Reflection Issues with JDK 17+**:
|
- **CRITICAL - BigDecimal Reflection Issues with JDK 17+**:
|
||||||
- **If using BigDecimal fields**, you may encounter reflection errors during seeding
|
- **If using BigDecimal fields**, you may encounter reflection errors during seeding
|
||||||
- **Error pattern**: `Unable to make field private final java.math.BigInteger java.math.BigDecimal.intVal accessible`
|
- **Error pattern**: `Unable to make field private final java.math.BigInteger java.math.BigDecimal.intVal accessible`
|
||||||
@ -505,7 +517,7 @@ private void populateRelationships(Entity entity) {
|
|||||||
- Service layer not populating transient relationship properties
|
- Service layer not populating transient relationship properties
|
||||||
- Controllers not using service layer for relationship loading
|
- Controllers not using service layer for relationship loading
|
||||||
|
|
||||||
#### **Template compatibility fixes**:
|
#### **Template compatibility fixes**
|
||||||
|
|
||||||
- **If templates access relationship properties** (e.g., `entity.relatedObjects`):
|
- **If templates access relationship properties** (e.g., `entity.relatedObjects`):
|
||||||
- Ensure transient properties exist on entities with proper getters/setters
|
- Ensure transient properties exist on entities with proper getters/setters
|
||||||
@ -515,7 +527,7 @@ private void populateRelationships(Entity entity) {
|
|||||||
- `Property or field 'xxx' cannot be found` → Add missing transient property
|
- `Property or field 'xxx' cannot be found` → Add missing transient property
|
||||||
- `EL1008E` errors → Service layer not populating relationships
|
- `EL1008E` errors → Service layer not populating relationships
|
||||||
|
|
||||||
#### **Service layer verification**:
|
#### **Service layer verification**
|
||||||
|
|
||||||
- **Ensure all controllers use service layer** instead of direct repository access
|
- **Ensure all controllers use service layer** instead of direct repository access
|
||||||
- **Verify service methods populate relationships** before returning entities
|
- **Verify service methods populate relationships** before returning entities
|
||||||
@ -555,7 +567,7 @@ When encountering template errors:
|
|||||||
|
|
||||||
### Step 10 — **Systematic Error Resolution Process**
|
### Step 10 — **Systematic Error Resolution Process**
|
||||||
|
|
||||||
#### When compilation fails:
|
#### When compilation fails
|
||||||
|
|
||||||
1. **Run `mvn compile` first** - fix main source issues before tests
|
1. **Run `mvn compile` first** - fix main source issues before tests
|
||||||
2. **Run `mvn test-compile`** - systematically fix each test compilation error
|
2. **Run `mvn test-compile`** - systematically fix each test compilation error
|
||||||
@ -567,7 +579,7 @@ When encountering template errors:
|
|||||||
|
|
||||||
### Step 10 — **Systematic Error Resolution Process**
|
### Step 10 — **Systematic Error Resolution Process**
|
||||||
|
|
||||||
#### When compilation fails:
|
#### When compilation fails
|
||||||
|
|
||||||
1. **Run `mvn compile` first** - fix main source issues before tests
|
1. **Run `mvn compile` first** - fix main source issues before tests
|
||||||
2. **Run `mvn test-compile`** - systematically fix each test compilation error
|
2. **Run `mvn test-compile`** - systematically fix each test compilation error
|
||||||
@ -576,7 +588,8 @@ When encountering template errors:
|
|||||||
- `method X cannot be applied to given types` → Remove pagination parameters
|
- `method X cannot be applied to given types` → Remove pagination parameters
|
||||||
- `cannot find symbol: method Y()` → Update to new repository method names
|
- `cannot find symbol: method Y()` → Update to new repository method names
|
||||||
- Method signature conflicts → Rename conflicting methods
|
- Method signature conflicts → Rename conflicting methods
|
||||||
#### When runtime fails:
|
|
||||||
|
#### When runtime fails
|
||||||
|
|
||||||
1. **Check application logs** for specific error messages
|
1. **Check application logs** for specific error messages
|
||||||
2. **Look for template/SpEL errors**:
|
2. **Look for template/SpEL errors**:
|
||||||
@ -585,7 +598,7 @@ When encountering template errors:
|
|||||||
3. **Verify service layer usage** in controllers
|
3. **Verify service layer usage** in controllers
|
||||||
4. **Test navigation through all application pages**
|
4. **Test navigation through all application pages**
|
||||||
|
|
||||||
#### Common error patterns and solutions:
|
#### Common error patterns and solutions
|
||||||
|
|
||||||
- **`method findByLastNameStartingWith cannot be applied`** → Remove `Pageable` parameter
|
- **`method findByLastNameStartingWith cannot be applied`** → Remove `Pageable` parameter
|
||||||
- **`cannot find symbol: method findPetTypes()`** → Change to `findAllOrderByName()`
|
- **`cannot find symbol: method findPetTypes()`** → Change to `findAllOrderByName()`
|
||||||
@ -712,7 +725,7 @@ If runtime fails after successful compilation:
|
|||||||
|
|
||||||
### **Authentication Troubleshooting Guide** (CRITICAL)
|
### **Authentication Troubleshooting Guide** (CRITICAL)
|
||||||
|
|
||||||
#### **Common Authentication Serialization Errors**:
|
#### **Common Authentication Serialization Errors**
|
||||||
|
|
||||||
1. **`Cannot pass null or empty values to constructor`**:
|
1. **`Cannot pass null or empty values to constructor`**:
|
||||||
|
|
||||||
@ -751,7 +764,7 @@ If runtime fails after successful compilation:
|
|||||||
- **Solution**: Update repository `findOneByLogin` method to work with Cosmos DB
|
- **Solution**: Update repository `findOneByLogin` method to work with Cosmos DB
|
||||||
- **Verification**: Test repository methods independently
|
- **Verification**: Test repository methods independently
|
||||||
|
|
||||||
#### **Authentication Debugging Checklist**:
|
#### **Authentication Debugging Checklist**
|
||||||
|
|
||||||
- [ ] User entity fully serializable (no `@JsonIgnore` on persisted fields)
|
- [ ] User entity fully serializable (no `@JsonIgnore` on persisted fields)
|
||||||
- [ ] Password field accessible and not null
|
- [ ] Password field accessible and not null
|
||||||
@ -823,6 +836,7 @@ default List<Entity> customFindMethod() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
3. **Add JVM argument** (if BigDecimal must be kept):
|
3. **Add JVM argument** (if BigDecimal must be kept):
|
||||||
|
|
||||||
```
|
```
|
||||||
--add-opens java.base/java.math=ALL-UNNAMED
|
--add-opens java.base/java.math=ALL-UNNAMED
|
||||||
```
|
```
|
||||||
@ -872,10 +886,11 @@ public Set<RelatedEntity> getRelatedEntities() {
|
|||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### **Enhanced Error Resolution Process**
|
### **Enhanced Error Resolution Process**
|
||||||
|
|
||||||
#### **Common Error Patterns and Solutions**:
|
#### **Common Error Patterns and Solutions**
|
||||||
|
|
||||||
1. **Reactive Type Casting Errors**:
|
1. **Reactive Type Casting Errors**:
|
||||||
- **Pattern**: `cannot be cast to java.util.List`
|
- **Pattern**: `cannot be cast to java.util.List`
|
||||||
@ -897,7 +912,8 @@ public Set<RelatedEntity> getRelatedEntities() {
|
|||||||
- **Fix**: Update service methods to handle String-based entity references
|
- **Fix**: Update service methods to handle String-based entity references
|
||||||
- **Files**: Service classes, DTOs, entity relationship methods
|
- **Files**: Service classes, DTOs, entity relationship methods
|
||||||
|
|
||||||
#### **Enhanced Validation Checklist**:
|
#### **Enhanced Validation Checklist**
|
||||||
|
|
||||||
- [ ] **Repository reactive casting handled**: No ClassCastException on collection returns
|
- [ ] **Repository reactive casting handled**: No ClassCastException on collection returns
|
||||||
- [ ] **BigDecimal compatibility resolved**: Java 17+ serialization works
|
- [ ] **BigDecimal compatibility resolved**: Java 17+ serialization works
|
||||||
- [ ] **Health checks updated**: No database dependencies in health configuration
|
- [ ] **Health checks updated**: No database dependencies in health configuration
|
||||||
@ -912,39 +928,40 @@ public Set<RelatedEntity> getRelatedEntities() {
|
|||||||
### **Top Runtime Issues to Check**
|
### **Top Runtime Issues to Check**
|
||||||
|
|
||||||
1. **Repository Collection Casting**:
|
1. **Repository Collection Casting**:
|
||||||
```java
|
|
||||||
// Fix any repository methods that return collections:
|
|
||||||
default List<Entity> customFindMethod() {
|
|
||||||
return StreamSupport.stream(this.findAll().spliterator(), false)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
2. **BigDecimal Compatibility (Java 17+)**:
|
```java
|
||||||
|
// Fix any repository methods that return collections:
|
||||||
|
default List<Entity> customFindMethod() {
|
||||||
|
return StreamSupport.stream(this.findAll().spliterator(), false)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
```java
|
2. **BigDecimal Compatibility (Java 17+)**:
|
||||||
// Replace BigDecimal fields with alternatives:
|
|
||||||
private Double amount; // Or String for high precision
|
|
||||||
|
|
||||||
```
|
```java
|
||||||
|
// Replace BigDecimal fields with alternatives:
|
||||||
|
private Double amount; // Or String for high precision
|
||||||
|
|
||||||
3. **Health Check Configuration**:
|
```
|
||||||
```yaml
|
|
||||||
# Remove database dependencies from health checks:
|
|
||||||
management:
|
|
||||||
health:
|
|
||||||
readiness:
|
|
||||||
include: 'ping,diskSpace'
|
|
||||||
```
|
|
||||||
|
|
||||||
### **Authentication Conversion Patterns**
|
3. **Health Check Configuration**:
|
||||||
|
|
||||||
- **Remove `@JsonIgnore` from fields that need Cosmos DB persistence**
|
```yaml
|
||||||
- **Store complex objects as simple types** (e.g., authorities as `Set<String>`)
|
# Remove database dependencies from health checks:
|
||||||
- **Convert between simple and complex types** in service/repository layers
|
management:
|
||||||
|
health:
|
||||||
|
readiness:
|
||||||
|
include: 'ping,diskSpace'
|
||||||
|
```
|
||||||
|
|
||||||
### **Template/UI Compatibility Patterns**
|
### **Authentication Conversion Patterns**
|
||||||
|
|
||||||
- **Add transient properties** with `@JsonIgnore` for UI access to related data
|
- **Remove `@JsonIgnore` from fields that need Cosmos DB persistence**
|
||||||
- **Use service layer** to populate transient relationships before rendering
|
- **Store complex objects as simple types** (e.g., authorities as `Set<String>`)
|
||||||
- **Never return repository results directly** to templates without relationship population
|
- **Convert between simple and complex types** in service/repository layers
|
||||||
|
|
||||||
|
### **Template/UI Compatibility Patterns**
|
||||||
|
|
||||||
|
- **Add transient properties** with `@JsonIgnore` for UI access to related data
|
||||||
|
- **Use service layer** to populate transient relationships before rendering
|
||||||
|
- **Never return repository results directly** to templates without relationship population
|
||||||
|
|||||||
@ -226,9 +226,9 @@ Option 2: GitHub Release
|
|||||||
|
|
||||||
Once installed, you can search for packages locally:
|
Once installed, you can search for packages locally:
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
winget search "Visual Studio Code"
|
winget search "Visual Studio Code"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will help you find the exact package IDs (like `Microsoft.VisualStudioCode`) needed for your image definition files and understand which winget sources you will need to use.
|
This will help you find the exact package IDs (like `Microsoft.VisualStudioCode`) needed for your image definition files and understand which winget sources you will need to use.
|
||||||
|
|
||||||
|
|||||||
@ -386,6 +386,7 @@ end
|
|||||||
```
|
```
|
||||||
|
|
||||||
Make the file executable:
|
Make the file executable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chmod +x bin/mcp-server
|
chmod +x bin/mcp-server
|
||||||
```
|
```
|
||||||
@ -622,24 +623,24 @@ Add to `claude_desktop_config.json`:
|
|||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
my-mcp-server/
|
my-mcp-server/
|
||||||
├── Gemfile # Dependencies
|
├── Gemfile # Dependencies
|
||||||
├── Rakefile # Build tasks
|
├── Rakefile # Build tasks
|
||||||
├── lib/ # Source code
|
├── lib/ # Source code
|
||||||
│ ├── my_mcp_server.rb # Main entry point
|
│ ├── my_mcp_server.rb # Main entry point
|
||||||
│ └── my_mcp_server/ # Module namespace
|
│ └── my_mcp_server/ # Module namespace
|
||||||
│ ├── server.rb # Server setup
|
│ ├── server.rb # Server setup
|
||||||
│ ├── tools/ # Tool implementations
|
│ ├── tools/ # Tool implementations
|
||||||
│ ├── prompts/ # Prompt templates
|
│ ├── prompts/ # Prompt templates
|
||||||
│ └── resources/ # Resource handlers
|
│ └── resources/ # Resource handlers
|
||||||
├── bin/ # Executables
|
├── bin/ # Executables
|
||||||
│ └── mcp-server # Stdio server
|
│ └── mcp-server # Stdio server
|
||||||
├── test/ # Test suite
|
├── test/ # Test suite
|
||||||
│ ├── test_helper.rb # Test configuration
|
│ ├── test_helper.rb # Test configuration
|
||||||
│ └── tools/ # Tool tests
|
│ └── tools/ # Tool tests
|
||||||
└── README.md # This file
|
└── README.md # This file
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@ -79,6 +79,14 @@ function processFile(filePath) {
|
|||||||
if (!inOuter) {
|
if (!inOuter) {
|
||||||
// Look for start of an outer fence
|
// Look for start of an outer fence
|
||||||
if (m) {
|
if (m) {
|
||||||
|
const rest = m.groups.rest || '';
|
||||||
|
// Check if this is a single-line fence (opening and closing on same line)
|
||||||
|
const closingMatch = rest.match(new RegExp(`\`{${m.groups.ticks.length},}\\s*$`));
|
||||||
|
if (closingMatch) {
|
||||||
|
// Single-line code block, skip it
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
inOuter = true;
|
inOuter = true;
|
||||||
outerIndent = m.groups.indent || '';
|
outerIndent = m.groups.indent || '';
|
||||||
outerTicksLen = m.groups.ticks.length;
|
outerTicksLen = m.groups.ticks.length;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user