code
stringlengths
73
34.1k
label
stringclasses
1 value
@Help( help = "Delete the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public void deletePhysicalNetworkFunctionRecord(final String idNsr, final String idPnfr) throws SDKException { String url = idNsr + "/pnfrecords" + "/" + idPnfr; requestDelete(url); }
java
@Help( help = "Create the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public PhysicalNetworkFunctionRecord postPhysicalNetworkFunctionRecord( final String idNsr, final PhysicalNetworkFunctionRecord physicalNetworkFunctionRecord) throws SDKException { String url = ...
java
@Help( help = "Update the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public PhysicalNetworkFunctionRecord updatePNFD( final String idNsr, final String idPnfr, final PhysicalNetworkFunctionRecord physicalNetworkFunctionRecord) throws SDKException { Str...
java
@Help(help = "Scales out/add a VNF to a running NetworkServiceRecord with specific id") public void restartVnfr(final String idNsr, final String idVnfr, String imageName) throws SDKException { HashMap<String, Serializable> jsonBody = new HashMap<>(); jsonBody.put("imageName", imageName); String url ...
java
@Help(help = "Upgrades a VNFR to a defined VNFD in a running NSR with specific id") public void upgradeVnfr(final String idNsr, final String idVnfr, final String idVnfd) throws SDKException { HashMap<String, Serializable> jsonBody = new HashMap<>(); jsonBody.put("vnfdId", idVnfd); String url = idNsr...
java
@Help(help = "Updates a VNFR to a defined VNFD in a running NSR with specific id") public void updateVnfr(final String idNsr, final String idVnfr) throws SDKException { String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/update"; requestPost(url); }
java
@Help( help = "Executes a script at runtime for a VNFR of a defined VNFD in a running NSR with specific id" ) public void executeScript(final String idNsr, final String idVnfr, String script) throws SDKException { String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/execute-script"; reque...
java
@Help( help = "Resumes a NSR that failed while executing a script in a VNFR. The id in the URL specifies the Network Service Record that will be resumed." ) public void resume(final String idNsr) throws SDKException { String url = idNsr + "/resume"; requestPost(url); }
java
public static Token[] parse(String text, boolean optimize) { if (text == null) { return null; } if (text.length() == 0) { Token t = new Token(text); return new Token[] { t }; } Token[] tokens = null; List<Token> tokenList = Tokenizer.to...
java
public static Token[] makeTokens(String text, boolean tokenize) { if (text == null) { return null; } Token[] tokens; if (tokenize) { tokens = parse(text); } else { tokens = new Token[1]; tokens[0] = new Token(text); } ...
java
public static List<Token> tokenize(CharSequence input, boolean textTrim) { if (input == null) { throw new IllegalArgumentException("input must not be null"); } int inputLen = input.length(); if (inputLen == 0) { List<Token> tokens = new ArrayList<>(1); ...
java
private static Token createToken(char symbol, StringBuilder nameBuf, StringBuilder valueBuf) { String value = null; if (valueBuf.length() > 0) { value = valueBuf.toString(); valueBuf.setLength(0); // empty the value buffer } if (nameBuf.length() > 0) { ...
java
public static Token[] optimize(Token[] tokens) { if (tokens == null) { return null; } String firstVal = null; String lastVal = null; if (tokens.length == 1) { if (tokens[0].getType() == TokenType.TEXT) { firstVal = tokens[0].getDefaultVal...
java
private static String trimLeadingWhitespace(String string) { if (string.isEmpty()) { return string; } int start = 0; char c; for (int i = 0; i < string.length(); i++) { c = string.charAt(i); if (!Character.isWhitespace(c)) { s...
java
private static String trimTrailingWhitespace(String string) { int end = 0; char c; for (int i = string.length() - 1; i >= 0; i--) { c = string.charAt(i); if (!Character.isWhitespace(c)) { end = i; break; } } if...
java
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (validating) { try { InputSource source = null; if (publicId != null) { String path = doctypeMap.get(publicId.toUpperCase()); ...
java
public static Pointcut createPointcut(PointcutRule pointcutRule) { if (pointcutRule.getPointcutType() == PointcutType.REGEXP) { return createRegexpPointcut(pointcutRule.getPointcutPatternRuleList()); } else { return createWildcardPointcut(pointcutRule.getPointcutPatternRuleList()...
java
@SuppressWarnings("rawtypes") protected String parseStringParameter(Map params, String paramName) { Object paramModel = params.get(paramName); if (paramModel == null) { return null; } if (!(paramModel instanceof SimpleScalar)) { throw new IllegalArgumentExcept...
java
@SuppressWarnings("rawtypes") protected String[] parseSequenceParameter(Map params, String paramName) throws TemplateModelException { Object paramModel = params.get(paramName); if (paramModel == null) { return null; } if (!(paramModel instanceof SimpleSequence)) { ...
java
private List<String> transformSimpleSequenceAsStringList(SimpleSequence sequence, String paramName) throws TemplateModelException { List<String> list = new ArrayList<>(); int size = sequence.size(); for (int i = 0; i < size; i++) { TemplateModel model = sequence.get(i); ...
java
public ItemRule newAttributeItemRule(String attributeName) { ItemRule itemRule = new ItemRule(); itemRule.setName(attributeName); addAttributeItemRule(itemRule); return itemRule; }
java
public static EchoActionRule newInstance(String id, Boolean hidden) { EchoActionRule echoActionRule = new EchoActionRule(); echoActionRule.setActionId(id); echoActionRule.setHidden(hidden); return echoActionRule; }
java
public static EnvironmentRule newInstance(String profile) { EnvironmentRule environmentRule = new EnvironmentRule(); environmentRule.setProfile(profile); return environmentRule; }
java
public String getName(Activity activity) { if (nameTokens != null && nameTokens.length > 0) { TokenEvaluator evaluator = new TokenExpression(activity); return evaluator.evaluateAsString(nameTokens); } else { return name; } }
java
public void setName(String name) { this.name = name; List<Token> tokens = Tokenizer.tokenize(name, true); int tokenCount = 0; for (Token t : tokens) { if (t.getType() != TokenType.TEXT) { tokenCount++; } } if (tokenCount > 0) { ...
java
public static DispatchRule replicate(DispatchRule dispatchRule) { DispatchRule dr = new DispatchRule(); dr.setName(dispatchRule.getName(), dispatchRule.getNameTokens()); dr.setContentType(dispatchRule.getContentType()); dr.setEncoding(dispatchRule.getEncoding()); dr.setDefaultRes...
java
@Override public Session newSession(String id) { long created = System.currentTimeMillis(); Session session = sessionCache.newSession(id, created, (defaultMaxIdleSecs > 0 ? defaultMaxIdleSecs * 1000L : -1)); try { sessionCache.put(id, session); sessionsCreatedStats.in...
java
private Session removeSession(String id) { try { Session session = sessionCache.delete(id); if (session != null) { session.beginInvalidate(); for (int i = sessionListeners.size() - 1; i >= 0; i--) { sessionListeners.get(i).sessionDestro...
java
@Override public void addEventListener(EventListener listener) { if (listener instanceof SessionListener) { sessionListeners.add((SessionListener)listener); } if (listener instanceof SessionAttributeListener) { sessionAttributeListeners.add((SessionAttributeListener)l...
java
@Override public void removeEventListener(EventListener listener) { if (listener instanceof SessionListener) { sessionListeners.remove(listener); } if (listener instanceof SessionAttributeListener) { sessionAttributeListeners.remove(listener); } }
java
private static String getMessage(Collection<Object> brokenReferences) { StringBuilder sb = new StringBuilder(); for (Object o : brokenReferences) { if (sb.length() > 0) { sb.append(", "); } sb.append(o); } return "Unable to resolve refe...
java
public void parse(RuleAppender ruleAppender) throws Exception { InputStream inputStream = null; try { ruleAppender.setNodeTracker(parser.getNodeTracker()); inputStream = ruleAppender.getInputStream(); InputSource inputSource = new InputSource(inputStream); ...
java
private void addDescriptionNodelets() { parser.setXpath("/aspectran/description"); parser.addNodelet(attrs -> { String style = attrs.get("style"); parser.pushObject(style); }); parser.addNodeEndlet(text -> { String style = parser.popObject(); ...
java
private void addSettingsNodelets() { parser.setXpath("/aspectran/settings"); parser.addNodeEndlet(text -> { assistant.applySettings(); }); parser.setXpath("/aspectran/settings/setting"); parser.addNodelet(attrs -> { String name = attrs.get("name"); ...
java
private void addTypeAliasNodelets() { parser.setXpath("/aspectran/typeAliases"); parser.addNodeEndlet(text -> { if (StringUtils.hasLength(text)) { Parameters parameters = new VariableParameters(text); for (String alias : parameters.getParameterNameSet()) { ...
java
private void addAppendNodelets() { parser.setXpath("/aspectran/append"); parser.addNodelet(attrs -> { String file = attrs.get("file"); String resource = attrs.get("resource"); String url = attrs.get("url"); String format = attrs.get("format"); ...
java
public static String getFullPath(String filename) { if (filename == null) { return null; } int index = indexOfLastSeparator(filename); if (index < 0) { return StringUtils.EMPTY; } return filename.substring(0, index); }
java
public static boolean isValidFileExtension(String filename, String allowedFileExtensions, String deniedFileExtensions) { if (filename == null) { return false; } String ext = getExtension(filename).toLowerCase(); if (allowedFileExtensions != null && !allowedFileExtensions.is...
java
public static File getUniqueFile(File srcFile, char extSeparator) throws IOException { if (srcFile == null) { throw new IllegalArgumentException("srcFile must not be null"); } String path = getFullPath(srcFile.getCanonicalPath()); String name = removeExtension(srcFile.getNam...
java
private void execute(Command command, CommandLineParser lineParser) { ConsoleWrapper wrappedConsole = new ConsoleWrapper(console); PrintWriter outputWriter = null; try { ParsedOptions options = lineParser.parseOptions(command.getOptions()); outputWriter = OutputRedirectio...
java
private void execute(TransletCommandLine transletCommandLine) { if (transletCommandLine.getRequestName() != null) { try { service.translate(transletCommandLine, console); } catch (TransletNotFoundException e) { console.writeError("No command or translet ma...
java
public void setBeanClass(Class<?> beanClass) { this.beanClass = beanClass; this.className = beanClass.getName(); this.factoryBean = FactoryBean.class.isAssignableFrom(beanClass); this.disposableBean = DisposableBean.class.isAssignableFrom(beanClass); this.initializableBean = Init...
java
public ItemRule newConstructorArgumentItemRule() { ItemRule itemRule = new ItemRule(); itemRule.setAutoNamed(true); addConstructorArgumentItemRule(itemRule); return itemRule; }
java
public void addConstructorArgumentItemRule(ItemRule constructorArgumentItemRule) { if (constructorArgumentItemRuleMap == null) { constructorArgumentItemRuleMap = new ItemRuleMap(); } constructorArgumentItemRuleMap.putItemRule(constructorArgumentItemRule); }
java
public ItemRule newPropertyItemRule(String propertyName) { ItemRule itemRule = new ItemRule(); itemRule.setName(propertyName); addPropertyItemRule(itemRule); return itemRule; }
java
public void addPropertyItemRule(ItemRule propertyItemRule) { if (propertyItemRuleMap == null) { propertyItemRuleMap = new ItemRuleMap(); } propertyItemRuleMap.putItemRule(propertyItemRule); }
java
public void speak(String text) { if (voice == null) { throw new IllegalStateException("Cannot find a voice named " + voiceName); } voice.speak(text); }
java
protected ActivityContext createActivityContext(ContextRuleAssistant assistant) throws BeanReferenceException, IllegalRuleException { initContextEnvironment(assistant); AspectranActivityContext activityContext = new AspectranActivityContext(assistant.getContextEnvironment()); Aspec...
java
private void initAspectRuleRegistry(ContextRuleAssistant assistant) { AspectRuleRegistry aspectRuleRegistry = assistant.getAspectRuleRegistry(); BeanRuleRegistry beanRuleRegistry = assistant.getBeanRuleRegistry(); TransletRuleRegistry transletRuleRegistry = assistant.getTransletRuleRegistry(); ...
java
public String getPath(Activity activity) { if (pathTokens != null && pathTokens.length > 0) { TokenEvaluator evaluator = new TokenExpression(activity); return evaluator.evaluateAsString(pathTokens); } else { return path; } }
java
public void setPath(String path) { this.path = path; List<Token> tokens = Tokenizer.tokenize(path, true); int tokenCount = 0; for (Token t : tokens) { if (t.getType() != TokenType.TEXT) { tokenCount++; } } if (tokenCount > 0) { ...
java
public ItemRule newParameterItemRule(String parameterName) { ItemRule itemRule = new ItemRule(); itemRule.setName(parameterName); addParameterItemRule(itemRule); return itemRule; }
java
public void addParameterItemRule(ItemRule parameterItemRule) { if (parameterItemRuleMap == null) { parameterItemRuleMap = new ItemRuleMap(); } parameterItemRuleMap.putItemRule(parameterItemRule); }
java
public void setParameters(Map<String, String> parameters) { if (parameters == null || parameters.isEmpty()) { this.parameterItemRuleMap = null; } else { ItemRuleMap itemRuleMap = new ItemRuleMap(); for (Map.Entry<String, String> entry : parameters.entrySet()) { ...
java
protected String formatMessage(String msg, Object[] args, Locale locale) { if (msg == null || (!this.alwaysUseMessageFormat && (args == null || args.length == 0))) { return msg; } MessageFormat messageFormat = null; synchronized (this.messageFormatsPerMessage) { M...
java
protected MessageFormat createMessageFormat(String msg, Locale locale) { return new MessageFormat((msg != null ? msg : ""), locale); }
java
public static <T> T createInstance(Class<T> cls) { Constructor<T> ctor; try { ctor = findConstructor(cls); } catch (NoSuchMethodException e) { throw new IllegalArgumentException("Class " + cls.getName() + " has no default (no arg) constructor"); ...
java
public static <T> T createInstance(Class<T> cls, Object... args) { Class<?>[] argTypes = new Class<?>[args.length]; for (int i = 0; i < args.length; i++) { argTypes[i] = args[i].getClass(); } return createInstance(cls, args, argTypes); }
java
public static <T> Constructor<T> findConstructor(Class<T> cls, Class<?>... argTypes) throws NoSuchMethodException { Constructor<T> ctor; try { ctor = cls.getDeclaredConstructor(argTypes); } catch (NoSuchMethodException e) { throw e; } catch (Exception ...
java
private static boolean isLoadable(Class<?> clazz, ClassLoader classLoader) { try { return (clazz == classLoader.loadClass(clazz.getName())); // Else: different class with same name found } catch (ClassNotFoundException ex) { // No corresponding class found at all ...
java
public static Object invokeExactStaticMethod(Class<?> objectClass, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { return invokeExactStaticMethod(objectClass, methodName, EMPTY_OBJECT_ARRAY, EMPTY_CLASS_PARAMETERS); }
java
private RequestContext createRequestContext(final HttpServletRequest req) { return new RequestContext() { @Override public String getCharacterEncoding() { return req.getCharacterEncoding(); } @Override public String getContentType() { ...
java
public boolean matches(CharSequence input) { separatorCount = -1; separatorIndex = 0; if (input == null) { this.input = null; separatorFlags = null; return false; } this.input = input; separatorFlags = new int[input.length()]; ...
java
private boolean isProfileActive(String profile) { validateProfile(profile); Set<String> currentActiveProfiles = doGetActiveProfiles(); return (currentActiveProfiles.contains(profile) || (currentActiveProfiles.isEmpty() && doGetDefaultProfiles().contains(profile))); }
java
protected void indent() throws IOException { if (prettyPrint) { for (int i = 0; i < indentDepth; i++) { writer.write(indentString); } } }
java
public JsonWriter writeName(String name) throws IOException { indent(); writer.write(escape(name)); writer.write(":"); if (prettyPrint) { writer.write(" "); } willWriteValue = true; return this; }
java
public JsonWriter openSquareBracket() throws IOException { if (!willWriteValue) { indent(); } writer.write("["); nextLine(); indentDepth++; willWriteValue = false; return this; }
java
public static String stringify(Object object, boolean prettyPrint) throws IOException { if (prettyPrint) { return stringify(object, DEFAULT_INDENT_STRING); } else { return stringify(object, null); } }
java
public static String stringify(Object object, String indentString) throws IOException { if (object == null) { return null; } Writer out = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(out, indentString); jsonWriter.write(object); jsonWriter.close(...
java
public void putSetting(String name, String value) throws IllegalRuleException { if (StringUtils.isEmpty(name)) { throw new IllegalRuleException("Default setting name can not be null"); } DefaultSettingType settingType = DefaultSettingType.resolve(name); if (settingType == nul...
java
public String resolveAliasType(String alias) { String type = getAliasedType(alias); return (type == null ? alias: type); }
java
private void setAssistantLocal(AssistantLocal newAssistantLocal) { this.assistantLocal = newAssistantLocal; scheduleRuleRegistry.setAssistantLocal(newAssistantLocal); transletRuleRegistry.setAssistantLocal(newAssistantLocal); templateRuleRegistry.setAssistantLocal(newAssistantLocal); ...
java
public AssistantLocal backupAssistantLocal() { AssistantLocal oldAssistantLocal = assistantLocal; AssistantLocal newAssistantLocal = assistantLocal.replicate(); setAssistantLocal(newAssistantLocal); return oldAssistantLocal; }
java
public void resolveAdviceBeanClass(AspectRule aspectRule) throws IllegalRuleException { String beanIdOrClass = aspectRule.getAdviceBeanId(); if (beanIdOrClass != null) { Class<?> beanClass = resolveBeanClass(beanIdOrClass, aspectRule); if (beanClass != null) { asp...
java
public void resolveActionBeanClass(BeanMethodActionRule beanMethodActionRule) throws IllegalRuleException { String beanIdOrClass = beanMethodActionRule.getBeanId(); if (beanIdOrClass != null) { Class<?> beanClass = resolveBeanClass(beanIdOrClass, beanMethodActionRule); if (beanCl...
java
public void resolveFactoryBeanClass(BeanRule beanRule) throws IllegalRuleException { String beanIdOrClass = beanRule.getFactoryBeanId(); if (beanRule.isFactoryOffered() && beanIdOrClass != null) { Class<?> beanClass = resolveBeanClass(beanIdOrClass, beanRule); if (beanClass != nu...
java
public void resolveBeanClass(ItemRule itemRule) throws IllegalRuleException { Iterator<Token[]> it = ItemRule.tokenIterator(itemRule); if (it != null) { while (it.hasNext()) { Token[] tokens = it.next(); if (tokens != null) { for (Token tok...
java
public void resolveBeanClass(Token[] tokens) throws IllegalRuleException { if (tokens != null) { for (Token token : tokens) { resolveBeanClass(token); } } }
java
public void resolveBeanClass(AutowireRule autowireRule) throws IllegalRuleException { if (autowireRule.getTargetType() == AutowireTargetType.FIELD) { if (autowireRule.isRequired()) { Class<?>[] types = autowireRule.getTypes(); String[] qualifiers = autowireRule.getQua...
java
public void resolveBeanClass(ScheduleRule scheduleRule) throws IllegalRuleException { String beanId = scheduleRule.getSchedulerBeanId(); if (beanId != null) { Class<?> beanClass = resolveBeanClass(beanId, scheduleRule); if (beanClass != null) { scheduleRule.setSch...
java
public void resolveBeanClass(TemplateRule templateRule) throws IllegalRuleException { String beanId = templateRule.getEngineBeanId(); if (beanId != null) { Class<?> beanClass = resolveBeanClass(beanId, templateRule); if (beanClass != null) { templateRule.setEngine...
java
public Collection<BeanRule> getBeanRules() { Collection<BeanRule> idBasedBeanRules = beanRuleRegistry.getIdBasedBeanRules(); Collection<Set<BeanRule>> typeBasedBeanRules = beanRuleRegistry.getTypeBasedBeanRules(); Collection<BeanRule> configurableBeanRules = beanRuleRegistry.getConfigurableBeanR...
java
@Override protected MessageFormat resolveCode(String code, Locale locale) { MessageFormat messageFormat = null; for (int i = 0; messageFormat == null && i < this.basenames.length; i++) { ResourceBundle bundle = getResourceBundle(this.basenames[i], locale); if (bundle != null)...
java
protected ResourceBundle getResourceBundle(String basename, Locale locale) { if (this.cacheMillis >= 0) { // Fresh ResourceBundle.getBundle call in order to let ResourceBundle // do its native caching, at the expense of more extensive lookup steps. return doGetBundle(basename...
java
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException { return ResourceBundle.getBundle(basename, locale, getClassLoader(), new MessageSourceControl()); }
java
protected MessageFormat getMessageFormat(ResourceBundle bundle, String code, Locale locale) throws MissingResourceException { Map<String, Map<Locale, MessageFormat>> codeMap = this.cachedBundleMessageFormats.get(bundle); Map<Locale, MessageFormat> localeMap = null; if (codeMap != nul...
java
public void addNodelet(String xpath, NodeletAdder nodeletAdder) { nodeletAdder.add(xpath, this); setXpath(xpath); }
java
private void parseMultipartFormData() { String multipartFormDataParser = getSetting(MULTIPART_FORM_DATA_PARSER_SETTING_NAME); if (multipartFormDataParser == null) { throw new MultipartRequestParseException("The setting name 'multipartFormDataParser' for multipart " + "for...
java
@Override public String getHeader(String name) { return (headers != null ? headers.getFirst(name) : null); }
java
@Override public Collection<String> getHeaders(String name) { return (headers != null ? headers.get(name) : null); }
java
@Override public void setHeader(String name, String value) { touchHeaders().set(name, value); }
java
@Override public void addHeader(String name, String value) { touchHeaders().add(name, value); }
java
private void setInactivityTimer(long ms) { if (sessionInactivityTimer == null) { sessionInactivityTimer = new SessionInactivityTimer(sessionHandler.getScheduler(), this); } sessionInactivityTimer.setIdleTimeout(ms); }
java
protected void stopInactivityTimer() { try (Lock ignored = locker.lockIfNotHeld()) { if (sessionInactivityTimer != null) { sessionInactivityTimer.setIdleTimeout(-1); sessionInactivityTimer = null; if (log.isDebugEnabled()) { log.deb...
java
protected boolean isExpiredAt(long time) { try (Lock ignored = locker.lockIfNotHeld()) { checkValidForRead(); return sessionData.isExpiredAt(time); } }
java
protected boolean isIdleLongerThan (int sec) { long now = System.currentTimeMillis(); try (Lock ignored = locker.lockIfNotHeld()) { return ((sessionData.getAccessedTime() + (sec * 1000)) <= now); } }
java
protected void checkValidForWrite() throws IllegalStateException { checkLocked(); if (state == State.INVALID) { throw new IllegalStateException("Not valid for write: session " + this); } if (state == State.INVALIDATING) { return; // in the process of being inval...
java
protected void checkValidForRead() throws IllegalStateException { checkLocked(); if (state == State.INVALID) { throw new IllegalStateException("Invalid for read: session " + this); } if (state == State.INVALIDATING) { return; } if (!isResident()) ...
java
public void setName(String name) { if (name.endsWith(ARRAY_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.ARRAY; } else if (name.endsWith(MAP_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.MAP; ...
java
public List<String> getValueList() { if (tokensList == null) { return null; } if (tokensList.isEmpty()) { return new ArrayList<>(); } else { List<String> list = new ArrayList<>(tokensList.size()); for (Token[] tokens : tokensList) { ...
java