@ -68,10 +68,58 @@ public class InformationSystemUtils {
}
}
public static void checkSSDPresent ( DefinitionItem definitionItem , String category , String scope )
throws Exception {
try {
if ( definitionItem = = null | | definitionItem . getClientId ( ) = = null
| | definitionItem . getClientId ( ) . isEmpty ( ) )
throw new Exception ( "Invalid definition: " + definitionItem ) ;
if ( category = = null | | category . isEmpty ( ) )
throw new Exception ( "Invalid category: " + category ) ;
if ( scope = = null | | scope . isEmpty ( ) )
throw new Exception ( "Invalid scope: " + scope ) ;
ScopeProvider . instance . set ( scope ) ;
// AccessTokenProvider.instance.set(token);
// SecurityTokenProvider.instance.set(token);
SimpleQuery query = ICFactory . queryFor ( ServiceEndpoint . class ) ;
query . addCondition ( "$resource/Profile/Category/text() eq '" + category + "'" )
. addCondition ( "$resource/Profile/Name/text() eq '" + definitionItem . getClientId ( ) + "'" ) ;
DiscoveryClient < ServiceEndpoint > client = ICFactory . clientFor ( ServiceEndpoint . class ) ;
List < ServiceEndpoint > resources = client . submit ( query ) ;
for ( ServiceEndpoint ssd : resources ) {
if ( definitionItem . getClientId ( ) . compareTo ( ssd . profile ( ) . name ( ) ) = = 0 ) {
StringBuilder error = new StringBuilder ( ) ;
error . append ( "System Service " ) ;
error . append ( definitionItem . getClientId ( ) ) ;
error . append ( " already present in the scope: " ) ;
error . append ( scope ) ;
logger . error ( error . toString ( ) ) ;
throw new Exception ( error . toString ( ) ) ;
}
}
logger . debug ( "System Service not already present on IS in scope: " + scope ) ;
return ;
} catch ( Throwable e ) {
logger . error ( e . getLocalizedMessage ( ) , e ) ;
throw e ;
}
}
public static ArrayList < DefinitionItem > retrieveSSD ( String category , String scope ) throws Exception {
try {
logger . debug ( "Retrieve System Services Definition on IS" ) ;
if ( category = = null | | category . isEmpty ( ) )
throw new Exception ( "Invalid category: " + category ) ;
if ( scope = = null | | scope . isEmpty ( ) )
throw new Exception ( "Invalid scope: " + scope ) ;
@ -134,6 +182,8 @@ public class InformationSystemUtils {
* token ) ;
* /
checkSSDPresent ( definitionItem , category , scope ) ;
IAMService iamService = retrieveIAMService ( scope ) ;
ServiceEndpoint toPublish = new ServiceEndpoint ( ) ;
@ -217,7 +267,7 @@ public class InformationSystemUtils {
List < ServiceEndpoint > resources = client . submit ( query ) ;
if ( resources ! = null & & ! resources . isEmpty ( ) ) {
ServiceEndpoint toDelete = resources . get ( 0 ) ;
ServiceEndpoint toDelete = resources . get ( 0 ) ;
logger . debug ( "Requested delete: {}" , toDelete ) ;
try {
@ -232,7 +282,7 @@ public class InformationSystemUtils {
logger . debug ( "Deleted on IS" ) ;
} else {
String error = "No resources found with name: " + definitionItem . getClientId ( ) ;
String error = "No resources found with name: " + definitionItem . getClientId ( ) ;
logger . error ( error ) ;
throw new Exception ( error ) ;
}