@GET @Path("/folder/{path: .*}") @Produces(MediaType.APPLICATION_JSON) public Folder getFolder(@PathParam("path") String path, @QueryParam("includeContents") @DefaultValue("true") boolean includeContents) throws NamespaceException, FolderNotFoundException, DatasetNotFoundException { FolderPath folderPath = FolderPath.fromURLPath(spaceName, path); try { final FolderConfig folderConfig = namespaceService.getFolder(folderPath.toNamespaceKey()); final NamespaceTree contents = includeContents ? newNamespaceTree(namespaceService.list(folderPath.toNamespaceKey())) : null; return newFolder(folderPath, folderConfig, contents); } catch (NamespaceNotFoundException nfe) { throw new FolderNotFoundException(folderPath, nfe); } }
@GET @Path("/folder/{path: .*}") @Produces(MediaType.APPLICATION_JSON) public Folder getFolder(@PathParam("path") String path, @QueryParam("includeContents") @DefaultValue("true") boolean includeContents) throws Exception { FolderPath folderPath = FolderPath.fromURLPath(homeName, path); try { final FolderConfig folderConfig = namespaceService.getFolder(folderPath.toNamespaceKey()); final NamespaceTree contents = includeContents ? newNamespaceTree(namespaceService.list(folderPath.toNamespaceKey())) : null; return newFolder(folderPath, folderConfig, contents); } catch (NamespaceNotFoundException nfe) { throw new FolderNotFoundException(folderPath, nfe); } }
private void verifyFolderNotInNamespace(NamespaceService ns, NamespaceKey nsKey) throws NamespaceException { try { ns.getFolder(nsKey); fail("getFolder didn't throw exception"); } catch (NamespaceNotFoundException nfe) { } }
protected Folder createFolder(Folder folder, NamespaceAttribute... attributes) throws NamespaceException { NamespaceKey parentKey = new NamespaceKey(folder.getPath().subList(0, folder.getPath().size() - 1)); List<NameSpaceContainer> entities = namespaceService.getEntities(Collections.singletonList(parentKey)); NameSpaceContainer container = entities.get(0); if (container == null) { // if we can't find it by id, maybe its not in the namespace throw new IllegalArgumentException(String.format("Could not find entity with path [%s].", folder.getPath())); } NamespaceKey key = new NamespaceKey(folder.getPath()); switch (container.getType()) { case SPACE: case HOME: case FOLDER: { namespaceService.addOrUpdateFolder(key, getFolderConfig(folder), attributes); break; } default: { throw new UnsupportedOperationException(String.format("Can not create a folder inside a [%s].", container.getType())); } } return getFolderFromConfig(namespaceService.getFolder(key), null); }
private void assertFoldersExist(List<String> expFolders) throws Exception { for (String folderPath : expFolders) { NamespaceKey folderKey = new NamespaceKey(SqlUtils.parseSchemaPath(folderPath)); namespaceService.getFolder(folderKey); // if the folder doesn't exit we get an exception } }
protected void updateFolder(Folder folder, NamespaceAttribute... attributes) throws NamespaceException { NamespaceKey namespaceKey = new NamespaceKey(folder.getPath()); FolderConfig folderConfig = namespaceService.getFolder(namespaceKey); Preconditions.checkArgument(CollectionUtils.isEqualCollection(folder.getPath(), folderConfig.getFullPathList()), "Folder path is immutable."); NameSpaceContainer rootContainer = getRootContainer(folder.getPath()); if (rootContainer.getType() == NameSpaceContainer.Type.SOURCE) { throw new UnsupportedOperationException("Can not update a folder inside a source"); } namespaceService.addOrUpdateFolder(namespaceKey, getFolderConfig(folder), attributes); }
private void assertFoldersDoNotExist(List<String> expFolders) throws Exception { for (String folderPath : expFolders) { NamespaceKey folderKey = new NamespaceKey(SqlUtils.parseSchemaPath(folderPath)); try { namespaceService.getFolder(folderKey); // if the folder doesn't exit we get an exception fail(); } catch (NamespaceNotFoundException ex) { /* no-op */ } } }
final FolderConfig folderConfig = systemUserNamespaceService.getFolder(folderKey); systemUserNamespaceService.deleteFolder(folderKey, folderConfig.getTag()); refreshResult = true;
public void deleteFolder() { NamespaceKey key = TEST_FOLDER_PATH.toNamespaceKey(); FolderConfig config; try { config = getNamespaceService().getFolder(key); if (config != null) { getNamespaceService().deleteFolder(key, config.getTag()); } }catch (NamespaceException e) { } }
folderConfig = namespaceService.getFolder(folderPath.toNamespaceKey());