diff --git a/open-metadata-implementation/admin-services/admin-services-server/src/main/java/org/odpi/openmetadata/adminservices/server/OMAGServerOperationalServices.java b/open-metadata-implementation/admin-services/admin-services-server/src/main/java/org/odpi/openmetadata/adminservices/server/OMAGServerOperationalServices.java index f655ec72141..ced49c65d6c 100644 --- a/open-metadata-implementation/admin-services/admin-services-server/src/main/java/org/odpi/openmetadata/adminservices/server/OMAGServerOperationalServices.java +++ b/open-metadata-implementation/admin-services/admin-services-server/src/main/java/org/odpi/openmetadata/adminservices/server/OMAGServerOperationalServices.java @@ -168,6 +168,904 @@ public SuccessMessageResponse activateWithStoredConfig(String userId, return response; } + /** + * Activate the open metadata and governance services using the supplied configuration + * document. Inside the configuration document are sections that each relate + * to an open metadata and governance subsystem. This method reads the configuration + * document, starting up each requested subsystem. If any subsystem throws an exception, + * the whole start up process is halted and the exception is returned to the caller. + * + * @param userId user that is issuing the request + * @param configuration properties used to initialize the services + * @return success message response or + * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or + * OMAGInvalidParameterException the server name is invalid or + * OMAGConfigurationErrorException there is a problem using the supplied configuration. + */ + public SuccessMessageResponse activateServerWithSuppliedConfig(String userId, + OMAGServerConfig configuration) + { + final String methodName = "activateServerWithSuppliedConfig"; + final String actionDescription = "Initialize OMAG standalone Server subsystems"; + RESTCallToken token = null; + + + List activatedServiceList = new ArrayList<>(); + OMAGOperationalServicesInstance instance = null; + SuccessMessageResponse response = new SuccessMessageResponse(); + + String serverName =configuration.getLocalServerName(); + + try + { + /* + * Check that a serverName and userId is supplied + */ + token = restCallLogger.logRESTCall(serverName, userId, methodName); + errorHandler.validateServerName(serverName, methodName); + errorHandler.validateUserId(userId, serverName, methodName); + + + /* + * Validate the content of the configuration document. This will throw an exception if the + * configuration document is null or the combination of requested services does not make a useful server. + */ + ServerTypeClassifier serverTypeClassifier = new ServerTypeClassifier(serverName, configuration); + ServerTypeClassification serverTypeClassification = serverTypeClassifier.getServerType(); + + /* + * If the server type is not set then use the value from the classification. + */ + if (configuration.getLocalServerType() == null) + { + configuration.setLocalServerType(serverTypeClassification.getServerTypeName()); + } + + /* + * Save the configuration document to the config store. This ensures we have the latest version of the + * config document on file. + */ +// configStore.saveServerConfig(serverName, methodName, configuration); + + /* + * Validate that the server is not running already. If it is running it should be shutdown. + */ +// if (instanceHandler.isServerActive(userId, serverName)) +// { +// this.deactivateTemporarily(userId, serverName); +// } + + /* + * The instance saves the operational services objects for this server instance so they can be retrieved + * in response to subsequent REST calls for the server. These instances provide the multi-tenant + * support in Egeria. + */ + instance = new OMAGOperationalServicesInstance(serverName, + serverTypeClassification, + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), + configuration.getMaxPageSize()); + instance.setServerActiveStatus(ServerActiveStatus.STARTING); + + /* + * Save the configuration that is going to be used to start the server for this instance. This configuration can be queried by + * the operator to verify the configuration used to start the server. (The values in the config store may have been + * updated since the server was started.) + */ + instance.setOperationalConfiguration(configuration); + + /* ================================ + * Ready to start subsystems. A failure in startup for any subsystem is fatal. + */ + + /* + * Initialize the open metadata repository services first since other services depend on it. + * (Even the governance servers need the audit log.) + */ + OMRSOperationalServices operationalRepositoryServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.STARTING); + operationalRepositoryServices = new OMRSOperationalServices(configuration.getLocalServerName(), + configuration.getLocalServerType(), + configuration.getOrganizationName(), + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getLocalServerURL(), + configuration.getMaxPageSize()); + activatedServiceList.add(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName()); + operationalRepositoryServices.initializeAuditLog(configuration.getRepositoryServicesConfig(), + serverTypeClassification.getServerTypeName()); + + + + /* + * Create an audit log for logging initialization progress and errors. + * Each subsystem should be logging the start up of their components and handling + * their errors. However the logging and error handling done by this method is to bracket the + * start up of the different types of subsystems and provide minimal diagnostics for + * immature subsystems that have not yet developed their logging and error handling. + */ + OMRSAuditLog auditLog = operationalRepositoryServices.getAuditLog( + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceCode(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceDevelopmentStatus(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceDescription(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceWiki()); + instance.setAuditLog(auditLog); + + /* + * There are many paging services in Egeria. This value sets a maximum page size that a requester can use. + * It is passed to each subsystem at start up so it can enforce the limit on all paging REST calls. + * Having a limit helps to prevent a denial of service attack that uses very large requests to overwhelm the server. + * If this value is 0 it means there is no upper limit. If this value is negative then it is invalid. + */ + this.validateMaxPageSize(configuration.getMaxPageSize(), serverName, auditLog, methodName); + + /* + * Save the instance of the repository services and then initialize it. OMRS has 2 modes of initialization. + * Firstly for a basic server such as a governance server, just the audit log is initialized. + * For a metadata server, repository proxy and conformance test server, initialization will optionally set up the + * connector to the local repository, initialize the enterprise repository services (used by + * the access services and conformance test server) and connect to the server's cohorts. It is controlled by the settings in the + * repository services configuration document. The repository services instance is saved since it needs to be called for shutdown. + */ + instance.setOperationalRepositoryServices(operationalRepositoryServices); + + /* + * At this point the type of server influences the start-up sequence. + */ + if ((ServerTypeClassification.METADATA_SERVER.equals(serverTypeClassification)) || + (ServerTypeClassification.METADATA_ACCESS_POINT.equals(serverTypeClassification)) || + (ServerTypeClassification.REPOSITORY_PROXY.equals(serverTypeClassification)) || + (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification))) + { + /* + * This server is a source of metadata and is capable of joining an open metadata repository cohort. + */ + operationalRepositoryServices.initializeCohortMember(configuration.getRepositoryServicesConfig()); + + /* + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + OpenMetadataServerSecurityVerifier securityVerifier = + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog(CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + /* + * Pass the resulting security verifier to the repository services. It will be set up in the local + * repository (if there is a local repository in this server). This is the point where we connect to the cohort. + */ + operationalRepositoryServices.setSecurityVerifier(securityVerifier); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Next initialize the Open Connector Framework (OCF) metadata services. These services are only initialized + * if the enterprise repository services are enabled. They support requests for metadata from connectors running + * outside the metadata server. + */ + OMRSRepositoryConnector enterpriseRepositoryConnector + = operationalRepositoryServices.getEnterpriseOMRSRepositoryConnector(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName()); + + if (enterpriseRepositoryConnector != null) + { + /* + * The enterprise repository services have been requested so OCF metadata management can be started. + */ + OCFMetadataOperationalServices operationalOCFMetadataServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); + operationalOCFMetadataServices = new OCFMetadataOperationalServices(configuration.getLocalServerName(), + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); + + instance.setOperationalOCFMetadataServices(operationalOCFMetadataServices); + activatedServiceList.add(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName()); + + /* + * The enterprise repository services have been requested so GAF metadata management can also be started. + */ + GAFMetadataOperationalServices operationalGAFMetadataServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); + operationalGAFMetadataServices = new GAFMetadataOperationalServices(configuration.getLocalServerName(), + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); + + instance.setOperationalGAFMetadataServices(operationalGAFMetadataServices); + activatedServiceList.add(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName()); + } + + /* + * Now initialize the configured open metadata access services. Each access service has its own subsystem. It is + * initialized via an Admin object that controls its start up and shutdown. The configuration service just needs to create the + * appropriate admin object (specified in the configuration) and initialize it with its own configuration + * document. The admin object then does the rest. The admin objects are stored in the instance since + * they also need to be called for shutdown. + * + * Each access service is given access to the events from open metadata repository cohorts that this server connects to. + * The enterprise topic connector supplies these events. The access service registers a listener with it to receive them. + */ + OMRSTopicConnector enterpriseTopicConnector = operationalRepositoryServices.getEnterpriseOMRSTopicConnector(); + + initializeAccessServices(instance, + configuration.getAccessServicesConfig(), + operationalRepositoryServices, + enterpriseTopicConnector, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + auditLog); + + /* + * Initialize the Open Metadata Conformance Suite Services. This runs the Open Metadata TestLabs that are + * part of the ODPi Egeria Conformance Program. + */ + if (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification)) + { + ConformanceSuiteOperationalServices + operationalConformanceSuiteServices = new ConformanceSuiteOperationalServices(configuration.getLocalServerName(), + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getMaxPageSize()); + instance.setOperationalConformanceSuiteServices(operationalConformanceSuiteServices); + operationalConformanceSuiteServices.initialize(configuration.getConformanceSuiteConfig(), + enterpriseTopicConnector, + operationalRepositoryServices.getEnterpriseConnectorManager(), + operationalRepositoryServices.getAuditLog( + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceCode(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDevelopmentStatus(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDescription(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceWiki())); + + activatedServiceList.add(GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName()); + } + + /* + * The enterprise topic passes OMRS Events from the cohort to the listening access services. + * During the access services start up, they registered listeners with the enterprise topic. + * Starting the enterprise topic will start the flow of events to the registered access services. + */ + if (enterpriseTopicConnector != null) + { + try + { + enterpriseTopicConnector.start(); + } + catch (Exception error) + { + throw new OMAGConfigurationErrorException(OMAGAdminErrorCode.ENTERPRISE_TOPIC_START_FAILED.getMessageDefinition(serverName, + "in memory", + error.getClass().getName(), + error.getMessage()), + this.getClass().getName(), + methodName); + } + } + } + + else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) + { + /* + * Set up the repository services REST API + */ + operationalRepositoryServices.initializeViewServer(configuration.getRepositoryServicesConfig()); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + + /* + * Set up the view services that are the speciality of the view server. + */ + initializeViewServices(instance, + configuration.getViewServicesConfig(), + operationalRepositoryServices, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + configuration.getMaxPageSize(), + auditLog); + } + else /* governance servers */ + { + /* + * Set up the repository services REST API + */ + operationalRepositoryServices.initializeGovernanceServer(configuration.getRepositoryServicesConfig()); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Governance servers are varied in nature. Many host connectors that exchange metadata with third party technologies. + * However they may also host specific types of engines, or provide an implementation of a complete governance service. + * Because of this variety, Egeria does not (yet) provide any specialist frameworks for supporting the governance servers. + * all the implementation is in the governance services subsystems initialized below. + * + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + + /* + * Start up the governance services subsystem. Each type of governance server has its own type of governance services + * subsystem. Each is responsible for handling its own errors. The error handling that follows helps to position + * where any issues are occurring. + */ + try + { + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.STARTING_GOVERNANCE_SERVICES.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); + + initializeGovernanceServices(instance, + configuration, + serverTypeClassification, + operationalRepositoryServices, + activatedServiceList); + + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICES_STARTED.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); + } + catch (OMAGConfigurationErrorException error) + { + /* + * There is a configuration error that means that the governance services subsystem can not start. Since this is + * the primary function of the server then there is no purpose in continuing. + */ + auditLog.logException(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getReportedErrorMessage()), + error); + throw error; + } + catch (Exception error) + { + /* + * Uncontrolled error from the governance service subsystem. The subsystem could be in any state. + * Capture additional information about the error and stop the server startup. + */ + auditLog.logException(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getMessage()), + error); + throw error; + } + } + + /* + * All subsystems are started - just log messages and return. + */ + instance.setServerActiveStatus(ServerActiveStatus.RUNNING); + + String successMessage = new Date().toString() + " " + serverName + " is running the following services: " + activatedServiceList.toString(); + + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.SERVER_STARTUP_SUCCESS.getMessageDefinition(serverName, + activatedServiceList.toString())); + + response.setSuccessMessage(successMessage); + } +// catch (UserNotAuthorizedException error) +// { +// exceptionHandler.captureNotAuthorizedException(response, error); +// cleanUpRunningServiceInstances(userId, serverName, methodName, instance); +// } + catch (OMAGConfigurationErrorException error) + { + exceptionHandler.captureConfigurationErrorException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (OMAGInvalidParameterException error) + { + exceptionHandler.captureInvalidParameterException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (OMAGNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (Exception error) + { + exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } + + + /** + * Activate the open metadata and governance services using the supplied configuration + * document. Inside the configuration document are sections that each relate + * to an open metadata and governance subsystem. This method reads the configuration + * document, starting up each requested subsystem. If any subsystem throws an exception, + * the whole start up process is halted and the exception is returned to the caller. + * + * @param userId user that is issuing the request + * @param configuration properties used to initialize the services + * @param serverName local server name + * @return success message response or + * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or + * OMAGInvalidParameterException the server name is invalid or + * OMAGConfigurationErrorException there is a problem using the supplied configuration. + */ + public SuccessMessageResponse activateWithSuppliedConfig(String userId, + String serverName, + OMAGServerConfig configuration) + { + final String methodName = "activateWithSuppliedConfig"; + final String actionDescription = "Initialize OMAG Server subsystems"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + List activatedServiceList = new ArrayList<>(); + OMAGOperationalServicesInstance instance = null; + SuccessMessageResponse response = new SuccessMessageResponse(); + + try + { + /* + * Check that a serverName and userId is supplied + */ + errorHandler.validateServerName(serverName, methodName); + errorHandler.validateUserId(userId, serverName, methodName); + + /* + * Validate the content of the configuration document. This will throw an exception if the + * configuration document is null or the combination of requested services does not make a useful server. + */ + ServerTypeClassifier serverTypeClassifier = new ServerTypeClassifier(serverName, configuration); + ServerTypeClassification serverTypeClassification = serverTypeClassifier.getServerType(); + + /* + * If the server type is not set then use the value from the classification. + */ + if (configuration.getLocalServerType() == null) + { + configuration.setLocalServerType(serverTypeClassification.getServerTypeName()); + } + + /* + * Save the configuration document to the config store. This ensures we have the latest version of the + * config document on file. + */ + configStore.saveServerConfig(serverName, methodName, configuration); + + /* + * Validate that the server is not running already. If it is running it should be shutdown. + */ + if (instanceHandler.isServerActive(userId, serverName)) + { + this.deactivateTemporarily(userId, serverName); + } + + /* + * The instance saves the operational services objects for this server instance so they can be retrieved + * in response to subsequent REST calls for the server. These instances provide the multi-tenant + * support in Egeria. + */ + instance = new OMAGOperationalServicesInstance(serverName, + serverTypeClassification, + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), + configuration.getMaxPageSize()); + instance.setServerActiveStatus(ServerActiveStatus.STARTING); + + /* + * Save the configuration that is going to be used to start the server for this instance. This configuration can be queried by + * the operator to verify the configuration used to start the server. (The values in the config store may have been + * updated since the server was started.) + */ + instance.setOperationalConfiguration(configuration); + + /* ================================ + * Ready to start subsystems. A failure in startup for any subsystem is fatal. + */ + + /* + * Initialize the open metadata repository services first since other services depend on it. + * (Even the governance servers need the audit log.) + */ + OMRSOperationalServices operationalRepositoryServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.STARTING); + operationalRepositoryServices = new OMRSOperationalServices(configuration.getLocalServerName(), + configuration.getLocalServerType(), + configuration.getOrganizationName(), + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getLocalServerURL(), + configuration.getMaxPageSize()); + activatedServiceList.add(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName()); + operationalRepositoryServices.initializeAuditLog(configuration.getRepositoryServicesConfig(), + serverTypeClassification.getServerTypeName()); + + + + /* + * Create an audit log for logging initialization progress and errors. + * Each subsystem should be logging the start up of their components and handling + * their errors. However the logging and error handling done by this method is to bracket the + * start up of the different types of subsystems and provide minimal diagnostics for + * immature subsystems that have not yet developed their logging and error handling. + */ + OMRSAuditLog auditLog = operationalRepositoryServices.getAuditLog( + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceCode(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceDevelopmentStatus(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceDescription(), + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceWiki()); + instance.setAuditLog(auditLog); + + /* + * There are many paging services in Egeria. This value sets a maximum page size that a requester can use. + * It is passed to each subsystem at start up so it can enforce the limit on all paging REST calls. + * Having a limit helps to prevent a denial of service attack that uses very large requests to overwhelm the server. + * If this value is 0 it means there is no upper limit. If this value is negative then it is invalid. + */ + this.validateMaxPageSize(configuration.getMaxPageSize(), serverName, auditLog, methodName); + + /* + * Save the instance of the repository services and then initialize it. OMRS has 2 modes of initialization. + * Firstly for a basic server such as a governance server, just the audit log is initialized. + * For a metadata server, repository proxy and conformance test server, initialization will optionally set up the + * connector to the local repository, initialize the enterprise repository services (used by + * the access services and conformance test server) and connect to the server's cohorts. It is controlled by the settings in the + * repository services configuration document. The repository services instance is saved since it needs to be called for shutdown. + */ + instance.setOperationalRepositoryServices(operationalRepositoryServices); + + /* + * At this point the type of server influences the start-up sequence. + */ + if ((ServerTypeClassification.METADATA_SERVER.equals(serverTypeClassification)) || + (ServerTypeClassification.METADATA_ACCESS_POINT.equals(serverTypeClassification)) || + (ServerTypeClassification.REPOSITORY_PROXY.equals(serverTypeClassification)) || + (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification))) + { + /* + * This server is a source of metadata and is capable of joining an open metadata repository cohort. + */ + operationalRepositoryServices.initializeCohortMember(configuration.getRepositoryServicesConfig()); + + /* + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + OpenMetadataServerSecurityVerifier securityVerifier = + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog(CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + /* + * Pass the resulting security verifier to the repository services. It will be set up in the local + * repository (if there is a local repository in this server). This is the point where we connect to the cohort. + */ + operationalRepositoryServices.setSecurityVerifier(securityVerifier); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Next initialize the Open Connector Framework (OCF) metadata services. These services are only initialized + * if the enterprise repository services are enabled. They support requests for metadata from connectors running + * outside the metadata server. + */ + OMRSRepositoryConnector enterpriseRepositoryConnector + = operationalRepositoryServices.getEnterpriseOMRSRepositoryConnector(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName()); + + if (enterpriseRepositoryConnector != null) + { + /* + * The enterprise repository services have been requested so OCF metadata management can be started. + */ + OCFMetadataOperationalServices operationalOCFMetadataServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); + operationalOCFMetadataServices = new OCFMetadataOperationalServices(configuration.getLocalServerName(), + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); + + instance.setOperationalOCFMetadataServices(operationalOCFMetadataServices); + activatedServiceList.add(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName()); + + /* + * The enterprise repository services have been requested so GAF metadata management can also be started. + */ + GAFMetadataOperationalServices operationalGAFMetadataServices; + + instance.setServerServiceActiveStatus(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); + operationalGAFMetadataServices = new GAFMetadataOperationalServices(configuration.getLocalServerName(), + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); + + instance.setOperationalGAFMetadataServices(operationalGAFMetadataServices); + activatedServiceList.add(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName()); + } + + /* + * Now initialize the configured open metadata access services. Each access service has its own subsystem. It is + * initialized via an Admin object that controls its start up and shutdown. The configuration service just needs to create the + * appropriate admin object (specified in the configuration) and initialize it with its own configuration + * document. The admin object then does the rest. The admin objects are stored in the instance since + * they also need to be called for shutdown. + * + * Each access service is given access to the events from open metadata repository cohorts that this server connects to. + * The enterprise topic connector supplies these events. The access service registers a listener with it to receive them. + */ + OMRSTopicConnector enterpriseTopicConnector = operationalRepositoryServices.getEnterpriseOMRSTopicConnector(); + + initializeAccessServices(instance, + configuration.getAccessServicesConfig(), + operationalRepositoryServices, + enterpriseTopicConnector, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + auditLog); + + /* + * Initialize the Open Metadata Conformance Suite Services. This runs the Open Metadata TestLabs that are + * part of the ODPi Egeria Conformance Program. + */ + if (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification)) + { + ConformanceSuiteOperationalServices + operationalConformanceSuiteServices = new ConformanceSuiteOperationalServices(configuration.getLocalServerName(), + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getMaxPageSize()); + instance.setOperationalConformanceSuiteServices(operationalConformanceSuiteServices); + operationalConformanceSuiteServices.initialize(configuration.getConformanceSuiteConfig(), + enterpriseTopicConnector, + operationalRepositoryServices.getEnterpriseConnectorManager(), + operationalRepositoryServices.getAuditLog( + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceCode(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDevelopmentStatus(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDescription(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceWiki())); + + activatedServiceList.add(GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName()); + } + + /* + * The enterprise topic passes OMRS Events from the cohort to the listening access services. + * During the access services start up, they registered listeners with the enterprise topic. + * Starting the enterprise topic will start the flow of events to the registered access services. + */ + if (enterpriseTopicConnector != null) + { + try + { + enterpriseTopicConnector.start(); + } + catch (Exception error) + { + throw new OMAGConfigurationErrorException(OMAGAdminErrorCode.ENTERPRISE_TOPIC_START_FAILED.getMessageDefinition(serverName, + "in memory", + error.getClass().getName(), + error.getMessage()), + this.getClass().getName(), + methodName); + } + } + } + + else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) + { + /* + * Set up the repository services REST API + */ + operationalRepositoryServices.initializeViewServer(configuration.getRepositoryServicesConfig()); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + + /* + * Set up the view services that are the speciality of the view server. + */ + initializeViewServices(instance, + configuration.getViewServicesConfig(), + operationalRepositoryServices, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + configuration.getMaxPageSize(), + auditLog); + } + else /* governance servers */ + { + /* + * Set up the repository services REST API + */ + operationalRepositoryServices.initializeGovernanceServer(configuration.getRepositoryServicesConfig()); + instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.RUNNING); + + /* + * Governance servers are varied in nature. Many host connectors that exchange metadata with third party technologies. + * However they may also host specific types of engines, or provide an implementation of a complete governance service. + * Because of this variety, Egeria does not (yet) provide any specialist frameworks for supporting the governance servers. + * all the implementation is in the governance services subsystems initialized below. + * + * Set up the server instance - ensure it is active and the security has been set up correctly. + */ + platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); + + + /* + * Start up the governance services subsystem. Each type of governance server has its own type of governance services + * subsystem. Each is responsible for handling its own errors. The error handling that follows helps to position + * where any issues are occurring. + */ + try + { + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.STARTING_GOVERNANCE_SERVICES.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); + + initializeGovernanceServices(instance, + configuration, + serverTypeClassification, + operationalRepositoryServices, + activatedServiceList); + + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICES_STARTED.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); + } + catch (OMAGConfigurationErrorException error) + { + /* + * There is a configuration error that means that the governance services subsystem can not start. Since this is + * the primary function of the server then there is no purpose in continuing. + */ + auditLog.logException(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getReportedErrorMessage()), + error); + throw error; + } + catch (Exception error) + { + /* + * Uncontrolled error from the governance service subsystem. The subsystem could be in any state. + * Capture additional information about the error and stop the server startup. + */ + auditLog.logException(actionDescription, + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getMessage()), + error); + throw error; + } + } + + /* + * All subsystems are started - just log messages and return. + */ + instance.setServerActiveStatus(ServerActiveStatus.RUNNING); + + String successMessage = new Date().toString() + " " + serverName + " is running the following services: " + activatedServiceList.toString(); + + auditLog.logMessage(actionDescription, + OMAGAdminAuditCode.SERVER_STARTUP_SUCCESS.getMessageDefinition(serverName, + activatedServiceList.toString())); + + response.setSuccessMessage(successMessage); + } + catch (UserNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (OMAGConfigurationErrorException error) + { + exceptionHandler.captureConfigurationErrorException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (OMAGInvalidParameterException error) + { + exceptionHandler.captureInvalidParameterException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (OMAGNotAuthorizedException error) + { + exceptionHandler.captureNotAuthorizedException(response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + catch (Exception error) + { + exceptionHandler.capturePlatformRuntimeException(serverName, methodName, response, error); + cleanUpRunningServiceInstances(userId, serverName, methodName, instance); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + return response; + } /** * Activate the open metadata and governance services using the supplied configuration @@ -178,18 +1076,17 @@ public SuccessMessageResponse activateWithStoredConfig(String userId, * * @param userId user that is issuing the request * @param configuration properties used to initialize the services - * @param serverName local server name * @return success message response or * OMAGNotAuthorizedException the supplied userId is not authorized to issue this command or * OMAGInvalidParameterException the server name is invalid or * OMAGConfigurationErrorException there is a problem using the supplied configuration. */ public SuccessMessageResponse activateWithSuppliedConfig(String userId, - String serverName, OMAGServerConfig configuration) { final String methodName = "activateWithSuppliedConfig"; final String actionDescription = "Initialize OMAG Server subsystems"; + String serverName = configuration.getLocalServerName(); RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); @@ -224,15 +1121,15 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId * Save the configuration document to the config store. This ensures we have the latest version of the * config document on file. */ - configStore.saveServerConfig(serverName, methodName, configuration); +// configStore.saveServerConfig(serverName, methodName, configuration); /* * Validate that the server is not running already. If it is running it should be shutdown. */ - if (instanceHandler.isServerActive(userId, serverName)) - { - this.deactivateTemporarily(userId, serverName); - } +// if (instanceHandler.isServerActive(userId, serverName)) +// { +// this.deactivateTemporarily(userId, serverName); +// } /* * The instance saves the operational services objects for this server instance so they can be retrieved @@ -240,9 +1137,9 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId * support in Egeria. */ instance = new OMAGOperationalServicesInstance(serverName, - serverTypeClassification, - CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), - configuration.getMaxPageSize()); + serverTypeClassification, + CommonServicesDescription.ADMIN_OPERATIONAL_SERVICES.getServiceName(), + configuration.getMaxPageSize()); instance.setServerActiveStatus(ServerActiveStatus.STARTING); /* @@ -264,15 +1161,15 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId instance.setServerServiceActiveStatus(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName(), ServerActiveStatus.STARTING); operationalRepositoryServices = new OMRSOperationalServices(configuration.getLocalServerName(), - configuration.getLocalServerType(), - configuration.getOrganizationName(), - configuration.getLocalServerUserId(), - configuration.getLocalServerPassword(), - configuration.getLocalServerURL(), - configuration.getMaxPageSize()); + configuration.getLocalServerType(), + configuration.getOrganizationName(), + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getLocalServerURL(), + configuration.getMaxPageSize()); activatedServiceList.add(CommonServicesDescription.REPOSITORY_SERVICES.getServiceName()); operationalRepositoryServices.initializeAuditLog(configuration.getRepositoryServicesConfig(), - serverTypeClassification.getServerTypeName()); + serverTypeClassification.getServerTypeName()); @@ -313,9 +1210,9 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId * At this point the type of server influences the start-up sequence. */ if ((ServerTypeClassification.METADATA_SERVER.equals(serverTypeClassification)) || - (ServerTypeClassification.METADATA_ACCESS_POINT.equals(serverTypeClassification)) || - (ServerTypeClassification.REPOSITORY_PROXY.equals(serverTypeClassification)) || - (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification))) + (ServerTypeClassification.METADATA_ACCESS_POINT.equals(serverTypeClassification)) || + (ServerTypeClassification.REPOSITORY_PROXY.equals(serverTypeClassification)) || + (ServerTypeClassification.CONFORMANCE_SERVER.equals(serverTypeClassification))) { /* * This server is a source of metadata and is capable of joining an open metadata repository cohort. @@ -327,13 +1224,13 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId */ OpenMetadataServerSecurityVerifier securityVerifier = platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), - serverName, - operationalRepositoryServices.getAuditLog(CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), - configuration.getServerSecurityConnection()); + serverName, + operationalRepositoryServices.getAuditLog(CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); /* * Pass the resulting security verifier to the repository services. It will be set up in the local @@ -359,15 +1256,15 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId instance.setServerServiceActiveStatus(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); operationalOCFMetadataServices = new OCFMetadataOperationalServices(configuration.getLocalServerName(), - enterpriseRepositoryConnector, - operationalRepositoryServices.getAuditLog( - CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceCode(), - CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), - CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), - CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDescription(), - CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceWiki()), - configuration.getLocalServerUserId(), - configuration.getMaxPageSize()); + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); instance.setOperationalOCFMetadataServices(operationalOCFMetadataServices); activatedServiceList.add(CommonServicesDescription.OCF_METADATA_MANAGEMENT.getServiceName()); @@ -379,15 +1276,15 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId instance.setServerServiceActiveStatus(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), ServerActiveStatus.STARTING); operationalGAFMetadataServices = new GAFMetadataOperationalServices(configuration.getLocalServerName(), - enterpriseRepositoryConnector, - operationalRepositoryServices.getAuditLog( - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceCode(), - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDescription(), - CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceWiki()), - configuration.getLocalServerUserId(), - configuration.getMaxPageSize()); + enterpriseRepositoryConnector, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceCode(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDevelopmentStatus(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceDescription(), + CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceWiki()), + configuration.getLocalServerUserId(), + configuration.getMaxPageSize()); instance.setOperationalGAFMetadataServices(operationalGAFMetadataServices); activatedServiceList.add(CommonServicesDescription.GAF_METADATA_MANAGEMENT.getServiceName()); @@ -406,13 +1303,13 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId OMRSTopicConnector enterpriseTopicConnector = operationalRepositoryServices.getEnterpriseOMRSTopicConnector(); initializeAccessServices(instance, - configuration.getAccessServicesConfig(), - operationalRepositoryServices, - enterpriseTopicConnector, - configuration.getLocalServerUserId(), - serverName, - activatedServiceList, - auditLog); + configuration.getAccessServicesConfig(), + operationalRepositoryServices, + enterpriseTopicConnector, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + auditLog); /* * Initialize the Open Metadata Conformance Suite Services. This runs the Open Metadata TestLabs that are @@ -422,19 +1319,19 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId { ConformanceSuiteOperationalServices operationalConformanceSuiteServices = new ConformanceSuiteOperationalServices(configuration.getLocalServerName(), - configuration.getLocalServerUserId(), - configuration.getLocalServerPassword(), - configuration.getMaxPageSize()); + configuration.getLocalServerUserId(), + configuration.getLocalServerPassword(), + configuration.getMaxPageSize()); instance.setOperationalConformanceSuiteServices(operationalConformanceSuiteServices); operationalConformanceSuiteServices.initialize(configuration.getConformanceSuiteConfig(), - enterpriseTopicConnector, - operationalRepositoryServices.getEnterpriseConnectorManager(), - operationalRepositoryServices.getAuditLog( - GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceCode(), - GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDevelopmentStatus(), - GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName(), - GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDescription(), - GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceWiki())); + enterpriseTopicConnector, + operationalRepositoryServices.getEnterpriseConnectorManager(), + operationalRepositoryServices.getAuditLog( + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceCode(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDevelopmentStatus(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceDescription(), + GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceWiki())); activatedServiceList.add(GovernanceServicesDescription.CONFORMANCE_SUITE_SERVICES.getServiceName()); } @@ -453,11 +1350,11 @@ public SuccessMessageResponse activateWithSuppliedConfig(String userId catch (Exception error) { throw new OMAGConfigurationErrorException(OMAGAdminErrorCode.ENTERPRISE_TOPIC_START_FAILED.getMessageDefinition(serverName, - "in memory", - error.getClass().getName(), - error.getMessage()), - this.getClass().getName(), - methodName); + "in memory", + error.getClass().getName(), + error.getMessage()), + this.getClass().getName(), + methodName); } } } @@ -474,27 +1371,27 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) * Set up the server instance - ensure it is active and the security has been set up correctly. */ platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), - serverName, - operationalRepositoryServices.getAuditLog( - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), - configuration.getServerSecurityConnection()); + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); /* * Set up the view services that are the speciality of the view server. */ initializeViewServices(instance, - configuration.getViewServicesConfig(), - operationalRepositoryServices, - configuration.getLocalServerUserId(), - serverName, - activatedServiceList, - configuration.getMaxPageSize(), - auditLog); + configuration.getViewServicesConfig(), + operationalRepositoryServices, + configuration.getLocalServerUserId(), + serverName, + activatedServiceList, + configuration.getMaxPageSize(), + auditLog); } else /* governance servers */ { @@ -513,14 +1410,14 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) * Set up the server instance - ensure it is active and the security has been set up correctly. */ platformInstanceMap.startUpServerInstance(configuration.getLocalServerUserId(), - serverName, - operationalRepositoryServices.getAuditLog( - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), - CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), - configuration.getServerSecurityConnection()); + serverName, + operationalRepositoryServices.getAuditLog( + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceCode(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDevelopmentStatus(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceName(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceDescription(), + CommonServicesDescription.OPEN_METADATA_SECURITY.getServiceWiki()), + configuration.getServerSecurityConnection()); /* @@ -531,18 +1428,18 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) try { auditLog.logMessage(actionDescription, - OMAGAdminAuditCode.STARTING_GOVERNANCE_SERVICES.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), - serverName)); + OMAGAdminAuditCode.STARTING_GOVERNANCE_SERVICES.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); initializeGovernanceServices(instance, - configuration, - serverTypeClassification, - operationalRepositoryServices, - activatedServiceList); + configuration, + serverTypeClassification, + operationalRepositoryServices, + activatedServiceList); auditLog.logMessage(actionDescription, - OMAGAdminAuditCode.GOVERNANCE_SERVICES_STARTED.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), - serverName)); + OMAGAdminAuditCode.GOVERNANCE_SERVICES_STARTED.getMessageDefinition(serverTypeClassifier.getServerType().getServerTypeName(), + serverName)); } catch (OMAGConfigurationErrorException error) { @@ -551,11 +1448,11 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) * the primary function of the server then there is no purpose in continuing. */ auditLog.logException(actionDescription, - OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), - serverTypeClassifier.getServerType().getServerTypeName(), - serverName, - error.getReportedErrorMessage()), - error); + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getReportedErrorMessage()), + error); throw error; } catch (Exception error) @@ -565,11 +1462,11 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) * Capture additional information about the error and stop the server startup. */ auditLog.logException(actionDescription, - OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), - serverTypeClassifier.getServerType().getServerTypeName(), - serverName, - error.getMessage()), - error); + OMAGAdminAuditCode.GOVERNANCE_SERVICE_FAILURE.getMessageDefinition(error.getClass().getName(), + serverTypeClassifier.getServerType().getServerTypeName(), + serverName, + error.getMessage()), + error); throw error; } } @@ -582,16 +1479,16 @@ else if (ServerTypeClassification.VIEW_SERVER.equals(serverTypeClassification)) String successMessage = new Date().toString() + " " + serverName + " is running the following services: " + activatedServiceList.toString(); auditLog.logMessage(actionDescription, - OMAGAdminAuditCode.SERVER_STARTUP_SUCCESS.getMessageDefinition(serverName, - activatedServiceList.toString())); + OMAGAdminAuditCode.SERVER_STARTUP_SUCCESS.getMessageDefinition(serverName, + activatedServiceList.toString())); response.setSuccessMessage(successMessage); } - catch (UserNotAuthorizedException error) - { - exceptionHandler.captureNotAuthorizedException(response, error); - cleanUpRunningServiceInstances(userId, serverName, methodName, instance); - } +// catch (UserNotAuthorizedException error) +// { +// exceptionHandler.captureNotAuthorizedException(response, error); +// cleanUpRunningServiceInstances(userId, serverName, methodName, instance); +// } catch (OMAGConfigurationErrorException error) { exceptionHandler.captureConfigurationErrorException(response, error); diff --git a/open-metadata-implementation/server-standalone/pom.xml b/open-metadata-implementation/server-standalone/pom.xml new file mode 100644 index 00000000000..be7bc95e331 --- /dev/null +++ b/open-metadata-implementation/server-standalone/pom.xml @@ -0,0 +1,36 @@ + + + + + + + + + + open-metadata-implementation + org.odpi.egeria + 4.0-SNAPSHOT + + + 4.0.0 + + + scm:git:git://github.com/odpi/egeria.git + scm:git:ssh://github.com/odpi/egeria.git + http://github.com/odpi/egeria/tree/main + + + Server standalone + + The server standalone provides an single server to host the open metadata services. + + + server-chassis + pom + + server-standalone-spring + + + diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/build.gradle b/open-metadata-implementation/server-standalone/server-standalone-spring/build.gradle new file mode 100644 index 00000000000..f59a447195b --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/build.gradle @@ -0,0 +1,141 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Contributors to the ODPi Egeria project. + */ + +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin") + } +} + +plugins { + id 'org.springframework.boot' +} + +dependencies { + implementation 'org.springframework.boot:spring-boot' + testImplementation('org.springframework.boot:spring-boot-starter-test') + implementation 'org.springframework.boot:spring-boot-autoconfigure' + implementation 'org.springframework.boot:spring-boot-starter-actuator' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.apache.tomcat.embed:tomcat-embed-core' + //implementation 'org.springframework.boot:spring-boot-starter-tomcat' + //implementation 'javax.servlet:javax.servlet-api' + // Explicitly needed for gradle - added by maven plugin + + runtimeOnly 'io.micrometer:micrometer-registry-prometheus' + implementation 'org.springframework:spring-beans' + implementation 'org.springframework:spring-core' + implementation 'org.springframework:spring-context' + implementation project(':open-metadata-implementation:admin-services:admin-services-server') + compileOnly project(':open-metadata-implementation:common-services:ffdc-services') + implementation project(':open-metadata-implementation:admin-services:admin-services-api') + runtimeOnly 'ch.qos.logback:logback-classic' + implementation project(':open-metadata-implementation:adapters:authentication-plugins:http-helper') + implementation 'org.slf4j:slf4j-api' + runtimeOnly 'org.springdoc:springdoc-openapi-ui' + implementation 'io.swagger.core.v3:swagger-annotations' + runtimeOnly 'org.hibernate:hibernate-validator' +// runtimeOnly project(':open-metadata-implementation:platform-services:platform-services-spring') +// runtimeOnly project(':open-metadata-implementation:admin-services:admin-services-spring') + implementation 'com.fasterxml.jackson.core:jackson-databind' + + // The following are only included at runtime for the full platform (ie adminChassisOnly is not set as a property) + if (!project.hasProperty("adminChassisOnly")) { + runtimeOnly project(':open-metadata-implementation:view-services:server-author-view:server-author-view-spring') + runtimeOnly project(':open-metadata-implementation:view-services:glossary-author-view:glossary-author-view-spring') + runtimeOnly project(':open-metadata-implementation:view-services:rex-view:rex-view-spring') + runtimeOnly project(':open-metadata-implementation:view-services:tex-view:tex-view-spring') + runtimeOnly project(':open-metadata-implementation:view-services:dino-view:dino-view-spring') + runtimeOnly project(':open-metadata-implementation:access-services:security-officer:security-officer-spring') + runtimeOnly project(':open-metadata-implementation:access-services:security-manager:security-manager-spring') + runtimeOnly project(':open-metadata-implementation:access-services:data-manager:data-manager-spring') + runtimeOnly project(':open-metadata-implementation:governance-servers:open-lineage-services:open-lineage-services-spring') + runtimeOnly project(':open-metadata-implementation:access-services:glossary-view:glossary-view-spring') + runtimeOnly project(':open-metadata-implementation:access-services:asset-lineage:asset-lineage-spring') + runtimeOnly project(':open-metadata-implementation:governance-servers:data-engine-proxy-services:data-engine-proxy-services-spring') + runtimeOnly project(':open-metadata-implementation:access-services:data-engine:data-engine-spring') + runtimeOnly project(':open-metadata-implementation:access-services:subject-area:subject-area-spring') + runtimeOnly project(':open-metadata-implementation:access-services:analytics-modeling:analytics-modeling-spring') + runtimeOnly project(':open-metadata-implementation:access-services:asset-catalog:asset-catalog-spring') + runtimeOnly project(':open-metadata-implementation:access-services:governance-program:governance-program-spring') + runtimeOnly project(':open-metadata-implementation:access-services:governance-engine:governance-engine-spring') + runtimeOnly project(':open-metadata-implementation:engine-services:governance-action:governance-action-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:security-integrator:security-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:organization-integrator:organization-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:infrastructure-integrator:infrastructure-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:lineage-integrator:lineage-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:files-integrator:files-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:display-integrator:display-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:database-integrator:database-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:analytics-integrator:analytics-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:api-integrator:api-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:catalog-integrator:catalog-integrator-spring') + runtimeOnly project(':open-metadata-implementation:access-services:discovery-engine:discovery-engine-spring') + runtimeOnly project(':open-metadata-implementation:access-services:stewardship-action:stewardship-action-spring') + runtimeOnly project(':open-metadata-implementation:access-services:community-profile:community-profile-spring') + runtimeOnly project(':open-metadata-implementation:access-services:design-model:design-model-spring') + runtimeOnly project(':open-metadata-implementation:access-services:data-privacy:data-privacy-spring') + runtimeOnly project(':open-metadata-implementation:access-services:it-infrastructure:it-infrastructure-spring') + runtimeOnly project(':open-metadata-implementation:access-services:project-management:project-management-spring') + runtimeOnly project(':open-metadata-implementation:access-services:dev-ops:dev-ops-spring') + runtimeOnly project(':open-metadata-implementation:access-services:software-developer:software-developer-spring') + runtimeOnly project(':open-metadata-implementation:access-services:digital-architecture:digital-architecture-spring') + runtimeOnly project(':open-metadata-implementation:access-services:digital-service:digital-service-spring') + runtimeOnly project(':open-metadata-implementation:access-services:data-science:data-science-spring') + runtimeOnly project(':open-metadata-implementation:engine-services:repository-governance:repository-governance-spring') + runtimeOnly project(':open-metadata-implementation:access-services:asset-consumer:asset-consumer-spring') + runtimeOnly project(':open-metadata-implementation:access-services:asset-manager:asset-manager-spring') + runtimeOnly project(':open-metadata-implementation:access-services:asset-owner:asset-owner-spring') + runtimeOnly project(':open-metadata-implementation:engine-services:asset-analysis:asset-analysis-spring') + runtimeOnly project(':open-metadata-implementation:repository-services:repository-services-spring') + runtimeOnly project(':open-metadata-conformance-suite:open-metadata-conformance-suite-spring') + runtimeOnly project(':open-metadata-implementation:framework-services:ocf-metadata-management:ocf-metadata-spring') + // originally not in gradle build at all + runtimeOnly project(':open-metadata-implementation:framework-services:gaf-metadata-management:gaf-metadata-spring') + // Not in original maven adminChassisOnly profile, but proposed + runtimeOnly project(':open-metadata-implementation:governance-servers:integration-daemon-services:integration-daemon-services-spring') + runtimeOnly project(':open-metadata-implementation:governance-servers:engine-host-services:engine-host-services-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:search-integrator:search-integrator-spring') + runtimeOnly project(':open-metadata-implementation:integration-services:topic-integrator:topic-integrator-spring') + } +} + +description = 'OMAG Server standalone for Spring' + +bootJar { + manifest { + attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher' + } +} + +java { + withJavadocJar() +} + +test { + useJUnitPlatform() +} + +// See https://stackoverflow.com/questions/61197984/bootjar-mavenjar-artifact-wasnt-produced-by-this-build +// Remove the regular (plain) jar & replace with the SpringBoot version +configurations { + [apiElements, runtimeElements].each { + it.outgoing.artifacts.removeIf { + it.buildDependencies.getDependencies(null).contains(jar) + } + it.outgoing.artifact(bootJar) + } +} + +// Assuming the plugin has been applied +loggingCapabilities { + // Configuration goes here + enforceLogback() +} diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/pom.xml b/open-metadata-implementation/server-standalone/server-standalone-spring/pom.xml new file mode 100644 index 00000000000..4bfe58132a0 --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/pom.xml @@ -0,0 +1,897 @@ + + + + + + + + + server-standalone + org.odpi.egeria + 4.0-SNAPSHOT + + + 4.0.0 + + + scm:git:git://github.com/odpi/egeria.git + scm:git:ssh://github.com/odpi/egeria.git + http://github.com/odpi/egeria/tree/main + + + OMAG Server standalone for Spring + + Provides the spring-based OMAG standalone server. + + + server-standalone-spring + + + + + org.springframework.boot + spring-boot + + + + org.springframework.boot + spring-boot-autoconfigure + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.apache.logging.log4j + log4j-api + + + + + + io.micrometer + micrometer-registry-prometheus + + + + org.springframework + spring-beans + + + + org.springframework + spring-context + + + + org.odpi.egeria + platform-services-spring + runtime + + + + org.odpi.egeria + search-integrator-api + runtime + + + + org.odpi.egeria + search-integrator-spring + runtime + + + + org.odpi.egeria + admin-services-spring + runtime + + + + org.odpi.egeria + admin-services-server + + + + org.odpi.egeria + admin-services-api + + + + org.odpi.egeria + ocf-metadata-spring + runtime + + + + org.odpi.egeria + gaf-metadata-spring + runtime + + + + org.odpi.egeria + repository-services-spring + runtime + + + + org.odpi.egeria + open-metadata-conformance-suite-spring + runtime + + + + org.odpi.egeria + asset-analysis-spring + runtime + + + + org.odpi.egeria + asset-consumer-spring + runtime + + + + org.odpi.egeria + asset-manager-spring + runtime + + + + org.odpi.egeria + asset-owner-spring + runtime + + + + + org.odpi.egeria + asset-catalog-topic-connector + runtime + + + + org.odpi.egeria + discovery-engine-spring + runtime + + + + org.odpi.egeria + repository-governance-spring + runtime + + + + org.odpi.egeria + stewardship-action-spring + runtime + + + + org.odpi.egeria + community-profile-spring + runtime + + + + org.odpi.egeria + design-model-spring + runtime + + + + org.odpi.egeria + data-privacy-spring + runtime + + + + org.odpi.egeria + it-infrastructure-spring + runtime + + + + org.odpi.egeria + project-management-spring + runtime + + + + org.odpi.egeria + dev-ops-spring + runtime + + + + org.odpi.egeria + software-developer-spring + runtime + + + + org.odpi.egeria + digital-architecture-spring + runtime + + + + org.odpi.egeria + digital-service-spring + runtime + + + + org.odpi.egeria + api-integrator-spring + runtime + + + + org.odpi.egeria + analytics-integrator-spring + runtime + + + + org.odpi.egeria + catalog-integrator-spring + runtime + + + + org.odpi.egeria + database-integrator-spring + runtime + + + + org.odpi.egeria + display-integrator-spring + runtime + + + + org.odpi.egeria + files-integrator-spring + runtime + + + + org.odpi.egeria + lineage-integrator-spring + runtime + + + + org.odpi.egeria + infrastructure-integrator-spring + runtime + + + + org.odpi.egeria + organization-integrator-spring + runtime + + + + org.odpi.egeria + security-integrator-spring + runtime + + + + org.odpi.egeria + topic-integrator-spring + runtime + + + + org.odpi.egeria + data-science-spring + runtime + + + + org.odpi.egeria + governance-action-spring + runtime + + + + org.odpi.egeria + governance-engine-spring + runtime + + + + org.odpi.egeria + governance-program-spring + runtime + + + + org.odpi.egeria + asset-catalog-spring + runtime + + + + org.odpi.egeria + analytics-modeling-spring + runtime + + + + org.odpi.egeria + subject-area-spring + runtime + + + + org.odpi.egeria + data-engine-spring + runtime + + + + org.odpi.egeria + glossary-view-spring + runtime + + + + org.odpi.egeria + asset-lineage-spring + runtime + + + + org.odpi.egeria + open-lineage-services-spring + runtime + + + + org.odpi.egeria + integration-daemon-services-spring + runtime + + + + org.odpi.egeria + engine-host-services-spring + runtime + + + + org.odpi.egeria + data-manager-spring + runtime + + + + org.odpi.egeria + security-manager-spring + runtime + + + + org.odpi.egeria + security-officer-spring + runtime + + + + org.odpi.egeria + glossary-author-view-spring + runtime + + + + org.odpi.egeria + rex-view-spring + runtime + + + + org.odpi.egeria + tex-view-spring + runtime + + + + org.odpi.egeria + dino-view-spring + runtime + + + + org.odpi.egeria + server-author-view-spring + runtime + + + + org.odpi.egeria + data-engine-proxy-services-spring + runtime + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-validation + + + + ch.qos.logback + logback-classic + compile + + + + ch.qos.logback + logback-core + compile + + + + org.odpi.egeria + http-helper + + + + org.slf4j + slf4j-api + + + + org.springframework + spring-core + + + + + + org.springdoc + springdoc-openapi-ui + + + + io.swagger.core.v3 + swagger-annotations + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + ZIP + + + + + repackage + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + analyze + + analyze-only + + + + + org.odpi.egeria:*spring* + + org.odpi.egeria:*connector* + + + org.springframework.boot:spring-boot-starter-web:* + + org.springframework.boot:spring-boot-starter-validation:* + + + + org.springframework.boot:spring-boot-starter-security:* + + + org.springdoc:springdoc-openapi-ui:* + + + org.odpi.egeria:search-integrator-api:* + + + + + javax.annotation:javax.annotation-api:* + + + + + + + + + + + + + + full-platform + + + !adminChassisOnly + + + + + org.odpi.egeria + ocf-metadata-spring + runtime + + + + org.odpi.egeria + gaf-metadata-spring + runtime + + + + org.odpi.egeria + repository-services-spring + runtime + + + + org.odpi.egeria + open-metadata-conformance-suite-spring + runtime + + + + org.odpi.egeria + asset-analysis-spring + runtime + + + + org.odpi.egeria + asset-consumer-spring + runtime + + + + org.odpi.egeria + asset-manager-spring + runtime + + + + org.odpi.egeria + asset-owner-spring + runtime + + + + org.odpi.egeria + repository-governance-spring + runtime + + + + org.odpi.egeria + discovery-engine-spring + runtime + + + + org.odpi.egeria + stewardship-action-spring + runtime + + + + org.odpi.egeria + community-profile-spring + runtime + + + + org.odpi.egeria + design-model-spring + runtime + + + + org.odpi.egeria + data-privacy-spring + runtime + + + + org.odpi.egeria + it-infrastructure-spring + runtime + + + + org.odpi.egeria + project-management-spring + runtime + + + + org.odpi.egeria + dev-ops-spring + runtime + + + + org.odpi.egeria + software-developer-spring + runtime + + + + org.odpi.egeria + digital-architecture-spring + runtime + + + + org.odpi.egeria + digital-service-spring + runtime + + + + org.odpi.egeria + data-science-spring + runtime + + + + org.odpi.egeria + api-integrator-spring + runtime + + + + org.odpi.egeria + analytics-integrator-spring + runtime + + + + org.odpi.egeria + catalog-integrator-spring + runtime + + + + org.odpi.egeria + database-integrator-spring + runtime + + + + org.odpi.egeria + display-integrator-spring + runtime + + + + org.odpi.egeria + files-integrator-spring + runtime + + + + org.odpi.egeria + lineage-integrator-spring + runtime + + + + org.odpi.egeria + infrastructure-integrator-spring + runtime + + + + org.odpi.egeria + organization-integrator-spring + runtime + + + + org.odpi.egeria + security-integrator-spring + runtime + + + + org.odpi.egeria + governance-action-spring + runtime + + + + org.odpi.egeria + governance-engine-spring + runtime + + + + org.odpi.egeria + governance-program-spring + runtime + + + + org.odpi.egeria + asset-catalog-spring + runtime + + + + org.odpi.egeria + analytics-modeling-spring + runtime + + + + org.odpi.egeria + subject-area-spring + runtime + + + + org.odpi.egeria + data-engine-spring + runtime + + + + org.odpi.egeria + data-engine-proxy-services-spring + runtime + + + + org.odpi.egeria + glossary-view-spring + runtime + + + + org.odpi.egeria + asset-lineage-spring + runtime + + + + org.odpi.egeria + open-lineage-services-spring + runtime + + + + org.odpi.egeria + data-manager-spring + runtime + + + + org.odpi.egeria + security-officer-spring + runtime + + + + org.odpi.egeria + security-manager-spring + runtime + + + + org.odpi.egeria + glossary-author-view-spring + runtime + + + + org.odpi.egeria + rex-view-spring + runtime + + + + org.odpi.egeria + tex-view-spring + runtime + + + + org.odpi.egeria + dino-view-spring + runtime + + + + org.odpi.egeria + server-author-view-spring + runtime + + + + + openapi + + + openapi + + + + + + org.springdoc + springdoc-openapi-maven-plugin + + + integration-test + + generate + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + pre-integration-test + + start + + + + post-integration-test + + stop + + + + + + + + + diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/OMAGServerStandalone.java b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/OMAGServerStandalone.java new file mode 100644 index 00000000000..12bfbfe5be9 --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/OMAGServerStandalone.java @@ -0,0 +1,230 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.serverstandalone.springboot; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import org.odpi.openmetadata.adminservices.server.OMAGServerOperationalServices; +import org.odpi.openmetadata.adminservices.rest.SuccessMessageResponse; +import org.odpi.openmetadata.http.HttpHelper; +import org.odpi.openmetadata.http.HttpRequestHeadersFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; + + +@SpringBootApplication( + scanBasePackages = {"${scan.packages}"} +) +@OpenAPIDefinition( + info = @Info( + title = "Egeria's Open Metadata and Governance (OMAG) Server Platform", + version = "4.0-SNAPSHOT", + description = "The OMAG Server Platform provides a runtime process and platform for Open Metadata and Governance (OMAG) Services.\n" + + "\n" + + "The OMAG services are configured and activated in OMAG Servers using the Administration Services.\n" + + "The configuration operations of the admin services create configuration documents, one for each OMAG Server. " + + "Inside a configuration document is the definition of which OMAG services to activate in the server. " + + "These include the repository services (any type of server), the access services (for metadata access points " + + "and metadata servers), governance services (for governance servers) and view services (for view servers). " + + "Once a configuration document is defined, the OMAG Server can be started and stopped multiple times by " + + "the admin services server instance operations. \n" + + "\n" + + "The OMAG Server Platform also supports platform services to query details of the servers running on the platform.\n" + + "\n" + + "The OMAG Server Platform can host multiple OMAG servers at any one time. " + + "Each OMAG server is isolated within the server platform and so the OMAG server platform can be used to support multi-tenant " + + "operation for a cloud service, " + + "or host a variety of different OMAG Servers needed at a particular location.\n" + + "\n" + + "NOTE: many REST APIs are not guaranteed to be backward-compatible from release to release since they have supported Java clients. " + + "REST APIs may be used for development, testing, evaluation. Click on the documentation for each module to discover more ...", + license = @License(name = "Apache 2.0 License", url = "https://www.apache.org/licenses/LICENSE-2.0"), + contact = @Contact(url = "https://egeria-project.org", name = "Egeria Project", + email = "egeria-technical-discuss@lists.lfaidata.foundation") + ), + + externalDocs = @ExternalDocumentation(description = "OMAG Server Platform documentation", + url="https://egeria-project.org/concepts/omag-server-platform/") +) + + +@Configuration +public class OMAGServerStandalone +{ + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + private static final ObjectReader OBJECT_READER = OBJECT_MAPPER.reader(); + @Value("${strict.ssl}") + Boolean strictSSL; + + @Value("${startup.user}") + String sysUser; + + @Value("${server.config.location}") + String configFilelocation; + + @Value("${header.name.list}") + List headerNames; + + @Autowired + private Environment env; + + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + + private boolean triggeredRuntimeHalt = false; + private String startupMessage = ""; + private OMAGServerOperationalServices operationalServices = new OMAGServerOperationalServices(); + + private static final Logger log = LoggerFactory.getLogger(OMAGServerStandalone.class); + + public static void main(String[] args) { + SpringApplication.run(OMAGServerStandalone.class, args); + } + + @Bean + public InitializingBean getInitialize() + { + return () -> { + if (!strictSSL) + { + log.warn("strict.ssl is set to false! Invalid certificates will be accepted for connection!"); + HttpHelper.noStrictSSL(); + } else if( System.getProperty("javax.net.ssl.trustStore")==null ) { + //load the 'javax.net.ssl.trustStore' and + //'javax.net.ssl.trustStorePassword' from application.properties + System.setProperty("javax.net.ssl.trustStore", env.getProperty("server.ssl.trust-store")); + System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.trust-store-password")); + } + }; + } + + + /** + * Starts the server + */ + private void startServer() + { + + OMAGServerConfig configuration = null; + StartupFailEvent customSpringEvent = null; + try { + System.err.println("configFilelocation="+configFilelocation); + if (configFilelocation != null) { + configuration = OBJECT_READER.readValue(new File(configFilelocation), OMAGServerConfig.class); + } + } catch(IOException e) { + startupMessage = "Server startup failed - as configuration could not be read" ; + customSpringEvent = new StartupFailEvent(this, startupMessage); + } + if (configuration !=null) { + SuccessMessageResponse response = operationalServices.activateWithSuppliedConfig(sysUser.trim(), configuration); + + if (response.getRelatedHTTPCode() == 200) { + startupMessage = response.getSuccessMessage(); + } else { + startupMessage = "Server startup failed with error: " + response.getExceptionErrorMessage(); + customSpringEvent = new StartupFailEvent(this, startupMessage); + } + } + if (customSpringEvent !=null) { + applicationEventPublisher.publishEvent(customSpringEvent); + triggeredRuntimeHalt = true; + } + + } + + + /** + * Deactivate all servers that were started automatically + */ +// private void temporaryDeactivateServers() +// { +// List servers = getAutoStartList(); +// +// if (servers != null) +// { +// log.info("Temporarily deactivating any auto-started servers '{}'", servers); +// +// System.out.println(new Date() + " OMAG Server Platform shutdown requested. Shutting down auto-started servers (if running): " + servers); +// +// operationalServices.deactivateTemporarilyServerList(sysUser, servers); +// } +// } + + @Component + public class ApplicationContextListener + { + + @EventListener(ApplicationReadyEvent.class) + public void applicationReady() { + startServer(); + System.out.println(OMAGServerStandalone.this.startupMessage); + + if(triggeredRuntimeHalt){ + Runtime.getRuntime().halt(43); + } + System.out.println(new Date() + " OMAG server platform ready for more configuration"); + } + + @EventListener + public void onApplicationEvent(ContextClosedEvent event) + { + // temporaryDeactivateServers(); + } + } + + @Component + public class CustomSpringEventListener implements ApplicationListener + { + @Override + public void onApplicationEvent(StartupFailEvent event) { + log.info("Received startup fail event with message: {} " + event.getMessage()); + // temporaryDeactivateServers(); + } + + } + + /** + * Initialization of HttpRequestHeadersFilter. headerNames is a list of headers defined in application properties. + * @return bean of an initialized FilterRegistrationBean + */ + @Bean + public FilterRegistrationBean getRequestHeadersFilter() { + FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(); + + registrationBean.setFilter(new HttpRequestHeadersFilter(headerNames)); + registrationBean.addUrlPatterns("/*"); + registrationBean.setOrder(1); + + return registrationBean; + } + +} diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/StartupFailEvent.java b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/StartupFailEvent.java new file mode 100644 index 00000000000..76500e061fb --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/java/org/odpi/openmetadata/serverstandalone/springboot/StartupFailEvent.java @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +package org.odpi.openmetadata.serverstandalone.springboot; + +import org.springframework.context.ApplicationEvent; + +/** + * Application event used for the case of startup list fails + */ +public class StartupFailEvent extends ApplicationEvent { + + private static final long serialVersionUID = 1L; + + private Object source; + private String message; + + public StartupFailEvent(Object source, String message) { + super(source); + this.source = source; + this.message = message; + } + + public Object getSource() { + return source; + } + + public String getMessage() { + return message; + } +} diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/application.properties b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/application.properties new file mode 100644 index 00000000000..199d74d5649 --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/application.properties @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the ODPi Egeria project. + + +server.port=9443 +server.ssl.key-store=classpath:keystore.p12 +server.ssl.key-store-password=egeria +server.ssl.keyStoreType=PKCS12 +server.ssl.keyAlias=egeriaserverchassis + +server.ssl.trust-store=truststore.p12 +server.ssl.trust-store-password=egeria + +# WARNING! setting 'false' allows java clients to open https connections without checking certificates validity +# Alternate you can import self signed certificates into java truststore or setup an truststore only for this app +# by adding the store into server.ssl.trust-store parameter +strict.ssl=true + +################################################ +### startup servers configuration +################################################ +scan.packages=org.odpi.openmetadata.* +#userId used to startup the list of configured servers default is 'system' +startup.user=system +# Comma separated names of servers to be started +server.config.location= +# Comma separated values of http headers to be added to ThreadLocal +header.name.list= + +################################################ +### Logging +################################################ +logging.level.root=OFF +logging.level.org.springframework=ERROR +#logging.level.org.odpi.openmetadata.commonservices=DEBUG +#logging.level.org.odpi.openmetadata.accessservices.subjectarea.handlers=DEBUG +logging.level.org.springframework.boot.web.embedded.tomcat=INFO +logging.level.org.odpi.openmetadata.serverchassis.springboot=INFO + +################################################ +### Swagger Docs +################################################ +springdoc.version='@springdoc.version@' +springdoc.api-docs.enabled=true +springdoc.api-docs.path=/v3/api-docs +springdoc.swagger-ui.path=/swagger-ui.html +springdoc.swagger-ui.displayRequestDuration=true +springdoc.swagger-ui.tagsSorter=alpha +springdoc.swagger-ui.operationsSorter=alpha +springdoc.swagger-ui.docExpansion=none + +################################################ +### Spring Boot Actuator +################################################ +# Endpoints web configuration +#management.endpoints.web.exposure.include=* +management.health.cassandra.enabled=false + diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/banner.txt b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/banner.txt new file mode 100644 index 00000000000..2009d638360 --- /dev/null +++ b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/banner.txt @@ -0,0 +1,9 @@ +${AnsiColor.CYAN} Project Egeria - Open Metadata and Governance +${AnsiColor.CYAN} ____ __ ___ ___ ______ _____ +${AnsiColor.CYAN} / __ \ / |/ // | / ____/ / ___/ ___ ____ _ __ ___ ____ +${AnsiColor.CYAN} / / / // /|_/ // /| | / / __ \__ \ / _ \ / __/| | / // _ \ / __/ +${AnsiColor.CYAN} / /_/ // / / // ___ |/ /_/ / ___/ // __// / | |/ // __// / +${AnsiColor.CYAN} \____//_/ /_//_/ |_|\____/ /____/ \___//_/ |___/ \___//_/ +${AnsiColor.CYAN} +${AnsiColor.CYAN} :: Powered by Spring Boot${spring-boot.formatted-version} :: +${Ansi.DEFAULT} \ No newline at end of file diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/keystore.p12 b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/keystore.p12 new file mode 100644 index 00000000000..e6998da14a2 Binary files /dev/null and b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/keystore.p12 differ diff --git a/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/truststore.p12 b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/truststore.p12 new file mode 100644 index 00000000000..65dfaa50d31 Binary files /dev/null and b/open-metadata-implementation/server-standalone/server-standalone-spring/src/main/resources/truststore.p12 differ diff --git a/pom.xml b/pom.xml index 8656188ac30..da25b7ef634 100644 --- a/pom.xml +++ b/pom.xml @@ -2830,6 +2830,13 @@ ${open-metadata.version} + + org.odpi.egeria + server-standalone-spring + compile + ${open-metadata.version} + + org.odpi.egeria open-lineage-janus-connector diff --git a/settings.gradle b/settings.gradle index a7481754935..552981f79d6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -388,6 +388,9 @@ include(':open-metadata-implementation:integration-services:topic-integrator:top include(':open-metadata-implementation:integration-services') include(':open-metadata-implementation:server-chassis:server-chassis-spring') include(':open-metadata-implementation:server-chassis') +include(':open-metadata-implementation:server-standalone:server-standalone-spring') +include(':open-metadata-implementation:server-standalone') +include(':open-metadata-implementation:admin-services:admin-services-standalone-server') include(':open-metadata-implementation:user-interfaces:ui-chassis:ui-chassis-spring') include(':open-metadata-implementation:user-interfaces:ui-chassis') include(':open-metadata-implementation:user-interfaces') @@ -807,6 +810,9 @@ project(':open-metadata-implementation:platform-services:platform-services-sprin project(':open-metadata-implementation:platform-services').projectDir = file('open-metadata-implementation/platform-services') project(':open-metadata-implementation:server-chassis:server-chassis-spring').projectDir = file('open-metadata-implementation/server-chassis/server-chassis-spring') project(':open-metadata-implementation:server-chassis').projectDir = file('open-metadata-implementation/server-chassis') +project(':open-metadata-implementation:server-standalone:server-standalone-spring').projectDir = file('open-metadata-implementation/server-standalone/server-standalone-spring') +project(':open-metadata-implementation:server-standalone').projectDir = file('open-metadata-implementation/server-standalone') +project(':open-metadata-implementation:admin-services:admin-services-standalone-server').projectDir = file('open-metadata-implementation/admin-services/admin-services-standalone-server') project(':open-metadata-implementation:user-interfaces:ui-chassis:ui-chassis-spring').projectDir = file('open-metadata-implementation/user-interfaces/ui-chassis/ui-chassis-spring') project(':open-metadata-implementation:user-interfaces:ui-chassis').projectDir = file('open-metadata-implementation/user-interfaces/ui-chassis') project(':open-metadata-implementation:user-interfaces').projectDir = file('open-metadata-implementation/user-interfaces')