From 484e6de232bdaf891267056436e155fd66c7973d Mon Sep 17 00:00:00 2001 From: siddharth0905 Date: Thu, 16 Aug 2018 11:08:21 +0300 Subject: Add audit logging for WF Also formatting fixes. Change-Id: Ia57e7b3c7208df962fcc7305822a055984aafe0b Issue-ID: SDC-1530 Signed-off-by: siddharth0905 Signed-off-by: vempo --- .../sdc/workflow/api/types/CollectionResponse.java | 16 +++++++++ .../onap/sdc/workflow/api/types/ErrorResponse.java | 16 +++++++++ .../org/onap/sdc/workflow/api/types/Paging.java | 16 +++++++++ .../org/onap/sdc/workflow/api/types/Sorting.java | 16 +++++++++ .../api/types/UnexpectedErrorResponse.java | 16 +++++++++ .../workflow/api/types/VersionStatesFormatter.java | 16 +++++++++ .../types/dto/ArtifactDeliveriesRequestDto.java | 3 +- .../sdc/workflow/api/validation/NoDuplicates.java | 17 ++++++++++ .../api/validation/NoDuplicatesValidator.java | 16 +++++++++ .../server/config/ApplicationConfigurer.java | 35 +++++++++++++++++++ .../server/config/LoggingInterceptorConfig.java | 39 ++++++++++++++++++++++ .../sdc/workflow/server/config/SwaggerConfig.java | 16 +++++++++ .../sdc/workflow/server/config/ZusammenConfig.java | 18 +++++++++- .../server/filters/SessionContextFilter.java | 16 +++++++++ .../VersionStatusModificationException.java | 16 +++++++++ .../exceptions/VersionValidationException.java | 18 +++++++++- .../src/main/resources/application-dev.properties | 6 +++- .../src/main/resources/application.properties | 6 +++- 18 files changed, 297 insertions(+), 5 deletions(-) create mode 100644 workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java create mode 100644 workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java (limited to 'workflow-designer-be/src') diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java index 831ccc34..1734dd6c 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import java.util.Collection; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java index 1b8fb3c8..45f54341 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import lombok.AllArgsConstructor; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java index 0a27e1e6..7e47f6d6 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import static org.onap.sdc.workflow.services.types.PagingConstants.MAX_LIMIT; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java index f02a05fe..1a0c1a15 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import java.util.Arrays; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java index fbc5ab39..8cf513a2 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import lombok.Getter; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java index 18ed50c5..51e75edf 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.types; import java.util.Arrays; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java index e3dc212a..2ec272fc 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.sdc.workflow.api.types.dto; import lombok.Data; @@ -37,7 +38,7 @@ public class ArtifactDeliveriesRequestDto { public ArtifactDeliveriesRequestDto(){ } - public ArtifactDeliveriesRequestDto(String method, String endpoint){ + public ArtifactDeliveriesRequestDto(String method, String endpoint) { this.method = method; this.endpoint = endpoint; } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java index ca4932ac..296e4387 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.validation; import java.lang.annotation.Documented; @@ -13,6 +29,7 @@ import javax.validation.Payload; @Documented @Constraint(validatedBy = {NoDuplicatesValidator.class}) public @interface NoDuplicates { + String message(); Class[] groups() default {}; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java index 13bbf0e9..2020bb83 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.api.validation; import java.util.Collection; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java new file mode 100644 index 00000000..e631a12c --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + +package org.onap.sdc.workflow.server.config; + +import org.openecomp.sdc.logging.servlet.spring.LoggingInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class ApplicationConfigurer implements WebMvcConfigurer { + + @Autowired + LoggingInterceptor loggingInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(loggingInterceptor); + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java new file mode 100644 index 00000000..53dbda59 --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + +package org.onap.sdc.workflow.server.config; + +import org.openecomp.sdc.logging.servlet.HttpHeader; +import org.openecomp.sdc.logging.servlet.spring.LoggingInterceptor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class LoggingInterceptorConfig { + + @Value("${onap.logging.requestIdHeader}") + private String[] loggingRequestIdHeaders; + + @Value("${onap.logging.partnerNameHeader}") + private String[] loggingPartnerNameHeader; + + @Bean + public LoggingInterceptor createLoggingInterceptor() { + return new LoggingInterceptor(new HttpHeader(loggingRequestIdHeaders), + new HttpHeader(loggingPartnerNameHeader)); + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java index f17cea1f..a2eca63a 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.server.config; import static springfox.documentation.builders.PathSelectors.regex; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java index 092c3464..23e8643b 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.server.config; import javax.annotation.PostConstruct; @@ -19,7 +35,7 @@ public class ZusammenConfig { private String cassandraAuth; @PostConstruct - public void init(){ + public void init() { System.setProperty("cassandra.nodes", cassandraAddress); System.setProperty("cassandra.user", cassandraUser); System.setProperty("cassandra.password", cassandraPassword); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java index 28838327..e9742fcd 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.server.filters; import java.io.IOException; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java index 7264682a..4eb8af42 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.services.exceptions; import org.openecomp.sdc.versioning.dao.types.VersionStatus; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java index bd7d61f2..815bc0b2 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java @@ -1,6 +1,22 @@ +/* + * Copyright © 2018 European Support Limited + * + * 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. + */ + package org.onap.sdc.workflow.services.exceptions; -public class VersionValidationException extends RuntimeException{ +public class VersionValidationException extends RuntimeException { private static final String MSG = "Error creating or modifying version for workflow with id %s: %s"; diff --git a/workflow-designer-be/src/main/resources/application-dev.properties b/workflow-designer-be/src/main/resources/application-dev.properties index 897b0422..12a99021 100644 --- a/workflow-designer-be/src/main/resources/application-dev.properties +++ b/workflow-designer-be/src/main/resources/application-dev.properties @@ -25,4 +25,8 @@ spring.data.cassandra.password=${CS_PASSWORD:} zusammen.cassandra.isAuthenticate=${CS_AUTHENTICATE:false} #Actuators -management.endpoint.health.show-details=always \ No newline at end of file +management.endpoint.health.show-details=always + +#Headers are comma separated list +onap.logging.requestIdHeader=X-ECOMP-RequestID,X-ONAP-RequestID +onap.logging.partnerNameHeader=USER_ID \ No newline at end of file diff --git a/workflow-designer-be/src/main/resources/application.properties b/workflow-designer-be/src/main/resources/application.properties index 64b58fd5..5fa56d82 100644 --- a/workflow-designer-be/src/main/resources/application.properties +++ b/workflow-designer-be/src/main/resources/application.properties @@ -29,4 +29,8 @@ spring.data.cassandra.password=${CS_PASSWORD:} zusammen.cassandra.isAuthenticate=${CS_AUTHENTICATE:true} #Actuators -management.endpoint.health.show-details=always \ No newline at end of file +management.endpoint.health.show-details=always + +#Headers are comma separated list +onap.logging.requestIdHeader=X-ECOMP-RequestID,X-ONAP-RequestID +onap.logging.partnerNameHeader=USER_ID \ No newline at end of file -- cgit 1.2.3-korg