public List<ResourceTreeEntity> getSpaces() throws NamespaceException, UnsupportedEncodingException { final List<ResourceTreeEntity> resources = Lists.newArrayList(); for (SpaceConfig spaceConfig : namespaceService.get().getSpaces()) { resources.add(new ResourceTreeEntity(spaceConfig)); } return resources; }
public List<CatalogItem> getTopLevelCatalogItems() { List<CatalogItem> topLevelItems = new ArrayList<>(); try { HomeConfig homeForCurrentUser = getHomeForCurrentUser(); topLevelItems.add(CatalogItem.fromHomeConfig(homeForCurrentUser)); } catch (NamespaceException e) { // if for some reason we can't find a home space, log it but keep going logger.warn("Failed to find home space for user [{}]", context.getUserPrincipal().getName()); } for (SpaceConfig spaceConfig : namespaceService.getSpaces()) { topLevelItems.add(CatalogItem.fromSpaceConfig(spaceConfig)); } for (SourceConfig sourceConfig : sourceService.getSources()) { topLevelItems.add(CatalogItem.fromSourceConfig(sourceConfig)); } return topLevelItems; }
@GET @Path("/spaces") @Produces(APPLICATION_JSON) public JobFilterItems searchSpaces(@QueryParam("filter") String query, @QueryParam("limit") Integer limit) throws NamespaceException { final JobFilterItems spaces = new JobFilterItems(); for (SpaceConfig spaceConfig : namespaceService.getSpaces()) { if (query == null || spaceConfig.getName().contains(query)) { spaces.add(new JobFilterItem(spaceConfig.getName(), spaceConfig.getName())); if (limit != null && spaces.getItems().size() >= limit) { break; } } } return spaces; }
for(SpaceConfig space : namespace.getSpaces()) { if(rootsToSaveSet.contains(space.getName())) { continue;
@GET @Produces(MediaType.APPLICATION_JSON) public Spaces getSpaces() throws Exception { final Spaces spaces = new Spaces(); for (SpaceConfig spaceConfig : namespaceService.getSpaces()) { int datasetCount = 0; try { datasetCount = namespaceService.getDatasetCount(new SpacePath(spaceConfig.getName()).toNamespaceKey(), BoundedDatasetCount.SEARCH_TIME_LIMIT_MS, BoundedDatasetCount.COUNT_LIMIT_TO_STOP_SEARCH).getCount(); } catch (IllegalArgumentException e) { logger.warn("Could not load dataset count for {} because it has a invalid name: {}", spaceConfig.getName(), e.getMessage()); } catch (NamespaceException e) { logger.warn("Could not load dataset count for {}: {}", spaceConfig.getName(), e.getMessage()); } try { // we catch exceptions here so the user can still see their other Spaces spaces.add(newSpace(spaceConfig, datasetCount)); } catch (NamespaceNotFoundException e) { logger.warn("Skipping Space {} because namespace not found: {}", spaceConfig.getName(), e.getMessage()); } } return spaces; }
private CheckPoint checkPoint() throws Exception { CheckPoint checkPoint = new CheckPoint(); NamespaceService namespaceService = newNamespaceService(); UserService userService = l(UserService.class); JobsService jobsService = l(JobsService.class); checkPoint.sources = namespaceService.getSources(); checkPoint.spaces = namespaceService.getSpaces(); checkPoint.homes = namespaceService.getHomeSpaces(); checkPoint.users = Arrays.asList(Iterables.toArray(userService.getAllUsers(10000), User.class)); checkPoint.datasets = Lists.newArrayList(); checkPoint.virtualDatasetVersions = Lists.newArrayList(); checkPoint.accelerations = Lists.newArrayList(); /** DX-4498 for (NamespaceKey ds : namespaceService.getAllDatasets(new NamespaceKey(""))) { DatasetConfig datasetConfig = namespaceService.getDataset(ds); checkPoint.datasets.add(datasetConfig); checkPoint.virtualDatasetVersions.addAll( Arrays.asList(Iterables.toArray(datasetService.getAllVersions(new DatasetPath(ds.getPathComponents())), VirtualDatasetUI.class))); if (datasetConfig.getAccelerationId() != null) { checkPoint.accelerations.add(accelerationService.getAccelerationById(new AccelerationId(datasetConfig.getAccelerationId()))); } } */ checkPoint.jobs = ImmutableList.copyOf(jobsService.getAllJobs(null, null, null, 0, Integer.MAX_VALUE, "tshiran")); return checkPoint; }
@Test @Ignore // TODO DX-3144 public void testTestApis() { doc("Creating test dataset"); NamespaceService ns = newNamespaceService(); expectSuccess(getBuilder(getAPIv2().path("/test/create")).buildPost(Entity.json(""))); assertEquals(4, ns.getSpaces().size()); assertEquals(1, ns.getHomeSpaces().size()); doc("Clearing all data"); expectSuccess(getBuilder(getAPIv2().path("/test/clear")).buildPost(Entity.json(""))); assertEquals(0, ns.getSpaces().size()); assertEquals(0, ns.getHomeSpaces().size()); expectSuccess(getBuilder(getAPIv2().path("/test/create")).buildPost(Entity.json(""))); assertEquals(4, ns.getSpaces().size()); assertEquals(1, ns.getHomeSpaces().size()); expectSuccess(getBuilder(getAPIv2().path("/test/clear")).buildPost(Entity.json(""))); assertEquals(0, ns.getSpaces().size()); assertEquals(0, ns.getHomeSpaces().size()); }
@Test public void testListTopLevelCatalog() throws Exception { // home space always exists int topLevelCount = newSourceService().getSources().size() + newNamespaceService().getSpaces().size() + 1; ResponseList<CatalogItem> items = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildGet(), new GenericType<ResponseList<CatalogItem>>() {}); assertEquals(items.getData().size(), topLevelCount); int homeCount = 0; int spaceCount = 0; int sourceCount = 0; for (CatalogItem item : items.getData()) { if (item.getType() == CatalogItem.CatalogItemType.CONTAINER) { if (item.getContainerType() == CatalogItem.ContainerSubType.HOME) { homeCount++; } if (item.getContainerType() == CatalogItem.ContainerSubType.SPACE) { spaceCount++; } if (item.getContainerType() == CatalogItem.ContainerSubType.SOURCE) { sourceCount++; } } } assertEquals(homeCount, 1); assertEquals(spaceCount, newNamespaceService().getSpaces().size()); assertEquals(sourceCount, 1); }
List<SpaceConfig> spaces = ns.getSpaces(); System.out.println(spaces); assertEquals(5, spaces.size());
spaceConfig.setName("mySpace"); spaceConfig.setId(new EntityId("space-id")); when(namespaceService.getSpaces()).thenReturn(Arrays.asList(spaceConfig));