@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; }
public ResourceTreeEntity(SpaceConfig spaceConfig) throws UnsupportedEncodingException { this.type = ResourceType.SPACE; this.name = spaceConfig.getName(); this.fullPath = Collections.singletonList(this.name); this.url = "/resourcetree/" + new NamespaceKey(this.fullPath).toUrlEncodedString(); }
protected void deleteSpace(SpaceConfig spaceConfig, String version) throws NamespaceException { namespaceService.deleteSpace(new NamespaceKey(spaceConfig.getName()), version); }
@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; }
protected void updateSpace(Space space, NamespaceAttribute... attributes) throws NamespaceException { NamespaceKey namespaceKey = new NamespaceKey(space.getName()); SpaceConfig spaceConfig = namespaceService.getSpace(namespaceKey); Preconditions.checkArgument(space.getName().equals(spaceConfig.getName()), "Space name is immutable."); namespaceService.addOrUpdateSpace(namespaceKey, getSpaceConfig(space), attributes); }
protected Space getSpaceFromConfig(SpaceConfig config, List<CatalogItem> children) { return new Space( config.getId().getId(), config.getName(), String.valueOf(config.getTag()), config.getCtime(), children ); }
private static CatalogItem fromSpaceConfig(SpaceConfig spaceConfig, CollaborationTag tags) { return new Builder() .setId(spaceConfig.getId().getId()) .setPath(Lists.newArrayList(spaceConfig.getName())) .setTag(String.valueOf(spaceConfig.getTag())) .setType(CatalogItemType.CONTAINER) .setContainerType(ContainerSubType.SPACE) .setTags(tags) .build(); }
SpaceConfig config = (SpaceConfig) object; Space space = getSpaceFromConfig(config, getChildrenForPath(new NamespaceKey(config.getName()))); return Optional.of((CatalogEntity) space); } else if (object instanceof DatasetConfig) {
public static Space newInstance(SpaceConfig spaceConfig, NamespaceTree contents, int datasetCount) { String id = spaceConfig.getId() != null ? spaceConfig.getId().getId() : null; return new Space(id, spaceConfig.getName(), spaceConfig.getDescription(), spaceConfig.getTag(), contents, datasetCount, spaceConfig.getCtime()); } }
@Test public void testGetSpaceCatalogEntityById() throws Exception { SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setId(new EntityId("space-id")); spaceConfig.setName("mySpace"); NameSpaceContainer namespaceContainer = new NameSpaceContainer(); namespaceContainer.setType(NameSpaceContainer.Type.SPACE); namespaceContainer.setSpace(spaceConfig); when(namespaceService.getEntityById(spaceConfig.getId().getId())).thenReturn(namespaceContainer); when(namespaceService.getEntities(Collections.singletonList(new NamespaceKey(spaceConfig.getName())))).thenReturn(Collections.singletonList(namespaceContainer)); // for children listing, we just send the space back to keep it simple when(namespaceService.list(new NamespaceKey(spaceConfig.getName()))).thenReturn(Collections.singletonList(namespaceContainer)); Optional<CatalogEntity> catalogEntityById = catalogServiceHelper.getCatalogEntityById(spaceConfig.getId().getId()); assertTrue(catalogEntityById.isPresent()); CatalogEntity catalogEntity = catalogEntityById.get(); assertTrue(catalogEntity instanceof Space); Space space = (Space) catalogEntity; assertEquals(space.getId(), spaceConfig.getId().getId()); assertEquals(space.getChildren().size(), 1); }
@BeforeClass public static void before() throws Exception { NamespaceService namespaceService = newNamespaceService(); SpaceConfig spaceConfig = new SpaceConfig(); spaceConfig.setName("searchSpace"); namespaceService.addOrUpdateSpace(new NamespaceKey(spaceConfig.getName()), spaceConfig); }
public void addCPSource(boolean createFolder) throws Exception { getSourceService().registerSourceWithRuntime(InternalFileConf.create(TEST_SOURCE, new URI("classpath:///acceleration/"), SchemaMutability.ALL, CatalogService.DEFAULT_METADATA_POLICY)); final NamespaceService nsService = getNamespaceService(); final SpaceConfig config = new SpaceConfig().setName(TEST_SPACE); if(!nsService.exists(new SpacePath(config.getName()).toNamespaceKey())) { nsService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); } if (createFolder) { final FolderConfig folderConfig = new FolderConfig().setName(TEST_FOLDER); nsService.addOrUpdateFolder(TEST_FOLDER_PATH.toNamespaceKey(), folderConfig); } }
@Test public void testSpace() throws Exception { // create a new space Space newSpace = new Space(null, "final frontier", null, null, null); Space space = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newSpace)), new GenericType<Space>() {}); SpaceConfig spaceConfig = newNamespaceService().getSpace(new NamespaceKey(newSpace.getName())); assertEquals(space.getId(), spaceConfig.getId().getId()); assertEquals(space.getName(), spaceConfig.getName()); // make sure that trying to create the space again fails expectStatus(Response.Status.CONFLICT, getBuilder(getPublicAPI(3).path(CATALOG_PATH)).buildPost(Entity.json(newSpace))); // delete the space expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(spaceConfig.getId().getId())).buildDelete()); thrown.expect(NamespaceException.class); newNamespaceService().getSpace(new NamespaceKey(spaceConfig.getName())); }
namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("b"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("c"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config);
protected void setSpace() throws NamespaceException, IOException { clearAllDataExceptUser(); final SpaceConfig foo = new SpaceConfig().setName("spacefoo"); SpacePath spacePath = new SpacePath(new SpaceName(foo.getName())); newNamespaceService().addOrUpdateSpace(spacePath.toNamespaceKey(), foo); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar").toNamespaceKey(), new FolderConfig().setName("folderbar").setFullPathList(asList("spacefoo", "folderbar"))); newNamespaceService().addOrUpdateFolder(new FolderPath("spacefoo.folderbar.folderbaz").toNamespaceKey(), new FolderConfig().setName("folderbaz").setFullPathList(asList("spacefoo", "folderbar", "folderbaz"))); }
@BeforeClass public static void init() throws Exception { BaseTestServer.init(); final NamespaceService nsService = getNamespaceService(); final SpaceConfig config = new SpaceConfig().setName(TEST_SPACE); nsService.addOrUpdateSpace(new SpacePath(config.getName()).toNamespaceKey(), config); materializationStore = new MaterializationStore(p(KVStoreProvider.class)); entriesStore = new ReflectionEntriesStore(p(KVStoreProvider.class)); }
SpaceConfig config = new SpaceConfig(); config.setName("a"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("b"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config); config = new SpaceConfig(); config.setName("c"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config.getName())).toNamespaceKey(), config);
config2.setDescription("space2"); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config2.getName())).toNamespaceKey(), config2); namespaceService.addOrUpdateSpace(new SpacePath(new SpaceName(config1.getName())).toNamespaceKey(), config1); assertEquals(config1.getName(), space1.getName()); assertEquals(config2.getName(), space2.getName());
namespaceService.addOrUpdateSpace(new NamespaceKey(space1.getName()), space1); SpaceConfig newSpace1 = namespaceService.getSpace(new NamespaceKey(space1.getName())); Assert.assertEquals(space1, newSpace1); namespaceService.addOrUpdateSpace(new NamespaceKey(space2.getName()), space2); SpaceConfig newSpace2 = namespaceService.getSpace(new NamespaceKey(space2.getName())); Assert.assertEquals(space2, newSpace2); namespaceService.addOrUpdateSpace(new NamespaceKey(space1.getName()), space1); namespaceService.addOrUpdateSpace(new NamespaceKey(space2.getName()), space2);