Merging 2024Q2_RC into main, creating 2024Q2 Release

Merging 2024Q2_RC into main, creating 2024Q2 Release #6 (closed)

Merge request reports

Loading
+56 −0
Changes for src/main/java/org/etsi/osl/centrallog/service/CentralLogService.java: 56 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.centrallog.service;

/*-
 * ========================LICENSE_START=================================
 * org.etsi.osl.bugzilla
 * %%
 * Copyright (C) 2019 openslice.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;


/**
 * @author ichatzis
 *
 * based on
 * https://github.com/apache/camel/tree/master/examples/camel-example-spring-boot-activemq
 * https://github.com/indrabasak/spring-consul-example 
 */
// This is equivalent to @Configuration, @EnableAutoConfiguration, and @ComponentScan
@SpringBootApplication
// This annotation is used for consul
@EnableDiscoveryClient
//@EnableRetry
// This is from spring-cloud to allow local configuration application
@RefreshScope
// @EnableAutoConfiguration annotation tells Spring Boot to "guess" how you will want to configure Spring, 
// based on the jar dependencies that you have added. For example, If HSQLDB is on your classpath, and you 
// have not manually configured any database connection beans, then Spring will auto-configure an in-memory database. 
@EnableAutoConfiguration
// This is enabled by default
@EnableConfigurationProperties
public class CentralLogService {
	public static void main(String[] args) {		
		SpringApplication.run( CentralLogService.class, args);	
	}
}
+45 −0
Changes for src/main/java/org/etsi/osl/centrallog/service/CentralLoggerConfig.java: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.centrallog.service;

/*-
 * ========================LICENSE_START=================================
 * org.etsi.osl.portal.api
 * %%
 * Copyright (C) 2019 openslice.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */
/**
 * @author ichatzis
 **/

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties
@ConfigurationProperties
public class CentralLoggerConfig {

	
    private String centrallogurl;

	public String getCentrallogurl() {
		return centrallogurl;
	}

	public void setCentrallogurl(String centrallogurl) {
		this.centrallogurl = centrallogurl;
	} 
}
+73 −0
Changes for src/main/java/org/etsi/osl/centrallog/service/CentralLoggerRouteBuilder.java: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.centrallog.service;
/*-
 * ========================LICENSE_START=================================
 * org.etsi.osl.portal.api
 * %%
 * Copyright (C) 2019 openslice.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */
/**
 * @author ichatzis
 **/

import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
@Component
public class CentralLoggerRouteBuilder  extends RouteBuilder{
		
	
	private static String CENTRALLOGGERURL = "";
	
	@Autowired
	private CentralLoggerConfig centrallogerconfig;
	private static final transient Log logger = LogFactory.getLog( CentralLoggerRouteBuilder.class.getName());
	
	public void configure() {

		
		if ( centrallogerconfig.getCentrallogurl() != null) {
			CENTRALLOGGERURL = centrallogerconfig.getCentrallogurl();
		}
		
		if ( ( CENTRALLOGGERURL == null ) || CENTRALLOGGERURL.equals( "" ) ){
			logger.info( "NO CENTRALLOGGERURL ROUTING. ELASTICURL = " + CENTRALLOGGERURL);
			return; 
		}
		logger.info( "ENABLED CENTRALLOGGERURL ROUTING. ELASTICURL = " + CENTRALLOGGERURL);			
	
		String url = CENTRALLOGGERURL;

		from("jms:topic:centrallogger.log")
		.log( "jms:topic:centrallogger.log package with body ${body} !" )
		.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST))
        .setHeader("Content-Type", constant("application/json"))
        .to("log:DEBUG?showBody=true&showHeaders=true")
        .doTry()
			.toD(  url  )
	        .to("log:DEBUG?showBody=true&showHeaders=true")			
        .doCatch(Exception.class)
	        .setBody(exceptionMessage().convertToString())
	        .to("log:DEBUG?showBody=true&showHeaders=true")			
	    .end();
	}
	
}
+39 −0
Changes for src/main/resources/application.yml: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line

# For Spring Actuator /info endpoint
info:
    artifact: centrallog-service
    name: centrallog-service
    description: Spring centrallog-service
    version: 1.0.0

server:
  port: 13013
    

logging:
  level:
    org.apache.camel: INFO
  file: logs/application-debug.log
  pattern:
    console: "%d %-5level %logger : %msg%n"
    file: "%d %-5level [%thread] %logger : %msg%n"
        
   
spring:
  config:
    activate:
      on-profile: "default"
  application:
    name: centrallog-service
  activemq:
    brokerUrl: tcp://localhost:61616?jms.watchTopicAdvisories=false
    user: artemis
    password: artemis
    pool:
      enabled: true
      max-connections: 100
    packages:
      trust-all: true

centrallogurl: "http://elk_ip:elk_port/index_name/_doc"
+0 −0

Empty file added.

Loading
Loading