repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
apiman/apiman
gateway/engine/3scale/src/main/java/io/apiman/gateway/engine/threescale/beans/ProxyRule.java
ProxyRule.convertPattern
private static String convertPattern(ProxyRule bean) { String str = bean.getPattern().replaceAll("\\{.+?\\}", "([^/&?]*)"); // /foo/{bar}/{baz} => /foo/([^\/&?]*)/([^/&?]*).* return str.endsWith("$") ? str : str + ".*"; // Implicitly other stuff on end unless $ explicitly specified (see description) }
java
private static String convertPattern(ProxyRule bean) { String str = bean.getPattern().replaceAll("\\{.+?\\}", "([^/&?]*)"); // /foo/{bar}/{baz} => /foo/([^\/&?]*)/([^/&?]*).* return str.endsWith("$") ? str : str + ".*"; // Implicitly other stuff on end unless $ explicitly specified (see description) }
[ "private", "static", "String", "convertPattern", "(", "ProxyRule", "bean", ")", "{", "String", "str", "=", "bean", ".", "getPattern", "(", ")", ".", "replaceAll", "(", "\"\\\\{.+?\\\\}\"", ",", "\"([^/&?]*)\"", ")", ";", "// /foo/{bar}/{baz} => /foo/([^\\/&?]*)/([^/...
slash, ampersand or question mark.
[ "slash", "ampersand", "or", "question", "mark", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/3scale/src/main/java/io/apiman/gateway/engine/threescale/beans/ProxyRule.java#L82-L85
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/SearchCriteriaUtil.java
SearchCriteriaUtil.validateSearchCriteria
public static final void validateSearchCriteria(SearchCriteriaBean criteria) throws InvalidSearchCriteriaException { if (criteria.getPaging() != null) { if (criteria.getPaging().getPage() < 1) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingPage")); //$NON-NLS-1$ } if (criteria.getPaging().getPageSize() < 1) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingPageSize")); //$NON-NLS-1$ } } int count = 1; for (SearchCriteriaFilterBean filter : criteria.getFilters()) { if (filter.getName() == null || filter.getName().trim().length() == 0) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterName", count)); //$NON-NLS-1$ } if (filter.getValue() == null || filter.getValue().trim().length() == 0) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterValue", count)); //$NON-NLS-1$ } if (filter.getOperator() == null || !validOperators.contains(filter.getOperator())) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterOperator", count)); //$NON-NLS-1$ } count++; } if (criteria.getOrderBy() != null && (criteria.getOrderBy().getName() == null || criteria.getOrderBy().getName().trim().length() == 0)) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingOrderByName")); //$NON-NLS-1$ } }
java
public static final void validateSearchCriteria(SearchCriteriaBean criteria) throws InvalidSearchCriteriaException { if (criteria.getPaging() != null) { if (criteria.getPaging().getPage() < 1) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingPage")); //$NON-NLS-1$ } if (criteria.getPaging().getPageSize() < 1) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingPageSize")); //$NON-NLS-1$ } } int count = 1; for (SearchCriteriaFilterBean filter : criteria.getFilters()) { if (filter.getName() == null || filter.getName().trim().length() == 0) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterName", count)); //$NON-NLS-1$ } if (filter.getValue() == null || filter.getValue().trim().length() == 0) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterValue", count)); //$NON-NLS-1$ } if (filter.getOperator() == null || !validOperators.contains(filter.getOperator())) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingSearchFilterOperator", count)); //$NON-NLS-1$ } count++; } if (criteria.getOrderBy() != null && (criteria.getOrderBy().getName() == null || criteria.getOrderBy().getName().trim().length() == 0)) { throw new InvalidSearchCriteriaException(Messages.i18n.format("SearchCriteriaUtil.MissingOrderByName")); //$NON-NLS-1$ } }
[ "public", "static", "final", "void", "validateSearchCriteria", "(", "SearchCriteriaBean", "criteria", ")", "throws", "InvalidSearchCriteriaException", "{", "if", "(", "criteria", ".", "getPaging", "(", ")", "!=", "null", ")", "{", "if", "(", "criteria", ".", "ge...
Validates that the search criteria bean is complete and makes sense. @param criteria the search criteria @throws InvalidSearchCriteriaException when the search criteria is not valid
[ "Validates", "that", "the", "search", "criteria", "bean", "is", "complete", "and", "makes", "sense", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/SearchCriteriaUtil.java#L53-L78
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java
ReflectionUtils.callIfExists
public static <T> void callIfExists(T object, String methodName) throws SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { try { Method method = object.getClass().getMethod(methodName); method.invoke(object); } catch (NoSuchMethodException e) { } }
java
public static <T> void callIfExists(T object, String methodName) throws SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { try { Method method = object.getClass().getMethod(methodName); method.invoke(object); } catch (NoSuchMethodException e) { } }
[ "public", "static", "<", "T", ">", "void", "callIfExists", "(", "T", "object", ",", "String", "methodName", ")", "throws", "SecurityException", ",", "IllegalAccessException", ",", "IllegalArgumentException", ",", "InvocationTargetException", "{", "try", "{", "Method...
Call a method if it exists. Use very sparingly and generally prefer interfaces. @param object The object @param methodName Method name to call on the object @throws SecurityException reflection - security manager to indicate a security violation @throws IllegalAccessException reflection - does not allow access @throws IllegalArgumentException reflection - argument not allowed @throws InvocationTargetException reflection - exception thrown by an invoked method or constructor
[ "Call", "a", "method", "if", "it", "exists", ".", "Use", "very", "sparingly", "and", "generally", "prefer", "interfaces", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java#L39-L46
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java
ReflectionUtils.loadClass
public static Class<?> loadClass(String classname) { Class<?> c = null; // First try a simple Class.forName() try { c = Class.forName(classname); } catch (ClassNotFoundException e) { } // Didn't work? Try using this class's classloader. if (c == null) { try { c = ReflectionUtils.class.getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { } } // Still didn't work? Try the thread's context classloader. if (c == null) { try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { } } return c; }
java
public static Class<?> loadClass(String classname) { Class<?> c = null; // First try a simple Class.forName() try { c = Class.forName(classname); } catch (ClassNotFoundException e) { } // Didn't work? Try using this class's classloader. if (c == null) { try { c = ReflectionUtils.class.getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { } } // Still didn't work? Try the thread's context classloader. if (c == null) { try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { } } return c; }
[ "public", "static", "Class", "<", "?", ">", "loadClass", "(", "String", "classname", ")", "{", "Class", "<", "?", ">", "c", "=", "null", ";", "// First try a simple Class.forName()", "try", "{", "c", "=", "Class", ".", "forName", "(", "classname", ")", "...
Loads a class. @param classname
[ "Loads", "a", "class", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java#L52-L67
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java
ReflectionUtils.findSetter
public static Method findSetter(Class<?> onClass, Class<?> targetClass) { Method[] methods = onClass.getMethods(); for (Method method : methods) { Class<?>[] ptypes = method.getParameterTypes(); if (method.getName().startsWith("set") && ptypes.length == 1 && ptypes[0] == targetClass) { //$NON-NLS-1$ return method; } } return null; }
java
public static Method findSetter(Class<?> onClass, Class<?> targetClass) { Method[] methods = onClass.getMethods(); for (Method method : methods) { Class<?>[] ptypes = method.getParameterTypes(); if (method.getName().startsWith("set") && ptypes.length == 1 && ptypes[0] == targetClass) { //$NON-NLS-1$ return method; } } return null; }
[ "public", "static", "Method", "findSetter", "(", "Class", "<", "?", ">", "onClass", ",", "Class", "<", "?", ">", "targetClass", ")", "{", "Method", "[", "]", "methods", "=", "onClass", ".", "getMethods", "(", ")", ";", "for", "(", "Method", "method", ...
Squishy way to find a setter method. @param onClass, targetClass
[ "Squishy", "way", "to", "find", "a", "setter", "method", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/ReflectionUtils.java#L73-L82
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/auth/JDBCIdentityValidator.java
JDBCIdentityValidator.createClient
private IJdbcClient createClient(IPolicyContext context, JDBCIdentitySource config) throws Throwable { IJdbcComponent jdbcComponent = context.getComponent(IJdbcComponent.class); if (config.getType() == JDBCType.datasource || config.getType() == null) { DataSource ds = lookupDatasource(config); return jdbcComponent.create(ds); } if (config.getType() == JDBCType.url) { JdbcOptionsBean options = new JdbcOptionsBean(); options.setJdbcUrl(config.getJdbcUrl()); options.setUsername(config.getUsername()); options.setPassword(config.getPassword()); options.setAutoCommit(true); return jdbcComponent.createStandalone(options); } throw new Exception("Unknown JDBC options."); //$NON-NLS-1$ }
java
private IJdbcClient createClient(IPolicyContext context, JDBCIdentitySource config) throws Throwable { IJdbcComponent jdbcComponent = context.getComponent(IJdbcComponent.class); if (config.getType() == JDBCType.datasource || config.getType() == null) { DataSource ds = lookupDatasource(config); return jdbcComponent.create(ds); } if (config.getType() == JDBCType.url) { JdbcOptionsBean options = new JdbcOptionsBean(); options.setJdbcUrl(config.getJdbcUrl()); options.setUsername(config.getUsername()); options.setPassword(config.getPassword()); options.setAutoCommit(true); return jdbcComponent.createStandalone(options); } throw new Exception("Unknown JDBC options."); //$NON-NLS-1$ }
[ "private", "IJdbcClient", "createClient", "(", "IPolicyContext", "context", ",", "JDBCIdentitySource", "config", ")", "throws", "Throwable", "{", "IJdbcComponent", "jdbcComponent", "=", "context", ".", "getComponent", "(", "IJdbcComponent", ".", "class", ")", ";", "...
Creates the appropriate jdbc client. @param context @param config
[ "Creates", "the", "appropriate", "jdbc", "client", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/auth/JDBCIdentityValidator.java#L113-L129
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/ServiceRegistryUtil.java
ServiceRegistryUtil.getSingleService
@SuppressWarnings("javadoc") public static <T> T getSingleService(Class<T> serviceInterface) throws IllegalStateException { // Cached single service values are derived from the values cached when checking // for multiple services T rval = null; Set<T> services = getServices(serviceInterface); if (services.size() > 1) { throw new IllegalStateException("Multiple implementations found of " + serviceInterface); //$NON-NLS-1$ } else if (!services.isEmpty()) { rval = services.iterator().next(); } return rval; }
java
@SuppressWarnings("javadoc") public static <T> T getSingleService(Class<T> serviceInterface) throws IllegalStateException { // Cached single service values are derived from the values cached when checking // for multiple services T rval = null; Set<T> services = getServices(serviceInterface); if (services.size() > 1) { throw new IllegalStateException("Multiple implementations found of " + serviceInterface); //$NON-NLS-1$ } else if (!services.isEmpty()) { rval = services.iterator().next(); } return rval; }
[ "@", "SuppressWarnings", "(", "\"javadoc\"", ")", "public", "static", "<", "T", ">", "T", "getSingleService", "(", "Class", "<", "T", ">", "serviceInterface", ")", "throws", "IllegalStateException", "{", "// Cached single service values are derived from the values cached ...
Gets a single service by its interface. @param serviceInterface the service interface @throws IllegalStateException method has been invoked at an illegal or inappropriate time
[ "Gets", "a", "single", "service", "by", "its", "interface", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/ServiceRegistryUtil.java#L42-L55
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/ServiceRegistryUtil.java
ServiceRegistryUtil.getServices
@SuppressWarnings("unchecked") public static <T> Set<T> getServices(Class<T> serviceInterface) { synchronized(servicesCache) { if (servicesCache.containsKey(serviceInterface)) { return (Set<T>) servicesCache.get(serviceInterface); } Set<T> services = new LinkedHashSet<>(); try { for (T service : ServiceLoader.load(serviceInterface)) { services.add(service); } } catch (ServiceConfigurationError sce) { // No services found - don't check again. } servicesCache.put(serviceInterface, services); return services; } }
java
@SuppressWarnings("unchecked") public static <T> Set<T> getServices(Class<T> serviceInterface) { synchronized(servicesCache) { if (servicesCache.containsKey(serviceInterface)) { return (Set<T>) servicesCache.get(serviceInterface); } Set<T> services = new LinkedHashSet<>(); try { for (T service : ServiceLoader.load(serviceInterface)) { services.add(service); } } catch (ServiceConfigurationError sce) { // No services found - don't check again. } servicesCache.put(serviceInterface, services); return services; } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "getServices", "(", "Class", "<", "T", ">", "serviceInterface", ")", "{", "synchronized", "(", "servicesCache", ")", "{", "if", "(", "servicesCache...
Get a set of service implementations for a given interface. @param serviceInterface the service interface @return the set of services
[ "Get", "a", "set", "of", "service", "implementations", "for", "a", "given", "interface", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/ServiceRegistryUtil.java#L62-L80
train
apiman/apiman
common/config/src/main/java/io/apiman/common/config/ConfigFileConfiguration.java
ConfigFileConfiguration.findConfigUrlInDirectory
protected static URL findConfigUrlInDirectory(File directory, String configName) { if (directory.isDirectory()) { File cfile = new File(directory, configName); if (cfile.isFile()) { try { return cfile.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } } } return null; }
java
protected static URL findConfigUrlInDirectory(File directory, String configName) { if (directory.isDirectory()) { File cfile = new File(directory, configName); if (cfile.isFile()) { try { return cfile.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } } } return null; }
[ "protected", "static", "URL", "findConfigUrlInDirectory", "(", "File", "directory", ",", "String", "configName", ")", "{", "if", "(", "directory", ".", "isDirectory", "(", ")", ")", "{", "File", "cfile", "=", "new", "File", "(", "directory", ",", "configName...
Returns a URL to a file with the given name inside the given directory.
[ "Returns", "a", "URL", "to", "a", "file", "with", "the", "given", "name", "inside", "the", "given", "directory", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/config/src/main/java/io/apiman/common/config/ConfigFileConfiguration.java#L46-L58
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/TimeRestrictedAccessPolicy.java
TimeRestrictedAccessPolicy.canProcessRequest
private boolean canProcessRequest(TimeRestrictedAccessConfig config, String destination) { if (destination == null || destination.trim().length() == 0) { destination = "/"; //$NON-NLS-1$ } List<TimeRestrictedAccess> rulesEnabledForPath = getRulesMatchingPath(config, destination); if(rulesEnabledForPath.size()!=0){ DateTime currentTime = new DateTime(DateTimeZone.UTC); for (TimeRestrictedAccess rule : rulesEnabledForPath) { boolean matchesDay = matchesDay(currentTime, rule); if (matchesDay) { boolean matchesTime = matchesTime(rule); if (matchesTime) { return true; } } } return false; } return true; }
java
private boolean canProcessRequest(TimeRestrictedAccessConfig config, String destination) { if (destination == null || destination.trim().length() == 0) { destination = "/"; //$NON-NLS-1$ } List<TimeRestrictedAccess> rulesEnabledForPath = getRulesMatchingPath(config, destination); if(rulesEnabledForPath.size()!=0){ DateTime currentTime = new DateTime(DateTimeZone.UTC); for (TimeRestrictedAccess rule : rulesEnabledForPath) { boolean matchesDay = matchesDay(currentTime, rule); if (matchesDay) { boolean matchesTime = matchesTime(rule); if (matchesTime) { return true; } } } return false; } return true; }
[ "private", "boolean", "canProcessRequest", "(", "TimeRestrictedAccessConfig", "config", ",", "String", "destination", ")", "{", "if", "(", "destination", "==", "null", "||", "destination", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", ...
Evaluates whether the destination provided matches any of the configured pathsToIgnore and matches specified time range. @param config The {@link IgnoredResourcesConfig} containing the pathsToIgnore @param destination The destination to evaluate @return true if any path matches the destination. false otherwise
[ "Evaluates", "whether", "the", "destination", "provided", "matches", "any", "of", "the", "configured", "pathsToIgnore", "and", "matches", "specified", "time", "range", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/TimeRestrictedAccessPolicy.java#L90-L109
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractIPListPolicy.java
AbstractIPListPolicy.getRemoteAddr
protected String getRemoteAddr(ApiRequest request, IPListConfig config) { String httpHeader = config.getHttpHeader(); if (httpHeader != null && httpHeader.trim().length() > 0) { String value = (String) request.getHeaders().get(httpHeader); if (value != null) { return value; } } return request.getRemoteAddr(); }
java
protected String getRemoteAddr(ApiRequest request, IPListConfig config) { String httpHeader = config.getHttpHeader(); if (httpHeader != null && httpHeader.trim().length() > 0) { String value = (String) request.getHeaders().get(httpHeader); if (value != null) { return value; } } return request.getRemoteAddr(); }
[ "protected", "String", "getRemoteAddr", "(", "ApiRequest", "request", ",", "IPListConfig", "config", ")", "{", "String", "httpHeader", "=", "config", ".", "getHttpHeader", "(", ")", ";", "if", "(", "httpHeader", "!=", "null", "&&", "httpHeader", ".", "trim", ...
Gets the remote address for comparison. @param request the request @param config the config
[ "Gets", "the", "remote", "address", "for", "comparison", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractIPListPolicy.java#L35-L44
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractIPListPolicy.java
AbstractIPListPolicy.isMatch
protected boolean isMatch(IPListConfig config, String remoteAddr) { if (config.getIpList().contains(remoteAddr)) { return true; } try { String [] remoteAddrSplit = remoteAddr.split("\\."); //$NON-NLS-1$ for (String ip : config.getIpList()) { String [] ipSplit = ip.split("\\."); //$NON-NLS-1$ if (remoteAddrSplit.length == ipSplit.length) { int numParts = ipSplit.length; boolean matches = true; for (int idx = 0; idx < numParts; idx++) { if (ipSplit[idx].equals("*") || ipSplit[idx].equals(remoteAddrSplit[idx])) { //$NON-NLS-1$ // This component matches! } else { matches = false; break; } } if (matches) { return true; } } } } catch (Throwable t) { // eat it } return false; }
java
protected boolean isMatch(IPListConfig config, String remoteAddr) { if (config.getIpList().contains(remoteAddr)) { return true; } try { String [] remoteAddrSplit = remoteAddr.split("\\."); //$NON-NLS-1$ for (String ip : config.getIpList()) { String [] ipSplit = ip.split("\\."); //$NON-NLS-1$ if (remoteAddrSplit.length == ipSplit.length) { int numParts = ipSplit.length; boolean matches = true; for (int idx = 0; idx < numParts; idx++) { if (ipSplit[idx].equals("*") || ipSplit[idx].equals(remoteAddrSplit[idx])) { //$NON-NLS-1$ // This component matches! } else { matches = false; break; } } if (matches) { return true; } } } } catch (Throwable t) { // eat it } return false; }
[ "protected", "boolean", "isMatch", "(", "IPListConfig", "config", ",", "String", "remoteAddr", ")", "{", "if", "(", "config", ".", "getIpList", "(", ")", ".", "contains", "(", "remoteAddr", ")", ")", "{", "return", "true", ";", "}", "try", "{", "String",...
Returns true if the remote address is a match for the configured values in the IP List. @param config the config @param remoteAddr the remote address
[ "Returns", "true", "if", "the", "remote", "address", "is", "a", "match", "for", "the", "configured", "values", "in", "the", "IP", "List", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractIPListPolicy.java#L52-L80
train
apiman/apiman
manager/api/war/tomcat8/src/main/java/io/apiman/manager/api/war/tomcat8/Tomcat8PluginRegistry.java
Tomcat8PluginRegistry.getPluginDir
private static File getPluginDir() { String dataDirPath = System.getProperty("catalina.home"); //$NON-NLS-1$ File dataDir = new File(dataDirPath, "data"); //$NON-NLS-1$ if (!dataDir.getParentFile().isDirectory()) { throw new RuntimeException("Failed to find Tomcat home at: " + dataDirPath); //$NON-NLS-1$ } if (!dataDir.exists()) { dataDir.mkdir(); } File pluginsDir = new File(dataDir, "apiman/plugins"); //$NON-NLS-1$ return pluginsDir; }
java
private static File getPluginDir() { String dataDirPath = System.getProperty("catalina.home"); //$NON-NLS-1$ File dataDir = new File(dataDirPath, "data"); //$NON-NLS-1$ if (!dataDir.getParentFile().isDirectory()) { throw new RuntimeException("Failed to find Tomcat home at: " + dataDirPath); //$NON-NLS-1$ } if (!dataDir.exists()) { dataDir.mkdir(); } File pluginsDir = new File(dataDir, "apiman/plugins"); //$NON-NLS-1$ return pluginsDir; }
[ "private", "static", "File", "getPluginDir", "(", ")", "{", "String", "dataDirPath", "=", "System", ".", "getProperty", "(", "\"catalina.home\"", ")", ";", "//$NON-NLS-1$", "File", "dataDir", "=", "new", "File", "(", "dataDirPath", ",", "\"data\"", ")", ";", ...
Creates the directory to use for the plugin registry. The location of the plugin registry is in the tomcat data directory.
[ "Creates", "the", "directory", "to", "use", "for", "the", "plugin", "registry", ".", "The", "location", "of", "the", "plugin", "registry", "is", "in", "the", "tomcat", "data", "directory", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/war/tomcat8/src/main/java/io/apiman/manager/api/war/tomcat8/Tomcat8PluginRegistry.java#L48-L59
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.wrapResultHandler
private IAsyncResultHandler<IEngineResult> wrapResultHandler(final IAsyncResultHandler<IEngineResult> handler) { return (IAsyncResult<IEngineResult> result) -> { boolean doRecord = true; if (result.isError()) { recordErrorMetrics(result.getError()); } else { IEngineResult engineResult = result.getResult(); if (engineResult.isFailure()) { recordFailureMetrics(engineResult.getPolicyFailure()); } else { recordSuccessMetrics(engineResult.getApiResponse()); doRecord = false; // don't record the metric now because we need to record # of bytes downloaded, which hasn't happened yet } } requestMetric.setRequestEnd(new Date()); if (doRecord) { metrics.record(requestMetric); } handler.handle(result); }; }
java
private IAsyncResultHandler<IEngineResult> wrapResultHandler(final IAsyncResultHandler<IEngineResult> handler) { return (IAsyncResult<IEngineResult> result) -> { boolean doRecord = true; if (result.isError()) { recordErrorMetrics(result.getError()); } else { IEngineResult engineResult = result.getResult(); if (engineResult.isFailure()) { recordFailureMetrics(engineResult.getPolicyFailure()); } else { recordSuccessMetrics(engineResult.getApiResponse()); doRecord = false; // don't record the metric now because we need to record # of bytes downloaded, which hasn't happened yet } } requestMetric.setRequestEnd(new Date()); if (doRecord) { metrics.record(requestMetric); } handler.handle(result); }; }
[ "private", "IAsyncResultHandler", "<", "IEngineResult", ">", "wrapResultHandler", "(", "final", "IAsyncResultHandler", "<", "IEngineResult", ">", "handler", ")", "{", "return", "(", "IAsyncResult", "<", "IEngineResult", ">", "result", ")", "->", "{", "boolean", "d...
Wraps the result handler so that metrics can be properly recorded.
[ "Wraps", "the", "result", "handler", "so", "that", "metrics", "can", "be", "properly", "recorded", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L172-L192
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.recordSuccessMetrics
protected void recordSuccessMetrics(ApiResponse response) { requestMetric.setResponseCode(response.getCode()); requestMetric.setResponseMessage(response.getMessage()); }
java
protected void recordSuccessMetrics(ApiResponse response) { requestMetric.setResponseCode(response.getCode()); requestMetric.setResponseMessage(response.getMessage()); }
[ "protected", "void", "recordSuccessMetrics", "(", "ApiResponse", "response", ")", "{", "requestMetric", ".", "setResponseCode", "(", "response", ".", "getCode", "(", ")", ")", ";", "requestMetric", ".", "setResponseMessage", "(", "response", ".", "getMessage", "("...
Record success metrics
[ "Record", "success", "metrics" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L197-L200
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.recordFailureMetrics
protected void recordFailureMetrics(PolicyFailure failure) { requestMetric.setResponseCode(failure.getResponseCode()); requestMetric.setFailure(true); requestMetric.setFailureCode(failure.getFailureCode()); requestMetric.setFailureReason(failure.getMessage()); }
java
protected void recordFailureMetrics(PolicyFailure failure) { requestMetric.setResponseCode(failure.getResponseCode()); requestMetric.setFailure(true); requestMetric.setFailureCode(failure.getFailureCode()); requestMetric.setFailureReason(failure.getMessage()); }
[ "protected", "void", "recordFailureMetrics", "(", "PolicyFailure", "failure", ")", "{", "requestMetric", ".", "setResponseCode", "(", "failure", ".", "getResponseCode", "(", ")", ")", ";", "requestMetric", ".", "setFailure", "(", "true", ")", ";", "requestMetric",...
Record failure metrics
[ "Record", "failure", "metrics" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L205-L210
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.resolvePropertyReplacements
protected void resolvePropertyReplacements(Api api) { if (api == null) { return; } String endpoint = api.getEndpoint(); endpoint = resolveProperties(endpoint); api.setEndpoint(endpoint); Map<String, String> properties = api.getEndpointProperties(); for (Entry<String, String> entry : properties.entrySet()) { String value = entry.getValue(); value = resolveProperties(value); entry.setValue(value); } resolvePropertyReplacements(api.getApiPolicies()); }
java
protected void resolvePropertyReplacements(Api api) { if (api == null) { return; } String endpoint = api.getEndpoint(); endpoint = resolveProperties(endpoint); api.setEndpoint(endpoint); Map<String, String> properties = api.getEndpointProperties(); for (Entry<String, String> entry : properties.entrySet()) { String value = entry.getValue(); value = resolveProperties(value); entry.setValue(value); } resolvePropertyReplacements(api.getApiPolicies()); }
[ "protected", "void", "resolvePropertyReplacements", "(", "Api", "api", ")", "{", "if", "(", "api", "==", "null", ")", "{", "return", ";", "}", "String", "endpoint", "=", "api", ".", "getEndpoint", "(", ")", ";", "endpoint", "=", "resolveProperties", "(", ...
Response API property replacements
[ "Response", "API", "property", "replacements" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L537-L553
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.resolvePropertyReplacements
protected void resolvePropertyReplacements(ApiContract apiContract) { if (apiContract == null) { return; } Api api = apiContract.getApi(); if (api != null) { resolvePropertyReplacements(api); } resolvePropertyReplacements(apiContract.getPolicies()); }
java
protected void resolvePropertyReplacements(ApiContract apiContract) { if (apiContract == null) { return; } Api api = apiContract.getApi(); if (api != null) { resolvePropertyReplacements(api); } resolvePropertyReplacements(apiContract.getPolicies()); }
[ "protected", "void", "resolvePropertyReplacements", "(", "ApiContract", "apiContract", ")", "{", "if", "(", "apiContract", "==", "null", ")", "{", "return", ";", "}", "Api", "api", "=", "apiContract", ".", "getApi", "(", ")", ";", "if", "(", "api", "!=", ...
Resolve contract property replacements
[ "Resolve", "contract", "property", "replacements" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L558-L567
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.resolvePropertyReplacements
private void resolvePropertyReplacements(List<Policy> apiPolicies) { if (apiPolicies != null) { for (Policy policy : apiPolicies) { String config = policy.getPolicyJsonConfig(); config = resolveProperties(config); policy.setPolicyJsonConfig(config); } } }
java
private void resolvePropertyReplacements(List<Policy> apiPolicies) { if (apiPolicies != null) { for (Policy policy : apiPolicies) { String config = policy.getPolicyJsonConfig(); config = resolveProperties(config); policy.setPolicyJsonConfig(config); } } }
[ "private", "void", "resolvePropertyReplacements", "(", "List", "<", "Policy", ">", "apiPolicies", ")", "{", "if", "(", "apiPolicies", "!=", "null", ")", "{", "for", "(", "Policy", "policy", ":", "apiPolicies", ")", "{", "String", "config", "=", "policy", "...
Resolve property replacements for list of policies
[ "Resolve", "property", "replacements", "for", "list", "of", "policies" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L572-L580
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.resolveProperties
private String resolveProperties(String value) { if (value.contains("${")) { //$NON-NLS-1$ return PROPERTY_SUBSTITUTOR.replace(value); } else { return value; } }
java
private String resolveProperties(String value) { if (value.contains("${")) { //$NON-NLS-1$ return PROPERTY_SUBSTITUTOR.replace(value); } else { return value; } }
[ "private", "String", "resolveProperties", "(", "String", "value", ")", "{", "if", "(", "value", ".", "contains", "(", "\"${\"", ")", ")", "{", "//$NON-NLS-1$", "return", "PROPERTY_SUBSTITUTOR", ".", "replace", "(", "value", ")", ";", "}", "else", "{", "ret...
Resolve a property
[ "Resolve", "a", "property" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L585-L591
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.validateRequest
protected void validateRequest(ApiRequest request) throws InvalidContractException { ApiContract contract = request.getContract(); boolean matches = true; if (!contract.getApi().getOrganizationId().equals(request.getApiOrgId())) { matches = false; } if (!contract.getApi().getApiId().equals(request.getApiId())) { matches = false; } if (!contract.getApi().getVersion().equals(request.getApiVersion())) { matches = false; } if (!matches) { throw new InvalidContractException(Messages.i18n.format("EngineImpl.InvalidContractForApi", //$NON-NLS-1$ request.getApiOrgId(), request.getApiId(), request.getApiVersion())); } }
java
protected void validateRequest(ApiRequest request) throws InvalidContractException { ApiContract contract = request.getContract(); boolean matches = true; if (!contract.getApi().getOrganizationId().equals(request.getApiOrgId())) { matches = false; } if (!contract.getApi().getApiId().equals(request.getApiId())) { matches = false; } if (!contract.getApi().getVersion().equals(request.getApiVersion())) { matches = false; } if (!matches) { throw new InvalidContractException(Messages.i18n.format("EngineImpl.InvalidContractForApi", //$NON-NLS-1$ request.getApiOrgId(), request.getApiId(), request.getApiVersion())); } }
[ "protected", "void", "validateRequest", "(", "ApiRequest", "request", ")", "throws", "InvalidContractException", "{", "ApiContract", "contract", "=", "request", ".", "getContract", "(", ")", ";", "boolean", "matches", "=", "true", ";", "if", "(", "!", "contract"...
Validates that the contract being used for the request is valid against the api information included in the request. Basically the request includes information indicating which specific api is being invoked. This method ensures that the api information in the contract matches the requested api. @param request the request to validate
[ "Validates", "that", "the", "contract", "being", "used", "for", "the", "request", "is", "valid", "against", "the", "api", "information", "included", "in", "the", "request", ".", "Basically", "the", "request", "includes", "information", "indicating", "which", "sp...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L601-L618
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.createApiConnectionResponseHandler
private IAsyncResultHandler<IApiConnectionResponse> createApiConnectionResponseHandler() { return (IAsyncResult<IApiConnectionResponse> result) -> { if (result.isSuccess()) { requestMetric.setApiEnd(new Date()); // The result came back. NB: still need to put it through the response chain. apiConnectionResponse = result.getResult(); ApiResponse apiResponse = apiConnectionResponse.getHead(); context.setAttribute("apiman.engine.apiResponse", apiResponse); //$NON-NLS-1$ // Execute the response chain to evaluate the response. responseChain = createResponseChain((ApiResponse response) -> { // Send the api response to the caller. final EngineResultImpl engineResult = new EngineResultImpl(response); engineResult.setConnectorResponseStream(apiConnectionResponse); resultHandler.handle(AsyncResultImpl.create(engineResult)); // We've come all the way through the response chain successfully responseChain.bodyHandler(buffer -> { requestMetric.setBytesDownloaded(requestMetric.getBytesDownloaded() + buffer.length()); engineResult.write(buffer); }); responseChain.endHandler(isEnd -> { engineResult.end(); finished = true; metrics.record(requestMetric); }); // Signal to the connector that it's safe to start transmitting data. apiConnectionResponse.transmit(); }); // Write data from the back-end response into the response chain. apiConnectionResponse.bodyHandler(buffer -> responseChain.write(buffer)); // Indicate back-end response is finished to the response chain. apiConnectionResponse.endHandler(isEnd -> responseChain.end()); responseChain.doApply(apiResponse); } else { resultHandler.handle(AsyncResultImpl.create(result.getError())); } }; }
java
private IAsyncResultHandler<IApiConnectionResponse> createApiConnectionResponseHandler() { return (IAsyncResult<IApiConnectionResponse> result) -> { if (result.isSuccess()) { requestMetric.setApiEnd(new Date()); // The result came back. NB: still need to put it through the response chain. apiConnectionResponse = result.getResult(); ApiResponse apiResponse = apiConnectionResponse.getHead(); context.setAttribute("apiman.engine.apiResponse", apiResponse); //$NON-NLS-1$ // Execute the response chain to evaluate the response. responseChain = createResponseChain((ApiResponse response) -> { // Send the api response to the caller. final EngineResultImpl engineResult = new EngineResultImpl(response); engineResult.setConnectorResponseStream(apiConnectionResponse); resultHandler.handle(AsyncResultImpl.create(engineResult)); // We've come all the way through the response chain successfully responseChain.bodyHandler(buffer -> { requestMetric.setBytesDownloaded(requestMetric.getBytesDownloaded() + buffer.length()); engineResult.write(buffer); }); responseChain.endHandler(isEnd -> { engineResult.end(); finished = true; metrics.record(requestMetric); }); // Signal to the connector that it's safe to start transmitting data. apiConnectionResponse.transmit(); }); // Write data from the back-end response into the response chain. apiConnectionResponse.bodyHandler(buffer -> responseChain.write(buffer)); // Indicate back-end response is finished to the response chain. apiConnectionResponse.endHandler(isEnd -> responseChain.end()); responseChain.doApply(apiResponse); } else { resultHandler.handle(AsyncResultImpl.create(result.getError())); } }; }
[ "private", "IAsyncResultHandler", "<", "IApiConnectionResponse", ">", "createApiConnectionResponseHandler", "(", ")", "{", "return", "(", "IAsyncResult", "<", "IApiConnectionResponse", ">", "result", ")", "->", "{", "if", "(", "result", ".", "isSuccess", "(", ")", ...
Creates a response handler that is called by the api connector once a connection to the back end api has been made and a response received.
[ "Creates", "a", "response", "handler", "that", "is", "called", "by", "the", "api", "connector", "once", "a", "connection", "to", "the", "back", "end", "api", "has", "been", "made", "and", "a", "response", "received", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L686-L730
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.handleStream
protected void handleStream() { inboundStreamHandler.handle(new ISignalWriteStream() { boolean streamFinished = false; @Override public void write(IApimanBuffer buffer) { if (streamFinished) { throw new IllegalStateException("Attempted write after #end() was called."); //$NON-NLS-1$ } requestChain.write(buffer); } @Override public void end() { requestChain.end(); streamFinished = true; } /** * @see io.apiman.gateway.engine.io.IAbortable#abort() */ @Override public void abort(Throwable t) { // If this is called, it means that something went wrong on the inbound // side of things - so we need to make sure we abort and cleanup the // api connector resources. We'll also call handle() on the result // handler so that the caller knows something went wrong. streamFinished = true; apiConnection.abort(t); resultHandler.handle(AsyncResultImpl.<IEngineResult>create(new RequestAbortedException(t))); } @Override public boolean isFinished() { return streamFinished; } @Override public void drainHandler(IAsyncHandler<Void> drainHandler) { apiConnection.drainHandler(drainHandler); } @Override public boolean isFull() { return apiConnection.isFull(); } }); }
java
protected void handleStream() { inboundStreamHandler.handle(new ISignalWriteStream() { boolean streamFinished = false; @Override public void write(IApimanBuffer buffer) { if (streamFinished) { throw new IllegalStateException("Attempted write after #end() was called."); //$NON-NLS-1$ } requestChain.write(buffer); } @Override public void end() { requestChain.end(); streamFinished = true; } /** * @see io.apiman.gateway.engine.io.IAbortable#abort() */ @Override public void abort(Throwable t) { // If this is called, it means that something went wrong on the inbound // side of things - so we need to make sure we abort and cleanup the // api connector resources. We'll also call handle() on the result // handler so that the caller knows something went wrong. streamFinished = true; apiConnection.abort(t); resultHandler.handle(AsyncResultImpl.<IEngineResult>create(new RequestAbortedException(t))); } @Override public boolean isFinished() { return streamFinished; } @Override public void drainHandler(IAsyncHandler<Void> drainHandler) { apiConnection.drainHandler(drainHandler); } @Override public boolean isFull() { return apiConnection.isFull(); } }); }
[ "protected", "void", "handleStream", "(", ")", "{", "inboundStreamHandler", ".", "handle", "(", "new", "ISignalWriteStream", "(", ")", "{", "boolean", "streamFinished", "=", "false", ";", "@", "Override", "public", "void", "write", "(", "IApimanBuffer", "buffer"...
Called when the api connector is ready to receive data from the inbound client request.
[ "Called", "when", "the", "api", "connector", "is", "ready", "to", "receive", "data", "from", "the", "inbound", "client", "request", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L736-L784
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.createRequestChain
private Chain<ApiRequest> createRequestChain(IAsyncHandler<ApiRequest> requestHandler) { RequestChain chain = new RequestChain(policyImpls, context); chain.headHandler(requestHandler); chain.policyFailureHandler(failure -> { // Jump straight to the response leg. // It will likely not have been initialised, so create one. if (responseChain == null) { // Its response will not be used as we take the failure path only, so we just use an empty lambda. responseChain = createResponseChain((ignored) -> {}); } responseChain.doFailure(failure); }); chain.policyErrorHandler(policyErrorHandler); return chain; }
java
private Chain<ApiRequest> createRequestChain(IAsyncHandler<ApiRequest> requestHandler) { RequestChain chain = new RequestChain(policyImpls, context); chain.headHandler(requestHandler); chain.policyFailureHandler(failure -> { // Jump straight to the response leg. // It will likely not have been initialised, so create one. if (responseChain == null) { // Its response will not be used as we take the failure path only, so we just use an empty lambda. responseChain = createResponseChain((ignored) -> {}); } responseChain.doFailure(failure); }); chain.policyErrorHandler(policyErrorHandler); return chain; }
[ "private", "Chain", "<", "ApiRequest", ">", "createRequestChain", "(", "IAsyncHandler", "<", "ApiRequest", ">", "requestHandler", ")", "{", "RequestChain", "chain", "=", "new", "RequestChain", "(", "policyImpls", ",", "context", ")", ";", "chain", ".", "headHand...
Creates the chain used to apply policies in order to the api request.
[ "Creates", "the", "chain", "used", "to", "apply", "policies", "in", "order", "to", "the", "api", "request", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L805-L819
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.createResponseChain
private Chain<ApiResponse> createResponseChain(IAsyncHandler<ApiResponse> responseHandler) { ResponseChain chain = new ResponseChain(policyImpls, context); chain.headHandler(responseHandler); chain.policyFailureHandler(result -> { if (apiConnectionResponse != null) { apiConnectionResponse.abort(); } policyFailureHandler.handle(result); }); chain.policyErrorHandler(result -> { if (apiConnectionResponse != null) { apiConnectionResponse.abort(); } policyErrorHandler.handle(result); }); return chain; }
java
private Chain<ApiResponse> createResponseChain(IAsyncHandler<ApiResponse> responseHandler) { ResponseChain chain = new ResponseChain(policyImpls, context); chain.headHandler(responseHandler); chain.policyFailureHandler(result -> { if (apiConnectionResponse != null) { apiConnectionResponse.abort(); } policyFailureHandler.handle(result); }); chain.policyErrorHandler(result -> { if (apiConnectionResponse != null) { apiConnectionResponse.abort(); } policyErrorHandler.handle(result); }); return chain; }
[ "private", "Chain", "<", "ApiResponse", ">", "createResponseChain", "(", "IAsyncHandler", "<", "ApiResponse", ">", "responseHandler", ")", "{", "ResponseChain", "chain", "=", "new", "ResponseChain", "(", "policyImpls", ",", "context", ")", ";", "chain", ".", "he...
Creates the chain used to apply policies in reverse order to the api response.
[ "Creates", "the", "chain", "used", "to", "apply", "policies", "in", "reverse", "order", "to", "the", "api", "response", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L824-L840
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.createPolicyFailureHandler
private IAsyncHandler<PolicyFailure> createPolicyFailureHandler() { return policyFailure -> { // One of the policies has triggered a failure. At this point we should stop processing and // send the failure to the client for appropriate handling. EngineResultImpl engineResult = new EngineResultImpl(policyFailure); resultHandler.handle(AsyncResultImpl.<IEngineResult> create(engineResult)); }; }
java
private IAsyncHandler<PolicyFailure> createPolicyFailureHandler() { return policyFailure -> { // One of the policies has triggered a failure. At this point we should stop processing and // send the failure to the client for appropriate handling. EngineResultImpl engineResult = new EngineResultImpl(policyFailure); resultHandler.handle(AsyncResultImpl.<IEngineResult> create(engineResult)); }; }
[ "private", "IAsyncHandler", "<", "PolicyFailure", ">", "createPolicyFailureHandler", "(", ")", "{", "return", "policyFailure", "->", "{", "// One of the policies has triggered a failure. At this point we should stop processing and", "// send the failure to the client for appropriate hand...
Creates the handler to use when a policy failure occurs during processing of a chain.
[ "Creates", "the", "handler", "to", "use", "when", "a", "policy", "failure", "occurs", "during", "processing", "of", "a", "chain", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L846-L853
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
ApiRequestExecutorImpl.createPolicyErrorHandler
private IAsyncHandler<Throwable> createPolicyErrorHandler() { return error -> resultHandler.handle(AsyncResultImpl.<IEngineResult> create(error)); }
java
private IAsyncHandler<Throwable> createPolicyErrorHandler() { return error -> resultHandler.handle(AsyncResultImpl.<IEngineResult> create(error)); }
[ "private", "IAsyncHandler", "<", "Throwable", ">", "createPolicyErrorHandler", "(", ")", "{", "return", "error", "->", "resultHandler", ".", "handle", "(", "AsyncResultImpl", ".", "<", "IEngineResult", ">", "create", "(", "error", ")", ")", ";", "}" ]
Creates the handler to use when an error is detected during the processing of a chain.
[ "Creates", "the", "handler", "to", "use", "when", "an", "error", "is", "detected", "during", "the", "processing", "of", "a", "chain", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java#L859-L861
train
apiman/apiman
manager/api/war/src/main/java/io/apiman/manager/api/war/WarApiManagerBootstrapperServlet.java
WarApiManagerBootstrapperServlet.getDataDir
private static File getDataDir() { File rval = null; // First check to see if a data directory has been explicitly configured via system property String dataDir = System.getProperty("apiman.bootstrap.data_dir"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir); } // If that wasn't set, then check to see if we're running in wildfly/eap if (rval == null) { dataDir = System.getProperty("jboss.server.data.dir"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir, "bootstrap"); //$NON-NLS-1$ } } // If that didn't work, try to locate a tomcat data directory if (rval == null) { dataDir = System.getProperty("catalina.home"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir, "data/bootstrap"); //$NON-NLS-1$ } } // If all else fails, just let it return null return rval; }
java
private static File getDataDir() { File rval = null; // First check to see if a data directory has been explicitly configured via system property String dataDir = System.getProperty("apiman.bootstrap.data_dir"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir); } // If that wasn't set, then check to see if we're running in wildfly/eap if (rval == null) { dataDir = System.getProperty("jboss.server.data.dir"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir, "bootstrap"); //$NON-NLS-1$ } } // If that didn't work, try to locate a tomcat data directory if (rval == null) { dataDir = System.getProperty("catalina.home"); //$NON-NLS-1$ if (dataDir != null) { rval = new File(dataDir, "data/bootstrap"); //$NON-NLS-1$ } } // If all else fails, just let it return null return rval; }
[ "private", "static", "File", "getDataDir", "(", ")", "{", "File", "rval", "=", "null", ";", "// First check to see if a data directory has been explicitly configured via system property", "String", "dataDir", "=", "System", ".", "getProperty", "(", "\"apiman.bootstrap.data_di...
Get the data directory
[ "Get", "the", "data", "directory" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/war/src/main/java/io/apiman/manager/api/war/WarApiManagerBootstrapperServlet.java#L112-L139
train
apiman/apiman
manager/api/gateway/src/main/java/io/apiman/manager/api/gateway/rest/RestGatewayLink.java
RestGatewayLink.configureBasicAuth
protected void configureBasicAuth(HttpRequest request) { try { String username = getConfig().getUsername(); String password = getConfig().getPassword(); String up = username + ":" + password; //$NON-NLS-1$ String base64 = new String(Base64.encodeBase64(up.getBytes("UTF-8"))); //$NON-NLS-1$ String authHeader = "Basic " + base64; //$NON-NLS-1$ request.setHeader("Authorization", authHeader); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
java
protected void configureBasicAuth(HttpRequest request) { try { String username = getConfig().getUsername(); String password = getConfig().getPassword(); String up = username + ":" + password; //$NON-NLS-1$ String base64 = new String(Base64.encodeBase64(up.getBytes("UTF-8"))); //$NON-NLS-1$ String authHeader = "Basic " + base64; //$NON-NLS-1$ request.setHeader("Authorization", authHeader); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
[ "protected", "void", "configureBasicAuth", "(", "HttpRequest", "request", ")", "{", "try", "{", "String", "username", "=", "getConfig", "(", ")", ".", "getUsername", "(", ")", ";", "String", "password", "=", "getConfig", "(", ")", ".", "getPassword", "(", ...
Configures BASIC authentication for the request. @param request
[ "Configures", "BASIC", "authentication", "for", "the", "request", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/gateway/src/main/java/io/apiman/manager/api/gateway/rest/RestGatewayLink.java#L207-L218
train
apiman/apiman
manager/api/beans/src/main/java/io/apiman/manager/api/beans/search/SearchCriteriaBean.java
SearchCriteriaBean.addFilter
public void addFilter(String name, String value, SearchCriteriaFilterOperator operator) { SearchCriteriaFilterBean filter = new SearchCriteriaFilterBean(); filter.setName(name); filter.setValue(value); filter.setOperator(operator); filters.add(filter); }
java
public void addFilter(String name, String value, SearchCriteriaFilterOperator operator) { SearchCriteriaFilterBean filter = new SearchCriteriaFilterBean(); filter.setName(name); filter.setValue(value); filter.setOperator(operator); filters.add(filter); }
[ "public", "void", "addFilter", "(", "String", "name", ",", "String", "value", ",", "SearchCriteriaFilterOperator", "operator", ")", "{", "SearchCriteriaFilterBean", "filter", "=", "new", "SearchCriteriaFilterBean", "(", ")", ";", "filter", ".", "setName", "(", "na...
Adds a single filter to the criteria. @param name the filter name @param value the filter value @param operator the operator type
[ "Adds", "a", "single", "filter", "to", "the", "criteria", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/beans/src/main/java/io/apiman/manager/api/beans/search/SearchCriteriaBean.java#L47-L53
train
apiman/apiman
common/config/src/main/java/io/apiman/common/config/options/AbstractOptions.java
AbstractOptions.getSubmap
public static Map<String, String> getSubmap(Map<String, String> mapIn, String subkey) { if (mapIn == null || mapIn.isEmpty()) { return Collections.emptyMap(); } // Get map sub-element. return mapIn.entrySet().stream() .filter(entry -> entry.getKey().toLowerCase().startsWith(subkey.toLowerCase())) .map(entry -> { String newKey = entry.getKey().substring(subkey.length(), entry.getKey().length()); return new AbstractMap.SimpleImmutableEntry<>(newKey, entry.getValue()); }) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); }
java
public static Map<String, String> getSubmap(Map<String, String> mapIn, String subkey) { if (mapIn == null || mapIn.isEmpty()) { return Collections.emptyMap(); } // Get map sub-element. return mapIn.entrySet().stream() .filter(entry -> entry.getKey().toLowerCase().startsWith(subkey.toLowerCase())) .map(entry -> { String newKey = entry.getKey().substring(subkey.length(), entry.getKey().length()); return new AbstractMap.SimpleImmutableEntry<>(newKey, entry.getValue()); }) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); }
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getSubmap", "(", "Map", "<", "String", ",", "String", ">", "mapIn", ",", "String", "subkey", ")", "{", "if", "(", "mapIn", "==", "null", "||", "mapIn", ".", "isEmpty", "(", ")", ")", "{...
Takes map and produces a submap using a key. For example, all foo.bar elements are inserted into the new map. @param mapIn config map in @param subkey subkey to determine the submap @return the submap
[ "Takes", "map", "and", "produces", "a", "submap", "using", "a", "key", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/config/src/main/java/io/apiman/common/config/options/AbstractOptions.java#L102-L114
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.valueChanged
public static boolean valueChanged(Set<?> before, Set<?> after) { if ((before == null && after == null) || after == null) { return false; } if (before == null) { if (after.isEmpty()) { return false; } else { return true; } } else { if (before.size() != after.size()) { return true; } for (Object bean : after) { if (!before.contains(bean)) { return true; } } } return false; }
java
public static boolean valueChanged(Set<?> before, Set<?> after) { if ((before == null && after == null) || after == null) { return false; } if (before == null) { if (after.isEmpty()) { return false; } else { return true; } } else { if (before.size() != after.size()) { return true; } for (Object bean : after) { if (!before.contains(bean)) { return true; } } } return false; }
[ "public", "static", "boolean", "valueChanged", "(", "Set", "<", "?", ">", "before", ",", "Set", "<", "?", ">", "after", ")", "{", "if", "(", "(", "before", "==", "null", "&&", "after", "==", "null", ")", "||", "after", "==", "null", ")", "{", "re...
Returns true only if the set has changed. @param before the value before change @param after the value after change @return true if value changed, else false
[ "Returns", "true", "only", "if", "the", "set", "has", "changed", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L104-L125
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.valueChanged
public static boolean valueChanged(Map<String, String> before, Map<String, String> after) { if ((before == null && after == null) || after == null) { return false; } if (before == null) { if (after.isEmpty()) { return false; } else { return true; } } else { if (before.size() != after.size()) { return true; } for (Entry<String, String> entry : after.entrySet()) { String key = entry.getKey(); String afterValue = entry.getValue(); if (!before.containsKey(key)) { return true; } String beforeValue = before.get(key); if (valueChanged(beforeValue, afterValue)) { return true; } } } return false; }
java
public static boolean valueChanged(Map<String, String> before, Map<String, String> after) { if ((before == null && after == null) || after == null) { return false; } if (before == null) { if (after.isEmpty()) { return false; } else { return true; } } else { if (before.size() != after.size()) { return true; } for (Entry<String, String> entry : after.entrySet()) { String key = entry.getKey(); String afterValue = entry.getValue(); if (!before.containsKey(key)) { return true; } String beforeValue = before.get(key); if (valueChanged(beforeValue, afterValue)) { return true; } } } return false; }
[ "public", "static", "boolean", "valueChanged", "(", "Map", "<", "String", ",", "String", ">", "before", ",", "Map", "<", "String", ",", "String", ">", "after", ")", "{", "if", "(", "(", "before", "==", "null", "&&", "after", "==", "null", ")", "||", ...
Returns true only if the map has changed. @param before the value before change @param after the value after change @return true if value changed, else false
[ "Returns", "true", "only", "if", "the", "map", "has", "changed", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L134-L161
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.organizationUpdated
public static AuditEntryBean organizationUpdated(OrganizationBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext); entry.setEntityId(null); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean organizationUpdated(OrganizationBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getId(), AuditEntityType.Organization, securityContext); entry.setEntityId(null); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "organizationUpdated", "(", "OrganizationBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "...
Creates an audit entry for the 'organization updated' event. @param bean the bean @param data the update @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "organization", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L203-L214
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.membershipGranted
public static AuditEntryBean membershipGranted(String organizationId, MembershipData data, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(organizationId, AuditEntityType.Organization, securityContext); entry.setEntityId(null); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Grant); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean membershipGranted(String organizationId, MembershipData data, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(organizationId, AuditEntityType.Organization, securityContext); entry.setEntityId(null); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Grant); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "membershipGranted", "(", "String", "organizationId", ",", "MembershipData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "organizationId", ",", "AuditEntityType", "....
Creates an audit entry for the 'membership granted' even. @param organizationId the organization id @param data the membership data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "membership", "granted", "even", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L223-L231
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.apiCreated
public static AuditEntryBean apiCreated(ApiBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
java
public static AuditEntryBean apiCreated(ApiBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
[ "public", "static", "AuditEntryBean", "apiCreated", "(", "ApiBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getOrganization", "(", ")", ".", "getId", "(", ")", ",", "AuditEntity...
Creates an audit entry for the 'API created' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "API", "created", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L256-L263
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.apiUpdated
public static AuditEntryBean apiUpdated(ApiBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean apiUpdated(ApiBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "apiUpdated", "(", "ApiBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ...
Creates an audit entry for the 'API updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "API", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L272-L283
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.apiVersionUpdated
public static AuditEntryBean apiVersionUpdated(ApiVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getApi().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean apiVersionUpdated(ApiVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getApi().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "apiVersionUpdated", "(", "ApiVersionBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "{", ...
Creates an audit entry for the 'API version updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "API", "version", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L307-L318
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.clientCreated
public static AuditEntryBean clientCreated(ClientBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
java
public static AuditEntryBean clientCreated(ClientBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
[ "public", "static", "AuditEntryBean", "clientCreated", "(", "ClientBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getOrganization", "(", ")", ".", "getId", "(", ")", ",", "Audit...
Creates an audit entry for the 'client created' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "client", "created", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L354-L361
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.clientUpdated
public static AuditEntryBean clientUpdated(ClientBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean clientUpdated(ClientBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "clientUpdated", "(", "ClientBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "retur...
Creates an audit entry for the 'client updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "client", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L370-L381
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.clientVersionUpdated
public static AuditEntryBean clientVersionUpdated(ClientVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getClient().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean clientVersionUpdated(ClientVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getClient().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "clientVersionUpdated", "(", "ClientVersionBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", ...
Creates an audit entry for the 'client version updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "client", "version", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L405-L416
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.contractCreatedToApi
public static AuditEntryBean contractCreatedToApi(ContractBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getApi().getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); // Ensure the order of contract-created events are deterministic by adding 1 ms to this one entry.setCreatedOn(new Date(entry.getCreatedOn().getTime() + 1)); entry.setWhat(AuditEntryType.CreateContract); entry.setEntityId(bean.getApi().getApi().getId()); entry.setEntityVersion(bean.getApi().getVersion()); ContractData data = new ContractData(bean); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean contractCreatedToApi(ContractBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getApi().getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); // Ensure the order of contract-created events are deterministic by adding 1 ms to this one entry.setCreatedOn(new Date(entry.getCreatedOn().getTime() + 1)); entry.setWhat(AuditEntryType.CreateContract); entry.setEntityId(bean.getApi().getApi().getId()); entry.setEntityVersion(bean.getApi().getVersion()); ContractData data = new ContractData(bean); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "contractCreatedToApi", "(", "ContractBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getApi", "(", ")", ".", "getApi", "(", ")", ".", "getO...
Creates an audit entry for the 'contract created' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "contract", "created", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L440-L450
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.policyAdded
public static AuditEntryBean policyAdded(PolicyBean bean, PolicyType type, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganizationId(), null, securityContext); entry.setWhat(AuditEntryType.AddPolicy); entry.setEntityId(bean.getEntityId()); entry.setEntityVersion(bean.getEntityVersion()); switch (type) { case Client: entry.setEntityType(AuditEntityType.Client); break; case Plan: entry.setEntityType(AuditEntityType.Plan); break; case Api: entry.setEntityType(AuditEntityType.Api); break; } PolicyData data = new PolicyData(); data.setPolicyDefId(bean.getDefinition().getId()); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean policyAdded(PolicyBean bean, PolicyType type, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganizationId(), null, securityContext); entry.setWhat(AuditEntryType.AddPolicy); entry.setEntityId(bean.getEntityId()); entry.setEntityVersion(bean.getEntityVersion()); switch (type) { case Client: entry.setEntityType(AuditEntityType.Client); break; case Plan: entry.setEntityType(AuditEntityType.Plan); break; case Api: entry.setEntityType(AuditEntityType.Api); break; } PolicyData data = new PolicyData(); data.setPolicyDefId(bean.getDefinition().getId()); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "policyAdded", "(", "PolicyBean", "bean", ",", "PolicyType", "type", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getOrganizationId", "(", ")", ",", "null...
Creates an audit entry for the 'policy added' event. Works for all three kinds of policies. @param bean the bean @param type the policy type @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "policy", "added", "event", ".", "Works", "for", "all", "three", "kinds", "of", "policies", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L492-L513
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.toJSON
private static String toJSON(Object data) { try { return mapper.writeValueAsString(data); } catch (Exception e) { throw new RuntimeException(e); } }
java
private static String toJSON(Object data) { try { return mapper.writeValueAsString(data); } catch (Exception e) { throw new RuntimeException(e); } }
[ "private", "static", "String", "toJSON", "(", "Object", "data", ")", "{", "try", "{", "return", "mapper", ".", "writeValueAsString", "(", "data", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ...
Writes the data object as a JSON string. @param data
[ "Writes", "the", "data", "object", "as", "a", "JSON", "string", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L581-L587
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.planCreated
public static AuditEntryBean planCreated(PlanBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
java
public static AuditEntryBean planCreated(PlanBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setData(null); entry.setWhat(AuditEntryType.Create); return entry; }
[ "public", "static", "AuditEntryBean", "planCreated", "(", "PlanBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getOrganization", "(", ")", ".", "getId", "(", ")", ",", "AuditEnti...
Creates an audit entry for the 'plan created' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "plan", "created", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L595-L602
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.planUpdated
public static AuditEntryBean planUpdated(PlanBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean planUpdated(PlanBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getId()); entry.setEntityVersion(null); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "planUpdated", "(", "PlanBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ...
Creates an audit entry for the 'plan updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "plan", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L611-L622
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.planVersionCreated
public static AuditEntryBean planVersionCreated(PlanVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getPlan().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Create); return entry; }
java
public static AuditEntryBean planVersionCreated(PlanVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getPlan().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Create); return entry; }
[ "public", "static", "AuditEntryBean", "planVersionCreated", "(", "PlanVersionBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getPlan", "(", ")", ".", "getOrganization", "(", ")", "...
Creates an audit entry for the 'plan version created' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "plan", "version", "created", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L630-L637
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.planVersionUpdated
public static AuditEntryBean planVersionUpdated(PlanVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getPlan().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
java
public static AuditEntryBean planVersionUpdated(PlanVersionBean bean, EntityUpdatedData data, ISecurityContext securityContext) { if (data.getChanges().isEmpty()) { return null; } AuditEntryBean entry = newEntry(bean.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(bean.getPlan().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Update); entry.setData(toJSON(data)); return entry; }
[ "public", "static", "AuditEntryBean", "planVersionUpdated", "(", "PlanVersionBean", "bean", ",", "EntityUpdatedData", "data", ",", "ISecurityContext", "securityContext", ")", "{", "if", "(", "data", ".", "getChanges", "(", ")", ".", "isEmpty", "(", ")", ")", "{"...
Creates an audit entry for the 'plan version updated' event. @param bean the bean @param data the updated data @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "plan", "version", "updated", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L646-L657
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.apiPublished
public static AuditEntryBean apiPublished(ApiVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getApi().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Publish); return entry; }
java
public static AuditEntryBean apiPublished(ApiVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(bean.getApi().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Publish); return entry; }
[ "public", "static", "AuditEntryBean", "apiPublished", "(", "ApiVersionBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getApi", "(", ")", ".", "getOrganization", "(", ")", ".", "g...
Creates an audit entry for the 'API published' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "API", "published", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L665-L672
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.clientRegistered
public static AuditEntryBean clientRegistered(ClientVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getClient().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Register); return entry; }
java
public static AuditEntryBean clientRegistered(ClientVersionBean bean, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(bean.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(bean.getClient().getId()); entry.setEntityVersion(bean.getVersion()); entry.setWhat(AuditEntryType.Register); return entry; }
[ "public", "static", "AuditEntryBean", "clientRegistered", "(", "ClientVersionBean", "bean", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "bean", ".", "getClient", "(", ")", ".", "getOrganization", "(", ")", ...
Creates an audit entry for the 'client registered' event. @param bean the bean @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "for", "the", "client", "registered", "event", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L695-L702
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.policiesReordered
public static AuditEntryBean policiesReordered(ApiVersionBean apiVersion, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(apiVersion.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(apiVersion.getApi().getId()); entry.setEntityVersion(apiVersion.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
java
public static AuditEntryBean policiesReordered(ApiVersionBean apiVersion, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(apiVersion.getApi().getOrganization().getId(), AuditEntityType.Api, securityContext); entry.setEntityId(apiVersion.getApi().getId()); entry.setEntityVersion(apiVersion.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
[ "public", "static", "AuditEntryBean", "policiesReordered", "(", "ApiVersionBean", "apiVersion", ",", "PolicyType", "policyType", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "apiVersion", ".", "getApi", "(", ")...
Called when the user reorders the policies in a API. @param apiVersion the API version @param policyType the policy type @param securityContext the security context @return the audit entry
[ "Called", "when", "the", "user", "reorders", "the", "policies", "in", "a", "API", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L740-L747
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.policiesReordered
public static AuditEntryBean policiesReordered(ClientVersionBean cvb, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(cvb.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(cvb.getClient().getId()); entry.setEntityVersion(cvb.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
java
public static AuditEntryBean policiesReordered(ClientVersionBean cvb, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(cvb.getClient().getOrganization().getId(), AuditEntityType.Client, securityContext); entry.setEntityId(cvb.getClient().getId()); entry.setEntityVersion(cvb.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
[ "public", "static", "AuditEntryBean", "policiesReordered", "(", "ClientVersionBean", "cvb", ",", "PolicyType", "policyType", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "cvb", ".", "getClient", "(", ")", "."...
Called when the user reorders the policies in an client. @param cvb the client and version @param policyType the policy type @param securityContext the security context @return the audit entry
[ "Called", "when", "the", "user", "reorders", "the", "policies", "in", "an", "client", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L756-L763
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.policiesReordered
public static AuditEntryBean policiesReordered(PlanVersionBean pvb, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(pvb.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(pvb.getPlan().getId()); entry.setEntityVersion(pvb.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
java
public static AuditEntryBean policiesReordered(PlanVersionBean pvb, PolicyType policyType, ISecurityContext securityContext) { AuditEntryBean entry = newEntry(pvb.getPlan().getOrganization().getId(), AuditEntityType.Plan, securityContext); entry.setEntityId(pvb.getPlan().getId()); entry.setEntityVersion(pvb.getVersion()); entry.setWhat(AuditEntryType.ReorderPolicies); return entry; }
[ "public", "static", "AuditEntryBean", "policiesReordered", "(", "PlanVersionBean", "pvb", ",", "PolicyType", "policyType", ",", "ISecurityContext", "securityContext", ")", "{", "AuditEntryBean", "entry", "=", "newEntry", "(", "pvb", ".", "getPlan", "(", ")", ".", ...
Called when the user reorders the policies in a plan. @param pvb the plan and version @param policyType the policy type @param securityContext the security context @return the audit entry
[ "Called", "when", "the", "user", "reorders", "the", "policies", "in", "a", "plan", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L772-L779
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java
AuditUtils.newEntry
private static AuditEntryBean newEntry(String orgId, AuditEntityType type, ISecurityContext securityContext) { // Wait for 1 ms to guarantee that two audit entries are never created at the same moment in time (which would // result in non-deterministic sorting by the storage layer) try { Thread.sleep(1); } catch (InterruptedException e) { throw new RuntimeException(e); } AuditEntryBean entry = new AuditEntryBean(); entry.setOrganizationId(orgId); entry.setEntityType(type); entry.setCreatedOn(new Date()); entry.setWho(securityContext.getCurrentUser()); return entry; }
java
private static AuditEntryBean newEntry(String orgId, AuditEntityType type, ISecurityContext securityContext) { // Wait for 1 ms to guarantee that two audit entries are never created at the same moment in time (which would // result in non-deterministic sorting by the storage layer) try { Thread.sleep(1); } catch (InterruptedException e) { throw new RuntimeException(e); } AuditEntryBean entry = new AuditEntryBean(); entry.setOrganizationId(orgId); entry.setEntityType(type); entry.setCreatedOn(new Date()); entry.setWho(securityContext.getCurrentUser()); return entry; }
[ "private", "static", "AuditEntryBean", "newEntry", "(", "String", "orgId", ",", "AuditEntityType", "type", ",", "ISecurityContext", "securityContext", ")", "{", "// Wait for 1 ms to guarantee that two audit entries are never created at the same moment in time (which would", "// resul...
Creates an audit entry. @param orgId the organization id @param type @param securityContext the security context @return the audit entry
[ "Creates", "an", "audit", "entry", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/audit/AuditUtils.java#L788-L799
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.clientVersionAlreadyExistsException
public static final ClientVersionAlreadyExistsException clientVersionAlreadyExistsException(String clientName, String version) { return new ClientVersionAlreadyExistsException(Messages.i18n.format("clientVersionAlreadyExists", clientName, version)); //$NON-NLS-1$ }
java
public static final ClientVersionAlreadyExistsException clientVersionAlreadyExistsException(String clientName, String version) { return new ClientVersionAlreadyExistsException(Messages.i18n.format("clientVersionAlreadyExists", clientName, version)); //$NON-NLS-1$ }
[ "public", "static", "final", "ClientVersionAlreadyExistsException", "clientVersionAlreadyExistsException", "(", "String", "clientName", ",", "String", "version", ")", "{", "return", "new", "ClientVersionAlreadyExistsException", "(", "Messages", ".", "i18n", ".", "format", ...
Creates an exception from an client name. @param clientName the client name @param version the version @return the exception
[ "Creates", "an", "exception", "from", "an", "client", "name", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L147-L149
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.clientVersionNotFoundException
public static final ClientVersionNotFoundException clientVersionNotFoundException(String clientId, String version) { return new ClientVersionNotFoundException(Messages.i18n.format("clientVersionDoesNotExist", clientId, version)); //$NON-NLS-1$ }
java
public static final ClientVersionNotFoundException clientVersionNotFoundException(String clientId, String version) { return new ClientVersionNotFoundException(Messages.i18n.format("clientVersionDoesNotExist", clientId, version)); //$NON-NLS-1$ }
[ "public", "static", "final", "ClientVersionNotFoundException", "clientVersionNotFoundException", "(", "String", "clientId", ",", "String", "version", ")", "{", "return", "new", "ClientVersionNotFoundException", "(", "Messages", ".", "i18n", ".", "format", "(", "\"client...
Creates an exception from an client id and version. @param clientId the client id @param version the client version @return the exception
[ "Creates", "an", "exception", "from", "an", "client", "id", "and", "version", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L183-L185
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.apiVersionAlreadyExistsException
public static final ApiVersionAlreadyExistsException apiVersionAlreadyExistsException(String apiName, String version) { return new ApiVersionAlreadyExistsException(Messages.i18n.format("ApiVersionAlreadyExists", apiName, version)); //$NON-NLS-1$ }
java
public static final ApiVersionAlreadyExistsException apiVersionAlreadyExistsException(String apiName, String version) { return new ApiVersionAlreadyExistsException(Messages.i18n.format("ApiVersionAlreadyExists", apiName, version)); //$NON-NLS-1$ }
[ "public", "static", "final", "ApiVersionAlreadyExistsException", "apiVersionAlreadyExistsException", "(", "String", "apiName", ",", "String", "version", ")", "{", "return", "new", "ApiVersionAlreadyExistsException", "(", "Messages", ".", "i18n", ".", "format", "(", "\"A...
Creates an exception from an API name. @param apiName the API name @param version the version @return the exception
[ "Creates", "an", "exception", "from", "an", "API", "name", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L210-L212
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.invalidPlanStatusException
public static InvalidPlanStatusException invalidPlanStatusException(List<PlanVersionSummaryBean> lockedPlans) { return new InvalidPlanStatusException(Messages.i18n.format("InvalidPlanStatus") + " " + joinList(lockedPlans)); //$NON-NLS-1$ //$NON-NLS-2$ }
java
public static InvalidPlanStatusException invalidPlanStatusException(List<PlanVersionSummaryBean> lockedPlans) { return new InvalidPlanStatusException(Messages.i18n.format("InvalidPlanStatus") + " " + joinList(lockedPlans)); //$NON-NLS-1$ //$NON-NLS-2$ }
[ "public", "static", "InvalidPlanStatusException", "invalidPlanStatusException", "(", "List", "<", "PlanVersionSummaryBean", ">", "lockedPlans", ")", "{", "return", "new", "InvalidPlanStatusException", "(", "Messages", ".", "i18n", ".", "format", "(", "\"InvalidPlanStatus\...
Creates an invalid plan status exception. @param lockedPlans the list of locked plans @return the exception
[ "Creates", "an", "invalid", "plan", "status", "exception", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L264-L266
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.planVersionAlreadyExistsException
public static final PlanVersionAlreadyExistsException planVersionAlreadyExistsException(String planName, String version) { return new PlanVersionAlreadyExistsException(Messages.i18n.format("PlanVersionAlreadyExists", planName, version)); //$NON-NLS-1$ }
java
public static final PlanVersionAlreadyExistsException planVersionAlreadyExistsException(String planName, String version) { return new PlanVersionAlreadyExistsException(Messages.i18n.format("PlanVersionAlreadyExists", planName, version)); //$NON-NLS-1$ }
[ "public", "static", "final", "PlanVersionAlreadyExistsException", "planVersionAlreadyExistsException", "(", "String", "planName", ",", "String", "version", ")", "{", "return", "new", "PlanVersionAlreadyExistsException", "(", "Messages", ".", "i18n", ".", "format", "(", ...
Creates an exception from an plan name. @param planName the plan name @param version the version @return the exception
[ "Creates", "an", "exception", "from", "an", "plan", "name", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L292-L294
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.planVersionNotFoundException
public static final PlanVersionNotFoundException planVersionNotFoundException(String planId, String version) { return new PlanVersionNotFoundException(Messages.i18n.format("PlanVersionDoesNotExist", planId, version)); //$NON-NLS-1$ }
java
public static final PlanVersionNotFoundException planVersionNotFoundException(String planId, String version) { return new PlanVersionNotFoundException(Messages.i18n.format("PlanVersionDoesNotExist", planId, version)); //$NON-NLS-1$ }
[ "public", "static", "final", "PlanVersionNotFoundException", "planVersionNotFoundException", "(", "String", "planId", ",", "String", "version", ")", "{", "return", "new", "PlanVersionNotFoundException", "(", "Messages", ".", "i18n", ".", "format", "(", "\"PlanVersionDoe...
Creates an exception from an plan id and version. @param planId the plan id @param version the version id @return the exception
[ "Creates", "an", "exception", "from", "an", "plan", "id", "and", "version", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L311-L313
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java
ExceptionFactory.pluginResourceNotFoundException
public static final PluginResourceNotFoundException pluginResourceNotFoundException(String resourceName, PluginCoordinates coordinates) { return new PluginResourceNotFoundException(Messages.i18n.format( "PluginResourceNotFound", resourceName, coordinates.toString())); //$NON-NLS-1$ }
java
public static final PluginResourceNotFoundException pluginResourceNotFoundException(String resourceName, PluginCoordinates coordinates) { return new PluginResourceNotFoundException(Messages.i18n.format( "PluginResourceNotFound", resourceName, coordinates.toString())); //$NON-NLS-1$ }
[ "public", "static", "final", "PluginResourceNotFoundException", "pluginResourceNotFoundException", "(", "String", "resourceName", ",", "PluginCoordinates", "coordinates", ")", "{", "return", "new", "PluginResourceNotFoundException", "(", "Messages", ".", "i18n", ".", "forma...
Creates an exception. @param resourceName the resource name @param coordinates the maven coordinates @return the exception
[ "Creates", "an", "exception", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/ExceptionFactory.java#L411-L415
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpConnectorFactory.java
HttpConnectorFactory.getSslStrategy
protected SSLSessionStrategy getSslStrategy(RequiredAuthType authType) { try { if (authType == RequiredAuthType.MTLS) { if (mutualAuthSslStrategy == null) { mutualAuthSslStrategy = SSLSessionStrategyFactory.buildMutual(tlsOptions); } return mutualAuthSslStrategy; } else { if (standardSslStrategy == null) { if (tlsOptions.isDevMode()) { standardSslStrategy = SSLSessionStrategyFactory.buildUnsafe(); } else { standardSslStrategy = SSLSessionStrategyFactory.buildStandard(tlsOptions); } } return standardSslStrategy; } } catch (Exception e) { throw new RuntimeException(e); } }
java
protected SSLSessionStrategy getSslStrategy(RequiredAuthType authType) { try { if (authType == RequiredAuthType.MTLS) { if (mutualAuthSslStrategy == null) { mutualAuthSslStrategy = SSLSessionStrategyFactory.buildMutual(tlsOptions); } return mutualAuthSslStrategy; } else { if (standardSslStrategy == null) { if (tlsOptions.isDevMode()) { standardSslStrategy = SSLSessionStrategyFactory.buildUnsafe(); } else { standardSslStrategy = SSLSessionStrategyFactory.buildStandard(tlsOptions); } } return standardSslStrategy; } } catch (Exception e) { throw new RuntimeException(e); } }
[ "protected", "SSLSessionStrategy", "getSslStrategy", "(", "RequiredAuthType", "authType", ")", "{", "try", "{", "if", "(", "authType", "==", "RequiredAuthType", ".", "MTLS", ")", "{", "if", "(", "mutualAuthSslStrategy", "==", "null", ")", "{", "mutualAuthSslStrate...
Creates the SSL strategy based on configured TLS options. @param authType @return an appropriate SSL strategy
[ "Creates", "the", "SSL", "strategy", "based", "on", "configured", "TLS", "options", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpConnectorFactory.java#L131-L151
train
apiman/apiman
common/util/src/main/java/io/apiman/common/util/AesEncrypter.java
AesEncrypter.main
public static final void main(String [] args) { if (args.length != 2) { printUsage(); return; } String cmd = args[0]; String input = args[1]; if ("encrypt".equals(cmd)) { //$NON-NLS-1$ System.out.println(AesEncrypter.encrypt(input).substring("$CRYPT::".length())); //$NON-NLS-1$ } else if ("decrypt".equals(cmd)) { //$NON-NLS-1$ System.out.println(AesEncrypter.decrypt("$CRYPT::" + input)); //$NON-NLS-1$ } else { printUsage(); } }
java
public static final void main(String [] args) { if (args.length != 2) { printUsage(); return; } String cmd = args[0]; String input = args[1]; if ("encrypt".equals(cmd)) { //$NON-NLS-1$ System.out.println(AesEncrypter.encrypt(input).substring("$CRYPT::".length())); //$NON-NLS-1$ } else if ("decrypt".equals(cmd)) { //$NON-NLS-1$ System.out.println(AesEncrypter.decrypt("$CRYPT::" + input)); //$NON-NLS-1$ } else { printUsage(); } }
[ "public", "static", "final", "void", "main", "(", "String", "[", "]", "args", ")", "{", "if", "(", "args", ".", "length", "!=", "2", ")", "{", "printUsage", "(", ")", ";", "return", ";", "}", "String", "cmd", "=", "args", "[", "0", "]", ";", "S...
Main entry point for the encrypter. Allows encryption and decryption of text from the command line. @param args
[ "Main", "entry", "point", "for", "the", "encrypter", ".", "Allows", "encryption", "and", "decryption", "of", "text", "from", "the", "command", "line", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/util/src/main/java/io/apiman/common/util/AesEncrypter.java#L151-L166
train
apiman/apiman
manager/ui/war/src/main/java/io/apiman/manager/ui/server/servlets/AbstractUIServlet.java
AbstractUIServlet.getTokenGenerator
protected ITokenGenerator getTokenGenerator() throws ServletException { if (tokenGenerator == null) { String tokenGeneratorClassName = getConfig().getManagementApiAuthTokenGenerator(); if (tokenGeneratorClassName == null) throw new ServletException("No token generator class specified."); //$NON-NLS-1$ try { Class<?> c = Class.forName(tokenGeneratorClassName); tokenGenerator = (ITokenGenerator) c.newInstance(); } catch (Exception e) { throw new ServletException("Error creating token generator."); //$NON-NLS-1$ } } return tokenGenerator; }
java
protected ITokenGenerator getTokenGenerator() throws ServletException { if (tokenGenerator == null) { String tokenGeneratorClassName = getConfig().getManagementApiAuthTokenGenerator(); if (tokenGeneratorClassName == null) throw new ServletException("No token generator class specified."); //$NON-NLS-1$ try { Class<?> c = Class.forName(tokenGeneratorClassName); tokenGenerator = (ITokenGenerator) c.newInstance(); } catch (Exception e) { throw new ServletException("Error creating token generator."); //$NON-NLS-1$ } } return tokenGenerator; }
[ "protected", "ITokenGenerator", "getTokenGenerator", "(", ")", "throws", "ServletException", "{", "if", "(", "tokenGenerator", "==", "null", ")", "{", "String", "tokenGeneratorClassName", "=", "getConfig", "(", ")", ".", "getManagementApiAuthTokenGenerator", "(", ")",...
Gets an instance of the configured token generator.
[ "Gets", "an", "instance", "of", "the", "configured", "token", "generator", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/ui/war/src/main/java/io/apiman/manager/ui/server/servlets/AbstractUIServlet.java#L57-L70
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/soap/SoapHeaderScanner.java
SoapHeaderScanner.scan
public boolean scan(IApimanBuffer buffer) throws SoapEnvelopeNotFoundException { if (this.buffer == null) { this.buffer = buffer; } else { this.buffer.append(buffer); } boolean scanComplete = doScan(); // If our buffer is already "max size" but we haven't found the start of the // soap envelope yet, then we're likely not going to find it. if (!scanComplete && this.buffer.length() >= getMaxBufferLength()) { throw new SoapEnvelopeNotFoundException(); } return scanComplete; }
java
public boolean scan(IApimanBuffer buffer) throws SoapEnvelopeNotFoundException { if (this.buffer == null) { this.buffer = buffer; } else { this.buffer.append(buffer); } boolean scanComplete = doScan(); // If our buffer is already "max size" but we haven't found the start of the // soap envelope yet, then we're likely not going to find it. if (!scanComplete && this.buffer.length() >= getMaxBufferLength()) { throw new SoapEnvelopeNotFoundException(); } return scanComplete; }
[ "public", "boolean", "scan", "(", "IApimanBuffer", "buffer", ")", "throws", "SoapEnvelopeNotFoundException", "{", "if", "(", "this", ".", "buffer", "==", "null", ")", "{", "this", ".", "buffer", "=", "buffer", ";", "}", "else", "{", "this", ".", "buffer", ...
Append the given data to any existing buffer, then scan the buffer looking for the soap headers. If scanning is complete, this method will return true. If more data is required, then the method will return false. If an error condition is detected, then an exception will be thrown. @param buffer
[ "Append", "the", "given", "data", "to", "any", "existing", "buffer", "then", "scan", "the", "buffer", "looking", "for", "the", "soap", "headers", ".", "If", "scanning", "is", "complete", "this", "method", "will", "return", "true", ".", "If", "more", "data"...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/soap/SoapHeaderScanner.java#L72-L85
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/soap/SoapHeaderScanner.java
SoapHeaderScanner.findFrom
private int findFrom(char c, int index) { int currentIdx = index; while (currentIdx < buffer.length()) { if (buffer.get(currentIdx) == c) { return currentIdx; } currentIdx++; } return -1; }
java
private int findFrom(char c, int index) { int currentIdx = index; while (currentIdx < buffer.length()) { if (buffer.get(currentIdx) == c) { return currentIdx; } currentIdx++; } return -1; }
[ "private", "int", "findFrom", "(", "char", "c", ",", "int", "index", ")", "{", "int", "currentIdx", "=", "index", ";", "while", "(", "currentIdx", "<", "buffer", ".", "length", "(", ")", ")", "{", "if", "(", "buffer", ".", "get", "(", "currentIdx", ...
Search for the given character in the buffer, starting at the given index. If not found, return -1. If found, return the index of the character. @param c @param index
[ "Search", "for", "the", "given", "character", "in", "the", "buffer", "starting", "at", "the", "given", "index", ".", "If", "not", "found", "return", "-", "1", ".", "If", "found", "return", "the", "index", "of", "the", "character", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/soap/SoapHeaderScanner.java#L269-L278
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/io/ByteBuffer.java
ByteBuffer.readFrom
public int readFrom(InputStream stream) throws IOException { int bytesRead = stream.read(buffer); if (bytesRead < 0) { bytesInBuffer = 0; } else { bytesInBuffer = bytesRead; } return bytesRead; }
java
public int readFrom(InputStream stream) throws IOException { int bytesRead = stream.read(buffer); if (bytesRead < 0) { bytesInBuffer = 0; } else { bytesInBuffer = bytesRead; } return bytesRead; }
[ "public", "int", "readFrom", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "int", "bytesRead", "=", "stream", ".", "read", "(", "buffer", ")", ";", "if", "(", "bytesRead", "<", "0", ")", "{", "bytesInBuffer", "=", "0", ";", "}", "els...
Reads from the input stream. @param stream the input stream to read from @throws IOException I/O error when reading from buffer @return bytes read from buffer
[ "Reads", "from", "the", "input", "stream", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/io/ByteBuffer.java#L328-L336
train
apiman/apiman
manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/StorageExporter.java
StorageExporter.export
public void export() { logger.info("----------------------------"); //$NON-NLS-1$ logger.info(Messages.i18n.format("StorageExporter.StartingExport")); //$NON-NLS-1$ try { storage.beginTx(); try { exportMetadata(); exportUsers(); exportGateways(); exportPlugins(); exportRoles(); exportPolicyDefs(); exportOrgs(); } finally { storage.rollbackTx(); try { writer.close(); } catch (Exception e) { } } logger.info(Messages.i18n.format("StorageExporter.ExportComplete")); //$NON-NLS-1$ logger.info("------------------------------------------"); //$NON-NLS-1$ } catch (StorageException e) { throw new RuntimeException(e); } }
java
public void export() { logger.info("----------------------------"); //$NON-NLS-1$ logger.info(Messages.i18n.format("StorageExporter.StartingExport")); //$NON-NLS-1$ try { storage.beginTx(); try { exportMetadata(); exportUsers(); exportGateways(); exportPlugins(); exportRoles(); exportPolicyDefs(); exportOrgs(); } finally { storage.rollbackTx(); try { writer.close(); } catch (Exception e) { } } logger.info(Messages.i18n.format("StorageExporter.ExportComplete")); //$NON-NLS-1$ logger.info("------------------------------------------"); //$NON-NLS-1$ } catch (StorageException e) { throw new RuntimeException(e); } }
[ "public", "void", "export", "(", ")", "{", "logger", ".", "info", "(", "\"----------------------------\"", ")", ";", "//$NON-NLS-1$", "logger", ".", "info", "(", "Messages", ".", "i18n", ".", "format", "(", "\"StorageExporter.StartingExport\"", ")", ")", ";", ...
Called begin the export process.
[ "Called", "begin", "the", "export", "process", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/export-import/src/main/java/io/apiman/manager/api/exportimport/manager/StorageExporter.java#L78-L101
train
apiman/apiman
manager/api/core/src/main/java/io/apiman/manager/api/core/util/PolicyTemplateUtil.java
PolicyTemplateUtil.generatePolicyDescription
public static void generatePolicyDescription(PolicyBean policy) throws Exception { PolicyDefinitionBean def = policy.getDefinition(); PolicyDefinitionTemplateBean templateBean = getTemplateBean(def); if (templateBean == null) { return; } String cacheKey = def.getId() + "::" + templateBean.getLanguage(); //$NON-NLS-1$ CompiledTemplate template = templateCache.get(cacheKey); if (template == null) { template = TemplateCompiler.compileTemplate(templateBean.getTemplate()); templateCache.put(cacheKey, template); } try { // TODO hack to fix broken descriptions - this util should probably not know about encrypted data String jsonConfig = policy.getConfiguration(); if (CurrentDataEncrypter.instance != null) { EntityType entityType = EntityType.Api; if (policy.getType() == PolicyType.Client) { entityType = EntityType.ClientApp; } else if (policy.getType() == PolicyType.Plan) { entityType = EntityType.Plan; } DataEncryptionContext ctx = new DataEncryptionContext(policy.getOrganizationId(), policy.getEntityId(), policy.getEntityVersion(), entityType); jsonConfig = CurrentDataEncrypter.instance.decrypt(jsonConfig, ctx); } Map<String, Object> configMap = mapper.readValue(jsonConfig, Map.class); configMap = new PolicyConfigMap(configMap); String desc = (String) TemplateRuntime.execute(template, configMap); policy.setDescription(desc); } catch (Exception e) { e.printStackTrace(); // TODO properly log the error policy.setDescription(templateBean.getTemplate()); } }
java
public static void generatePolicyDescription(PolicyBean policy) throws Exception { PolicyDefinitionBean def = policy.getDefinition(); PolicyDefinitionTemplateBean templateBean = getTemplateBean(def); if (templateBean == null) { return; } String cacheKey = def.getId() + "::" + templateBean.getLanguage(); //$NON-NLS-1$ CompiledTemplate template = templateCache.get(cacheKey); if (template == null) { template = TemplateCompiler.compileTemplate(templateBean.getTemplate()); templateCache.put(cacheKey, template); } try { // TODO hack to fix broken descriptions - this util should probably not know about encrypted data String jsonConfig = policy.getConfiguration(); if (CurrentDataEncrypter.instance != null) { EntityType entityType = EntityType.Api; if (policy.getType() == PolicyType.Client) { entityType = EntityType.ClientApp; } else if (policy.getType() == PolicyType.Plan) { entityType = EntityType.Plan; } DataEncryptionContext ctx = new DataEncryptionContext(policy.getOrganizationId(), policy.getEntityId(), policy.getEntityVersion(), entityType); jsonConfig = CurrentDataEncrypter.instance.decrypt(jsonConfig, ctx); } Map<String, Object> configMap = mapper.readValue(jsonConfig, Map.class); configMap = new PolicyConfigMap(configMap); String desc = (String) TemplateRuntime.execute(template, configMap); policy.setDescription(desc); } catch (Exception e) { e.printStackTrace(); // TODO properly log the error policy.setDescription(templateBean.getTemplate()); } }
[ "public", "static", "void", "generatePolicyDescription", "(", "PolicyBean", "policy", ")", "throws", "Exception", "{", "PolicyDefinitionBean", "def", "=", "policy", ".", "getDefinition", "(", ")", ";", "PolicyDefinitionTemplateBean", "templateBean", "=", "getTemplateBea...
Generates a dynamic description for the given policy and stores the result on the policy bean instance. This should be done prior to returning the policybean back to the user for a REST call to the management API. @param policy the policy @throws Exception any exception
[ "Generates", "a", "dynamic", "description", "for", "the", "given", "policy", "and", "stores", "the", "result", "on", "the", "policy", "bean", "instance", ".", "This", "should", "be", "done", "prior", "to", "returning", "the", "policybean", "back", "to", "the...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/core/src/main/java/io/apiman/manager/api/core/util/PolicyTemplateUtil.java#L68-L103
train
apiman/apiman
manager/api/core/src/main/java/io/apiman/manager/api/core/util/PolicyTemplateUtil.java
PolicyTemplateUtil.getTemplateBean
private static PolicyDefinitionTemplateBean getTemplateBean(PolicyDefinitionBean def) { Locale currentLocale = Messages.i18n.getLocale(); String lang = currentLocale.getLanguage(); String country = lang + "_" + currentLocale.getCountry(); //$NON-NLS-1$ PolicyDefinitionTemplateBean nullBean = null; PolicyDefinitionTemplateBean langBean = null; PolicyDefinitionTemplateBean countryBean = null; for (PolicyDefinitionTemplateBean pdtb : def.getTemplates()) { if (pdtb.getLanguage() == null) { nullBean = pdtb; } else if (pdtb.getLanguage().equals(country)) { countryBean = pdtb; break; } else if (pdtb.getLanguage().equals(lang)) { langBean = pdtb; } } if (countryBean != null) { return countryBean; } if (langBean != null) { return langBean; } if (nullBean != null) { return nullBean; } return null; }
java
private static PolicyDefinitionTemplateBean getTemplateBean(PolicyDefinitionBean def) { Locale currentLocale = Messages.i18n.getLocale(); String lang = currentLocale.getLanguage(); String country = lang + "_" + currentLocale.getCountry(); //$NON-NLS-1$ PolicyDefinitionTemplateBean nullBean = null; PolicyDefinitionTemplateBean langBean = null; PolicyDefinitionTemplateBean countryBean = null; for (PolicyDefinitionTemplateBean pdtb : def.getTemplates()) { if (pdtb.getLanguage() == null) { nullBean = pdtb; } else if (pdtb.getLanguage().equals(country)) { countryBean = pdtb; break; } else if (pdtb.getLanguage().equals(lang)) { langBean = pdtb; } } if (countryBean != null) { return countryBean; } if (langBean != null) { return langBean; } if (nullBean != null) { return nullBean; } return null; }
[ "private", "static", "PolicyDefinitionTemplateBean", "getTemplateBean", "(", "PolicyDefinitionBean", "def", ")", "{", "Locale", "currentLocale", "=", "Messages", ".", "i18n", ".", "getLocale", "(", ")", ";", "String", "lang", "=", "currentLocale", ".", "getLanguage"...
Determines the appropriate template bean to use given the current locale. @param def
[ "Determines", "the", "appropriate", "template", "bean", "to", "use", "given", "the", "current", "locale", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/core/src/main/java/io/apiman/manager/api/core/util/PolicyTemplateUtil.java#L109-L137
train
apiman/apiman
common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java
PluginUtils.getUserM2Repository
public static File getUserM2Repository() { // if there is m2override system propery, use it. String m2Override = System.getProperty("apiman.gateway.m2-repository-path"); //$NON-NLS-1$ if (m2Override != null) { return new File(m2Override).getAbsoluteFile(); } String userHome = System.getProperty("user.home"); //$NON-NLS-1$ if (userHome != null) { File userHomeDir = new File(userHome); if (userHomeDir.isDirectory()) { File m2Dir = new File(userHome, ".m2/repository"); //$NON-NLS-1$ if (m2Dir.isDirectory()) { return m2Dir; } } } return null; }
java
public static File getUserM2Repository() { // if there is m2override system propery, use it. String m2Override = System.getProperty("apiman.gateway.m2-repository-path"); //$NON-NLS-1$ if (m2Override != null) { return new File(m2Override).getAbsoluteFile(); } String userHome = System.getProperty("user.home"); //$NON-NLS-1$ if (userHome != null) { File userHomeDir = new File(userHome); if (userHomeDir.isDirectory()) { File m2Dir = new File(userHome, ".m2/repository"); //$NON-NLS-1$ if (m2Dir.isDirectory()) { return m2Dir; } } } return null; }
[ "public", "static", "File", "getUserM2Repository", "(", ")", "{", "// if there is m2override system propery, use it.", "String", "m2Override", "=", "System", ".", "getProperty", "(", "\"apiman.gateway.m2-repository-path\"", ")", ";", "//$NON-NLS-1$", "if", "(", "m2Override"...
Gets the user's local m2 directory or null if not found. @return user's M2 repo
[ "Gets", "the", "user", "s", "local", "m2", "directory", "or", "null", "if", "not", "found", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java#L100-L118
train
apiman/apiman
common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java
PluginUtils.getM2Path
public static File getM2Path(File m2Dir, PluginCoordinates coordinates) { String artifactSubPath = getMavenPath(coordinates); return new File(m2Dir, artifactSubPath); }
java
public static File getM2Path(File m2Dir, PluginCoordinates coordinates) { String artifactSubPath = getMavenPath(coordinates); return new File(m2Dir, artifactSubPath); }
[ "public", "static", "File", "getM2Path", "(", "File", "m2Dir", ",", "PluginCoordinates", "coordinates", ")", "{", "String", "artifactSubPath", "=", "getMavenPath", "(", "coordinates", ")", ";", "return", "new", "File", "(", "m2Dir", ",", "artifactSubPath", ")", ...
Find the plugin artifact in the local .m2 directory. @param m2Dir the maven m2 directory @param coordinates the coordinates @return the M2 path
[ "Find", "the", "plugin", "artifact", "in", "the", "local", ".", "m2", "directory", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java#L126-L129
train
apiman/apiman
common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java
PluginUtils.getMavenPath
public static String getMavenPath(PluginCoordinates coordinates) { StringBuilder artifactSubPath = new StringBuilder(); artifactSubPath.append(coordinates.getGroupId().replace('.', '/')); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getArtifactId()); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getVersion()); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getArtifactId()); artifactSubPath.append('-'); artifactSubPath.append(coordinates.getVersion()); if (coordinates.getClassifier() != null) { artifactSubPath.append('-'); artifactSubPath.append(coordinates.getClassifier()); } artifactSubPath.append('.'); artifactSubPath.append(coordinates.getType()); return artifactSubPath.toString(); }
java
public static String getMavenPath(PluginCoordinates coordinates) { StringBuilder artifactSubPath = new StringBuilder(); artifactSubPath.append(coordinates.getGroupId().replace('.', '/')); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getArtifactId()); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getVersion()); artifactSubPath.append('/'); artifactSubPath.append(coordinates.getArtifactId()); artifactSubPath.append('-'); artifactSubPath.append(coordinates.getVersion()); if (coordinates.getClassifier() != null) { artifactSubPath.append('-'); artifactSubPath.append(coordinates.getClassifier()); } artifactSubPath.append('.'); artifactSubPath.append(coordinates.getType()); return artifactSubPath.toString(); }
[ "public", "static", "String", "getMavenPath", "(", "PluginCoordinates", "coordinates", ")", "{", "StringBuilder", "artifactSubPath", "=", "new", "StringBuilder", "(", ")", ";", "artifactSubPath", ".", "append", "(", "coordinates", ".", "getGroupId", "(", ")", ".",...
Calculates the relative path of the artifact from the given coordinates. @param coordinates the coordinates @return the maven path
[ "Calculates", "the", "relative", "path", "of", "the", "artifact", "from", "the", "given", "coordinates", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/plugin/src/main/java/io/apiman/common/plugin/PluginUtils.java#L136-L154
train
apiman/apiman
manager/api/core/src/main/java/io/apiman/manager/api/core/logging/JsonLoggerImpl.java
JsonLoggerImpl.createLogger
@Override public IApimanLogger createLogger(Class <?> klazz) { delegatedLogger = LogManager.getLogger(klazz); this.klazz = klazz; return this; }
java
@Override public IApimanLogger createLogger(Class <?> klazz) { delegatedLogger = LogManager.getLogger(klazz); this.klazz = klazz; return this; }
[ "@", "Override", "public", "IApimanLogger", "createLogger", "(", "Class", "<", "?", ">", "klazz", ")", "{", "delegatedLogger", "=", "LogManager", ".", "getLogger", "(", "klazz", ")", ";", "this", ".", "klazz", "=", "klazz", ";", "return", "this", ";", "}...
Instantiate a JsonLogger @param klazz the class instantiating logger
[ "Instantiate", "a", "JsonLogger" ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/core/src/main/java/io/apiman/manager/api/core/logging/JsonLoggerImpl.java#L137-L142
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/CachingPolicy.java
CachingPolicy.buildCacheID
private static String buildCacheID(ApiRequest request) { StringBuilder req = new StringBuilder(); if (request.getContract() != null) { req.append(request.getApiKey()); } else { req.append(request.getApiOrgId()).append(KEY_SEPARATOR).append(request.getApiId()) .append(KEY_SEPARATOR).append(request.getApiVersion()); } req.append(KEY_SEPARATOR).append(request.getType()).append(KEY_SEPARATOR) .append(request.getDestination()); return req.toString(); }
java
private static String buildCacheID(ApiRequest request) { StringBuilder req = new StringBuilder(); if (request.getContract() != null) { req.append(request.getApiKey()); } else { req.append(request.getApiOrgId()).append(KEY_SEPARATOR).append(request.getApiId()) .append(KEY_SEPARATOR).append(request.getApiVersion()); } req.append(KEY_SEPARATOR).append(request.getType()).append(KEY_SEPARATOR) .append(request.getDestination()); return req.toString(); }
[ "private", "static", "String", "buildCacheID", "(", "ApiRequest", "request", ")", "{", "StringBuilder", "req", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "request", ".", "getContract", "(", ")", "!=", "null", ")", "{", "req", ".", "append", "...
Builds a cached request id composed by the API key followed by the HTTP verb and the destination. In the case where there's no API key the ID will contain ApiOrgId + ApiId + ApiVersion
[ "Builds", "a", "cached", "request", "id", "composed", "by", "the", "API", "key", "followed", "by", "the", "HTTP", "verb", "and", "the", "destination", ".", "In", "the", "case", "where", "there", "s", "no", "API", "key", "the", "ID", "will", "contain", ...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/CachingPolicy.java#L177-L188
train
apiman/apiman
gateway/engine/redis/src/main/java/io/apiman/gateway/engine/redis/common/RedisClientManager.java
RedisClientManager.reset
public void reset() { if (nonNull(client)) { synchronized (mutex) { if (nonNull(client)) { // double-guard client.shutdown(); client = null; } } } }
java
public void reset() { if (nonNull(client)) { synchronized (mutex) { if (nonNull(client)) { // double-guard client.shutdown(); client = null; } } } }
[ "public", "void", "reset", "(", ")", "{", "if", "(", "nonNull", "(", "client", ")", ")", "{", "synchronized", "(", "mutex", ")", "{", "if", "(", "nonNull", "(", "client", ")", ")", "{", "// double-guard", "client", ".", "shutdown", "(", ")", ";", "...
Shut down the Redis client.
[ "Shut", "down", "the", "Redis", "client", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/redis/src/main/java/io/apiman/gateway/engine/redis/common/RedisClientManager.java#L103-L112
train
apiman/apiman
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/ApimanLauncher.java
ApimanLauncher.handleDeployFailed
@Override public void handleDeployFailed(Vertx vertx, String mainVerticle, DeploymentOptions deploymentOptions, Throwable cause) { // Default behaviour is to close Vert.x if the deploy failed vertx.close(); }
java
@Override public void handleDeployFailed(Vertx vertx, String mainVerticle, DeploymentOptions deploymentOptions, Throwable cause) { // Default behaviour is to close Vert.x if the deploy failed vertx.close(); }
[ "@", "Override", "public", "void", "handleDeployFailed", "(", "Vertx", "vertx", ",", "String", "mainVerticle", ",", "DeploymentOptions", "deploymentOptions", ",", "Throwable", "cause", ")", "{", "// Default behaviour is to close Vert.x if the deploy failed", "vertx", ".", ...
A deployment failure has been encountered. You can override this method to customize the behavior. By default it closes the `vertx` instance. @param vertx the vert.x instance @param mainVerticle the verticle @param deploymentOptions the verticle deployment options @param cause the cause of the failure
[ "A", "deployment", "failure", "has", "been", "encountered", ".", "You", "can", "override", "this", "method", "to", "customize", "the", "behavior", ".", "By", "default", "it", "closes", "the", "vertx", "instance", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/ApimanLauncher.java#L109-L113
train
apiman/apiman
manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java
EsMarshalling.preMarshall
private static void preMarshall(Object bean) { try { Method method = bean.getClass().getDeclaredMethod("encryptData"); if (method != null) { method.invoke(bean); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } }
java
private static void preMarshall(Object bean) { try { Method method = bean.getClass().getDeclaredMethod("encryptData"); if (method != null) { method.invoke(bean); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } }
[ "private", "static", "void", "preMarshall", "(", "Object", "bean", ")", "{", "try", "{", "Method", "method", "=", "bean", ".", "getClass", "(", ")", ".", "getDeclaredMethod", "(", "\"encryptData\"", ")", ";", "if", "(", "method", "!=", "null", ")", "{", ...
Called before marshalling the bean to a form that will be used for storage in the DB. @param bean
[ "Called", "before", "marshalling", "the", "bean", "to", "a", "form", "that", "will", "be", "used", "for", "storage", "in", "the", "DB", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsMarshalling.java#L1437-L1446
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.getApiKey
protected String getApiKey(HttpServletRequest request, QueryMap queryParams) { String apiKey = request.getHeader("X-API-Key"); //$NON-NLS-1$ if (apiKey == null || apiKey.trim().length() == 0) { apiKey = queryParams.get("apikey"); //$NON-NLS-1$ } return apiKey; }
java
protected String getApiKey(HttpServletRequest request, QueryMap queryParams) { String apiKey = request.getHeader("X-API-Key"); //$NON-NLS-1$ if (apiKey == null || apiKey.trim().length() == 0) { apiKey = queryParams.get("apikey"); //$NON-NLS-1$ } return apiKey; }
[ "protected", "String", "getApiKey", "(", "HttpServletRequest", "request", ",", "QueryMap", "queryParams", ")", "{", "String", "apiKey", "=", "request", ".", "getHeader", "(", "\"X-API-Key\"", ")", ";", "//$NON-NLS-1$", "if", "(", "apiKey", "==", "null", "||", ...
Gets the API Key from the request. The API key can be passed either via a custom http request header called X-API-Key or else by a query parameter in the URL called apikey. @param request the inbound request @param queryParams the inbound request query params @return the api key or null if not found
[ "Gets", "the", "API", "Key", "from", "the", "request", ".", "The", "API", "key", "can", "be", "passed", "either", "via", "a", "custom", "http", "request", "header", "called", "X", "-", "API", "-", "Key", "or", "else", "by", "a", "query", "parameter", ...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L250-L256
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.writeResponse
protected void writeResponse(HttpServletResponse response, ApiResponse sresponse) { response.setStatus(sresponse.getCode()); for (Entry<String, String> entry : sresponse.getHeaders()) { response.addHeader(entry.getKey(), entry.getValue()); } }
java
protected void writeResponse(HttpServletResponse response, ApiResponse sresponse) { response.setStatus(sresponse.getCode()); for (Entry<String, String> entry : sresponse.getHeaders()) { response.addHeader(entry.getKey(), entry.getValue()); } }
[ "protected", "void", "writeResponse", "(", "HttpServletResponse", "response", ",", "ApiResponse", "sresponse", ")", "{", "response", ".", "setStatus", "(", "sresponse", ".", "getCode", "(", ")", ")", ";", "for", "(", "Entry", "<", "String", ",", "String", ">...
Writes the API response to the HTTP servlet response object. @param response @param sresponse
[ "Writes", "the", "API", "response", "to", "the", "HTTP", "servlet", "response", "object", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L293-L298
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.writeFailure
protected void writeFailure(final ApiRequest request, final HttpServletResponse resp, final PolicyFailure policyFailure) { getFailureWriter().write(request, policyFailure, new IApiClientResponse() { @Override public void write(StringBuffer buffer) { write(buffer.toString()); } @Override public void write(StringBuilder builder) { write(builder.toString()); } @Override public void write(String body) { try { resp.getOutputStream().write(body.getBytes("UTF-8")); //$NON-NLS-1$ resp.getOutputStream().flush(); } catch (IOException e) { e.printStackTrace(); } } /** * @see io.apiman.gateway.engine.IApiClientResponse#setStatusCode(int) */ @Override public void setStatusCode(int code) { resp.setStatus(code); } @Override public void setHeader(String headerName, String headerValue) { resp.setHeader(headerName, headerValue); } }); }
java
protected void writeFailure(final ApiRequest request, final HttpServletResponse resp, final PolicyFailure policyFailure) { getFailureWriter().write(request, policyFailure, new IApiClientResponse() { @Override public void write(StringBuffer buffer) { write(buffer.toString()); } @Override public void write(StringBuilder builder) { write(builder.toString()); } @Override public void write(String body) { try { resp.getOutputStream().write(body.getBytes("UTF-8")); //$NON-NLS-1$ resp.getOutputStream().flush(); } catch (IOException e) { e.printStackTrace(); } } /** * @see io.apiman.gateway.engine.IApiClientResponse#setStatusCode(int) */ @Override public void setStatusCode(int code) { resp.setStatus(code); } @Override public void setHeader(String headerName, String headerValue) { resp.setHeader(headerName, headerValue); } }); }
[ "protected", "void", "writeFailure", "(", "final", "ApiRequest", "request", ",", "final", "HttpServletResponse", "resp", ",", "final", "PolicyFailure", "policyFailure", ")", "{", "getFailureWriter", "(", ")", ".", "write", "(", "request", ",", "policyFailure", ","...
Writes a policy failure to the http response. @param request @param resp @param policyFailure
[ "Writes", "a", "policy", "failure", "to", "the", "http", "response", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L306-L341
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.writeError
protected void writeError(final ApiRequest request, final HttpServletResponse resp, final Throwable error) { getErrorWriter().write(request, error, new IApiClientResponse() { @Override public void write(StringBuffer buffer) { write(buffer.toString()); } @Override public void write(StringBuilder builder) { write(builder.toString()); } @Override public void write(String body) { try { resp.getOutputStream().write(body.getBytes("UTF-8")); //$NON-NLS-1$ resp.getOutputStream().flush(); } catch (IOException e) { e.printStackTrace(); } } /** * @see io.apiman.gateway.engine.IApiClientResponse#setStatusCode(int) */ @Override public void setStatusCode(int code) { resp.setStatus(code); } @Override public void setHeader(String headerName, String headerValue) { resp.setHeader(headerName, headerValue); } }); }
java
protected void writeError(final ApiRequest request, final HttpServletResponse resp, final Throwable error) { getErrorWriter().write(request, error, new IApiClientResponse() { @Override public void write(StringBuffer buffer) { write(buffer.toString()); } @Override public void write(StringBuilder builder) { write(builder.toString()); } @Override public void write(String body) { try { resp.getOutputStream().write(body.getBytes("UTF-8")); //$NON-NLS-1$ resp.getOutputStream().flush(); } catch (IOException e) { e.printStackTrace(); } } /** * @see io.apiman.gateway.engine.IApiClientResponse#setStatusCode(int) */ @Override public void setStatusCode(int code) { resp.setStatus(code); } @Override public void setHeader(String headerName, String headerValue) { resp.setHeader(headerName, headerValue); } }); }
[ "protected", "void", "writeError", "(", "final", "ApiRequest", "request", ",", "final", "HttpServletResponse", "resp", ",", "final", "Throwable", "error", ")", "{", "getErrorWriter", "(", ")", ".", "write", "(", "request", ",", "error", ",", "new", "IApiClient...
Writes an error to the servlet response object. @param request @param resp @param error
[ "Writes", "an", "error", "to", "the", "servlet", "response", "object", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L349-L384
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.parseApiRequestPath
protected static final ApiRequestPathInfo parseApiRequestPath(HttpServletRequest request) { return ApimanPathUtils.parseApiRequestPath(request.getHeader(ApimanPathUtils.X_API_VERSION_HEADER), request.getHeader(ApimanPathUtils.ACCEPT_HEADER), request.getPathInfo()); }
java
protected static final ApiRequestPathInfo parseApiRequestPath(HttpServletRequest request) { return ApimanPathUtils.parseApiRequestPath(request.getHeader(ApimanPathUtils.X_API_VERSION_HEADER), request.getHeader(ApimanPathUtils.ACCEPT_HEADER), request.getPathInfo()); }
[ "protected", "static", "final", "ApiRequestPathInfo", "parseApiRequestPath", "(", "HttpServletRequest", "request", ")", "{", "return", "ApimanPathUtils", ".", "parseApiRequestPath", "(", "request", ".", "getHeader", "(", "ApimanPathUtils", ".", "X_API_VERSION_HEADER", ")"...
Parse a API request path from servlet path info. @param pathInfo @return the path info parsed into its component parts
[ "Parse", "a", "API", "request", "path", "from", "servlet", "path", "info", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L391-L395
train
apiman/apiman
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
GatewayServlet.parseApiRequestQueryParams
protected static final QueryMap parseApiRequestQueryParams(String queryString) { QueryMap rval = new QueryMap(); if (queryString != null) { try { String[] pairSplit = queryString.split("&"); //$NON-NLS-1$ for (String paramPair : pairSplit) { int idx = paramPair.indexOf("="); //$NON-NLS-1$ String key, value; if (idx != -1) { key = URLDecoder.decode(paramPair.substring(0, idx), "UTF-8"); //$NON-NLS-1$ value = URLDecoder.decode(paramPair.substring(idx + 1), "UTF-8"); //$NON-NLS-1$ } else { key = URLDecoder.decode(paramPair, "UTF-8"); //$NON-NLS-1$ value = null; } rval.add(key, value); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } return rval; }
java
protected static final QueryMap parseApiRequestQueryParams(String queryString) { QueryMap rval = new QueryMap(); if (queryString != null) { try { String[] pairSplit = queryString.split("&"); //$NON-NLS-1$ for (String paramPair : pairSplit) { int idx = paramPair.indexOf("="); //$NON-NLS-1$ String key, value; if (idx != -1) { key = URLDecoder.decode(paramPair.substring(0, idx), "UTF-8"); //$NON-NLS-1$ value = URLDecoder.decode(paramPair.substring(idx + 1), "UTF-8"); //$NON-NLS-1$ } else { key = URLDecoder.decode(paramPair, "UTF-8"); //$NON-NLS-1$ value = null; } rval.add(key, value); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } return rval; }
[ "protected", "static", "final", "QueryMap", "parseApiRequestQueryParams", "(", "String", "queryString", ")", "{", "QueryMap", "rval", "=", "new", "QueryMap", "(", ")", ";", "if", "(", "queryString", "!=", "null", ")", "{", "try", "{", "String", "[", "]", "...
Parses the query string into a map. @param queryString
[ "Parses", "the", "query", "string", "into", "a", "map", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java#L401-L426
train
apiman/apiman
gateway/engine/hazelcast/src/main/java/io/apiman/gateway/engine/hazelcast/common/HazelcastInstanceManager.java
HazelcastInstanceManager.reset
public void reset() { if (null != hazelcastInstance) { synchronized (mutex) { if (null == hazelcastInstance) { hazelcastInstance.shutdown(); hazelcastInstance = null; } } } if (!stores.isEmpty()) { synchronized (mutex) { stores.clear(); } } }
java
public void reset() { if (null != hazelcastInstance) { synchronized (mutex) { if (null == hazelcastInstance) { hazelcastInstance.shutdown(); hazelcastInstance = null; } } } if (!stores.isEmpty()) { synchronized (mutex) { stores.clear(); } } }
[ "public", "void", "reset", "(", ")", "{", "if", "(", "null", "!=", "hazelcastInstance", ")", "{", "synchronized", "(", "mutex", ")", "{", "if", "(", "null", "==", "hazelcastInstance", ")", "{", "hazelcastInstance", ".", "shutdown", "(", ")", ";", "hazelc...
Shut down the Hazelcast instance and clear stores references.
[ "Shut", "down", "the", "Hazelcast", "instance", "and", "clear", "stores", "references", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/hazelcast/src/main/java/io/apiman/gateway/engine/hazelcast/common/HazelcastInstanceManager.java#L76-L90
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/FieldValidator.java
FieldValidator.validateName
public static void validateName(String name) throws InvalidNameException { if (StringUtils.isEmpty(name)) { throw ExceptionFactory.invalidNameException(Messages.i18n.format("FieldValidator.EmptyNameError")); //$NON-NLS-1$ } }
java
public static void validateName(String name) throws InvalidNameException { if (StringUtils.isEmpty(name)) { throw ExceptionFactory.invalidNameException(Messages.i18n.format("FieldValidator.EmptyNameError")); //$NON-NLS-1$ } }
[ "public", "static", "void", "validateName", "(", "String", "name", ")", "throws", "InvalidNameException", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "name", ")", ")", "{", "throw", "ExceptionFactory", ".", "invalidNameException", "(", "Messages", ".", ...
Validates an entity name. @param name @throws InvalidNameException
[ "Validates", "an", "entity", "name", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/FieldValidator.java#L38-L42
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/FieldValidator.java
FieldValidator.validateVersion
public static void validateVersion(String name) throws InvalidNameException { if (StringUtils.isEmpty(name)) { throw ExceptionFactory.invalidVersionException(Messages.i18n.format("FieldValidator.EmptyVersionError")); //$NON-NLS-1$ } }
java
public static void validateVersion(String name) throws InvalidNameException { if (StringUtils.isEmpty(name)) { throw ExceptionFactory.invalidVersionException(Messages.i18n.format("FieldValidator.EmptyVersionError")); //$NON-NLS-1$ } }
[ "public", "static", "void", "validateVersion", "(", "String", "name", ")", "throws", "InvalidNameException", "{", "if", "(", "StringUtils", ".", "isEmpty", "(", "name", ")", ")", "{", "throw", "ExceptionFactory", ".", "invalidVersionException", "(", "Messages", ...
Validates an version. @param name @throws InvalidNameException
[ "Validates", "an", "version", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/util/FieldValidator.java#L49-L53
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/SingleNodeRateLimiterComponent.java
SingleNodeRateLimiterComponent.saveBuckets
private void saveBuckets() { if (lastModifiedOn > lastSavedOn) { System.out.println("Persisting current rates to: " + savedRates); //$NON-NLS-1$ Properties props = new Properties(); for (Entry<String, RateLimiterBucket> entry : buckets.entrySet()) { String value = entry.getValue().getCount() + "|" + entry.getValue().getLast(); //$NON-NLS-1$ props.setProperty(entry.getKey(), value); } try (FileWriter writer = new FileWriter(savedRates)) { props.store(writer, "All apiman rate limits"); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } lastSavedOn = System.currentTimeMillis(); } }
java
private void saveBuckets() { if (lastModifiedOn > lastSavedOn) { System.out.println("Persisting current rates to: " + savedRates); //$NON-NLS-1$ Properties props = new Properties(); for (Entry<String, RateLimiterBucket> entry : buckets.entrySet()) { String value = entry.getValue().getCount() + "|" + entry.getValue().getLast(); //$NON-NLS-1$ props.setProperty(entry.getKey(), value); } try (FileWriter writer = new FileWriter(savedRates)) { props.store(writer, "All apiman rate limits"); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } lastSavedOn = System.currentTimeMillis(); } }
[ "private", "void", "saveBuckets", "(", ")", "{", "if", "(", "lastModifiedOn", ">", "lastSavedOn", ")", "{", "System", ".", "out", ".", "println", "(", "\"Persisting current rates to: \"", "+", "savedRates", ")", ";", "//$NON-NLS-1$", "Properties", "props", "=", ...
Saves the current list of buckets into a file.
[ "Saves", "the", "current", "list", "of", "buckets", "into", "a", "file", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/SingleNodeRateLimiterComponent.java#L140-L155
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/SingleNodeRateLimiterComponent.java
SingleNodeRateLimiterComponent.loadBuckets
private void loadBuckets() { Properties props = new Properties(); try (FileReader reader = new FileReader(savedRates)) { props.load(reader); } catch (IOException e) { throw new RuntimeException(e); } for (Entry<Object, Object> entry : props.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue().toString(); String [] split = value.split("="); //$NON-NLS-1$ long count = new Long(split[0]); long last = new Long(split[1]); RateLimiterBucket bucket = new RateLimiterBucket(); bucket.setCount(count); bucket.setLast(last); this.buckets.put(key, bucket); } }
java
private void loadBuckets() { Properties props = new Properties(); try (FileReader reader = new FileReader(savedRates)) { props.load(reader); } catch (IOException e) { throw new RuntimeException(e); } for (Entry<Object, Object> entry : props.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue().toString(); String [] split = value.split("="); //$NON-NLS-1$ long count = new Long(split[0]); long last = new Long(split[1]); RateLimiterBucket bucket = new RateLimiterBucket(); bucket.setCount(count); bucket.setLast(last); this.buckets.put(key, bucket); } }
[ "private", "void", "loadBuckets", "(", ")", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "try", "(", "FileReader", "reader", "=", "new", "FileReader", "(", "savedRates", ")", ")", "{", "props", ".", "load", "(", "reader", ")", "...
Loads the saved rates from a file. Done only on startup.
[ "Loads", "the", "saved", "rates", "from", "a", "file", ".", "Done", "only", "on", "startup", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/SingleNodeRateLimiterComponent.java#L160-L178
train
apiman/apiman
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/auth/LDAPIdentityValidator.java
LDAPIdentityValidator.formatDn
private String formatDn(String dnPattern, String username, ApiRequest request) { Map<String, String> valuesMap = request.getHeaders().toMap(); valuesMap.put("username", username); //$NON-NLS-1$ StrSubstitutor sub = new StrSubstitutor(valuesMap); return sub.replace(dnPattern); }
java
private String formatDn(String dnPattern, String username, ApiRequest request) { Map<String, String> valuesMap = request.getHeaders().toMap(); valuesMap.put("username", username); //$NON-NLS-1$ StrSubstitutor sub = new StrSubstitutor(valuesMap); return sub.replace(dnPattern); }
[ "private", "String", "formatDn", "(", "String", "dnPattern", ",", "String", "username", ",", "ApiRequest", "request", ")", "{", "Map", "<", "String", ",", "String", ">", "valuesMap", "=", "request", ".", "getHeaders", "(", ")", ".", "toMap", "(", ")", ";...
Formats the configured DN by replacing any properties it finds. @param dnPattern @param username @param request
[ "Formats", "the", "configured", "DN", "by", "replacing", "any", "properties", "it", "finds", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/auth/LDAPIdentityValidator.java#L269-L274
train
apiman/apiman
common/es/src/main/java/io/apiman/common/es/util/ESUtils.java
ESUtils.rootCause
public static Throwable rootCause(Throwable e) { Throwable cause = e; while (cause.getCause() != null) { cause = e.getCause(); } return cause; }
java
public static Throwable rootCause(Throwable e) { Throwable cause = e; while (cause.getCause() != null) { cause = e.getCause(); } return cause; }
[ "public", "static", "Throwable", "rootCause", "(", "Throwable", "e", ")", "{", "Throwable", "cause", "=", "e", ";", "while", "(", "cause", ".", "getCause", "(", ")", "!=", "null", ")", "{", "cause", "=", "e", ".", "getCause", "(", ")", ";", "}", "r...
Gets the root cause of an exception. @param e the root cause @return the throwable
[ "Gets", "the", "root", "cause", "of", "an", "exception", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/es/src/main/java/io/apiman/common/es/util/ESUtils.java#L36-L42
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java
ActionResourceImpl.retireApi
private void retireApi(ActionBean action) throws ActionException { if (!securityContext.hasPermission(PermissionType.apiAdmin, action.getOrganizationId())) throw ExceptionFactory.notAuthorizedException(); ApiVersionBean versionBean; try { versionBean = orgs.getApiVersion(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion()); } catch (ApiVersionNotFoundException e) { throw ExceptionFactory.actionException(Messages.i18n.format("ApiNotFound")); //$NON-NLS-1$ } // Validate that it's ok to perform this action - API must be Published. if (versionBean.getStatus() != ApiStatus.Published) { throw ExceptionFactory.actionException(Messages.i18n.format("InvalidApiStatus")); //$NON-NLS-1$ } Api gatewayApi = new Api(); gatewayApi.setOrganizationId(versionBean.getApi().getOrganization().getId()); gatewayApi.setApiId(versionBean.getApi().getId()); gatewayApi.setVersion(versionBean.getVersion()); // Retire the API from all relevant gateways try { storage.beginTx(); Set<ApiGatewayBean> gateways = versionBean.getGateways(); if (gateways == null) { throw new PublishingException("No gateways specified for API!"); //$NON-NLS-1$ } for (ApiGatewayBean apiGatewayBean : gateways) { IGatewayLink gatewayLink = createGatewayLink(apiGatewayBean.getGatewayId()); gatewayLink.retireApi(gatewayApi); gatewayLink.close(); } versionBean.setStatus(ApiStatus.Retired); versionBean.setRetiredOn(new Date()); ApiBean api = storage.getApi(action.getOrganizationId(), action.getEntityId()); if (api == null) { throw new PublishingException("Error: could not find API - " + action.getOrganizationId() + "=>" + action.getEntityId()); //$NON-NLS-1$ //$NON-NLS-2$ } if (api.getNumPublished() == null || api.getNumPublished() == 0) { api.setNumPublished(0); } else { api.setNumPublished(api.getNumPublished() - 1); } storage.updateApi(api); storage.updateApiVersion(versionBean); storage.createAuditEntry(AuditUtils.apiRetired(versionBean, securityContext)); storage.commitTx(); } catch (PublishingException e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("RetireError"), e); //$NON-NLS-1$ } catch (Exception e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("RetireError"), e); //$NON-NLS-1$ } log.debug(String.format("Successfully retired API %s on specified gateways: %s", //$NON-NLS-1$ versionBean.getApi().getName(), versionBean.getApi())); }
java
private void retireApi(ActionBean action) throws ActionException { if (!securityContext.hasPermission(PermissionType.apiAdmin, action.getOrganizationId())) throw ExceptionFactory.notAuthorizedException(); ApiVersionBean versionBean; try { versionBean = orgs.getApiVersion(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion()); } catch (ApiVersionNotFoundException e) { throw ExceptionFactory.actionException(Messages.i18n.format("ApiNotFound")); //$NON-NLS-1$ } // Validate that it's ok to perform this action - API must be Published. if (versionBean.getStatus() != ApiStatus.Published) { throw ExceptionFactory.actionException(Messages.i18n.format("InvalidApiStatus")); //$NON-NLS-1$ } Api gatewayApi = new Api(); gatewayApi.setOrganizationId(versionBean.getApi().getOrganization().getId()); gatewayApi.setApiId(versionBean.getApi().getId()); gatewayApi.setVersion(versionBean.getVersion()); // Retire the API from all relevant gateways try { storage.beginTx(); Set<ApiGatewayBean> gateways = versionBean.getGateways(); if (gateways == null) { throw new PublishingException("No gateways specified for API!"); //$NON-NLS-1$ } for (ApiGatewayBean apiGatewayBean : gateways) { IGatewayLink gatewayLink = createGatewayLink(apiGatewayBean.getGatewayId()); gatewayLink.retireApi(gatewayApi); gatewayLink.close(); } versionBean.setStatus(ApiStatus.Retired); versionBean.setRetiredOn(new Date()); ApiBean api = storage.getApi(action.getOrganizationId(), action.getEntityId()); if (api == null) { throw new PublishingException("Error: could not find API - " + action.getOrganizationId() + "=>" + action.getEntityId()); //$NON-NLS-1$ //$NON-NLS-2$ } if (api.getNumPublished() == null || api.getNumPublished() == 0) { api.setNumPublished(0); } else { api.setNumPublished(api.getNumPublished() - 1); } storage.updateApi(api); storage.updateApiVersion(versionBean); storage.createAuditEntry(AuditUtils.apiRetired(versionBean, securityContext)); storage.commitTx(); } catch (PublishingException e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("RetireError"), e); //$NON-NLS-1$ } catch (Exception e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("RetireError"), e); //$NON-NLS-1$ } log.debug(String.format("Successfully retired API %s on specified gateways: %s", //$NON-NLS-1$ versionBean.getApi().getName(), versionBean.getApi())); }
[ "private", "void", "retireApi", "(", "ActionBean", "action", ")", "throws", "ActionException", "{", "if", "(", "!", "securityContext", ".", "hasPermission", "(", "PermissionType", ".", "apiAdmin", ",", "action", ".", "getOrganizationId", "(", ")", ")", ")", "t...
Retires an API that is currently published to the Gateway. @param action
[ "Retires", "an", "API", "that", "is", "currently", "published", "to", "the", "Gateway", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java#L260-L321
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java
ActionResourceImpl.aggregateContractPolicies
private List<Policy> aggregateContractPolicies(ContractSummaryBean contractBean) { try { List<Policy> policies = new ArrayList<>(); PolicyType [] types = new PolicyType[] { PolicyType.Client, PolicyType.Plan, PolicyType.Api }; for (PolicyType policyType : types) { String org, id, ver; switch (policyType) { case Client: { org = contractBean.getClientOrganizationId(); id = contractBean.getClientId(); ver = contractBean.getClientVersion(); break; } case Plan: { org = contractBean.getApiOrganizationId(); id = contractBean.getPlanId(); ver = contractBean.getPlanVersion(); break; } case Api: { org = contractBean.getApiOrganizationId(); id = contractBean.getApiId(); ver = contractBean.getApiVersion(); break; } default: { throw new RuntimeException("Missing case for switch!"); //$NON-NLS-1$ } } List<PolicySummaryBean> clientPolicies = query.getPolicies(org, id, ver, policyType); try { storage.beginTx(); for (PolicySummaryBean policySummaryBean : clientPolicies) { PolicyBean policyBean = storage.getPolicy(policyType, org, id, ver, policySummaryBean.getId()); Policy policy = new Policy(); policy.setPolicyJsonConfig(policyBean.getConfiguration()); policy.setPolicyImpl(policyBean.getDefinition().getPolicyImpl()); policies.add(policy); } } finally { storage.rollbackTx(); } } return policies; } catch (Exception e) { throw ExceptionFactory.actionException( Messages.i18n.format("ErrorAggregatingPolicies", contractBean.getClientId() + "->" + contractBean.getApiDescription()), e); //$NON-NLS-1$ //$NON-NLS-2$ } }
java
private List<Policy> aggregateContractPolicies(ContractSummaryBean contractBean) { try { List<Policy> policies = new ArrayList<>(); PolicyType [] types = new PolicyType[] { PolicyType.Client, PolicyType.Plan, PolicyType.Api }; for (PolicyType policyType : types) { String org, id, ver; switch (policyType) { case Client: { org = contractBean.getClientOrganizationId(); id = contractBean.getClientId(); ver = contractBean.getClientVersion(); break; } case Plan: { org = contractBean.getApiOrganizationId(); id = contractBean.getPlanId(); ver = contractBean.getPlanVersion(); break; } case Api: { org = contractBean.getApiOrganizationId(); id = contractBean.getApiId(); ver = contractBean.getApiVersion(); break; } default: { throw new RuntimeException("Missing case for switch!"); //$NON-NLS-1$ } } List<PolicySummaryBean> clientPolicies = query.getPolicies(org, id, ver, policyType); try { storage.beginTx(); for (PolicySummaryBean policySummaryBean : clientPolicies) { PolicyBean policyBean = storage.getPolicy(policyType, org, id, ver, policySummaryBean.getId()); Policy policy = new Policy(); policy.setPolicyJsonConfig(policyBean.getConfiguration()); policy.setPolicyImpl(policyBean.getDefinition().getPolicyImpl()); policies.add(policy); } } finally { storage.rollbackTx(); } } return policies; } catch (Exception e) { throw ExceptionFactory.actionException( Messages.i18n.format("ErrorAggregatingPolicies", contractBean.getClientId() + "->" + contractBean.getApiDescription()), e); //$NON-NLS-1$ //$NON-NLS-2$ } }
[ "private", "List", "<", "Policy", ">", "aggregateContractPolicies", "(", "ContractSummaryBean", "contractBean", ")", "{", "try", "{", "List", "<", "Policy", ">", "policies", "=", "new", "ArrayList", "<>", "(", ")", ";", "PolicyType", "[", "]", "types", "=", ...
Aggregates the API, client, and plan policies into a single ordered list. @param contractBean
[ "Aggregates", "the", "API", "client", "and", "plan", "policies", "into", "a", "single", "ordered", "list", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java#L451-L501
train
apiman/apiman
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java
ActionResourceImpl.lockPlan
private void lockPlan(ActionBean action) throws ActionException { if (!securityContext.hasPermission(PermissionType.planAdmin, action.getOrganizationId())) throw ExceptionFactory.notAuthorizedException(); PlanVersionBean versionBean; try { versionBean = orgs.getPlanVersion(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion()); } catch (PlanVersionNotFoundException e) { throw ExceptionFactory.actionException(Messages.i18n.format("PlanNotFound")); //$NON-NLS-1$ } // Validate that it's ok to perform this action - plan must not already be locked if (versionBean.getStatus() == PlanStatus.Locked) { throw ExceptionFactory.actionException(Messages.i18n.format("InvalidPlanStatus")); //$NON-NLS-1$ } versionBean.setStatus(PlanStatus.Locked); versionBean.setLockedOn(new Date()); try { storage.beginTx(); storage.updatePlanVersion(versionBean); storage.createAuditEntry(AuditUtils.planLocked(versionBean, securityContext)); storage.commitTx(); } catch (Exception e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("LockError"), e); //$NON-NLS-1$ } log.debug(String.format("Successfully locked Plan %s: %s", //$NON-NLS-1$ versionBean.getPlan().getName(), versionBean.getPlan())); }
java
private void lockPlan(ActionBean action) throws ActionException { if (!securityContext.hasPermission(PermissionType.planAdmin, action.getOrganizationId())) throw ExceptionFactory.notAuthorizedException(); PlanVersionBean versionBean; try { versionBean = orgs.getPlanVersion(action.getOrganizationId(), action.getEntityId(), action.getEntityVersion()); } catch (PlanVersionNotFoundException e) { throw ExceptionFactory.actionException(Messages.i18n.format("PlanNotFound")); //$NON-NLS-1$ } // Validate that it's ok to perform this action - plan must not already be locked if (versionBean.getStatus() == PlanStatus.Locked) { throw ExceptionFactory.actionException(Messages.i18n.format("InvalidPlanStatus")); //$NON-NLS-1$ } versionBean.setStatus(PlanStatus.Locked); versionBean.setLockedOn(new Date()); try { storage.beginTx(); storage.updatePlanVersion(versionBean); storage.createAuditEntry(AuditUtils.planLocked(versionBean, securityContext)); storage.commitTx(); } catch (Exception e) { storage.rollbackTx(); throw ExceptionFactory.actionException(Messages.i18n.format("LockError"), e); //$NON-NLS-1$ } log.debug(String.format("Successfully locked Plan %s: %s", //$NON-NLS-1$ versionBean.getPlan().getName(), versionBean.getPlan())); }
[ "private", "void", "lockPlan", "(", "ActionBean", "action", ")", "throws", "ActionException", "{", "if", "(", "!", "securityContext", ".", "hasPermission", "(", "PermissionType", ".", "planAdmin", ",", "action", ".", "getOrganizationId", "(", ")", ")", ")", "t...
Locks the plan. @param action
[ "Locks", "the", "plan", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java#L585-L616
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/DefaultPluginRegistry.java
DefaultPluginRegistry.readPluginFile
protected Plugin readPluginFile(PluginCoordinates coordinates, File pluginFile) throws Exception { try { PluginClassLoader pluginClassLoader = createPluginClassLoader(pluginFile); URL specFile = pluginClassLoader.getResource(PluginUtils.PLUGIN_SPEC_PATH); if (specFile == null) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.MissingPluginSpecFile", PluginUtils.PLUGIN_SPEC_PATH)); //$NON-NLS-1$ } else { PluginSpec spec = PluginUtils.readPluginSpecFile(specFile); Plugin plugin = new Plugin(spec, coordinates, pluginClassLoader); // TODO use logger when available System.out.println("Read apiman plugin: " + spec); //$NON-NLS-1$ return plugin; } } catch (Exception e) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.InvalidPlugin", pluginFile.getAbsolutePath()), e); //$NON-NLS-1$ } }
java
protected Plugin readPluginFile(PluginCoordinates coordinates, File pluginFile) throws Exception { try { PluginClassLoader pluginClassLoader = createPluginClassLoader(pluginFile); URL specFile = pluginClassLoader.getResource(PluginUtils.PLUGIN_SPEC_PATH); if (specFile == null) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.MissingPluginSpecFile", PluginUtils.PLUGIN_SPEC_PATH)); //$NON-NLS-1$ } else { PluginSpec spec = PluginUtils.readPluginSpecFile(specFile); Plugin plugin = new Plugin(spec, coordinates, pluginClassLoader); // TODO use logger when available System.out.println("Read apiman plugin: " + spec); //$NON-NLS-1$ return plugin; } } catch (Exception e) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.InvalidPlugin", pluginFile.getAbsolutePath()), e); //$NON-NLS-1$ } }
[ "protected", "Plugin", "readPluginFile", "(", "PluginCoordinates", "coordinates", ",", "File", "pluginFile", ")", "throws", "Exception", "{", "try", "{", "PluginClassLoader", "pluginClassLoader", "=", "createPluginClassLoader", "(", "pluginFile", ")", ";", "URL", "spe...
Reads the plugin into an object. This method will fail if the plugin is not valid. This could happen if the file is not a java archive, or if the plugin spec file is missing from the archive, etc.
[ "Reads", "the", "plugin", "into", "an", "object", ".", "This", "method", "will", "fail", "if", "the", "plugin", "is", "not", "valid", ".", "This", "could", "happen", "if", "the", "file", "is", "not", "a", "java", "archive", "or", "if", "the", "plugin",...
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/DefaultPluginRegistry.java#L298-L314
train
apiman/apiman
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/DefaultPluginRegistry.java
DefaultPluginRegistry.downloadArtifactTo
protected void downloadArtifactTo(URL artifactUrl, File pluginFile, IAsyncResultHandler<File> handler) { InputStream istream = null; OutputStream ostream = null; try { URLConnection connection = artifactUrl.openConnection(); connection.connect(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; if (httpConnection.getResponseCode() != 200) { handler.handle(AsyncResultImpl.create(null)); return; } } istream = connection.getInputStream(); ostream = new FileOutputStream(pluginFile); IOUtils.copy(istream, ostream); ostream.flush(); handler.handle(AsyncResultImpl.create(pluginFile)); } catch (Exception e) { handler.handle(AsyncResultImpl.<File>create(e)); } finally { IOUtils.closeQuietly(istream); IOUtils.closeQuietly(ostream); } }
java
protected void downloadArtifactTo(URL artifactUrl, File pluginFile, IAsyncResultHandler<File> handler) { InputStream istream = null; OutputStream ostream = null; try { URLConnection connection = artifactUrl.openConnection(); connection.connect(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = (HttpURLConnection) connection; if (httpConnection.getResponseCode() != 200) { handler.handle(AsyncResultImpl.create(null)); return; } } istream = connection.getInputStream(); ostream = new FileOutputStream(pluginFile); IOUtils.copy(istream, ostream); ostream.flush(); handler.handle(AsyncResultImpl.create(pluginFile)); } catch (Exception e) { handler.handle(AsyncResultImpl.<File>create(e)); } finally { IOUtils.closeQuietly(istream); IOUtils.closeQuietly(ostream); } }
[ "protected", "void", "downloadArtifactTo", "(", "URL", "artifactUrl", ",", "File", "pluginFile", ",", "IAsyncResultHandler", "<", "File", ">", "handler", ")", "{", "InputStream", "istream", "=", "null", ";", "OutputStream", "ostream", "=", "null", ";", "try", ...
Download the artifact at the given URL and store it locally into the given plugin file path.
[ "Download", "the", "artifact", "at", "the", "given", "URL", "and", "store", "it", "locally", "into", "the", "given", "plugin", "file", "path", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/DefaultPluginRegistry.java#L375-L399
train
apiman/apiman
gateway/platforms/war/src/main/java/io/apiman/gateway/platforms/war/WarGateway.java
WarGateway.init
public static void init() { config = new WarEngineConfig(); // Surface the max-payload-buffer-size property as a system property, if it exists in the apiman.properties file if (System.getProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE) == null) { String propVal = config.getConfigProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE, null); if (propVal != null) { System.setProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE, propVal); } } ConfigDrivenEngineFactory factory = new ConfigDrivenEngineFactory(config); engine = factory.createEngine(); failureFormatter = loadFailureFormatter(); errorFormatter = loadErrorFormatter(); }
java
public static void init() { config = new WarEngineConfig(); // Surface the max-payload-buffer-size property as a system property, if it exists in the apiman.properties file if (System.getProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE) == null) { String propVal = config.getConfigProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE, null); if (propVal != null) { System.setProperty(GatewayConfigProperties.MAX_PAYLOAD_BUFFER_SIZE, propVal); } } ConfigDrivenEngineFactory factory = new ConfigDrivenEngineFactory(config); engine = factory.createEngine(); failureFormatter = loadFailureFormatter(); errorFormatter = loadErrorFormatter(); }
[ "public", "static", "void", "init", "(", ")", "{", "config", "=", "new", "WarEngineConfig", "(", ")", ";", "// Surface the max-payload-buffer-size property as a system property, if it exists in the apiman.properties file", "if", "(", "System", ".", "getProperty", "(", "Gate...
Initialize the gateway.
[ "Initialize", "the", "gateway", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/war/src/main/java/io/apiman/gateway/platforms/war/WarGateway.java#L44-L58
train
apiman/apiman
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java
ESRegistry.validateClient
private void validateClient(Client client) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new NoContractFoundException(Messages.i18n.format("ESRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract); } }
java
private void validateClient(Client client) throws RegistrationException { Set<Contract> contracts = client.getContracts(); if (contracts.isEmpty()) { throw new NoContractFoundException(Messages.i18n.format("ESRegistry.NoContracts")); //$NON-NLS-1$ } for (Contract contract : contracts) { validateContract(contract); } }
[ "private", "void", "validateClient", "(", "Client", "client", ")", "throws", "RegistrationException", "{", "Set", "<", "Contract", ">", "contracts", "=", "client", ".", "getContracts", "(", ")", ";", "if", "(", "contracts", ".", "isEmpty", "(", ")", ")", "...
Validate that the client should be registered. @param client
[ "Validate", "that", "the", "client", "should", "be", "registered", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java#L145-L153
train
apiman/apiman
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java
ESRegistry.getApi
protected Api getApi(String id) throws IOException { Get get = new Get.Builder(getIndexName(), id).type("api").build(); //$NON-NLS-1$ JestResult result = getClient().execute(get); if (result.isSucceeded()) { Api api = result.getSourceAsObject(Api.class); return api; } else { return null; } }
java
protected Api getApi(String id) throws IOException { Get get = new Get.Builder(getIndexName(), id).type("api").build(); //$NON-NLS-1$ JestResult result = getClient().execute(get); if (result.isSucceeded()) { Api api = result.getSourceAsObject(Api.class); return api; } else { return null; } }
[ "protected", "Api", "getApi", "(", "String", "id", ")", "throws", "IOException", "{", "Get", "get", "=", "new", "Get", ".", "Builder", "(", "getIndexName", "(", ")", ",", "id", ")", ".", "type", "(", "\"api\"", ")", ".", "build", "(", ")", ";", "//...
Gets the api synchronously. @param id @throws IOException
[ "Gets", "the", "api", "synchronously", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java#L283-L292
train
apiman/apiman
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java
ESRegistry.getClient
protected Client getClient(String id) throws IOException { Get get = new Get.Builder(getIndexName(), id).type("client").build(); //$NON-NLS-1$ JestResult result = getClient().execute(get); if (result.isSucceeded()) { Client client = result.getSourceAsObject(Client.class); return client; } else { return null; } }
java
protected Client getClient(String id) throws IOException { Get get = new Get.Builder(getIndexName(), id).type("client").build(); //$NON-NLS-1$ JestResult result = getClient().execute(get); if (result.isSucceeded()) { Client client = result.getSourceAsObject(Client.class); return client; } else { return null; } }
[ "protected", "Client", "getClient", "(", "String", "id", ")", "throws", "IOException", "{", "Get", "get", "=", "new", "Get", ".", "Builder", "(", "getIndexName", "(", ")", ",", "id", ")", ".", "type", "(", "\"client\"", ")", ".", "build", "(", ")", "...
Gets the client synchronously. @param id @throws IOException
[ "Gets", "the", "client", "synchronously", "." ]
8c049c2a2f2e4a69bbb6125686a15edd26f29c21
https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESRegistry.java#L313-L322
train