diff options
Diffstat (limited to 'src/main')
13 files changed, 429 insertions, 66 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java b/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java new file mode 100644 index 00000000..ca7cc362 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/MainApp.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +@SpringBootApplication +@Configuration +@ComponentScan +@EnableScheduling +public class MainApp { + + public static void main(String[] args) { + SpringApplication.run(MainApp.class, args); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java b/src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java deleted file mode 100644 index 5d865127..00000000 --- a/src/main/java/org/onap/dcaegen2/services/prh/ServerPrhApp.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * PROJECT - * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. - * ================================================================================ - * 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========================================================= - */ - -package org.onap.dcaegen2.services.prh; - -import java.util.logging.Level; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; - -import java.util.logging.Logger; - -public class ServerPrhApp { - - private static int port = 8080; - private static Logger logger = Logger.getLogger(ServerPrhApp.class.getName()); - - public static void main(String... args) { - logger.info("Starting PRH Application Service..."); - ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); - contextHandler.setContextPath("/"); - - Server jettyServer = new Server(port); - jettyServer.setHandler(contextHandler); - - ServletHolder jerseyServlet = contextHandler - .addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*"); - jerseyServlet.setInitOrder(0); - - jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", "org.onap.dcaegen2.services.prh"); - - try { - - jettyServer.start(); - logger.info("Server jetty running on port: " + port); - jettyServer.join(); - } catch (Exception ex) { - logger.log(Level.ALL, "Error occurred while starting Jetty", ex); - System.exit(1); - } finally { - jettyServer.destroy(); - } - - } - - private static void parseSettingsFileFromArgs() { - //TODO: Definition of for riding file configuration - } -}
\ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java new file mode 100644 index 00000000..3ea3d213 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/consumer/config/dmaap/DmaapConsumerConfiguration.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.consumer.config.dmaap; + +import org.immutables.value.Value; +import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +@Value.Immutable(prehash = true) +@Value.Style(stagedBuilder = true) +public abstract class DmaapConsumerConfiguration extends DmaapConfig { + + private static final long serialVersionUID = 1L; + + private String consumerId; + private String consumerGroup; + private Integer timeoutMS; + private Integer messageLimit; +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java new file mode 100644 index 00000000..58858b5c --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/AAIConfig.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.mutual.config; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +public abstract class AAIConfig implements Config { + +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java new file mode 100644 index 00000000..d0784457 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/Config.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.mutual.config; + +import java.io.Serializable; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +interface Config extends Serializable { + +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java new file mode 100644 index 00000000..0a2ee9d1 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/mutual/config/DmaapConfig.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.mutual.config; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +public abstract class DmaapConfig implements Config { + + private String dmmaphostName; + private Integer dmmapportNumber; + private String dmmaptopicName; + private String dmmapprotocol; + private String dmmapuserName; + private String dmmapuserPassword; + private String dmmapcontentType; +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java new file mode 100644 index 00000000..214ffa94 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/aai/AAIDmaapProducerConfiguration.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.publisher.config.aai; + +import java.net.URL; +import org.immutables.value.Value; +import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +@Value.Immutable(prehash = true) +@Value.Style(stagedBuilder = true) +public abstract class AAIDmaapProducerConfiguration extends DmaapConfig { + + private static final long serialVersionUID = 1L; + + private String aaiHost; + private Integer aaiHostPortNumber; + private String aaiProtocol; + private String aaiUserName; + private String aaiUserPassword; + private URL aaiProxyURL; + private boolean aaiIgnoreSSLCertificateErrors; +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java new file mode 100644 index 00000000..494fad4c --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/event/executor/publisher/config/dmaap/DmaapProducerConfiguration.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.event.executor.publisher.config.dmaap; + +import org.onap.dcaegen2.services.prh.event.executor.mutual.config.DmaapConfig; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ + +public class DmaapProducerConfiguration extends DmaapConfig { + + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java b/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java new file mode 100644 index 00000000..61b0c69b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/exceptions/AAINotFoundException.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.exceptions; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +public class AAINotFoundException extends Exception { + + public AAINotFoundException(String message) { + super(message); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java new file mode 100644 index 00000000..5902587b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.tasks; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +@Component +public class DmaapConsumerTask implements DmaapTask { + + private static final Logger logger = LoggerFactory.getLogger(DmaapConsumerTask.class); + private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + @Override + public void execute() { + logger.info("Start task DmaapConsumerTask::execute() :: Execution Time - {}", dateTimeFormatter.format( + LocalDateTime.now())); + //TODO: ADD implementation for executing request to consume topic from dmaap + + logger.info("End task DmaapConsumerTask::execute() :: Execution Time - {}", + dateTimeFormatter.format(LocalDateTime.now())); + } +}
\ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java new file mode 100644 index 00000000..bb3fdc6d --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapTask.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.tasks; + +import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +public interface DmaapTask { + + void execute() throws AAINotFoundException; + +} diff --git a/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java b/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java new file mode 100644 index 00000000..c06eceb0 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTask.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * PROJECT + * ================================================================================ + * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * ================================================================================ + * 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========================================================= + */ +package org.onap.dcaegen2.services.prh.tasks; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +/** + * @author Przemysław Wąsala <przemyslaw.wasala@nokia.com> on 3/23/18 + * @project pnf-registration-handler + */ +@Component +public class ScheduledTask { + + private static final int FIXED_DELAY = 1000; + private static final Logger logger = LoggerFactory.getLogger(ScheduledTask.class); + private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); + + private final DmaapTask dmaapConsumerTask; + + @Autowired + public ScheduledTask(DmaapConsumerTask dmaapConsumerTask) { + this.dmaapConsumerTask = dmaapConsumerTask; + } + + + @Scheduled(fixedDelay = FIXED_DELAY) + public void scheduledTaskAskingDMaaPOfConsumeEvent() { + logger.info("Task scheduledTaskAskingDMaaPOfConsumeEvent() :: Execution Time - {}", dateTimeFormatter.format( + LocalDateTime.now())); + try { + dmaapConsumerTask.execute(); + } catch (AAINotFoundException e) { + logger.warn("Task scheduledTaskAskingDMaaPOfConsumeEvent()::AAINotFoundException :: Execution Time - {}:{}", + dateTimeFormatter.format( + LocalDateTime.now()), e.getMessage()); + } + } + +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 00000000..ef147c10 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,7 @@ +server: + port: 8080 +logging: + level: + .: error + org.springframework: ERROR + org.onap.dcaegen2.services.prg: ERROR
\ No newline at end of file |