1616import java .util .stream .Stream ;
1717
1818import static java .util .Collections .emptyList ;
19+ import static java .util .stream .Collectors .joining ;
1920
2021@ SuppressWarnings ("unchecked" )
2122public class RemoteManage implements Manage {
@@ -45,30 +46,39 @@ public List<Map<String, Object>> providers(EntityType... entityTypes) {
4546
4647 @ Override
4748 public List <Map <String , Object >> providersByIdIn (EntityType entityType , List <String > identifiers ) {
48- LOG .debug ("providersByIdIn: " + entityType );
49+ LOG .debug (String . format ( "providersByIdIn (%s) %s" , entityType , identifiers . stream (). collect ( joining ( ") (" , "(" , ")" ))) );
4950 if (CollectionUtils .isEmpty (identifiers )) {
51+ LOG .debug ("No identifiers in providersByIdIn" );
5052 return emptyList ();
5153 }
52- String param = identifiers .stream ().map (id -> String .format ("\" %s\" " , id )).collect (Collectors . joining ("," ));
54+ String param = identifiers .stream ().map (id -> String .format ("\" %s\" " , id )).collect (joining ("," ));
5355 String body = String .format ("{ \" id\" : { \" $in\" : [%s]}}" , param );
5456 String manageUrl = String .format ("%s/manage/api/internal/rawSearch/%s" , url , entityType .collectionName ());
5557 List <Map <String , Object >> providers = restTemplate .postForObject (manageUrl , body , List .class );
58+ if (providers != null ) {
59+ LOG .debug (String .format ("Got %d results for providersByIdIn" , providers .size ()));
60+ }
5661 return transformProvider (providers );
5762 }
5863
5964 @ Override
6065 public Optional <Map <String , Object >> providerByEntityID (EntityType entityType , String entityID ) {
61- LOG .debug ("providerByEntityID: " + entityType );
66+ LOG .debug (String .format ("providerByEntityID (%s) %s" , entityType , entityID ));
67+
6268 String body = String .format ("{\" data.entityid\" :\" %s\" }" , entityID );
6369 String manageUrl = String .format ("%s/manage/api/internal/rawSearch/%s" , url , entityType .collectionName ());
6470 List <Map <String , Object >> providers = restTemplate .postForObject (manageUrl , body , List .class );
6571 List <Map <String , Object >> allProviders = transformProvider (providers );
72+ if (allProviders != null ) {
73+ LOG .debug (String .format ("Got %d results for providerByEntityID" , allProviders .size ()));
74+ }
6675 return allProviders .isEmpty () ? Optional .empty () : Optional .of (allProviders .get (0 ));
6776 }
6877
6978 @ Override
7079 public Map <String , Object > providerById (EntityType entityType , String id ) {
71- LOG .debug ("providerById: " + entityType );
80+ LOG .debug (String .format ("providerById (%s) %s" , entityType , id ));
81+
7282 String queryUrl = String .format ("%s/manage/api/internal/metadata/%s/%s" , url , entityType .collectionName (), id );
7383 return transformProvider (restTemplate .getForEntity (queryUrl , Map .class ).getBody ());
7484 }
@@ -79,6 +89,7 @@ public List<Map<String, Object>> provisioning(Collection<String> applicationIden
7989 LOG .debug ("provisionings for identifiers" );
8090
8191 if (CollectionUtils .isEmpty (applicationIdentifiers )) {
92+ LOG .debug ("No applicationIdentifiers in provisioning" );
8293 return emptyList ();
8394 }
8495 String queryUrl = String .format ("%s/manage/api/internal/provisioning" , url );
@@ -89,6 +100,7 @@ public List<Map<String, Object>> provisioning(Collection<String> applicationIden
89100 public List <Map <String , Object >> providersAllowedByIdPs (List <Map <String , Object >> identityProviders ) {
90101 LOG .debug ("providersAllowedByIdPs" );
91102 if (identityProviders .isEmpty ()) {
103+ LOG .debug ("No identityProviders in providersAllowedByIdPs" );
92104 return emptyList ();
93105 }
94106 if (identityProviders .stream ()
@@ -100,7 +112,7 @@ public List<Map<String, Object>> providersAllowedByIdPs(List<Map<String, Object>
100112 .flatMap (Collection ::stream )
101113 .map (m -> "\" " + m .get ("name" ) + "\" " )
102114 .distinct ()
103- .collect (Collectors . joining ("," ));
115+ .collect (joining ("," ));
104116
105117 String body = String .format ("{\" data.entityid\" :{\" $in\" :[%s]}}" , split );
106118 List <Map <String , Object >> results = new ArrayList <>();
@@ -111,6 +123,7 @@ public List<Map<String, Object>> providersAllowedByIdPs(List<Map<String, Object>
111123 List <Map <String , Object >> transformedProviders = transformProvider (providers );
112124 results .addAll (transformedProviders );
113125 });
126+ LOG .debug (String .format ("Got %d results for providersAllowedByIdPs" , results .size ()));
114127 return results ;
115128 }
116129
@@ -135,6 +148,9 @@ public List<Map<String, Object>> identityProvidersByInstitutionalGUID(String org
135148 List <Map <String , Object >> identityProviders = restTemplate .postForObject (
136149 String .format ("%s/manage/api/internal/search/%s" , this .url , EntityType .SAML20_IDP .collectionName ()),
137150 baseQuery , List .class );
151+ if (identityProviders != null ) {
152+ LOG .debug (String .format ("Got %d results for identityProvidersByInstitutionalGUID" , identityProviders .size ()));
153+ }
138154 return transformProvider (identityProviders );
139155 }
140156
0 commit comments