DcFileSystemProvider { public DatasetModel createDataset(Path path, CallContext context, DatasetModel dsReq, Set<DatasetOption> options) throws IOException{ if(dsReq == null){ throw new IOException("Not enough information to create create a Dataset node or view"); } DcFile dsParent = resolveFile(path.getParent()); String dsName = path.getFileName().toString(); Set<DatasetOption> dsOptions = new HashSet<>(options); Optional<DatasetModel> requestDataset = Optional.absent(); Optional<DatasetViewInfoModel> requestView = Optional.absent(); boolean createNode = dsOptions.remove(DatasetOption.CREATE_NODE); if(createNode){ checkPermission(context, dsParent, DcPermissions.INSERT); requestDataset = Optional.of(dsReq); } HashSet<DatasetOption> viewWork = new HashSet<>(Arrays.asList( DatasetOption.CREATE_VERSION, DatasetOption.MERGE_VERSION, DatasetOption.CREATE_LOCATIONS)); viewWork.retainAll(dsOptions); if(!viewWork.isEmpty()){ checkPermission(context, dsParent, DcPermissions.WRITE); if(dsReq instanceof DatasetWithViewModel){ requestView = Optional.of(((DatasetWithViewModel) dsReq).getViewInfo()); } else { throw new IllegalArgumentException("Unable to fulfill request"); } } try(DatasetDAO dao = daoFactory.newDatasetDAO()) { dao.lock(path.getParent()); DatasetModel ret = dao. createDataset(dsParent.getObject(), dsName, requestDataset, requestView, dsOptions); dao.commit(); childAdded(dsParent, path, FileType.FILE); return ret; } } DcFileSystemProvider(DAOFactory daoFactory, ModelProvider modelProvider); DAOFactory getDaoFactory(); ModelProvider getModelProvider(); DirectoryStream<Path> newOptimizedDirectoryStream(Path dir, CallContext context,
            final DirectoryStream.Filter<? super Path> filter, int max, 
            Optional<DatasetView> viewPrefetch); DcFile getFile(Path path, CallContext context); List<DcAclEntry> getAcl(Path path, CallContext context); String getPermissions(Path path, CallContext context,
            DcGroup group); Path getPath(String path); DatasetModel createDataset(Path path, CallContext context,   
            DatasetModel dsReq, Set<DatasetOption> options); DcFile mergeContainerAclEntries(Path path, CallContext context, 
            List<DcAclEntry> request, boolean clear); DcFile patchContainer(Path path, CallContext context, DatasetContainer request); DirectoryStream<DatasetModel> search(List<String> pathPatterns, CallContext context,
            DatasetView datasetView, String query,
            String containerQuery,
            String[] retrieveFields, String[] sortFields); DirectoryStream<DatasetContainer> searchContainers(List<String> pathPatterns,
            CallContext context,
            String query, String[] retrieveFields, String[] sortFields); DcFile patchDataset(Path path, CallContext context, 
            DatasetView view, DatasetModel request); DatasetViewInfoModel getDatasetViewInfo(DatacatRecord record,
            DatasetView view); void createDirectory(Path path, CallContext context,
            DatacatNode request); void delete(Path path, CallContext context); static final DirectoryStream.Filter<Path> ACCEPT_ALL_FILTER; }
@Test public void testCreateDataset() throws IOException{ DatasetModel.Builder builder = provider.getModelProvider().getDatasetBuilder(); builder.name("testCaseDataset001"); builder.dataType(DbHarness.TEST_DATATYPE_01); builder.fileFormat(DbHarness.TEST_FILEFORMAT_01); builder.datasetSource( DbHarness.TEST_DATASET_SOURCE); DatasetModel request = builder.build(); Path parentPath = provider.getPath(DbHarness.TEST_BASE_PATH); Path filePath = parentPath.resolve(request.getName()); HashSet<DatasetOption> options = new HashSet<>(Arrays.asList( DatasetOption.CREATE_NODE)); provider.createDataset( filePath, TestUtils.DEFAULT_TEST_CONTEXT, request, options); provider.delete(filePath, TestUtils.DEFAULT_TEST_CONTEXT); }