idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
22,100 | @ Help ( help = "Get the PhysicalNetworkFunctionDescriptor with specific id of a NetworkServiceDescriptor with specific id" ) public PhysicalNetworkFunctionDescriptor getPhysicalNetworkFunctionDescriptor ( final String idNsd , final String idPnf ) throws SDKException { String url = idNsd + "/pnfdescriptors" + "/" + idPnf ; return ( PhysicalNetworkFunctionDescriptor ) requestGetWithStatusAccepted ( url , PhysicalNetworkFunctionDescriptor . class ) ; } | Returns a specific PhysicalNetworkFunctionDescriptor that is contained in a particular NetworkServiceDescriptor . |
22,101 | @ Help ( help = "Delete the PhysicalNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public void deletePhysicalNetworkFunctionDescriptor ( final String idNsd , final String idPnf ) throws SDKException { String url = idNsd + "/pnfdescriptors" + "/" + idPnf ; requestDelete ( url ) ; } | Delete a specific PhysicalNetworkFunctionDescriptor which is contained in a particular NetworkServiceDescriptor . |
22,102 | @ Help ( help = "Create the PhysicalNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public PhysicalNetworkFunctionDescriptor createPhysicalNetworkFunctionDescriptor ( final String idNsd , final PhysicalNetworkFunctionDescriptor physicalNetworkFunctionDescriptor ) throws SDKException { String url = idNsd + "/pnfdescriptors" ; return ( PhysicalNetworkFunctionDescriptor ) requestPost ( url , physicalNetworkFunctionDescriptor ) ; } | Create a new PhysicalNetworkFunctionDescriptor in a NetworkServiceDescriptor |
22,103 | @ Help ( help = "Update the PhysicalNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public PhysicalNetworkFunctionDescriptor updatePNFD ( final String idNsd , final String idPnf , final PhysicalNetworkFunctionDescriptor physicalNetworkFunctionDescriptor ) throws SDKException { String url = idNsd + "/pnfdescriptors" + "/" + idPnf ; return ( PhysicalNetworkFunctionDescriptor ) requestPut ( url , physicalNetworkFunctionDescriptor ) ; } | Update a PhysicalNetworkFunctionDescriptor . |
22,104 | @ Help ( help = "Get all the Security of a NetworkServiceDescriptor with specific id" ) public Security getSecurities ( final String idNsd ) throws SDKException { String url = idNsd + "/security" ; return ( ( Security ) requestGet ( url , Security . class ) ) ; } | Returns a List of all Security objects that are contained in a specific NetworkServiceDescriptor . |
22,105 | @ Help ( help = "Delete the Security of a NetworkServiceDescriptor with specific id" ) public void deleteSecurity ( final String idNsd , final String idSecurity ) throws SDKException { String url = idNsd + "/security" + "/" + idSecurity ; requestDelete ( url ) ; } | Delete a Security object . |
22,106 | @ Help ( help = "Create the Security of a NetworkServiceDescriptor with specific id" ) public Security createSecurity ( final String idNSD , final Security security ) throws SDKException { String url = idNSD + "/security" + "/" ; return ( Security ) requestPost ( url , security ) ; } | Add a new Security object to a NetworkServiceDescriptor . |
22,107 | @ Help ( help = "Update the Security of a NetworkServiceDescriptor with specific id" ) public Security updateSecurity ( final String idNSD , final String idSecurity , final Security updatedSecurity ) throws SDKException { String url = idNSD + "/security" + "/" + idSecurity ; return ( Security ) requestPut ( url , updatedSecurity ) ; } | Update a Security object of a specific NetworkServiceDescriptor . |
22,108 | private static SAXParser getSAXParser ( ) { SoftReference < SAXParser > ref = PARSER . get ( ) ; SAXParser result = ref . get ( ) ; if ( result == null ) { Exception thrown ; try { result = SAX_FACTORY . newSAXParser ( ) ; ref = new SoftReference < SAXParser > ( result ) ; PARSER . set ( ref ) ; return result ; } catch ( ParserConfigurationException ex ) { thrown = ex ; } catch ( SAXException ex ) { thrown = ex ; } throw ( new IllegalStateException ( "Could not create SAX parser" , thrown ) ) ; } else { result . reset ( ) ; return result ; } } | Gets a SAXParser for use in parsing incoming messages . |
22,109 | protected String resolveResourceContextPath ( HttpServletRequest request , String resource ) { final String resourceContextPath = this . getResourceServerContextPath ( ) ; this . logger . debug ( "Attempting to locate resource serving webapp with context path: {}" , resourceContextPath ) ; final ServletContext resourceContext = this . servletContext . getContext ( resourceContextPath ) ; if ( resourceContext == null || ! resourceContextPath . equals ( resourceContext . getContextPath ( ) ) ) { this . logger . warn ( "Could not find resource serving webapp under context path {} ensure the resource server is deployed and cross context dispatching is enable for this web application" , resourceContextPath ) ; return request . getContextPath ( ) ; } this . logger . debug ( "Found resource serving webapp at: {}" , resourceContextPath ) ; URL url = null ; try { url = resourceContext . getResource ( resource ) ; } catch ( MalformedURLException e ) { } if ( url == null ) { this . logger . debug ( "Resource serving webapp {} doesn't contain resource {} Falling back to the local resource." , resourceContextPath , resource ) ; return request . getContextPath ( ) ; } this . logger . debug ( "Resource serving webapp {} contains resource {} Using resource server." , resourceContextPath , resource ) ; return resourceContextPath ; } | If the resource serving servlet context is available and the resource is available in the context create a URL to the resource in that context . If not create a local URL for the requested resource . |
22,110 | protected String getResourceServerContextPath ( ) { final String resourceContextPath = this . servletContext . getInitParameter ( RESOURCE_CONTEXT_INIT_PARAM ) ; if ( resourceContextPath == null ) { return DEFAULT_RESOURCE_CONTEXT ; } if ( ! resourceContextPath . startsWith ( "/" ) ) { return "/" . concat ( resourceContextPath ) ; } return resourceContextPath ; } | Determine the context name of the resource serving webapp |
22,111 | private static TerminalBindingCondition create ( final String condition , final String message ) { return createWithCode ( condition , message , null ) ; } | Helper method to call the helper method to add entries . |
22,112 | private static TerminalBindingCondition createWithCode ( final String condition , final String message , final Integer code ) { if ( condition == null ) { throw ( new IllegalArgumentException ( "condition may not be null" ) ) ; } if ( message == null ) { throw ( new IllegalArgumentException ( "message may not be null" ) ) ; } if ( COND_TO_INSTANCE . get ( condition ) != null ) { throw ( new IllegalStateException ( "Multiple definitions of condition: " + condition ) ) ; } TerminalBindingCondition result = new TerminalBindingCondition ( condition , message ) ; COND_TO_INSTANCE . put ( condition , result ) ; if ( code != null ) { if ( CODE_TO_INSTANCE . get ( code ) != null ) { throw ( new IllegalStateException ( "Multiple definitions of code: " + code ) ) ; } CODE_TO_INSTANCE . put ( code , result ) ; } return result ; } | Helper method to add entries . |
22,113 | @ Help ( help = "Creates a new service" ) public String create ( String serviceName , List < String > roles ) throws SDKException { HashMap < String , Object > requestBody = new HashMap < > ( ) ; requestBody . put ( "name" , serviceName ) ; requestBody . put ( "roles" , roles ) ; return new String ( ( byte [ ] ) requestPost ( "create" , requestBody , MediaType . APPLICATION_OCTET_STREAM_VALUE , MediaType . APPLICATION_JSON_VALUE ) ) ; } | Creates a new service . |
22,114 | public static String getVersion ( String path , Class < ? > klass ) { try { final InputStream in = klass . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( in != null ) { try { final BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; String line = reader . readLine ( ) ; while ( line != null ) { if ( line . startsWith ( "version" ) ) { return line . split ( "=" ) [ 1 ] ; } line = reader . readLine ( ) ; } } finally { in . close ( ) ; } } } catch ( IOException e ) { LOG . error ( "Could not read package version using path " + path + ":" , e ) ; } return "unknown" ; } | Attempts to get a version property from a specified resource |
22,115 | public static BodyQName create ( final String uri , final String local ) { return createWithPrefix ( uri , local , null ) ; } | Creates a new qualified name using a namespace URI and local name . |
22,116 | public static BodyQName createWithPrefix ( final String uri , final String local , final String prefix ) { if ( uri == null || uri . length ( ) == 0 ) { throw ( new IllegalArgumentException ( "URI is required and may not be null/empty" ) ) ; } if ( local == null || local . length ( ) == 0 ) { throw ( new IllegalArgumentException ( "Local arg is required and may not be null/empty" ) ) ; } if ( prefix == null || prefix . length ( ) == 0 ) { return new BodyQName ( new QName ( uri , local ) ) ; } else { return new BodyQName ( new QName ( uri , local , prefix ) ) ; } } | Creates a new qualified name using a namespace URI and local name along with an optional prefix . |
22,117 | public static boolean methodsAreEqual ( Method m1 , Method m2 ) { if ( ! m1 . getName ( ) . equals ( m2 . getName ( ) ) ) return false ; if ( ! m1 . getReturnType ( ) . equals ( m2 . getReturnType ( ) ) ) return false ; if ( ! Objects . deepEquals ( m1 . getParameterTypes ( ) , m2 . getParameterTypes ( ) ) ) return false ; return true ; } | Returns true if the two passed methods are equal . Methods are in this case regarded as equal if they take the same parameter types return the same return type and share the same name . |
22,118 | @ Help ( help = "Create the object of type {#}" ) public T create ( final T object ) throws SDKException { return ( T ) requestPost ( object ) ; } | Sends a request for creating an instance of type T to the NFVO API . |
22,119 | @ Help ( help = "Find all the objects of type {#}" ) public List < T > findAll ( ) throws SDKException { return Arrays . asList ( ( T [ ] ) requestGet ( null , clazz ) ) ; } | Sends a request for finding all instances of type T to the NFVO API . |
22,120 | @ Help ( help = "Find the object of type {#} through the id" ) public T findById ( final String id ) throws SDKException { return ( T ) requestGet ( id , clazz ) ; } | Sends a request to the NFVO API for finding an instance of type T specified by it s ID . |
22,121 | @ Help ( help = "Update the object of type {#} passing the new object and the id of the old object" ) public T update ( final T object , final String id ) throws SDKException { return ( T ) requestPut ( id , object ) ; } | Sends a request to the NFVO API for updating an instance of type T specified by its ID . |
22,122 | public String requestPost ( final String id ) throws SDKException { CloseableHttpResponse response = null ; HttpPost httpPost = null ; checkToken ( ) ; try { log . debug ( "pathUrl: " + pathUrl ) ; log . debug ( "id: " + pathUrl + "/" + id ) ; log . debug ( "Executing post on: " + this . pathUrl + "/" + id ) ; httpPost = new HttpPost ( this . pathUrl + "/" + id ) ; preparePostHeader ( httpPost , "application/json" , "application/json" ) ; response = httpClient . execute ( httpPost ) ; RestUtils . checkStatus ( response , HttpURLConnection . HTTP_CREATED ) ; String result = "" ; if ( response . getEntity ( ) != null ) { result = EntityUtils . toString ( response . getEntity ( ) ) ; } closeResponseObject ( response ) ; log . trace ( "received: " + result ) ; httpPost . releaseConnection ( ) ; return result ; } catch ( IOException e ) { log . error ( e . getMessage ( ) , e ) ; if ( httpPost != null ) { httpPost . releaseConnection ( ) ; } throw new SDKException ( "Could not http-post or open the object properly" , e . getStackTrace ( ) , "Could not http-post or open the object properly because: " + e . getMessage ( ) ) ; } catch ( SDKException e ) { if ( response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_UNAUTHORIZED ) { token = null ; if ( httpPost != null ) { httpPost . releaseConnection ( ) ; } return requestPost ( id ) ; } else { if ( httpPost != null ) { httpPost . releaseConnection ( ) ; } try { throw new SDKException ( "Status is " + response . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , EntityUtils . toString ( response . getEntity ( ) ) ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; throw new SDKException ( "Status is " + response . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , "could not provide reason because: " + e . getMessage ( ) ) ; } } } } | Does the POST Request |
22,123 | private void preparePostHeader ( HttpPost httpPost , String acceptMimeType , String contentMimeType ) { if ( acceptMimeType != null && ! acceptMimeType . equals ( "" ) ) { httpPost . setHeader ( new BasicHeader ( "accept" , acceptMimeType ) ) ; } if ( contentMimeType != null && ! contentMimeType . equals ( "" ) ) { httpPost . setHeader ( new BasicHeader ( "Content-Type" , contentMimeType ) ) ; } httpPost . setHeader ( new BasicHeader ( "project-id" , projectId ) ) ; if ( token != null && bearerToken != null ) { httpPost . setHeader ( new BasicHeader ( "authorization" , bearerToken . replaceAll ( "\"" , "" ) ) ) ; } } | Add accept content - type projectId and token headers to an HttpPost object . |
22,124 | public VNFPackage requestPostPackage ( final File f ) throws SDKException { CloseableHttpResponse response = null ; HttpPost httpPost = null ; checkToken ( ) ; try { log . debug ( "Executing post on " + pathUrl ) ; httpPost = new HttpPost ( this . pathUrl ) ; preparePostHeader ( httpPost , "application/json" , null ) ; MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder . create ( ) ; multipartEntityBuilder . addBinaryBody ( "file" , f ) ; httpPost . setEntity ( multipartEntityBuilder . build ( ) ) ; response = httpClient . execute ( httpPost ) ; RestUtils . checkStatus ( response , HttpURLConnection . HTTP_OK ) ; String result = "" ; if ( response . getEntity ( ) != null ) { try { result = EntityUtils . toString ( response . getEntity ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; closeResponseObject ( response ) ; httpPost . releaseConnection ( ) ; if ( statusCode != HttpURLConnection . HTTP_NO_CONTENT ) { JsonParser jsonParser = new JsonParser ( ) ; JsonElement jsonElement = jsonParser . parse ( result ) ; result = mapper . toJson ( jsonElement ) ; log . debug ( "Uploaded the VNFPackage" ) ; log . trace ( "received: " + result ) ; log . trace ( "Casting it into: " + VNFPackage . class ) ; return mapper . fromJson ( result , VNFPackage . class ) ; } return null ; } catch ( IOException e ) { httpPost . releaseConnection ( ) ; throw new SDKException ( "Could not create VNFPackage from file " + f . getName ( ) , e . getStackTrace ( ) , e . getMessage ( ) ) ; } catch ( SDKException e ) { if ( response != null && response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_UNAUTHORIZED ) { token = null ; if ( httpPost != null ) { httpPost . releaseConnection ( ) ; } closeResponseObject ( response ) ; return requestPostPackage ( f ) ; } else { if ( httpPost != null ) { httpPost . releaseConnection ( ) ; } try { throw new SDKException ( "Status is " + response . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , EntityUtils . toString ( response . getEntity ( ) ) ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; throw new SDKException ( "Status is " + response . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , "could not provide reason because: " + e . getMessage ( ) ) ; } } } } | Used to upload tar files to the NFVO for creating VNFPackages . |
22,125 | public void requestDelete ( final String id ) throws SDKException { CloseableHttpResponse response = null ; HttpDelete httpDelete = null ; checkToken ( ) ; try { log . debug ( "pathUrl: " + pathUrl ) ; log . debug ( "id: " + pathUrl + "/" + id ) ; log . info ( "Executing delete on: " + this . pathUrl + "/" + id ) ; httpDelete = new HttpDelete ( this . pathUrl + "/" + id ) ; httpDelete . setHeader ( new BasicHeader ( "project-id" , projectId ) ) ; if ( token != null ) { httpDelete . setHeader ( new BasicHeader ( "authorization" , bearerToken . replaceAll ( "\"" , "" ) ) ) ; } response = httpClient . execute ( httpDelete ) ; RestUtils . checkStatus ( response , HttpURLConnection . HTTP_NO_CONTENT ) ; httpDelete . releaseConnection ( ) ; } catch ( IOException e ) { log . error ( e . getMessage ( ) , e ) ; if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } throw new SDKException ( "Could not http-delete" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } catch ( SDKException e ) { if ( response != null && ( response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_UNAUTHORIZED ) ) { token = null ; if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } requestDelete ( id ) ; return ; } throw new SDKException ( "Could not http-delete or the api response was wrong" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } finally { if ( httpDelete != null ) { httpDelete . releaseConnection ( ) ; } } } | Executes a http delete with to a given id |
22,126 | public Object requestGet ( final String id , Class type ) throws SDKException { String url = this . pathUrl ; if ( id != null ) { url += "/" + id ; return requestGetWithStatus ( url , null , type ) ; } else { return requestGetAll ( url , type , null ) ; } } | Executes a http get with to a given id |
22,127 | public Serializable requestPut ( final String id , final Serializable object ) throws SDKException { CloseableHttpResponse response = null ; HttpPut httpPut = null ; checkToken ( ) ; try { log . trace ( "Object is: " + object ) ; String fileJSONNode = mapper . toJson ( object ) ; log . debug ( "Executing put on: " + this . pathUrl + "/" + id ) ; httpPut = new HttpPut ( this . pathUrl + "/" + id ) ; httpPut . setHeader ( new BasicHeader ( "accept" , "application/json" ) ) ; httpPut . setHeader ( new BasicHeader ( "Content-Type" , "application/json" ) ) ; httpPut . setHeader ( new BasicHeader ( "project-id" , projectId ) ) ; if ( token != null ) { httpPut . setHeader ( new BasicHeader ( "authorization" , bearerToken . replaceAll ( "\"" , "" ) ) ) ; } httpPut . setEntity ( new StringEntity ( fileJSONNode ) ) ; response = httpClient . execute ( httpPut ) ; RestUtils . checkStatus ( response , HttpURLConnection . HTTP_ACCEPTED ) ; String result = "" ; if ( response . getEntity ( ) != null ) { result = EntityUtils . toString ( response . getEntity ( ) ) ; } if ( response . getStatusLine ( ) . getStatusCode ( ) != HttpURLConnection . HTTP_NO_CONTENT ) { closeResponseObject ( response ) ; httpPut . releaseConnection ( ) ; JsonParser jsonParser = new JsonParser ( ) ; JsonElement jsonElement = jsonParser . parse ( result ) ; result = mapper . toJson ( jsonElement ) ; log . trace ( "received: " + result ) ; log . trace ( "Casting it into: " + object . getClass ( ) ) ; return mapper . fromJson ( result , object . getClass ( ) ) ; } closeResponseObject ( response ) ; httpPut . releaseConnection ( ) ; return null ; } catch ( IOException e ) { log . error ( e . getMessage ( ) , e ) ; if ( httpPut != null ) { httpPut . releaseConnection ( ) ; } throw new SDKException ( "PUT request failed. Either the request failed or the provided object is incorrect" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } catch ( SDKException e ) { if ( response != null && response . getStatusLine ( ) . getStatusCode ( ) == HttpStatus . SC_UNAUTHORIZED ) { token = null ; if ( httpPut != null ) { httpPut . releaseConnection ( ) ; } return requestPut ( id , object ) ; } else { if ( httpPut != null ) { httpPut . releaseConnection ( ) ; } throw new SDKException ( "PUT request failed" , e . getStackTrace ( ) , e . getMessage ( ) ) ; } } finally { if ( httpPut != null ) { httpPut . releaseConnection ( ) ; } } } | Executes a http put with to a given id while serializing the object content as json and returning the response |
22,128 | static BOSHClientConnEvent createConnectionClosedOnErrorEvent ( final BOSHClient source , final List < ComposableBody > outstanding , final Throwable cause ) { return new BOSHClientConnEvent ( source , false , outstanding , cause ) ; } | Creates a connection closed on error event . This represents an unexpected termination of the client session . |
22,129 | boolean isAccepted ( final String name ) { for ( String str : charsets ) { if ( str . equalsIgnoreCase ( name ) ) { return true ; } } return false ; } | Determines whether or not the specified charset is supported . |
22,130 | private static XmlPullParser getXmlPullParser ( ) { SoftReference < XmlPullParser > ref = XPP_PARSER . get ( ) ; XmlPullParser result = ref . get ( ) ; if ( result == null ) { Exception thrown ; try { XmlPullParserFactory factory = XmlPullParserFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; factory . setValidating ( false ) ; result = factory . newPullParser ( ) ; ref = new SoftReference < XmlPullParser > ( result ) ; XPP_PARSER . set ( ref ) ; return result ; } catch ( Exception ex ) { thrown = ex ; } throw ( new IllegalStateException ( "Could not create XmlPull parser" , thrown ) ) ; } else { return result ; } } | Gets a XmlPullParser for use in parsing incoming messages . |
22,131 | public static StaticBody fromStream ( final InputStream inStream ) throws BOSHException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream ( ) ; try { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int read ; do { read = inStream . read ( buffer ) ; if ( read > 0 ) { byteOut . write ( buffer , 0 , read ) ; } } while ( read >= 0 ) ; } catch ( IOException iox ) { throw ( new BOSHException ( "Could not read body data" , iox ) ) ; } return fromString ( byteOut . toString ( ) ) ; } | Creates an instance which is initialized by reading a body message from the provided stream . |
22,132 | public static StaticBody fromString ( final String rawXML ) throws BOSHException { BodyParserResults results = PARSER . parse ( rawXML ) ; return new StaticBody ( results . getAttributes ( ) , rawXML ) ; } | Creates an instance which is initialized by reading a body message from the provided raw XML string . |
22,133 | @ Help ( help = "Create a VNFPackage by uploading a tar file" ) public VNFPackage create ( String filePath ) throws SDKException { log . debug ( "Start uploading a VNFPackage using the tar at path " + filePath ) ; File f = new File ( filePath ) ; if ( f == null || ! f . exists ( ) ) { log . error ( "No package: " + f . getName ( ) + " found!" ) ; throw new SDKException ( "No package: " + f . getName ( ) + " found!" , new StackTraceElement [ 0 ] , "File " + filePath + " not existing" ) ; } return requestPostPackage ( f ) ; } | Uploads a VNFPackage to the NFVO . |
22,134 | @ Help ( help = "Find a User by his name" ) public User findByName ( String name ) throws SDKException { return ( User ) requestGet ( name , User . class ) ; } | Returns a User specified by his username . |
22,135 | @ Help ( help = "Change a user's password" ) public void changePassword ( String oldPassword , String newPassword ) throws SDKException { HashMap < String , String > requestBody = new HashMap < > ( ) ; requestBody . put ( "old_pwd" , oldPassword ) ; requestBody . put ( "new_pwd" , newPassword ) ; requestPut ( "changepwd" , requestBody ) ; } | Changes a User s password . |
22,136 | @ Help ( help = "Generate a new Key in the NFVO" ) public String generateKey ( String name ) throws SDKException { return ( String ) requestPost ( "generate" , name ) ; } | Generate a new Key in the NFVO . |
22,137 | @ Help ( help = "Import a Key into the NFVO by providing name and public key" ) public Key importKey ( String name , String publicKey ) throws SDKException { Key key = new Key ( ) ; key . setName ( name ) ; key . setPublicKey ( publicKey ) ; return ( Key ) requestPost ( key ) ; } | Import a Key into the NFVO by providing name and public key . |
22,138 | private String computeXML ( ) { BodyQName bodyName = getBodyQName ( ) ; StringBuilder builder = new StringBuilder ( ) ; builder . append ( "<" ) ; builder . append ( bodyName . getLocalPart ( ) ) ; for ( Map . Entry < BodyQName , String > entry : attrs . entrySet ( ) ) { builder . append ( " " ) ; BodyQName name = entry . getKey ( ) ; String prefix = name . getPrefix ( ) ; if ( prefix != null && prefix . length ( ) > 0 ) { builder . append ( prefix ) ; builder . append ( ":" ) ; } builder . append ( name . getLocalPart ( ) ) ; builder . append ( "='" ) ; builder . append ( escape ( entry . getValue ( ) ) ) ; builder . append ( "'" ) ; } builder . append ( " " ) ; builder . append ( XMLConstants . XMLNS_ATTRIBUTE ) ; builder . append ( "='" ) ; builder . append ( bodyName . getNamespaceURI ( ) ) ; builder . append ( "'>" ) ; if ( payload != null ) { builder . append ( payload ) ; } builder . append ( "</body>" ) ; return builder . toString ( ) ; } | Generate a String representation of the message body . |
22,139 | protected File findFile ( final List < File > sourceDirectories , String resourceFileName ) throws IOException { for ( final File sourceDirectory : sourceDirectories ) { final File resourceFile = new File ( sourceDirectory , resourceFileName ) ; if ( resourceFile . exists ( ) ) { return resourceFile ; } } throw new IOException ( "Failed to find resource " + resourceFileName + " in any of the source directories: " + sourceDirectories ) ; } | Find the File for the resource file in the various source directories . |
22,140 | protected void logAggregation ( final Deque < ? extends BasicInclude > elements , final String fileName ) { if ( this . logger . isDebugEnabled ( ) ) { final StringBuilder msg = new StringBuilder ( "Aggregated " ) . append ( fileName ) . append ( " from " ) . append ( generatePathList ( elements ) ) ; this . logger . debug ( msg ) ; } } | Log the result of an aggregation |
22,141 | public AbstractBody getBody ( ) throws InterruptedException , BOSHException { if ( toThrow != null ) { throw ( toThrow ) ; } lock . lock ( ) ; try { if ( ! sent ) { awaitResponse ( ) ; } } finally { lock . unlock ( ) ; } return body ; } | Wait for and then return the response body . |
22,142 | public int getHTTPStatus ( ) throws InterruptedException , BOSHException { if ( toThrow != null ) { throw ( toThrow ) ; } lock . lock ( ) ; try { if ( ! sent ) { awaitResponse ( ) ; } } finally { lock . unlock ( ) ; } return statusCode ; } | Wait for and then return the response HTTP status code . |
22,143 | private synchronized void awaitResponse ( ) throws BOSHException { HttpEntity entity = null ; try { HttpResponse httpResp = client . execute ( post , context ) ; entity = httpResp . getEntity ( ) ; byte [ ] data = EntityUtils . toByteArray ( entity ) ; String encoding = entity . getContentEncoding ( ) != null ? entity . getContentEncoding ( ) . getValue ( ) : null ; if ( ZLIBCodec . getID ( ) . equalsIgnoreCase ( encoding ) ) { data = ZLIBCodec . decode ( data ) ; } else if ( GZIPCodec . getID ( ) . equalsIgnoreCase ( encoding ) ) { data = GZIPCodec . decode ( data ) ; } body = StaticBody . fromString ( new String ( data , CHARSET ) ) ; statusCode = httpResp . getStatusLine ( ) . getStatusCode ( ) ; sent = true ; } catch ( IOException iox ) { abort ( ) ; toThrow = new BOSHException ( "Could not obtain response" , iox ) ; throw ( toThrow ) ; } catch ( RuntimeException ex ) { abort ( ) ; throw ( ex ) ; } } | Await the response storing the result in the instance variables of this class when they arrive . |
22,144 | public void addBOSHClientConnListener ( final BOSHClientConnListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } connListeners . add ( listener ) ; } | Adds a connection listener to the session . |
22,145 | public void removeBOSHClientConnListener ( final BOSHClientConnListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } connListeners . remove ( listener ) ; } | Removes a connection listener from the session . |
22,146 | public void addBOSHClientRequestListener ( final BOSHClientRequestListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } requestListeners . add ( listener ) ; } | Adds a request message listener to the session . |
22,147 | public void removeBOSHClientRequestListener ( final BOSHClientRequestListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } requestListeners . remove ( listener ) ; } | Removes a request message listener from the session if previously added . |
22,148 | public void addBOSHClientResponseListener ( final BOSHClientResponseListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } responseListeners . add ( listener ) ; } | Adds a response message listener to the session . |
22,149 | public void removeBOSHClientResponseListener ( final BOSHClientResponseListener listener ) { if ( listener == null ) { throw ( new IllegalArgumentException ( NULL_LISTENER ) ) ; } responseListeners . remove ( listener ) ; } | Removes a response message listener from the session if previously added . |
22,150 | public void disconnect ( final ComposableBody msg ) throws BOSHException { if ( msg == null ) { throw ( new IllegalArgumentException ( "Message body may not be null" ) ) ; } Builder builder = msg . rebuild ( ) ; builder . setAttribute ( Attributes . TYPE , TERMINATE ) ; send ( builder . build ( ) ) ; } | End the BOSH session by disconnecting from the remote BOSH connection manager sending the provided content in the final connection termination message . |
22,151 | void drain ( ) { lock . lock ( ) ; try { LOG . finest ( "Waiting while draining..." ) ; while ( isWorking ( ) && ( emptyRequestFuture == null || emptyRequestFuture . isDone ( ) ) ) { try { drained . await ( ) ; } catch ( InterruptedException intx ) { LOG . log ( Level . FINEST , INTERRUPTED , intx ) ; } } LOG . finest ( "Drained" ) ; } finally { lock . unlock ( ) ; } } | Wait until no more messages are waiting to be processed . |
22,152 | private void init ( ) { assertUnlocked ( ) ; lock . lock ( ) ; try { httpSender . init ( cfg ) ; LOG . info ( "Starting with " + DEFAULT_REQ_PROC_COUNT + " request processors" ) ; procThreads = new RequestProcessor [ DEFAULT_REQ_PROC_COUNT ] ; for ( int i = 0 ; i < procThreads . length ; i ++ ) { procThreads [ i ] = new RequestProcessor ( i ) ; procThreads [ i ] . start ( ) ; } } finally { lock . unlock ( ) ; } } | Initialize the session . This initializes the underlying HTTP transport implementation and starts the receive thread . |
22,153 | private void dispose ( final Throwable cause ) { assertUnlocked ( ) ; lock . lock ( ) ; try { if ( procThreads == null ) { return ; } for ( RequestProcessor processor : procThreads ) { processor . dispose ( ) ; } procThreads = null ; } finally { lock . unlock ( ) ; } if ( cause == null ) { fireConnectionClosed ( ) ; } else { fireConnectionClosedOnError ( cause ) ; } lock . lock ( ) ; try { clearEmptyRequest ( ) ; exchanges = null ; cmParams = null ; pendingResponseAcks = null ; pendingRequestAcks = null ; notEmpty . signalAll ( ) ; notFull . signalAll ( ) ; drained . signalAll ( ) ; } finally { lock . unlock ( ) ; } httpSender . destroy ( ) ; schedExec . shutdownNow ( ) ; } | Destroy this session . |
22,154 | private TerminalBindingCondition getTerminalBindingCondition ( final int respCode , final AbstractBody respBody ) { assertLocked ( ) ; if ( isTermination ( respBody ) ) { String str = respBody . getAttribute ( Attributes . CONDITION ) ; return TerminalBindingCondition . forString ( str ) ; } if ( cmParams != null && cmParams . getVersion ( ) == null ) { return TerminalBindingCondition . forHTTPResponseCode ( respCode ) ; } return null ; } | Evaluates the HTTP response code and response message and returns the terminal binding condition that it describes if any . |
22,155 | private boolean isImmediatelySendable ( final AbstractBody msg ) { assertLocked ( ) ; if ( cmParams == null ) { return exchanges . isEmpty ( ) ; } AttrRequests requests = cmParams . getRequests ( ) ; if ( requests == null ) { return true ; } int maxRequests = requests . intValue ( ) ; if ( exchanges . size ( ) < maxRequests ) { return true ; } if ( exchanges . size ( ) == maxRequests && ( isTermination ( msg ) || isPause ( msg ) ) ) { return true ; } return false ; } | Determines if the message specified is immediately sendable or if it needs to block until the session state changes . |
22,156 | private void blockUntilSendable ( final AbstractBody msg ) { assertLocked ( ) ; while ( isWorking ( ) && ! isImmediatelySendable ( msg ) ) { try { notFull . await ( ) ; } catch ( InterruptedException intx ) { LOG . log ( Level . FINEST , INTERRUPTED , intx ) ; } } } | Blocks until either the message provided becomes immediately sendable or until the session is terminated . |
22,157 | private ComposableBody applySessionCreationRequest ( final long rid , final ComposableBody orig ) throws BOSHException { assertLocked ( ) ; Builder builder = orig . rebuild ( ) ; builder . setAttribute ( Attributes . TO , cfg . getTo ( ) ) ; builder . setAttribute ( Attributes . XML_LANG , cfg . getLang ( ) ) ; builder . setAttribute ( Attributes . VER , AttrVersion . getSupportedVersion ( ) . toString ( ) ) ; builder . setAttribute ( Attributes . WAIT , "60" ) ; builder . setAttribute ( Attributes . HOLD , "1" ) ; builder . setAttribute ( Attributes . RID , Long . toString ( rid ) ) ; applyRoute ( builder ) ; applyFrom ( builder ) ; if ( cfg . isAckEnabled ( ) ) { builder . setAttribute ( Attributes . ACK , "1" ) ; } builder . setAttribute ( Attributes . SID , null ) ; return builder . build ( ) ; } | Modifies the specified body message such that it becomes a new BOSH session creation request . |
22,158 | private void applyRoute ( final Builder builder ) { assertLocked ( ) ; String route = cfg . getRoute ( ) ; if ( route != null ) { builder . setAttribute ( Attributes . ROUTE , route ) ; } } | Applies routing information to the request message who s builder has been provided . |
22,159 | private void applyFrom ( final Builder builder ) { assertLocked ( ) ; String from = cfg . getFrom ( ) ; if ( from != null ) { builder . setAttribute ( Attributes . FROM , from ) ; } } | Applies the local station ID information to the request message who s builder has been provided . |
22,160 | private ComposableBody applySessionData ( final long rid , final ComposableBody orig ) throws BOSHException { assertLocked ( ) ; Builder builder = orig . rebuild ( ) ; builder . setAttribute ( Attributes . SID , cmParams . getSessionID ( ) . toString ( ) ) ; builder . setAttribute ( Attributes . RID , Long . toString ( rid ) ) ; if ( cfg . isAckEnabled ( ) ) { applyResponseAcknowledgement ( builder , rid ) ; } return builder . build ( ) ; } | Applies existing session data to the outbound request returning the modified request . |
22,161 | private void applyResponseAcknowledgement ( final Builder builder , final long rid ) { assertLocked ( ) ; if ( responseAck . equals ( Long . valueOf ( - 1L ) ) ) { return ; } Long prevRID = Long . valueOf ( rid - 1L ) ; if ( responseAck . equals ( prevRID ) ) { return ; } builder . setAttribute ( Attributes . ACK , responseAck . toString ( ) ) ; } | Sets the ack attribute of the request to the value of the highest rid of a request for which it has already received a response in the case where it has also received all responses associated with lower rid values . The only exception is that after its session creation request the client SHOULD NOT include an ack attribute in any request if it has received responses to all its previous requests . |
22,162 | private void processMessages ( int idx ) { LOG . finest ( "Processing thread " + idx + " starting..." ) ; try { HTTPExchange exch ; do { exch = nextExchange ( idx ) ; if ( exch == null ) { break ; } ExchangeInterceptor interceptor = exchInterceptor . get ( ) ; if ( interceptor != null ) { HTTPExchange newExch = interceptor . interceptExchange ( exch ) ; if ( newExch == null ) { LOG . log ( Level . FINE , "Discarding exchange on request " + "of test hook: RID=" + exch . getRequest ( ) . getAttribute ( Attributes . RID ) ) ; lock . lock ( ) ; try { exchanges . remove ( exch ) ; } finally { lock . unlock ( ) ; } continue ; } exch = newExch ; } processExchange ( idx , exch ) ; } while ( true ) ; } finally { LOG . log ( Level . FINEST , "Processing thread exiting: " + idx ) ; } } | While we are connected process received responses . |
22,163 | private HTTPExchange nextExchange ( int idx ) { assertUnlocked ( ) ; final Thread thread = Thread . currentThread ( ) ; HTTPExchange exch = null ; lock . lock ( ) ; try { do { if ( procThreads == null || ! thread . equals ( procThreads [ idx ] . procThread ) ) { break ; } exch = claimExchange ( idx ) ; if ( exch == null ) { try { notEmpty . await ( ) ; } catch ( InterruptedException intx ) { LOG . log ( Level . FINEST , INTERRUPTED , intx ) ; } } } while ( exch == null ) ; } finally { lock . unlock ( ) ; } return exch ; } | Get the next message exchange to process blocking until one becomes available if nothing is already waiting for processing . |
22,164 | private HTTPExchange claimExchange ( int idx ) { assertLocked ( ) ; HTTPExchange exch = null ; for ( HTTPExchange toClaim : exchanges ) { if ( findProcessorForExchange ( toClaim ) == null ) { exch = toClaim ; break ; } } if ( exch != null ) { procThreads [ idx ] . procExchange = exch ; if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "Thread " + idx + " claimed: " + exch . getRequest ( ) . getAttribute ( Attributes . RID ) ) ; } } else { if ( LOG . isLoggable ( Level . FINEST ) ) LOG . finest ( "Thread " + idx + " will wait for new request..." ) ; } return exch ; } | Finds and claims the exchange that has not been taken by other request processor . |
22,165 | private void adjustRequestProcessorsPool ( ) { assertLocked ( ) ; AttrRequests attrRequests = cmParams . getRequests ( ) ; int requests = attrRequests != null ? attrRequests . intValue ( ) : 2 ; if ( requests <= 1 && "1" . equals ( String . valueOf ( cmParams . getHold ( ) ) ) ) { LOG . warning ( "CM supports only 1 requests at a time and there is" + " a risk of connection being stuck up to " + cmParams . getWait ( ) + "seconds" ) ; } if ( requests > procThreads . length ) { RequestProcessor [ ] oldProcessors = procThreads ; procThreads = new RequestProcessor [ requests ] ; System . arraycopy ( oldProcessors , 0 , procThreads , 0 , oldProcessors . length ) ; for ( int i = oldProcessors . length ; i < requests ; i ++ ) { procThreads [ i ] = new RequestProcessor ( i ) ; procThreads [ i ] . start ( ) ; } } } | Checks the value of REQ attribute received from the CM and adjusts the size of the request processors pool . |
22,166 | private void scheduleEmptyRequest ( long delay ) { assertLocked ( ) ; if ( delay < 0L ) { throw ( new IllegalArgumentException ( "Empty request delay must be >= 0 (was: " + delay + ")" ) ) ; } clearEmptyRequest ( ) ; if ( ! isWorking ( ) ) { return ; } if ( LOG . isLoggable ( Level . FINER ) ) { LOG . finer ( "Scheduling empty request in " + delay + "ms" ) ; } try { emptyRequestFuture = schedExec . schedule ( emptyRequestRunnable , delay , TimeUnit . MILLISECONDS ) ; } catch ( RejectedExecutionException rex ) { LOG . log ( Level . FINEST , "Could not schedule empty request" , rex ) ; } drained . signalAll ( ) ; } | Schedule an empty request to be sent if no other requests are sent in a reasonable amount of time . |
22,167 | private void sendEmptyRequest ( ) { assertUnlocked ( ) ; LOG . finest ( "Sending empty request" ) ; try { send ( ComposableBody . builder ( ) . build ( ) ) ; } catch ( BOSHException boshx ) { dispose ( boshx ) ; } } | Sends an empty request to maintain session requirements . If a request is sent within a reasonable time window the empty request transmission will be cancelled . |
22,168 | private long processPauseRequest ( final AbstractBody req ) { assertLocked ( ) ; if ( cmParams != null && cmParams . getMaxPause ( ) != null ) { try { AttrPause pause = AttrPause . createFromString ( req . getAttribute ( Attributes . PAUSE ) ) ; if ( pause != null ) { long delay = pause . getInMilliseconds ( ) - PAUSE_MARGIN ; if ( delay < 0 ) { delay = EMPTY_REQUEST_DELAY ; } return delay ; } } catch ( BOSHException boshx ) { LOG . log ( Level . FINEST , "Could not extract" , boshx ) ; } } return getDefaultEmptyRequestDelay ( ) ; } | Process the request to determine if the empty request delay can be determined by looking to see if the request is a pause request . If it can the request s delay is returned otherwise the default delay is returned . |
22,169 | private void processRequestAcknowledgements ( final AbstractBody req , final AbstractBody resp ) { assertLocked ( ) ; if ( ! cmParams . isAckingRequests ( ) ) { return ; } if ( resp . getAttribute ( Attributes . REPORT ) != null ) { return ; } String acked = resp . getAttribute ( Attributes . ACK ) ; Long ackUpTo ; if ( acked == null ) { ackUpTo = Long . parseLong ( req . getAttribute ( Attributes . RID ) ) ; } else { ackUpTo = Long . parseLong ( acked ) ; } if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "Removing pending acks up to: " + ackUpTo ) ; } Iterator < ComposableBody > iter = pendingRequestAcks . iterator ( ) ; while ( iter . hasNext ( ) ) { AbstractBody pending = iter . next ( ) ; Long pendingRID = Long . parseLong ( pending . getAttribute ( Attributes . RID ) ) ; if ( pendingRID . compareTo ( ackUpTo ) <= 0 ) { iter . remove ( ) ; } } } | Check the response for request acknowledgements and take appropriate action . |
22,170 | private void processResponseAcknowledgementData ( final AbstractBody req ) { assertLocked ( ) ; Long rid = Long . parseLong ( req . getAttribute ( Attributes . RID ) ) ; if ( responseAck . equals ( Long . valueOf ( - 1L ) ) ) { responseAck = rid ; } else { pendingResponseAcks . add ( rid ) ; Long whileVal = Long . valueOf ( responseAck . longValue ( ) + 1 ) ; while ( ! pendingResponseAcks . isEmpty ( ) && whileVal . equals ( pendingResponseAcks . first ( ) ) ) { responseAck = whileVal ; pendingResponseAcks . remove ( whileVal ) ; whileVal = Long . valueOf ( whileVal . longValue ( ) + 1 ) ; } } } | Process the response in order to update the response acknowlegement data . |
22,171 | private HTTPExchange processResponseAcknowledgementReport ( final AbstractBody resp ) throws BOSHException { assertLocked ( ) ; String reportStr = resp . getAttribute ( Attributes . REPORT ) ; if ( reportStr == null ) { return null ; } Long report = Long . parseLong ( reportStr ) ; Long time = Long . parseLong ( resp . getAttribute ( Attributes . TIME ) ) ; if ( LOG . isLoggable ( Level . FINE ) ) { LOG . fine ( "Received report of missing request (RID=" + report + ", time=" + time + "ms)" ) ; } Iterator < ComposableBody > iter = pendingRequestAcks . iterator ( ) ; AbstractBody req = null ; while ( iter . hasNext ( ) && req == null ) { AbstractBody pending = iter . next ( ) ; Long pendingRID = Long . parseLong ( pending . getAttribute ( Attributes . RID ) ) ; if ( report . equals ( pendingRID ) ) { req = pending ; } } if ( req == null ) { throw ( new BOSHException ( "Report of missing message with RID '" + reportStr + "' but local copy of that request was not found" ) ) ; } HTTPExchange exch = new HTTPExchange ( req ) ; exchanges . add ( exch ) ; notEmpty . signal ( ) ; return exch ; } | Process the response in order to check for and respond to any potential ack reports . |
22,172 | private void fireRequestSent ( final AbstractBody request ) { assertUnlocked ( ) ; BOSHMessageEvent event = null ; for ( BOSHClientRequestListener listener : requestListeners ) { if ( event == null ) { event = BOSHMessageEvent . createRequestSentEvent ( this , request ) ; } try { listener . requestSent ( event ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , UNHANDLED , ex ) ; } } } | Notifies all request listeners that the specified request is being sent . |
22,173 | private void fireResponseReceived ( final AbstractBody response ) { assertUnlocked ( ) ; BOSHMessageEvent event = null ; for ( BOSHClientResponseListener listener : responseListeners ) { if ( event == null ) { event = BOSHMessageEvent . createResponseReceivedEvent ( this , response ) ; } try { listener . responseReceived ( event ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , UNHANDLED , ex ) ; } } } | Notifies all response listeners that the specified response has been received . |
22,174 | private void fireConnectionEstablished ( ) { final boolean hadLock = lock . isHeldByCurrentThread ( ) ; if ( hadLock ) { lock . unlock ( ) ; } try { BOSHClientConnEvent event = null ; for ( BOSHClientConnListener listener : connListeners ) { if ( event == null ) { event = BOSHClientConnEvent . createConnectionEstablishedEvent ( this ) ; } try { listener . connectionEvent ( event ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , UNHANDLED , ex ) ; } } } finally { if ( hadLock ) { lock . lock ( ) ; } } } | Notifies all connection listeners that the session has been successfully established . |
22,175 | private void fireConnectionClosed ( ) { assertUnlocked ( ) ; BOSHClientConnEvent event = null ; for ( BOSHClientConnListener listener : connListeners ) { if ( event == null ) { event = BOSHClientConnEvent . createConnectionClosedEvent ( this ) ; } try { listener . connectionEvent ( event ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , UNHANDLED , ex ) ; } } } | Notifies all connection listeners that the session has been terminated normally . |
22,176 | private void fireConnectionClosedOnError ( final Throwable cause ) { assertUnlocked ( ) ; BOSHClientConnEvent event = null ; for ( BOSHClientConnListener listener : connListeners ) { if ( event == null ) { event = BOSHClientConnEvent . createConnectionClosedOnErrorEvent ( this , pendingRequestAcks , cause ) ; } try { listener . connectionEvent ( event ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , UNHANDLED , ex ) ; } } } | Notifies all connection listeners that the session has been terminated due to the exceptional condition provided . |
22,177 | public static void checkStatus ( CloseableHttpResponse httpResponse , final int httpStatus ) throws SDKException { if ( httpResponse . getStatusLine ( ) . getStatusCode ( ) != httpStatus ) { log . error ( "Status expected: " + httpStatus + " obtained: " + httpResponse . getStatusLine ( ) . getStatusCode ( ) ) ; log . error ( "httpresponse: " + httpResponse . toString ( ) ) ; String body ; try { body = EntityUtils . toString ( httpResponse . getEntity ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw new SDKException ( "Status is " + httpResponse . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , "could not provide reason because: " + e . getMessage ( ) ) ; } log . error ( "Body: " + body ) ; throw new SDKException ( "Status is " + httpResponse . getStatusLine ( ) . getStatusCode ( ) , new StackTraceElement [ 0 ] , body ) ; } } | Check whether a json repsonse has the right http status . If not an SDKException is thrown . |
22,178 | public final Set < BodyQName > getAttributeNames ( ) { Map < BodyQName , String > attrs = getAttributes ( ) ; return Collections . unmodifiableSet ( attrs . keySet ( ) ) ; } | Get a set of all defined attribute names . |
22,179 | public final String getAttribute ( final BodyQName attr ) { Map < BodyQName , String > attrs = getAttributes ( ) ; return attrs . get ( attr ) ; } | Get the value of the specified attribute . |
22,180 | boolean isAccepted ( final String name ) { for ( String str : encodings ) { if ( str . equalsIgnoreCase ( name ) ) { return true ; } } return false ; } | Determines whether or not the specified encoding is supported . |
22,181 | public static String buildAuthHeader ( String username , String token ) { if ( username == null || "" . equals ( username ) ) { throw new IllegalArgumentException ( "Username must be specified" ) ; } if ( token == null || "" . equals ( token ) ) { throw new IllegalArgumentException ( "Token must be specified" ) ; } return String . format ( "Basic %s" , base64Encode ( ( username + ":" + token ) . getBytes ( Charset . forName ( "UTF-8" ) ) ) ) ; } | Builds a new HTTP Authorization header for Librato API requests |
22,182 | @ Help ( help = "Create NetworkServiceRecord from NetworkServiceDescriptor id" ) public NetworkServiceRecord create ( final String id , HashMap < String , ArrayList < String > > vduVimInstances , ArrayList < String > keys , HashMap < String , Configuration > configurations , String monitoringIp ) throws SDKException { HashMap < String , Serializable > jsonBody = new HashMap < > ( ) ; jsonBody . put ( "keys" , keys ) ; jsonBody . put ( "vduVimInstances" , vduVimInstances ) ; jsonBody . put ( "configurations" , configurations ) ; jsonBody . put ( "monitoringIp" , monitoringIp ) ; return ( NetworkServiceRecord ) this . requestPost ( id , jsonBody , NetworkServiceRecord . class ) ; } | Create a new NetworkServiceRecord from a NetworkServiceDescriptor . |
22,183 | @ Help ( help = "Get all the VirtualNetworkFunctionRecords of NetworkServiceRecord with specific id" ) public List < VirtualNetworkFunctionRecord > getVirtualNetworkFunctionRecords ( final String id ) throws SDKException { String url = id + "/vnfrecords" ; return Arrays . asList ( ( VirtualNetworkFunctionRecord [ ] ) requestGetAll ( url , VirtualNetworkFunctionRecord . class ) ) ; } | Returns a List of all the VirtualNetworkFunctionRecords that are contained in a NetworkServiceRecord . |
22,184 | @ Help ( help = "Get the VirtualNetworkFunctionRecord of NetworkServiceRecord with specific id" ) public VirtualNetworkFunctionRecord getVirtualNetworkFunctionRecord ( final String id , final String idVnfr ) throws SDKException { String url = id + "/vnfrecords" + "/" + idVnfr ; return ( VirtualNetworkFunctionRecord ) requestGet ( url , VirtualNetworkFunctionRecord . class ) ; } | Returns a specific VirtualNetworkFunctionRecord which is contained in a NetworkServiceRecord . |
22,185 | @ Help ( help = "Delete the VirtualNetworkFunctionRecord of NetworkServiceRecord with specific id" ) public void deleteVirtualNetworkFunctionRecord ( final String id , final String idVnfr ) throws SDKException { String url = id + "/vnfrecords" + "/" + idVnfr ; requestDelete ( url ) ; } | Deletes a specific VirtualNetworkFunctionRecord . |
22,186 | @ Help ( help = "Switch to standby" ) public void switchToStandby ( final String idNsr , final String idVnfr , final String idVdu , final String idVnfc , final VNFCInstance failedVnfcInstance ) throws SDKException { String url = idNsr + "/vnfrecords/" + idVnfr + "/vdunits/" + idVdu + "/vnfcinstances/" + idVnfc + "/switchtostandby" ; requestPost ( url , failedVnfcInstance ) ; } | Make a VNFCInstance switch into standby mode . |
22,187 | @ Help ( help = "Execute a specific action specified in the nfvMessage" ) public void postAction ( final String idNsr , final String idVnfr , final String idVdu , final String idVnfc , final NFVMessage nfvMessage ) throws SDKException { String url = idNsr + "/vnfrecords/" + idVnfr + "/vdunits/" + idVdu + "/vnfcinstances/" + idVnfc + "/actions" ; requestPost ( url , nfvMessage ) ; } | Trigger the execution of a specific LifecycleEvent on a VNFCInstance . Currently only the HEAL LifecycleEvent is supported . |
22,188 | @ Help ( help = "create VirtualNetworkFunctionRecord" ) public VirtualNetworkFunctionRecord createVNFR ( final String idNsr , final VirtualNetworkFunctionRecord virtualNetworkFunctionRecord ) throws SDKException { String url = idNsr + "/vnfrecords" ; return ( VirtualNetworkFunctionRecord ) requestPost ( url , virtualNetworkFunctionRecord ) ; } | Create a new VirtualNetworkFunctionRecord and add it to a NetworkServiceRecord . |
22,189 | @ Help ( help = "create VNFCInstance. Aka SCALE OUT" ) public void createVNFCInstance ( final String idNsr , final String idVnfr , final VNFComponent vnfComponent , ArrayList < String > vimInstanceNames ) throws SDKException { String url = idNsr + "/vnfrecords/" + idVnfr + "/vdunits/vnfcinstances" ; HashMap < String , Serializable > body = new HashMap < > ( ) ; body . put ( "vnfComponent" , vnfComponent ) ; body . put ( "vimInstanceNames" , vimInstanceNames ) ; requestPost ( url , body ) ; } | Create a new VNFCInstance from a VNFComponent without specifying the VirtualDeploymentUnit to which the VNFCInstance shall be added . This is also called a scale out operation . |
22,190 | @ Help ( help = "remove VNFCInstance. Aka SCALE IN" ) public void deleteVNFCInstance ( final String idNsr , final String idVnfr ) throws SDKException { String url = idNsr + "/vnfrecords/" + idVnfr + "/vdunits/vnfcinstances" ; requestDelete ( url ) ; } | Delete a VNFCInstance from a VirtualNetworkFunctionRecord . This operation is also called scaling in . This method does not require you to specify the VirtualDeploymentUnit from which a VNFCInstance shall be deleted . |
22,191 | @ Help ( help = "update VirtualNetworkFunctionRecord" ) public String updateVNFR ( final String idNsr , final String idVnfr , final VirtualNetworkFunctionRecord virtualNetworkFunctionRecord ) throws SDKException { String url = idNsr + "/vnfrecords" + "/" + idVnfr ; return requestPut ( url , virtualNetworkFunctionRecord ) . toString ( ) ; } | Updates a VirtualNetworkFunctionRecord . |
22,192 | @ Help ( help = "Get all the VirtualNetworkFunctionRecord dependencies of NetworkServiceRecord with specific id" ) public List < VNFRecordDependency > getVNFDependencies ( final String idNsr ) throws SDKException { String url = idNsr + "/vnfdependencies" ; return Arrays . asList ( ( VNFRecordDependency [ ] ) requestGetAll ( url , VNFRecordDependency . class ) ) ; } | Returns a List of all the VNFRecordDependencies contained in a particular NetworkServiceRecord . |
22,193 | @ Help ( help = "Get the VirtualNetworkFunctionRecord Dependency of a NetworkServiceRecord with specific id" ) public VNFRecordDependency getVNFDependency ( final String idNsr , final String idVnfrDep ) throws SDKException { String url = idNsr + "/vnfdependencies" + "/" + idVnfrDep ; return ( VNFRecordDependency ) requestGet ( url , VNFRecordDependency . class ) ; } | Returns a specific VNFRecordDependency from a particular NetworkServiceRecord . |
22,194 | @ Help ( help = "Delete the VirtualNetworkFunctionRecord Dependency of a NetworkServiceRecord with specific id" ) public void deleteVNFDependency ( final String idNsr , final String idVnfrDep ) throws SDKException { String url = idNsr + "/vnfdependencies" + "/" + idVnfrDep ; requestDelete ( url ) ; } | Deletes a specific VNFRecordDependency from a NetworkServiceRecord . |
22,195 | @ Help ( help = "Create the VirtualNetworkFunctionRecord Dependency of a NetworkServiceRecord with specific id" ) public VNFRecordDependency postVNFDependency ( final String idNsr , final VNFRecordDependency vnfRecordDependency ) throws SDKException { String url = idNsr + "/vnfdependencies" + "/" ; return ( VNFRecordDependency ) requestPost ( url , vnfRecordDependency ) ; } | Add a new VNFRecordDependency to a NetworkServiceRecord . |
22,196 | @ Help ( help = "Update the VirtualNetworkFunctionRecord Dependency of a NetworkServiceRecord with specific id" ) public VNFRecordDependency updateVNFDependency ( final String idNsr , final String idVnfrDep , final VNFRecordDependency vnfRecordDependency ) throws SDKException { String url = idNsr + "/vnfdependencies" + "/" + idVnfrDep ; return ( VNFRecordDependency ) requestPut ( url , vnfRecordDependency ) ; } | Update a VNFRecordDependency . |
22,197 | @ Help ( help = "Start the specified VNFC Instance" ) public void startVNFCInstance ( final String nsrId , final String vnfrId , final String vduId , final String vnfcInstanceId ) throws SDKException { String url = nsrId + "/vnfrecords/" + vnfrId + "/vdunits/" + vduId + "/vnfcinstances/" + vnfcInstanceId + "/start" ; requestPost ( url ) ; } | Start a specific VNFCInstance . |
22,198 | @ Help ( help = "Get all the PhysicalNetworkFunctionRecords of a specific NetworkServiceRecord with id" ) public List < PhysicalNetworkFunctionRecord > getPhysicalNetworkFunctionRecords ( final String idNsr ) throws SDKException { String url = idNsr + "/pnfrecords" ; return Arrays . asList ( ( PhysicalNetworkFunctionRecord [ ] ) requestGetAll ( url , PhysicalNetworkFunctionRecord . class ) ) ; } | Returns a List of all the PhysicalNetworkFunctionRecords that are contained in a particular NetworkServiceRecord . |
22,199 | @ Help ( help = "Get the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public PhysicalNetworkFunctionRecord getPhysicalNetworkFunctionRecord ( final String idNsr , final String idPnfr ) throws SDKException { String url = idNsr + "/pnfrecords" + "/" + idPnfr ; return ( PhysicalNetworkFunctionRecord ) requestGetWithStatusAccepted ( url , PhysicalNetworkFunctionRecord . class ) ; } | Returns a specific PhysicalNetworkFunctionRecord . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.