@@ -28,7 +28,7 @@ public class CustomizableServicesManager {
28
28
/*public static String validateName(String name) {
29
29
30
30
}*/
31
- public static String readAPISpecification (String apiSpecificationPath ) {
31
+ public static String readAPISpecification (String apiSpecificationPath , String host ) {
32
32
//JSON parser object to parse read file
33
33
JSONObject jsonObj = null ;
34
34
try (FileReader reader = new FileReader (apiSpecificationPath )) {
@@ -40,9 +40,9 @@ public static String readAPISpecification(String apiSpecificationPath) {
40
40
JSONObject tagObj = new JSONObject ();
41
41
42
42
// Host only has hostname and port, meaning no protocol
43
- String strippedUrl = System . getProperty ( "agrold.baseurl" , "localhost:8080" ) .replaceAll ("http://" , "" ).replaceAll ("https://" , "" );
43
+ String strippedUrl = host .replaceAll ("http://" , "" ).replaceAll ("https://" , "" );
44
44
45
- // here we will fill the host property defined by the system property agrold.baseurl and agrold.name
45
+ // here we will fill the host property defined by the hosts from incoming requests & the system property agrold.name
46
46
jsonObj .put ("host" , strippedUrl );
47
47
48
48
jsonObj .put ("basePath" , "/" + System .getProperty ("agrold.name" , "aldp" ) + "/api" );
@@ -77,8 +77,8 @@ public static void writeAPISpecification(JSONObject apiSpecification, String api
77
77
* @param webServiceSpecification : a JSON object with the method as key
78
78
* @return the confirmation message
79
79
*/
80
- public static String addService (String name , String httpMethod , String webServiceSpecification ) {
81
- JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL ));
80
+ public static String addService (String name , String httpMethod , String webServiceSpecification , String host ) {
81
+ JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL , host ));
82
82
JSONObject newServiceSpec = new JSONObject ();
83
83
String sparqlPattern = "get" ;
84
84
newServiceSpec .put (httpMethod , new JSONObject (webServiceSpecification ));
@@ -90,8 +90,8 @@ public static String addService(String name, String httpMethod, String webServic
90
90
return "The service /api/customizable/" + name + " has been created!" ;
91
91
}
92
92
93
- public static String deleteService (String name , String httpMethod ) {
94
- JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL ));
93
+ public static String deleteService (String name , String httpMethod , String host ) {
94
+ JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL , host ));
95
95
String servicePath = PATH_FIXED_PART + name .replaceAll ("\\ s+" , "" );
96
96
if (apiSpecification .getJSONObject ("paths" ).has (servicePath )) {
97
97
apiSpecification .getJSONObject ("paths" ).remove (servicePath );
@@ -101,8 +101,8 @@ public static String deleteService(String name, String httpMethod) {
101
101
return "The service /api/customizable/" + name + " has been deleted!" ;
102
102
}
103
103
104
- public static String updateService (String name , String httpMethod , String webServiceSpecification ) {
105
- JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL ));
104
+ public static String updateService (String name , String httpMethod , String webServiceSpecification , String host ) {
105
+ JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL , host ));
106
106
JSONObject serviceNewSpec = new JSONObject (webServiceSpecification );
107
107
//System.out.println(newServiceSpec.toString());
108
108
String servicePath = PATH_FIXED_PART + name .replaceAll ("\\ s+" , "" );
@@ -120,8 +120,8 @@ public static String updateService(String name, String httpMethod, String webSer
120
120
//System.out.println(apiSpecification.toString());
121
121
}
122
122
123
- public static String queryCustomizableService (String serviceLocalName , MultivaluedMap <String , String > queryParams , String httpMethod , MediaType reponseMediaType ) throws IOException {
124
- JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL ));
123
+ public static String queryCustomizableService (String serviceLocalName , MultivaluedMap <String , String > queryParams , String httpMethod , MediaType reponseMediaType , String host ) throws IOException {
124
+ JSONObject apiSpecification = new JSONObject (readAPISpecification (Utils .AGROLDAPIJSONURL , host ));
125
125
String servicePath = PATH_FIXED_PART + serviceLocalName .replaceAll ("\\ s+" , "" );
126
126
JSONObject serviceCurrentSpec = apiSpecification .getJSONObject ("paths" ).getJSONObject (servicePath );
127
127
if (serviceCurrentSpec != null ) {
0 commit comments