code
stringlengths
73
34.1k
label
stringclasses
1 value
@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 + "/pnfdes...
java
@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; requestDelet...
java
@Help( help = "Create the PhysicalNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public PhysicalNetworkFunctionDescriptor createPhysicalNetworkFunctionDescriptor( final String idNsd, final PhysicalNetworkFunctionDescriptor physicalNetworkFunctionDescriptor) throw...
java
@Help( help = "Update the PhysicalNetworkFunctionDescriptor of a NetworkServiceDescriptor with specific id" ) public PhysicalNetworkFunctionDescriptor updatePNFD( final String idNsd, final String idPnf, final PhysicalNetworkFunctionDescriptor physicalNetworkFunctionDescriptor) th...
java
@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)); }
java
@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); }
java
@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); }
java
@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(ur...
java
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>(resul...
java
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); //Try...
java
protected String getResourceServerContextPath() { final String resourceContextPath = this.servletContext.getInitParameter(RESOURCE_CONTEXT_INIT_PARAM); if (resourceContextPath == null) { // if no resource context path was defined in the web.xml, use the // default ret...
java
private static TerminalBindingCondition create( final String condition, final String message) { return createWithCode(condition, message, null); }
java
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 (messag...
java
@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[]) reques...
java
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)); ...
java
public static BodyQName create( final String uri, final String local) { return createWithPrefix(uri, local, null); }
java
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")); } ...
java
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; }
java
@Help(help = "Create the object of type {#}") public T create(final T object) throws SDKException { return (T) requestPost(object); }
java
@Help(help = "Find all the objects of type {#}") public List<T> findAll() throws SDKException { return Arrays.asList((T[]) requestGet(null, clazz)); }
java
@Help(help = "Find the object of type {#} through the id") public T findById(final String id) throws SDKException { return (T) requestGet(id, clazz); }
java
@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); }
java
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); // call the api here log.debug("Executing post on: " +...
java
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.s...
java
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...
java
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); // call the api here log.info("Executing delete on...
java
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); } }
java
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); // call the api here ...
java
static BOSHClientConnEvent createConnectionClosedOnErrorEvent( final BOSHClient source, final List<ComposableBody> outstanding, final Throwable cause) { return new BOSHClientConnEvent(source, false, outstanding, cause); }
java
boolean isAccepted(final String name) { for (String str : charsets) { if (str.equalsIgnoreCase(name)) { return true; } } return false; }
java
private static XmlPullParser getXmlPullParser() { SoftReference<XmlPullParser> ref = XPP_PARSER.get(); XmlPullParser result = ref.get(); if (result == null) { Exception thrown; try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); ...
java
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.rea...
java
public static StaticBody fromString( final String rawXML) throws BOSHException { BodyParserResults results = PARSER.parse(rawXML); return new StaticBody(results.getAttributes(), rawXML); }
java
@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()...
java
@Help(help = "Find a User by his name") public User findByName(String name) throws SDKException { return (User) requestGet(name, User.class); }
java
@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", requestBod...
java
@Help(help = "Generate a new Key in the NFVO") public String generateKey(String name) throws SDKException { return (String) requestPost("generate", name); }
java
@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); }
java
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(" "); ...
java
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; ...
java
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(generatePath...
java
public AbstractBody getBody() throws InterruptedException, BOSHException { if (toThrow != null) { throw(toThrow); } lock.lock(); try { if (!sent) { awaitResponse(); } } finally { lock.unlock(); } retu...
java
public int getHTTPStatus() throws InterruptedException, BOSHException { if (toThrow != null) { throw(toThrow); } lock.lock(); try { if (!sent) { awaitResponse(); } } finally { lock.unlock(); } return ...
java
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.g...
java
public void addBOSHClientConnListener( final BOSHClientConnListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } connListeners.add(listener); }
java
public void removeBOSHClientConnListener( final BOSHClientConnListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } connListeners.remove(listener); }
java
public void addBOSHClientRequestListener( final BOSHClientRequestListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } requestListeners.add(listener); }
java
public void removeBOSHClientRequestListener( final BOSHClientRequestListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } requestListeners.remove(listener); }
java
public void addBOSHClientResponseListener( final BOSHClientResponseListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } responseListeners.add(listener); }
java
public void removeBOSHClientResponseListener( final BOSHClientResponseListener listener) { if (listener == null) { throw(new IllegalArgumentException(NULL_LISTENER)); } responseListeners.remove(listener); }
java
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); s...
java
void drain() { lock.lock(); try { LOG.finest("Waiting while draining..."); while (isWorking() && (emptyRequestFuture == null || emptyRequestFuture.isDone())) { try { drained.await(); } cat...
java
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_CO...
java
private void dispose(final Throwable cause) { assertUnlocked(); lock.lock(); try { if (procThreads == null) { // Already disposed return; } for (RequestProcessor processor : procThreads) { processor.disp...
java
private TerminalBindingCondition getTerminalBindingCondition( final int respCode, final AbstractBody respBody) { assertLocked(); if (isTermination(respBody)) { String str = respBody.getAttribute(Attributes.CONDITION); return TerminalBindingCondition.forSt...
java
private boolean isImmediatelySendable(final AbstractBody msg) { assertLocked(); if (cmParams == null) { // block if we're waiting for a response to our first request return exchanges.isEmpty(); } AttrRequests requests = cmParams.getRequests(); if (reques...
java
private void blockUntilSendable(final AbstractBody msg) { assertLocked(); while (isWorking() && !isImmediatelySendable(msg)) { try { notFull.await(); } catch (InterruptedException intx) { LOG.log(Level.FINEST, INTERRUPTED, intx); } ...
java
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.get...
java
private void applyRoute(final Builder builder) { assertLocked(); String route = cfg.getRoute(); if (route != null) { builder.setAttribute(Attributes.ROUTE, route); } }
java
private void applyFrom(final Builder builder) { assertLocked(); String from = cfg.getFrom(); if (from != null) { builder.setAttribute(Attributes.FROM, from); } }
java
private ComposableBody applySessionData( final long rid, final ComposableBody orig) throws BOSHException { assertLocked(); Builder builder = orig.rebuild(); builder.setAttribute(Attributes.SID, cmParams.getSessionID().toString()); builder.setAttri...
java
private void applyResponseAcknowledgement( final Builder builder, final long rid) { assertLocked(); if (responseAck.equals(Long.valueOf(-1L))) { // We have not received any responses yet return; } Long prevRID = Long.valueOf(rid - 1L); ...
java
private void processMessages(int idx) { LOG.finest("Processing thread " + idx + " starting..."); try { HTTPExchange exch; do { exch = nextExchange(idx); if (exch == null) { break; } // Test hook ...
java
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].procThrea...
java
private HTTPExchange claimExchange(int idx) { assertLocked(); HTTPExchange exch = null; // Claim the exchange for (HTTPExchange toClaim : exchanges) { if (findProcessorForExchange(toClaim) == null) { exch = toClaim; break; } ...
java
private void adjustRequestProcessorsPool() { assertLocked(); AttrRequests attrRequests = cmParams.getRequests(); int requests = attrRequests != null ? attrRequests.intValue() : 2; // NOTE In polling mode with default WAIT=60 connection // w...
java
private void scheduleEmptyRequest(long delay) { assertLocked(); if (delay < 0L) { throw(new IllegalArgumentException( "Empty request delay must be >= 0 (was: " + delay + ")")); } clearEmptyRequest(); if (!isWorking()) { return; ...
java
private void sendEmptyRequest() { assertUnlocked(); // Send an empty request LOG.finest("Sending empty request"); try { send(ComposableBody.builder().build()); } catch (BOSHException boshx) { dispose(boshx); } }
java
private long processPauseRequest( final AbstractBody req) { assertLocked(); if (cmParams != null && cmParams.getMaxPause() != null) { try { AttrPause pause = AttrPause.createFromString( req.getAttribute(Attributes.PAUSE)); ...
java
private void processRequestAcknowledgements( final AbstractBody req, final AbstractBody resp) { assertLocked(); if (!cmParams.isAckingRequests()) { return; } // If a report or time attribute is set, we aren't acking anything if (resp.getAttribute...
java
private void processResponseAcknowledgementData( final AbstractBody req) { assertLocked(); Long rid = Long.parseLong(req.getAttribute(Attributes.RID)); if (responseAck.equals(Long.valueOf(-1L))) { // This is the first request responseAck = rid; ...
java
private HTTPExchange processResponseAcknowledgementReport( final AbstractBody resp) throws BOSHException { assertLocked(); String reportStr = resp.getAttribute(Attributes.REPORT); if (reportStr == null) { // No report on this message retur...
java
private void fireRequestSent(final AbstractBody request) { assertUnlocked(); BOSHMessageEvent event = null; for (BOSHClientRequestListener listener : requestListeners) { if (event == null) { event = BOSHMessageEvent.createRequestSentEvent(this, request); ...
java
private void fireResponseReceived(final AbstractBody response) { assertUnlocked(); BOSHMessageEvent event = null; for (BOSHClientResponseListener listener : responseListeners) { if (event == null) { event = BOSHMessageEvent.createResponseReceivedEvent( ...
java
private void fireConnectionEstablished() { final boolean hadLock = lock.isHeldByCurrentThread(); if (hadLock) { lock.unlock(); } try { BOSHClientConnEvent event = null; for (BOSHClientConnListener listener : connListeners) { if (event =...
java
private void fireConnectionClosed() { assertUnlocked(); BOSHClientConnEvent event = null; for (BOSHClientConnListener listener : connListeners) { if (event == null) { event = BOSHClientConnEvent.createConnectionClosedEvent(this); } try { ...
java
private void fireConnectionClosedOnError( final Throwable cause) { assertUnlocked(); BOSHClientConnEvent event = null; for (BOSHClientConnListener listener : connListeners) { if (event == null) { event = BOSHClientConnEvent .create...
java
public static void checkStatus(CloseableHttpResponse httpResponse, final int httpStatus) throws SDKException { if (httpResponse.getStatusLine().getStatusCode() != httpStatus) { log.error( "Status expected: " + httpStatus + " obtained: " + httpResponse...
java
public final Set<BodyQName> getAttributeNames() { Map<BodyQName, String> attrs = getAttributes(); return Collections.unmodifiableSet(attrs.keySet()); }
java
public final String getAttribute(final BodyQName attr) { Map<BodyQName, String> attrs = getAttributes(); return attrs.get(attr); }
java
boolean isAccepted(final String name) { for (String str : encodings) { if (str.equalsIgnoreCase(name)) { return true; } } return false; }
java
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...
java
@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 S...
java
@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( (VirtualNetworkFunctionRecor...
java
@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 (VirtualNetworkFunctionRec...
java
@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); }
java
@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/" + id...
java
@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 + "/vnfrecor...
java
@Help(help = "create VirtualNetworkFunctionRecord") public VirtualNetworkFunctionRecord createVNFR( final String idNsr, final VirtualNetworkFunctionRecord virtualNetworkFunctionRecord) throws SDKException { String url = idNsr + "/vnfrecords"; return (VirtualNetworkFunctionRecord) requestPost(url, ...
java
@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/vnfcinstance...
java
@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); }
java
@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, virtua...
java
@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[]) req...
java
@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 (VNFR...
java
@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); }
java
@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" + "/"; ...
java
@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 = id...
java
@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/" ...
java
@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( (Physical...
java
@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 (PhysicalNetwor...
java