AtlasAuthorizationUtils { public static String getApi(String contextPath) { if (isDebugEnabled) { LOG.debug("==> getApi({})", contextPath); } if(contextPath == null){ contextPath = ""; } if (contextPath.startsWith(BASE_URL)) { contextPath = contextPath.substring(BASE_URL.length()); } else { if (contextPath.startsWith("/")) { contextPath = contextPath.substring(1); } } String[] split = contextPath.split("/", 3); String api = split[0]; if (Pattern.matches("v\\d", api)) { api = split[1]; } if (isDebugEnabled) { LOG.debug("<== getApi({}): {}", contextPath, api); } return api; }  static String getApi(String contextPath); static AtlasActionTypes getAtlasAction(String method); static Set<AtlasResourceTypes> getAtlasResourceType(String contextPath); static boolean isAccessAllowed(AtlasResourceTypes resourcetype, AtlasActionTypes actionType, String userName, Set<String> groups, HttpServletRequest request); static String getRequestIpAddress(HttpServletRequest httpServletRequest);  }
@Test public void testGetApi() { String contextPath = "/api/atlas/entities"; assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities"); contextPath = "/api/atlas/entities/111/traits"; assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities"); contextPath = "/api/atlas/v1/entities"; assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities"); contextPath = "/api/atlas/v1/entities/111/tags"; assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "entities"); contextPath = "/foo/bar"; assertEquals(AtlasAuthorizationUtils.getApi(contextPath), "foo"); }