33import com .fasterxml .jackson .databind .ObjectMapper ;
44import java .io .File ;
55import java .io .IOException ;
6- import java .time .LocalDateTime ;
7- import java .time .ZoneId ;
8- import java .time .ZonedDateTime ;
9- import java .time .format .DateTimeFormatter ;
106import java .util .*;
117import okhttp3 .*;
128import okio .ByteString ;
@@ -547,113 +543,8 @@ public String updateSecondaryProperty(
547543 String facetName ,
548544 String entityID ,
549545 String ID ,
550- String stringProperty ) {
551- MediaType mediaType = MediaType .parse ("application/json" );
552- RequestBody body =
553- RequestBody .create (
554- mediaType ,
555- ByteString .encodeUtf8 (
556- "{\n \" Working___DocumentInfoRecordString\" : \" " + stringProperty + "\" \n }" ));
557- Request request =
558- new Request .Builder ()
559- .url (
560- "https://"
561- + appUrl
562- + "/odata/v4/"
563- + serviceName
564- + "/"
565- + entityName
566- + "_"
567- + facetName
568- + "(up__ID="
569- + entityID
570- + ",ID="
571- + ID
572- + ",IsActiveEntity=false)" )
573- .method ("PATCH" , body )
574- .addHeader ("Content-Type" , "application/json" )
575- .addHeader ("Authorization" , token )
576- .build ();
577-
578- try (Response updateResponse = httpClient .newCall (request ).execute ()) {
579- if (updateResponse .code () != 200 ) {
580- System .out .println (
581- "Updating secondary property failed. Error : " + updateResponse .body ().string ());
582- throw new IOException ("Secondary Property was not updated" );
583- }
584- return "Updated" ;
585- } catch (IOException e ) {
586- System .out .println ("Secondary Property was not updated : " + e );
587- return "Secondary Property was not updated" ;
588- }
589- }
590-
591- public String updateSecondaryProperty (
592- String appUrl ,
593- String serviceName ,
594- String entityName ,
595- String facetName ,
596- String entityID ,
597- String ID ,
598- Integer integerProperty ) {
599- MediaType mediaType = MediaType .parse ("application/json" );
600- RequestBody body =
601- RequestBody .create (
602- mediaType ,
603- ByteString .encodeUtf8 (
604- "{\n \" Working___DocumentInfoRecordInt\" : " + integerProperty + "\n }" ));
605- Request request =
606- new Request .Builder ()
607- .url (
608- "https://"
609- + appUrl
610- + "/odata/v4/"
611- + serviceName
612- + "/"
613- + entityName
614- + "_"
615- + facetName
616- + "(up__ID="
617- + entityID
618- + ",ID="
619- + ID
620- + ",IsActiveEntity=false)" )
621- .method ("PATCH" , body )
622- .addHeader ("Content-Type" , "application/json" )
623- .addHeader ("Authorization" , token )
624- .build ();
625-
626- try (Response updateResponse = httpClient .newCall (request ).execute ()) {
627- if (updateResponse .code () != 200 ) {
628- System .out .println (
629- "Updating secondary property failed. Error : " + updateResponse .body ().string ());
630- throw new IOException ("Secondary Property was not updated" );
631- }
632- return "Updated" ;
633- } catch (IOException e ) {
634- System .out .println ("Secondary Property was not updated : " + e );
635- return "Secondary Property was not updated" ;
636- }
637- }
638-
639- public String updateSecondaryProperty (
640- String appUrl ,
641- String serviceName ,
642- String entityName ,
643- String facetName ,
644- String entityID ,
645- String ID ,
646- LocalDateTime dateTimeProperty ) {
647- MediaType mediaType = MediaType .parse ("application/json" );
648- // Format the LocalDateTime into an ISO 8601 string with zone offset
649- ZonedDateTime zonedDateTime = dateTimeProperty .atZone (ZoneId .systemDefault ());
650- String formattedDateTime = zonedDateTime .format (DateTimeFormatter .ISO_OFFSET_DATE_TIME );
546+ RequestBody requestBody ) {
651547
652- RequestBody body =
653- RequestBody .create (
654- mediaType ,
655- ByteString .encodeUtf8 (
656- "{\n \" Working___DocumentInfoRecordDate\" : \" " + formattedDateTime + "\" \n }" ));
657548 Request request =
658549 new Request .Builder ()
659550 .url (
@@ -670,68 +561,20 @@ public String updateSecondaryProperty(
670561 + ",ID="
671562 + ID
672563 + ",IsActiveEntity=false)" )
673- .method ("PATCH" , body )
564+ .method ("PATCH" , requestBody )
674565 .addHeader ("Content-Type" , "application/json" )
675566 .addHeader ("Authorization" , token )
676567 .build ();
677568
678569 try (Response updateResponse = httpClient .newCall (request ).execute ()) {
679570 if (updateResponse .code () != 200 ) {
680571 System .out .println (
681- "Updating secondary property failed. Error : " + updateResponse .body ().string ());
572+ "Updating secondary property failed. Error: " + updateResponse .body ().string ());
682573 throw new IOException ("Secondary Property was not updated" );
683574 }
684575 return "Updated" ;
685576 } catch (IOException e ) {
686- System .out .println ("Secondary Property was not updated : " + e );
687- return "Secondary Property was not updated" ;
688- }
689- }
690-
691- public String updateSecondaryProperty (
692- String appUrl ,
693- String serviceName ,
694- String entityName ,
695- String facetName ,
696- String entityID ,
697- String ID ,
698- Boolean booleanProperty ) {
699- MediaType mediaType = MediaType .parse ("application/json" );
700- RequestBody body =
701- RequestBody .create (
702- mediaType ,
703- ByteString .encodeUtf8 (
704- "{\n \" Working___DocumentInfoRecordBoolean\" : " + booleanProperty + "\n }" ));
705- Request request =
706- new Request .Builder ()
707- .url (
708- "https://"
709- + appUrl
710- + "/odata/v4/"
711- + serviceName
712- + "/"
713- + entityName
714- + "_"
715- + facetName
716- + "(up__ID="
717- + entityID
718- + ",ID="
719- + ID
720- + ",IsActiveEntity=false)" )
721- .method ("PATCH" , body )
722- .addHeader ("Content-Type" , "application/json" )
723- .addHeader ("Authorization" , token )
724- .build ();
725-
726- try (Response updateResponse = httpClient .newCall (request ).execute ()) {
727- if (updateResponse .code () != 200 ) {
728- System .out .println (
729- "Updating secondary property failed. Error : " + updateResponse .body ().string ());
730- throw new IOException ("Secondary Property was not updated" );
731- }
732- return "Updated" ;
733- } catch (IOException e ) {
734- System .out .println ("Secondary Property was not updated : " + e );
577+ System .out .println ("Secondary Property was not updated: " + e );
735578 return "Secondary Property was not updated" ;
736579 }
737580 }
0 commit comments