Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 | package org.onap.portalapp.conf;
|
| 24 |
|
| 25 | import org.onap.portalsdk.core.conf.AppInitializer;
|
| 26 | import javax.servlet.ServletContext;
|
| 27 | import javax.servlet.ServletException;
|
| 28 | import java.util.TimeZone;
|
| 29 |
|
| 30 | public class ExternalAppInitializer extends AppInitializer {
|
| 31 |
|
| 32 | @Override
|
| 33 | protected Class<?>[] getRootConfigClasses() {
|
| 34 | return super.getRootConfigClasses();
|
| 35 | }
|
| 36 |
|
| 37 | @Override
|
| 38 | protected Class<?>[] getServletConfigClasses() {
|
| 39 | Class<?> appConfigClass = ExternalAppConfig.class;
|
| 40 | // Show something on stdout to indicate the app is starting.
|
| 41 | System.out.println("ExternalAppInitializer: servlet configuration class is " + appConfigClass.getName());
|
| 42 | return new Class[] { appConfigClass };
|
| 43 | }
|
| 44 |
|
| 45 | /*
|
| 46 | * URL request will direct to the Spring dispatcher for processing
|
| 47 | */
|
| 48 | @Override
|
| 49 | protected String[] getServletMappings() {
|
| 50 | return super.getServletMappings();
|
| 51 | }
|
| 52 |
|
| 53 | // @Override
|
| 54 | // public void onStartup(ServletContext servletContext) throws ServletException {
|
| 55 | // super.onStartup(servletContext);
|
| 56 | // setDefaultTimeZoneToUTC();
|
| 57 | // servletContext.addFilter("requestFromLocalhost", LocalhostFilter.class)
|
| 58 | // .addMappingForUrlPatterns(null, false,
|
| 59 | // String.format("/%s/%s/*", ChangeManagementController.CHANGE_MANAGEMENT, ChangeManagementController.VNF_WORKFLOW_RELATION),
|
| 60 | // String.format("/%s/*", RoleGeneratorController.GENERATE_ROLE_SCRIPT),
|
| 61 | // String.format("/%s/*", MaintenanceController.MAINTENANCE));
|
| 62 | // }
|
| 63 |
|
| 64 | //set time zone to UTC so Dates would be written to DB in UTC timezone
|
| 65 | private void setDefaultTimeZoneToUTC() {
|
| 66 | System.setProperty("user.timezone", "UTC");
|
| 67 | TimeZone.setDefault(TimeZone.getTimeZone("UTC")); //since TimeZone cache previous user.timezone
|
| 68 | }
|
| 69 | }
|