66import okhttp3 .*;
77import okio .ByteString ;
88
9- public class Api {
9+ public class Api implements ApiInterface {
1010 private final Map <String , String > config ;
1111 private final OkHttpClient httpClient ;
1212 private static final ObjectMapper objectMapper = new ObjectMapper ();
1313 private final String token ;
14+ private final String serviceName ;
1415
1516 public Api (Map <String , String > config ) {
1617 this .config = new HashMap <>(config );
1718 this .httpClient = new OkHttpClient ();
1819 this .token = this .config .get ("Authorization" );
20+ this .serviceName = this .config .get ("serviceName" );
1921 }
2022
2123 public String createEntityDraft (
22- String appUrl , String serviceName , String entityName , String entityName2 , String srvpath ) {
24+ String appUrl , String entityName , String entityName2 , String srvpath ) {
2325 MediaType mediaType = MediaType .parse ("application/json" );
2426
2527 // Creating the Entity (draft)
@@ -55,8 +57,7 @@ public String createEntityDraft(
5557 return ("Could not create entity" );
5658 }
5759
58- public String editEntityDraft (
59- String appUrl , String serviceName , String entityName , String srvpath , String entityID ) {
60+ public String editEntityDraft (String appUrl , String entityName , String srvpath , String entityID ) {
6061 MediaType mediaType = MediaType .parse ("application/json" );
6162 Request request =
6263 new Request .Builder ()
@@ -88,8 +89,7 @@ public String editEntityDraft(
8889 return "Could not edit entity" ;
8990 }
9091
91- public String saveEntityDraft (
92- String appUrl , String serviceName , String entityName , String srvpath , String entityID ) {
92+ public String saveEntityDraft (String appUrl , String entityName , String srvpath , String entityID ) {
9393 Request request =
9494 new Request .Builder ()
9595 .url (
@@ -155,8 +155,7 @@ public String saveEntityDraft(
155155 return "Could not save entity" ;
156156 }
157157
158- public String deleteEntity (
159- String appUrl , String serviceName , String entityName , String entityID ) {
158+ public String deleteEntity (String appUrl , String entityName , String entityID ) {
160159 Request request =
161160 new Request .Builder ()
162161 .url (
@@ -185,7 +184,7 @@ public String deleteEntity(
185184 return ("Could not delete entity" );
186185 }
187186
188- public String checkEntity (String appUrl , String serviceName , String entityName , String entityID ) {
187+ public String checkEntity (String appUrl , String entityName , String entityID ) {
189188 Request request =
190189 new Request .Builder ()
191190 .url (
@@ -216,7 +215,6 @@ public String checkEntity(String appUrl, String serviceName, String entityName,
216215
217216 public List <String > createAttachment (
218217 String appUrl ,
219- String serviceName ,
220218 String entityName ,
221219 String facetName ,
222220 String entityID ,
@@ -358,12 +356,7 @@ public List<String> createAttachment(
358356 }
359357
360358 public String readAttachment (
361- String appUrl ,
362- String serviceName ,
363- String entityName ,
364- String facetName ,
365- String entityID ,
366- String ID )
359+ String appUrl , String entityName , String facetName , String entityID , String ID )
367360 throws IOException {
368361 Request request =
369362 new Request .Builder ()
@@ -391,11 +384,11 @@ public String readAttachment(
391384 Response response = httpClient .newCall (request ).execute ();
392385 if (!response .isSuccessful ()) {
393386 System .out .println (
394- "Read Attachnent failed in the"
387+ "Read Attachment failed in the"
395388 + facetName
396389 + " section. Error :"
397390 + response .body ().string ());
398- throw new IOException ("Read Attachnent failed in the" + facetName + " section" );
391+ throw new IOException ("Read Attachment failed in the" + facetName + " section" );
399392 }
400393 return "OK" ;
401394 } catch (IOException e ) {
@@ -405,12 +398,7 @@ public String readAttachment(
405398 }
406399
407400 public String readAttachmentDraft (
408- String appUrl ,
409- String serviceName ,
410- String entityName ,
411- String facetName ,
412- String entityID ,
413- String ID )
401+ String appUrl , String entityName , String facetName , String entityID , String ID )
414402 throws IOException {
415403 Request request =
416404 new Request .Builder ()
@@ -448,12 +436,7 @@ public String readAttachmentDraft(
448436 }
449437
450438 public String deleteAttachment (
451- String appUrl ,
452- String serviceName ,
453- String entityName ,
454- String facetName ,
455- String entityID ,
456- String ID ) {
439+ String appUrl , String entityName , String facetName , String entityID , String ID ) {
457440 Request request =
458441 new Request .Builder ()
459442 .url (
@@ -491,13 +474,7 @@ public String deleteAttachment(
491474 }
492475
493476 public String renameAttachment (
494- String appUrl ,
495- String serviceName ,
496- String entityName ,
497- String facetName ,
498- String entityID ,
499- String ID ,
500- String name ) {
477+ String appUrl , String entityName , String facetName , String entityID , String ID , String name ) {
501478 MediaType mediaType = MediaType .parse ("application/json" );
502479 RequestBody body =
503480 RequestBody .create (
@@ -541,7 +518,6 @@ public String renameAttachment(
541518
542519 public String updateSecondaryProperty (
543520 String appUrl ,
544- String serviceName ,
545521 String entityName ,
546522 String facetName ,
547523 String entityID ,
@@ -584,7 +560,6 @@ public String updateSecondaryProperty(
584560
585561 public String updateInvalidSecondaryProperty (
586562 String appUrl ,
587- String serviceName ,
588563 String entityName ,
589564 String facetName ,
590565 String entityID ,
@@ -628,12 +603,7 @@ public String updateInvalidSecondaryProperty(
628603 }
629604
630605 public Map <String , Object > fetchMetadata (
631- String appUrl ,
632- String serviceName ,
633- String entityName ,
634- String facetName ,
635- String entityID ,
636- String ID )
606+ String appUrl , String entityName , String facetName , String entityID , String ID )
637607 throws IOException {
638608 // Construct the URL for fetching attachment metadata
639609 String url =
0 commit comments