Search in sources :

Example 1 with FederatedServiceMap

use of org.platformlayer.service.federation.v1.FederatedServiceMap in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method buildFederationConfiguration.

// public static FederationMap buildFederationMap(HttpStrategy httpStrategy, TypedPlatformLayerClient localClient,
// TypedItemMapper mapper) throws OpsException {
// FederationConfiguration federationMapConfig = buildFederationConfiguration(localClient);
//
// FederationMap federationMap = new FederationMap(httpStrategy, mapper, federationMapConfig);
//
// if (localClient != null) {
// federationMap.addDefault(localClient);
// }
//
// return federationMap;
// }
public static FederationConfiguration buildFederationConfiguration(TypedPlatformLayerClient localClient) throws OpsException {
    FederationConfiguration federationMapConfig = new FederationConfiguration();
    String federationNamespace = "http://platformlayer.org/service/federation/v1.0";
    boolean federationEnabled = isServiceEnabled(localClient, federationNamespace);
    if (federationEnabled) {
        for (FederatedService service : localClient.listItems(FederatedService.class)) {
            PlatformLayerConnectionConfiguration config = new PlatformLayerConnectionConfiguration();
            config.key = service.getKey();
            config.secret = service.getSecret();
            config.authenticationEndpoint = service.getServer();
            config.tenant = service.getTenant();
            config.username = service.getUsername();
            config.platformlayerEndpoint = service.getServer();
            federationMapConfig.systems.add(config);
        }
        for (FederatedServiceMap map : localClient.listItems(FederatedServiceMap.class)) {
            FederationRule rule = new FederationRule();
            rule.target = map.getTarget();
            rule.serviceType = map.getServiceType();
            federationMapConfig.rules.add(rule);
        }
    }
    return federationMapConfig;
}
Also used : FederationConfiguration(org.platformlayer.federation.model.FederationConfiguration) PlatformLayerConnectionConfiguration(org.platformlayer.federation.model.PlatformLayerConnectionConfiguration) FederatedServiceMap(org.platformlayer.service.federation.v1.FederatedServiceMap) FederationRule(org.platformlayer.federation.model.FederationRule) FederatedService(org.platformlayer.service.federation.v1.FederatedService)

Aggregations

FederationConfiguration (org.platformlayer.federation.model.FederationConfiguration)1 FederationRule (org.platformlayer.federation.model.FederationRule)1 PlatformLayerConnectionConfiguration (org.platformlayer.federation.model.PlatformLayerConnectionConfiguration)1 FederatedService (org.platformlayer.service.federation.v1.FederatedService)1 FederatedServiceMap (org.platformlayer.service.federation.v1.FederatedServiceMap)1