@Test public void testGetApplicationBindings_inexistingApplication() throws Exception { Response resp = this.resource.getApplicationBindings( "inexisting" ); Assert.assertEquals( Status.NOT_FOUND.getStatusCode(), resp.getStatus()); }
@Override public Response getApplicationBindings( String applicationName ) { Response response; ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName ); if( ma == null ) { response = handleError( Status.NOT_FOUND, new RestError( REST_INEXISTING, application( applicationName )), lang( this.manager )).build(); } else { ApplicationBindings bindings = new ApplicationBindings(); for( Component c : ComponentHelpers.findAllComponents( ma.getApplication())) { for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( c ).values()) { if( ! var.isExternal()) continue; String prefix = VariableHelpers.parseVariableName( var.getName()).getKey(); bindings.prefixToItems.put( prefix, new ArrayList<ApplicationBindingItem> ()); } } for( ManagedApplication managedApp : this.manager.applicationMngr().getManagedApplications()) { String prefix = managedApp.getApplication().getTemplate().getExternalExportsPrefix(); if( prefix == null || ! bindings.prefixToItems.containsKey( prefix )) continue; Set<String> boundApps = ma.getApplication().getApplicationBindings().get( prefix ); boolean bound = boundApps != null && boundApps.contains( managedApp.getName()); ApplicationBindingItem item = new ApplicationBindingItem( managedApp.getName(), bound ); bindings.prefixToItems.get( prefix ).add( item ); } response = Response.ok().entity( bindings ).build(); } return response; }
ApplicationResource implements IApplicationResource { @Override public Response getApplicationBindings( String applicationName ) { Response response; ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName ); if( ma == null ) { response = handleError( Status.NOT_FOUND, new RestError( REST_INEXISTING, application( applicationName )), lang( this.manager )).build(); } else { ApplicationBindings bindings = new ApplicationBindings(); for( Component c : ComponentHelpers.findAllComponents( ma.getApplication())) { for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( c ).values()) { if( ! var.isExternal()) continue; String prefix = VariableHelpers.parseVariableName( var.getName()).getKey(); bindings.prefixToItems.put( prefix, new ArrayList<ApplicationBindingItem> ()); } } for( ManagedApplication managedApp : this.manager.applicationMngr().getManagedApplications()) { String prefix = managedApp.getApplication().getTemplate().getExternalExportsPrefix(); if( prefix == null || ! bindings.prefixToItems.containsKey( prefix )) continue; Set<String> boundApps = ma.getApplication().getApplicationBindings().get( prefix ); boolean bound = boundApps != null && boundApps.contains( managedApp.getName()); ApplicationBindingItem item = new ApplicationBindingItem( managedApp.getName(), bound ); bindings.prefixToItems.get( prefix ).add( item ); } response = Response.ok().entity( bindings ).build(); } return response; } }
ApplicationResource implements IApplicationResource { @Override public Response getApplicationBindings( String applicationName ) { Response response; ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName ); if( ma == null ) { response = handleError( Status.NOT_FOUND, new RestError( REST_INEXISTING, application( applicationName )), lang( this.manager )).build(); } else { ApplicationBindings bindings = new ApplicationBindings(); for( Component c : ComponentHelpers.findAllComponents( ma.getApplication())) { for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( c ).values()) { if( ! var.isExternal()) continue; String prefix = VariableHelpers.parseVariableName( var.getName()).getKey(); bindings.prefixToItems.put( prefix, new ArrayList<ApplicationBindingItem> ()); } } for( ManagedApplication managedApp : this.manager.applicationMngr().getManagedApplications()) { String prefix = managedApp.getApplication().getTemplate().getExternalExportsPrefix(); if( prefix == null || ! bindings.prefixToItems.containsKey( prefix )) continue; Set<String> boundApps = ma.getApplication().getApplicationBindings().get( prefix ); boolean bound = boundApps != null && boundApps.contains( managedApp.getName()); ApplicationBindingItem item = new ApplicationBindingItem( managedApp.getName(), bound ); bindings.prefixToItems.get( prefix ).add( item ); } response = Response.ok().entity( bindings ).build(); } return response; } ApplicationResource( Manager manager ); }
ApplicationResource implements IApplicationResource { @Override public Response getApplicationBindings( String applicationName ) { Response response; ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName ); if( ma == null ) { response = handleError( Status.NOT_FOUND, new RestError( REST_INEXISTING, application( applicationName )), lang( this.manager )).build(); } else { ApplicationBindings bindings = new ApplicationBindings(); for( Component c : ComponentHelpers.findAllComponents( ma.getApplication())) { for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( c ).values()) { if( ! var.isExternal()) continue; String prefix = VariableHelpers.parseVariableName( var.getName()).getKey(); bindings.prefixToItems.put( prefix, new ArrayList<ApplicationBindingItem> ()); } } for( ManagedApplication managedApp : this.manager.applicationMngr().getManagedApplications()) { String prefix = managedApp.getApplication().getTemplate().getExternalExportsPrefix(); if( prefix == null || ! bindings.prefixToItems.containsKey( prefix )) continue; Set<String> boundApps = ma.getApplication().getApplicationBindings().get( prefix ); boolean bound = boundApps != null && boundApps.contains( managedApp.getName()); ApplicationBindingItem item = new ApplicationBindingItem( managedApp.getName(), bound ); bindings.prefixToItems.get( prefix ).add( item ); } response = Response.ok().entity( bindings ).build(); } return response; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags ); }
ApplicationResource implements IApplicationResource { @Override public Response getApplicationBindings( String applicationName ) { Response response; ManagedApplication ma = this.manager.applicationMngr().findManagedApplicationByName( applicationName ); if( ma == null ) { response = handleError( Status.NOT_FOUND, new RestError( REST_INEXISTING, application( applicationName )), lang( this.manager )).build(); } else { ApplicationBindings bindings = new ApplicationBindings(); for( Component c : ComponentHelpers.findAllComponents( ma.getApplication())) { for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( c ).values()) { if( ! var.isExternal()) continue; String prefix = VariableHelpers.parseVariableName( var.getName()).getKey(); bindings.prefixToItems.put( prefix, new ArrayList<ApplicationBindingItem> ()); } } for( ManagedApplication managedApp : this.manager.applicationMngr().getManagedApplications()) { String prefix = managedApp.getApplication().getTemplate().getExternalExportsPrefix(); if( prefix == null || ! bindings.prefixToItems.containsKey( prefix )) continue; Set<String> boundApps = ma.getApplication().getApplicationBindings().get( prefix ); boolean bound = boundApps != null && boundApps.contains( managedApp.getName()); ApplicationBindingItem item = new ApplicationBindingItem( managedApp.getName(), bound ); bindings.prefixToItems.get( prefix ).add( item ); } response = Response.ok().entity( bindings ).build(); } return response; } ApplicationResource( Manager manager ); @Override Response changeInstanceState( String applicationName, String newState, String instancePath ); @Override Response setDescription( String applicationName, String desc ); @Override Response deployAndStartAll( String applicationName, String instancePath ); @Override Response stopAll( String applicationName, String instancePath ); @Override Response undeployAll( String applicationName, String instancePath ); @Override List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean allChildren ); @Override Response bindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response unbindApplication( String applicationName, String externalExportPrefix, String boundApp ); @Override Response replaceApplicationBindings( String applicationName, String externalExportPrefix, List<String> boundApps ); @Override Response getApplicationBindings( String applicationName ); @Override Response addInstance( String applicationName, String parentInstancePath, Instance instance ); @Override Response removeInstance( String applicationName, String instancePath ); @Override List<TargetAssociation> findTargetAssociations( String applicationName ); @Override Response resynchronize( String applicationName ); @Override List<Component> listComponents( String applicationName ); @Override List<Component> findComponentChildren( String applicationName, String componentName ); @Override List<Component> findComponentAncestors( String applicationName, String componentName ); @Override List<String> listCommands( String app ); @Override Response executeCommand( String app, String commandName ); @Override Response getCommandInstructions( String appName, String commandName ); @Override Response replaceTags( String name, String version, List<String> tags );  }