id
stringlengths
7
14
text
stringlengths
1
106k
223551095_2411
public static LogSearchConfigServer createLogSearchConfigServer(Map<String, String> properties, Class<? extends LogSearchConfigServer> defaultClass, boolean init) throws Exception { try { LogSearchConfigServer logSearchConfig = null; String configClassName = properties.get("logsearch.config.server.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfigServer.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigServer) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigServer.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties); } return logSearchConfig; } catch (Exception e) { LOG.error("Could not initialize logsearch config.", e); throw e; } }
223551095_2412
public static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName, Class<? extends LogSearchConfigLogFeeder> defaultClass, boolean init) throws Exception { try { LogSearchConfigLogFeeder logSearchConfig = null; String configClassName = properties.get("logsearch.config.logfeeder.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfig.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigLogFeeder) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigLogFeeder.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties, clusterName == null ? "null" : clusterName.toLowerCase()); } return logSearchConfig; } catch (Exception e) { LOG.error("Could not initialize logsearch config.", e); throw e; } }
223551095_2413
public static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName, Class<? extends LogSearchConfigLogFeeder> defaultClass, boolean init) throws Exception { try { LogSearchConfigLogFeeder logSearchConfig = null; String configClassName = properties.get("logsearch.config.logfeeder.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfig.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigLogFeeder) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigLogFeeder.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties, clusterName == null ? "null" : clusterName.toLowerCase()); } return logSearchConfig; } catch (Exception e) { LOG.error("Could not initialize logsearch config.", e); throw e; } }
223551095_2414
public static LogSearchConfigLogFeeder createLogSearchConfigLogFeeder(Map<String, String> properties, String clusterName, Class<? extends LogSearchConfigLogFeeder> defaultClass, boolean init) throws Exception { try { LogSearchConfigLogFeeder logSearchConfig = null; String configClassName = properties.get("logsearch.config.logfeeder.class"); if (configClassName != null && !"".equals(configClassName.trim())) { Class<?> clazz = Class.forName(configClassName); if (LogSearchConfig.class.isAssignableFrom(clazz)) { logSearchConfig = (LogSearchConfigLogFeeder) clazz.newInstance(); } else { throw new IllegalArgumentException("Class " + configClassName + " does not implement the interface " + LogSearchConfigLogFeeder.class.getName()); } } else { logSearchConfig = defaultClass.newInstance(); } if (init) { logSearchConfig.init(properties, clusterName == null ? "null" : clusterName.toLowerCase()); } return logSearchConfig; } catch (Exception e) { LOG.error("Could not initialize logsearch config.", e); throw e; } }
223551095_2435
@Override public SolrQuery convert(EventHistoryRequest eventHistoryRequest) { SolrQuery eventHistoryQuery = new SolrQuery(); eventHistoryQuery.setQuery("*:*"); int startIndex = StringUtils.isNotEmpty(eventHistoryRequest.getStartIndex()) && StringUtils.isNumeric(eventHistoryRequest.getStartIndex()) ? Integer.parseInt(eventHistoryRequest.getStartIndex()) : 0; int maxRows = StringUtils.isNotEmpty(eventHistoryRequest.getPageSize()) && StringUtils.isNumeric(eventHistoryRequest.getPageSize()) ? Integer.parseInt(eventHistoryRequest.getPageSize()) : 10; SolrQuery.ORDER order = eventHistoryRequest.getSortType() != null && SolrQuery.ORDER.desc.equals(SolrQuery.ORDER.valueOf(eventHistoryRequest.getSortType())) ? SolrQuery.ORDER.desc : SolrQuery.ORDER.asc; String sortBy = StringUtils.isNotEmpty(eventHistoryRequest.getSortBy()) ? eventHistoryRequest.getSortBy() : FILTER_NAME; String filterName = StringUtils.isBlank(eventHistoryRequest.getFilterName()) ? "*" : "*" + eventHistoryRequest.getFilterName() + "*"; eventHistoryQuery.addFilterQuery(String.format("%s:%s", ROW_TYPE, eventHistoryRequest.getRowType())); eventHistoryQuery.addFilterQuery(String.format("%s:%s", FILTER_NAME, SolrUtil.makeSearcableString(filterName))); eventHistoryQuery.setStart(startIndex); eventHistoryQuery.setRows(maxRows); SolrQuery.SortClause sortOrder = SolrQuery.SortClause.create(sortBy, order); List<SolrQuery.SortClause> sort = new ArrayList<>(); sort.add(sortOrder); eventHistoryQuery.setSorts(sort); SolrUtil.addListFilterToSolrQuery(eventHistoryQuery, CLUSTER, eventHistoryRequest.getClusters()); return eventHistoryQuery; }
223551095_2446
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!authPropsConfig.isAuthExternalEnabled()) { LOG.debug("external server auth is disabled."); return authentication; } String username = authentication.getName(); String password = (String) authentication.getCredentials(); if (StringUtils.isBlank(username)) { throw new BadCredentialsException("Username can't be null or empty."); } if (StringUtils.isBlank(password)) { throw new BadCredentialsException("Password can't be null or empty."); } password = StringEscapeUtils.unescapeHtml(password); username = StringEscapeUtils.unescapeHtml(username); try { String finalLoginUrl = authPropsConfig.getExternalAuthLoginUrl().replace("$USERNAME", username); String responseObj = (String) externalServerClient.sendGETRequest(finalLoginUrl, String.class, username, password); if (!isAllowedRole(responseObj)) { LOG.error(username + " doesn't have permission"); throw new BadCredentialsException("Invalid User"); } } catch (Exception e) { LOG.error("Login failed for username :" + username + " Error :" + e.getLocalizedMessage()); throw new BadCredentialsException("Bad credentials"); } authentication = new UsernamePasswordAuthenticationToken(username, password, getAuthorities()); return authentication; }
223551095_2447
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (!authPropsConfig.isAuthExternalEnabled()) { LOG.debug("external server auth is disabled."); return authentication; } String username = authentication.getName(); String password = (String) authentication.getCredentials(); if (StringUtils.isBlank(username)) { throw new BadCredentialsException("Username can't be null or empty."); } if (StringUtils.isBlank(password)) { throw new BadCredentialsException("Password can't be null or empty."); } password = StringEscapeUtils.unescapeHtml(password); username = StringEscapeUtils.unescapeHtml(username); try { String finalLoginUrl = authPropsConfig.getExternalAuthLoginUrl().replace("$USERNAME", username); String responseObj = (String) externalServerClient.sendGETRequest(finalLoginUrl, String.class, username, password); if (!isAllowedRole(responseObj)) { LOG.error(username + " doesn't have permission"); throw new BadCredentialsException("Invalid User"); } } catch (Exception e) { LOG.error("Login failed for username :" + username + " Error :" + e.getLocalizedMessage()); throw new BadCredentialsException("Bad credentials"); } authentication = new UsernamePasswordAuthenticationToken(username, password, getAuthorities()); return authentication; }
223551095_2448
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2449
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2450
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2451
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2452
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2453
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2454
@Override public Authentication authenticate(Authentication inAuthentication) throws AuthenticationException { logger.info("Authenticating user:" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); logger.info("authentication.class=" + inAuthentication.getClass().getName()); HashMap<String, Object> auditRecord = new HashMap<String, Object>(); auditRecord.put("user", inAuthentication.getName()); auditRecord.put("principal", inAuthentication.getPrincipal().toString()); auditRecord.put("auth_class", inAuthentication.getClass().getName()); if (inAuthentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken authClass = (UsernamePasswordAuthenticationToken) inAuthentication; Object details = authClass.getDetails(); if (details instanceof WebAuthenticationDetails) { WebAuthenticationDetails webAuthentication = (WebAuthenticationDetails) details; auditRecord.put("remote_ip", webAuthentication.getRemoteAddress()); auditRecord.put("session", webAuthentication.getSessionId()); } } boolean isSuccess = false; try { Authentication authentication = inAuthentication; AuthenticationException authException = null; for (AuthMethod authMethod : AuthMethod.values()) { try { authentication = doAuth(authentication, authMethod); if (authentication != null && authentication.isAuthenticated()) { logger.info("Authenticated using method=" + authMethod.name() + ", user=" + authentication.getName()); auditRecord.put("result", "allowed"); isSuccess = true; auditRecord.put("authType", authMethod.name()); return authentication; } } catch (AuthenticationException ex) { if (authException == null) { authException = ex; } } catch (Exception e) { logger.error(e, e.getCause()); } } auditRecord.put("result", "denied"); logger.warn("Authentication failed for user=" + inAuthentication.getName() + ", userDetail=" + inAuthentication.toString()); if (authException != null) { auditRecord.put("reason", authException.getMessage()); throw authException; } return authentication; } finally { String jsonStr = JSONUtil.mapToJSON(auditRecord); auditLogger.log(isSuccess ? Level.INFO : Level.WARN, jsonStr); } }
223551095_2468
static String joinPaths(String firstPath, String... paths) { StringBuilder joined = new StringBuilder(firstPath); for(String path: paths) { if (path.isEmpty()) { /* NOP */ } else if (joined.length() == 0) { joined.append(path); } else if (joined.charAt(joined.length() - 1) == '/') { if (path.startsWith("/")) { joined.append(path.substring(1, path.length())); } else { joined.append(path); } } else { if (path.startsWith("/")) { joined.append(path); } else { joined.append('/').append(path); } } } return joined.toString(); }
223551095_2469
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2470
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2471
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2472
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2473
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2474
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }
223551095_2475
@Override public Swagger read(Set<Class<?>> classes) { // scan for and register nested API classes logger.debug("Looking for nested API's"); for (Class<?> cls: classes) { logger.debug("Examining API {}", cls.getSimpleName()); for (Method method: cls.getMethods()) { Path methodPath = AnnotationUtils.findAnnotation(method, Path.class); if (null != methodPath) { Class<?> returnType = method.getReturnType(); Api nestedApi = AnnotationUtils.findAnnotation(returnType, Api.class); Path nestedApiPath = AnnotationUtils.findAnnotation(returnType, Path.class); logger.debug("Examining API method {}#{}, path={}, returnType={}", cls.getSimpleName(), method.getName(), nestedApiPath != null ? nestedApiPath.value() : null, returnType.getSimpleName()); if (null != nestedApi) { if (null != nestedApiPath) { logger.info("This class exists both as top level and nested API: {}, treating it as top level API", returnType.getName()); } else { boolean skipAdd = false; Class<?> preferredParentClass = cls; String parentApiPath; String methodPathAsString = methodPath.value(); // API is a nested API of multiple top level APIs if (nestedAPIs.containsKey(returnType)) { SwaggerPreferredParent preferredParentAnnotation = AnnotationUtils.findAnnotation(returnType, SwaggerPreferredParent.class); if (null != preferredParentAnnotation) { preferredParentClass = preferredParentAnnotation.preferredParent(); if (nestedAPIs.get(returnType).parentApi.getName().equals(preferredParentClass.getName())) { skipAdd = true; } else { logger.info("Setting top level API of {} to {} based on @SwaggerPreferredParent " + "annotation", returnType, preferredParentClass.getSimpleName()); try { method = preferredParentClass.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException exc) { skipAdd = true; logger.error("{} class defined as parent API is invalid due to method mismatch! Ignoring " + "API {}", preferredParentClass, returnType); } } } else { logger.warn("{} is a nested API of multiple top level API's. Ignoring top level API {}", returnType, cls); skipAdd = true; } } if (skipAdd) { continue; } else { nestedAPIs.remove(returnType); } // API parent customization by @SwaggerOverwriteNestedAPI SwaggerOverwriteNestedAPI swaggerOverwriteNestedAPI = AnnotationUtils.findAnnotation(returnType, SwaggerOverwriteNestedAPI.class); if (null != swaggerOverwriteNestedAPI) { preferredParentClass = swaggerOverwriteNestedAPI.parentApi(); parentApiPath = swaggerOverwriteNestedAPI.parentApiPath(); methodPathAsString = swaggerOverwriteNestedAPI.parentMethodPath(); } else { parentApiPath = validateParentApiPath(preferredParentClass); } logger.info("Registering nested API: {}", returnType); NestedApiRecord nar = new NestedApiRecord(returnType, preferredParentClass, parentApiPath, method, methodPathAsString); nestedAPIs.put(returnType, nar); } } } } } logger.info("Found {} nested API's", nestedAPIs.size()); // With all information gathered, call superclass implementation return super.read(classes); }