SpaceAccessVoter implements AccessDecisionVoter { protected String extractSpaceId(String pathInfo) { for (String prefix : EXCEPTIONAL_PATH_PREFIXES) { if (pathInfo.startsWith(prefix)) { return pathInfo.substring(prefix.length()); } } String spaceId = pathInfo; if (spaceId.startsWith("/")) { spaceId = pathInfo.substring(1); } int slashIndex = spaceId.indexOf("/"); if (slashIndex > 0) { spaceId = spaceId.substring(0, slashIndex); } return spaceId; } SpaceAccessVoter(StorageProviderFactory storageProviderFactory,
                            UserDetailsService userDetailsService); StorageProviderFactory getStorageProviderFactory(); boolean supports(ConfigAttribute configAttribute); boolean supports(Class aClass);  }
@Test public void testExtractSpaceIdFromPathInof() { String spaceId = "space-id"; String[] spaceIds = { "/manifest/" + spaceId, "/bit-integrity/" + spaceId, "/report/space/" + spaceId, "/" + spaceId + "/arbitrary-path/content-id" }; SpaceAccessVoter voter = new SpaceAccessVoter(null, null) { @Override public int vote(Authentication authentication, Object object, Collection attributes) { return 0; } }; for (String spid : spaceIds) { assertEquals(spaceId, voter.extractSpaceId(spid)); } }