Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / main / java / org / openecomp / sparky / JaxrsEchoService.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25
26 package org.openecomp.sparky;
27
28 import com.att.ajsc.beans.PropertiesMapBean;
29 import com.att.ajsc.filemonitor.AJSCPropertiesMap;
30
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35
36
37 /**
38  * The Class JaxrsEchoService.
39  */
40 @Path("/jaxrs-services")
41 public class JaxrsEchoService {
42   
43   /**
44    * Ping.
45    *
46    * @param input the input
47    * @return the string
48    */
49   @GET
50   @Path("/echo/{input}")
51   @Produces("text/plain")
52   public String ping(@PathParam("input") String input) {
53     return "Hello";
54   }
55
56   /**
57    * Gets the property.
58    *
59    * @param fileName the file name
60    * @param input the input
61    * @return the property
62    */
63   @GET
64   @Path("/property/{fileName}/{input:.*}")
65   @Produces("text/plain")
66   public String getProperty(@PathParam("fileName") String fileName,
67       @PathParam("input") String input) {
68     String val = null;
69     try {
70       val = AJSCPropertiesMap.getProperty(fileName, input);
71       if (val == null || val.isEmpty() || val.length() < 1) {
72         val = PropertiesMapBean.getProperty(fileName, input);
73       }
74     } catch (Exception ex) {
75       System.out.println("*** Error retrieving property " + input + ": " + ex);
76     }
77     if (val == null) {
78       return "Property is not available";
79     }
80     return "Property value is, " + val + ".";
81   }
82
83 }