@Override public Collection<Application> getApplications() { return super.getApplications(); }
@Override public Collection<Application> getApplications() { return super.getApplications(); }
static List<Application> findApplicationsByUrl( Topology topology, String url ) { List<Application> foundApps = new ArrayList<>(); if( topology != null ) { url = Urls.trimLeadingAndTrailingSlash( url ); Collection<Application> searchApps = topology.getApplications(); if( searchApps != null ) { for( Application searchApp : searchApps ) { List<String> searchUrls = searchApp.getUrls(); if( searchUrls == null || searchUrls.isEmpty() ) { searchUrls = new ArrayList<>(1); searchUrls.add( searchApp.getName() ); } for( String searchUrl : searchUrls ) { if( url.equalsIgnoreCase( Urls.trimLeadingAndTrailingSlash( searchUrl ) ) ) { foundApps.add( searchApp ); break; } } } } } return foundApps; }
static List<Application> findApplicationsByUrl( Topology topology, String url ) { List<Application> foundApps = new ArrayList<>(); if( topology != null ) { url = Urls.trimLeadingAndTrailingSlash( url ); Collection<Application> searchApps = topology.getApplications(); if( searchApps != null ) { for( Application searchApp : searchApps ) { List<String> searchUrls = searchApp.getUrls(); if( searchUrls == null || searchUrls.isEmpty() ) { searchUrls = new ArrayList<>(1); searchUrls.add( searchApp.getName() ); } for( String searchUrl : searchUrls ) { if( url.equalsIgnoreCase( Urls.trimLeadingAndTrailingSlash( searchUrl ) ) ) { foundApps.add( searchApp ); break; } } } } } return foundApps; }
private static Map<String,ServiceDeploymentContributor> selectContextApplications( GatewayConfig config, Topology topology ) { Map<String,ServiceDeploymentContributor> contributors = new HashMap<>(); if( topology != null ) { for( Application application : topology.getApplications() ) { String name = application.getName(); if( name == null || name.isEmpty() ) { throw new DeploymentException( "Topologies cannot contain an application without a name." ); } ApplicationDeploymentContributor contributor = new ApplicationDeploymentContributor( config, application ); List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>( 1 ); urls.add( "/" + name ); } for( String url : urls ) { if( url == null || url.isEmpty() || url.equals( "/" ) ) { if( !topology.getServices().isEmpty() ) { throw new DeploymentException( String.format(Locale.ROOT, "Topologies with services cannot contain an application (%s) with a root url.", name ) ); } } contributors.put( url, contributor ); } } } return contributors; }
private static Map<String,ServiceDeploymentContributor> selectContextApplications( GatewayConfig config, Topology topology ) { Map<String,ServiceDeploymentContributor> contributors = new HashMap<>(); if( topology != null ) { for( Application application : topology.getApplications() ) { String name = application.getName(); if( name == null || name.isEmpty() ) { throw new DeploymentException( "Topologies cannot contain an application without a name." ); } ApplicationDeploymentContributor contributor = new ApplicationDeploymentContributor( config, application ); List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>( 1 ); urls.add( "/" + name ); } for( String url : urls ) { if( url == null || url.isEmpty() || "/".equals(url) ) { if( !topology.getServices().isEmpty() ) { throw new DeploymentException( String.format(Locale.ROOT, "Topologies with services cannot contain an application (%s) with a root url.", name ) ); } } contributors.put( url, contributor ); } } } return contributors; }
private synchronized void internalDeployApplications( Topology topology, File topoDir ) throws IOException, ZipException, ParserConfigurationException, TransformerException, SAXException { if( topology != null ) { Collection<Application> applications = topology.getApplications(); if( applications != null ) { for( Application application : applications ) { List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { internalDeployApplication( topology, topoDir, application, application.getName() ); } else { for( String url : urls ) { internalDeployApplication( topology, topoDir, application, url ); } } } } } }
private synchronized void internalDeployApplications( Topology topology, File topoDir ) throws IOException, ZipException, ParserConfigurationException, TransformerException, SAXException { if( topology != null ) { Collection<Application> applications = topology.getApplications(); if( applications != null ) { for( Application application : applications ) { List<String> urls = application.getUrls(); if( urls == null || urls.isEmpty() ) { internalDeployApplication( topoDir, application, application.getName() ); } else { for( String url : urls ) { internalDeployApplication( topoDir, application, url ); } } } } } }
static void validateNoAppsWithDuplicateUrlsInTopology( Topology topology ) { if( topology != null ) { Collection<Application> apps = topology.getApplications(); if( apps != null ) { for( Application app : apps ) { List<String> urls = app.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>(1); urls.add( app.getName() ); } for( String url : urls ) { List<Application> dups = findApplicationsByUrl( topology, url ); if( dups != null ) { for( Application dup : dups ) { if( dup != app ) { //NOPMD - check for exact same object throw new DeploymentException( "Topology " + topology.getName() + " contains applications " + app.getName() + " and " + dup.getName() + " with the same url: " + url ); } } } } } } } }
static void validateNoAppsWithDuplicateUrlsInTopology( Topology topology ) { if( topology != null ) { Collection<Application> apps = topology.getApplications(); if( apps != null ) { for( Application app : apps ) { List<String> urls = app.getUrls(); if( urls == null || urls.isEmpty() ) { urls = new ArrayList<>(1); urls.add( app.getName() ); } for( String url : urls ) { List<Application> dups = findApplicationsByUrl( topology, url ); if( dups != null ) { for( Application dup : dups ) { if( dup != app ) { throw new DeploymentException( "Topology " + topology.getName() + " contains applications " + app.getName() + " and " + dup.getName() + " with the same url: " + url ); } } } } } } } }
public static Topology getTopology( org.apache.knox.gateway.topology.Topology topology) { Topology topologyResource = new Topology(); topologyResource.setName(topology.getName()); topologyResource.setTimestamp(topology.getTimestamp()); topologyResource.setPath(topology.getDefaultServicePath()); topologyResource.setUri(topology.getUri()); topologyResource.setGenerated(topology.isGenerated()); for ( org.apache.knox.gateway.topology.Provider provider : topology.getProviders() ) { topologyResource.getProviders().add( getProvider(provider) ); } for ( org.apache.knox.gateway.topology.Service service : topology.getServices() ) { topologyResource.getServices().add( getService(service) ); } for ( org.apache.knox.gateway.topology.Application application : topology.getApplications() ) { topologyResource.getApplications().add( getApplication(application) ); } return topologyResource; }