PathResource extends BaseResource { public Response getChildren(java.nio.file.Path dcp, DcFile dirFile, RequestView requestView, HashMap<String, List<String>> queryParams){ boolean withDs = queryParams.containsKey("datasets") ? Boolean.valueOf( queryParams.get("datasets").get(0)) : true; Class<? extends ContainerStat> statType = null; if(queryParams.containsKey("stat")){ statType = getProvider().getModelProvider().getStatByName(queryParams.get("stat").get(0).toLowerCase()); } int max = queryParams.containsKey("max") ? Integer.valueOf( queryParams.get("max").get(0)) :100000; int offset = queryParams.containsKey("offset") ? Integer.valueOf( queryParams.get("offset").get(0)) :0; boolean showCount = queryParams.containsKey("showCount") ? Boolean.valueOf( queryParams.get("showCount").get(0)) :false; List<DatacatNode> retList = new ArrayList<>(); int count = 0; DirectoryStream<java.nio.file.Path> stream = null; try { String childrenView = requestView.get("children"); CallContext context = buildCallContext(); DatasetView dsview = null; if(!"containers".equals(childrenView)){ dsview = requestView.getDatasetView(DatasetView.CURRENT_ALL); } stream = getProvider() .newOptimizedDirectoryStream(dirFile.getPath(), context, DcFileSystemProvider.ACCEPT_ALL_FILTER, max, Optional.fromNullable(dsview)); Iterator<java.nio.file.Path> iter = stream.iterator(); while(iter.hasNext() && (retList.size() < max || showCount)){ java.nio.file.Path p = iter.next(); DcFile file = null; try { file = getProvider().getFile(p, context); } catch (AccessDeniedException ex){ continue; } if(!withDs && file.isRegularFile()){ continue; } if(count >= offset && retList.size() < max){ DatacatNode ret; if(file.isRegularFile()){ try { ret = file.getAttributeView(DatasetViewProvider.class).withView(requestView.getDatasetView(), requestView.includeMetadata()); } catch (NoSuchFileException ex){ continue; } } else { ret = file.getAttributeView(ContainerViewProvider.class).withView(statType); } retList.add(ret); } count++; } } catch (NotDirectoryException ex){ return Response.status(Response.Status.NOT_FOUND) .entity("File exists, but Path is not a directory").build(); } catch (IOException ex){ return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("Error accessing the file system: " + ex.getMessage()).build(); } finally { try { if(stream != null){ stream.close(); } } catch(IOException ex) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("Error accessing the file system: " + ex.getMessage()).build(); } } String start = Integer.toString(offset); String end = Integer.toString(offset+ (retList.size() - 1)); String len= showCount ? Integer.toString(count - 1) : "*"; Response resp = Response .ok( new GenericEntity<List<DatacatNode>>(retList) {}) .header( "Content-Range", String.format("items %s-%s/%s", start, end, len)) .build(); return resp; } PathResource(@PathParam("id") List<PathSegment> pathSegments, @Context UriInfo ui); @HEAD Response getHead(@DefaultValue("false") @QueryParam("refresh") boolean refresh); @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN}) Response getRootBean(@DefaultValue("basic") @QueryParam("stat") StatTypeWrapper statType, 
            @DefaultValue("false") @QueryParam("refresh") boolean refresh); @GET @Path(idRegex) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN}) Response getBean(@DefaultValue("false") @QueryParam("refresh") boolean refresh); Response getBean(String path, HashMap<String,List<String>> matrixParams, 
            HashMap<String, List<String>> extraQueryParams, boolean refresh); Response getChildren(java.nio.file.Path dcp, DcFile dirFile, RequestView requestView, HashMap<String, List<String>> queryParams);  }
@Test public void testGetChildren() throws IOException{ generateFoldersAndDatasetsAndVersions(this, 10, 10); Response resp = target("/path.json/testpath/folder00004;children") .request() .header("authentication", DbHarness.TEST_USER) .get(); TestCase.assertEquals(200, resp.getStatus()); String content = resp.readEntity(String.class); TestCase.assertTrue(content.startsWith("[{\"_type\":\"dataset\"")); resp = target("/path.json/testpath/folder00004;children=") .request() .header("authentication", DbHarness.TEST_USER) .get(); TestCase.assertTrue(content.equals(resp.readEntity(String.class))); TestCase.assertEquals(200, resp.getStatus()); }