Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;


import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -65,7 +65,6 @@
* @see AdapterSelector
*/
@Slf4j
@Component
public class AdapterRegistry {

/** Spring application context for bean discovery. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


import java.util.Optional;

Expand Down Expand Up @@ -51,7 +51,6 @@
* @see EcmPortProvider
*/
@Slf4j
@Component
public class AdapterSelector {

/** The adapter registry containing all available adapters. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.fireflyframework.ecm.domain.model.document.Document;
import org.fireflyframework.ecm.port.document.DocumentSearchPort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;


import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -38,13 +38,11 @@
* Stores indexed documents in-memory and supports basic filters.
*/
@Slf4j
@Component
@EcmAdapter(
type = "local-search",
description = "Local in-memory DocumentSearchPort adapter",
supportedFeatures = { AdapterFeature.SEARCH, AdapterFeature.METADATA_SEARCH }
)
@ConditionalOnProperty(name = "firefly.ecm.search.enabled", havingValue = "true", matchIfMissing = false)
public class LocalDocumentSearchAdapter implements DocumentSearchPort {

private final Map<UUID, Document> index = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.fireflyframework.ecm.domain.model.security.Permission;
import org.fireflyframework.ecm.port.security.PermissionPort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;


import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand All @@ -38,13 +38,11 @@
* Provides a functional, non-stub adapter to satisfy hexagonal port contracts.
*/
@Slf4j
@Component
@EcmAdapter(
type = "local-permissions",
description = "Local in-memory PermissionPort adapter",
supportedFeatures = { AdapterFeature.PERMISSIONS }
)
@ConditionalOnProperty(name = "firefly.ecm.permissions.enabled", havingValue = "true", matchIfMissing = false)
public class LocalPermissionAdapter implements PermissionPort {

private final Map<UUID, Permission> store = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.fireflyframework.ecm.port.idp.*;
import org.fireflyframework.ecm.port.security.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
* Factory for creating no-op adapter implementations for all ECM port interfaces.
Expand All @@ -48,7 +48,6 @@
* @see NoOpAdapterBase
*/
@Slf4j
@Component
public class NoOpAdapterFactory {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.fireflyframework.ecm.adapter.AdapterRegistry;
import org.fireflyframework.ecm.adapter.AdapterSelector;
import org.fireflyframework.ecm.adapter.local.LocalDocumentSearchAdapter;
import org.fireflyframework.ecm.adapter.local.LocalPermissionAdapter;
import org.fireflyframework.ecm.adapter.noop.NoOpAdapterFactory;
import org.fireflyframework.ecm.port.document.*;
import org.fireflyframework.ecm.port.folder.*;
Expand All @@ -27,10 +29,11 @@
import org.fireflyframework.ecm.service.EcmPortProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
* Spring Boot auto-configuration for the Firefly ECM (Enterprise Content Management) system.
Expand All @@ -41,7 +44,7 @@
* <li>Adapter discovery and registration</li>
* <li>Port provider configuration</li>
* <li>Conditional bean creation based on feature flags</li>
* <li>Component scanning for ECM-related beans</li>
* <li>Explicit bean registration for ECM infrastructure components</li>
* </ul>
*
* <p>The auto-configuration is activated when the property {@code firefly.ecm.enabled}
Expand Down Expand Up @@ -72,10 +75,57 @@
@Slf4j
@AutoConfiguration
@EnableConfigurationProperties(EcmProperties.class)
@ComponentScan(basePackages = "org.fireflyframework.ecm")
@ConditionalOnProperty(prefix = "firefly.ecm", name = "enabled", havingValue = "true", matchIfMissing = true)
public class EcmAutoConfiguration {

/**
* Configures the adapter registry for discovering and managing ECM adapters.
*
* <p>The adapter registry automatically discovers all ECM adapters in the Spring
* application context and provides efficient access to them based on type or
* interface requirements.</p>
*
* @param applicationContext the Spring application context for bean discovery
* @return a configured AdapterRegistry instance
* @see AdapterRegistry
*/
@Bean
@ConditionalOnMissingBean
public AdapterRegistry adapterRegistry(ApplicationContext applicationContext) {
return new AdapterRegistry(applicationContext);
}

/**
* Configures the adapter selector for choosing appropriate ECM adapters.
*
* <p>The adapter selector implements the adapter selection logic, providing
* intelligent fallback mechanisms and validation capabilities.</p>
*
* @param adapterRegistry the registry containing available adapters
* @return a configured AdapterSelector instance
* @see AdapterSelector
*/
@Bean
@ConditionalOnMissingBean
public AdapterSelector adapterSelector(AdapterRegistry adapterRegistry) {
return new AdapterSelector(adapterRegistry);
}

/**
* Configures the no-op adapter factory for creating fallback adapter implementations.
*
* <p>The no-op adapter factory provides a centralized way to create no-op adapters
* that serve as fallbacks when no real adapter implementations are available.</p>
*
* @return a configured NoOpAdapterFactory instance
* @see NoOpAdapterFactory
*/
@Bean
@ConditionalOnMissingBean
public NoOpAdapterFactory noOpAdapterFactory() {
return new NoOpAdapterFactory();
}

/**
* Configures the central ECM port provider that manages adapter selection and port provisioning.
*
Expand All @@ -90,11 +140,46 @@ public class EcmAutoConfiguration {
* @see AdapterSelector
*/
@Bean
@ConditionalOnMissingBean
public EcmPortProvider ecmPortProvider(AdapterSelector adapterSelector, EcmProperties ecmProperties) {
log.info("Configuring ECM Port Provider with adapter type: {}", ecmProperties.getAdapterType());
return new EcmPortProvider(adapterSelector, ecmProperties);
}

/**
* Configures the local in-memory document search adapter.
*
* <p>This bean is only created when the {@code firefly.ecm.search.enabled} property
* is set to {@code true}. It provides an in-memory search implementation for
* development and testing purposes.</p>
*
* @return a configured LocalDocumentSearchAdapter instance
* @see LocalDocumentSearchAdapter
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "firefly.ecm.search.enabled", havingValue = "true", matchIfMissing = false)
public LocalDocumentSearchAdapter localDocumentSearchAdapter() {
return new LocalDocumentSearchAdapter();
}

/**
* Configures the local in-memory permission adapter.
*
* <p>This bean is only created when the {@code firefly.ecm.permissions.enabled} property
* is set to {@code true}. It provides an in-memory permission management implementation
* for development and testing purposes.</p>
*
* @return a configured LocalPermissionAdapter instance
* @see LocalPermissionAdapter
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "firefly.ecm.permissions.enabled", havingValue = "true", matchIfMissing = false)
public LocalPermissionAdapter localPermissionAdapter() {
return new LocalPermissionAdapter();
}

/**
* Configures the document port for basic document CRUD operations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.fireflyframework.ecm.port.esignature.*;
import org.fireflyframework.ecm.port.idp.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


import java.util.Optional;

Expand Down Expand Up @@ -76,7 +76,6 @@
* @see EcmAutoConfiguration
*/
@Slf4j
@Service
public class EcmPortProvider {

/** The adapter selector responsible for choosing appropriate adapters. */
Expand Down