Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Notification
Commits
a02c2815
Commit
a02c2815
authored
Mar 02, 2021
by
Sutton
Browse files
Adding back some missing code
parent
6ee627ee
Pipeline
#29468
passed with stages
in 44 minutes and 6 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
notification-core/src/main/java/org/opengroup/osdu/notification/utils/NotificationFilter.java
0 → 100644
View file @
a02c2815
// Copyright © 2020 Amazon Web Services
// Copyright 2017-2019, Schlumberger
//
// 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.opengroup.osdu.notification.utils
;
import
org.opengroup.osdu.core.common.http.ResponseHeadersFactory
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
javax.inject.Inject
;
import
javax.servlet.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Map
;
@Component
public
class
NotificationFilter
implements
Filter
{
@Inject
private
DpsHeaders
dpsHeaders
;
private
ResponseHeadersFactory
responseHeadersFactory
=
new
ResponseHeadersFactory
();
// defaults to * for any front-end, string must be comma-delimited if more than one domain
@Value
(
"${ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS:*}"
)
String
ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS
;
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
chain
.
doFilter
(
request
,
response
);
HttpServletResponse
httpResponse
=
(
HttpServletResponse
)
response
;
this
.
dpsHeaders
.
addCorrelationIdIfMissing
();
Map
<
String
,
String
>
responseHeaders
=
responseHeadersFactory
.
getResponseHeaders
(
ACCESS_CONTROL_ALLOW_ORIGIN_DOMAINS
);
for
(
Map
.
Entry
<
String
,
String
>
header
:
responseHeaders
.
entrySet
())
{
httpResponse
.
setHeader
(
header
.
getKey
(),
header
.
getValue
());
}
httpResponse
.
addHeader
(
DpsHeaders
.
CORRELATION_ID
,
this
.
dpsHeaders
.
getCorrelationId
());
}
@Override
public
void
destroy
()
{
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment