update the pom version for the security issue fix
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / main / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / common / restclient / SystemEnvVariablesDefImpl.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
18
19 import java.io.File;
20 import java.io.IOException;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * System environment variable helper implementation.<br/>
27  * <p>
28  * </p>
29  * 
30  * @author
31  * @version 24-Jun-2016
32  */
33 public class SystemEnvVariablesDefImpl implements SystemEnvVariables {
34
35     private static final Logger LOG = LoggerFactory.getLogger(SystemEnvVariablesDefImpl.class);
36
37     @Override
38     public String getAppRoot() {
39         String appRoot = null;
40         appRoot = System.getProperty("catalina.base");
41         if(appRoot != null) {
42             appRoot = getCanonicalPath(appRoot);
43         }
44         return appRoot;
45     }
46
47     /**
48      * Gets the canonical path<br/>
49      * 
50      * @param inPath input path
51      * @return the canonical path.
52      * @since
53      */
54     private String getCanonicalPath(final String inPath) {
55         String path = null;
56         try {
57             if(inPath != null) {
58                 final File file = new File(inPath);
59                 path = file.getCanonicalPath();
60             }
61         } catch(final IOException e) {
62             LOG.error("file.getCanonicalPath() IOException:", e);
63         }
64         return path;
65     }
66
67 }