DataSetDefRegistryCDI extends DataSetDefRegistryImpl implements CSVFileStorage { @Override public void registerDataSetDef(DataSetDef def, String subjectId, String message) { if (def.getUUID() == null) { final String uuid = uuidGenerator.newUuid(); def.setUUID(uuid); } if (subjectId == null || message == null) { ioService.startBatch(fileSystem); } else { ioService.startBatch(fileSystem, new CommentedOption(subjectId, message)); } try { String defJson = getDataSetDefJsonMarshaller().toJsonString(def); Path defPath = resolveNioPath(def); ioService.write(defPath, defJson); if (def instanceof CSVDataSetDef) { saveCSVFile((CSVDataSetDef) def); } super.registerDataSetDef(def, subjectId, message); } catch (Exception e) { throw exceptionManager.handleException( new Exception("Can't register the data set definition\n" + def, e)); } finally { ioService.endBatch(); } } DataSetDefRegistryCDI(); @Inject  DataSetDefRegistryCDI(@Config("10485760" /* 10 Mb */) int maxCsvLength,
                                 @Named("ioStrategy") IOService ioService,
                                 DataSetProviderRegistryCDI dataSetProviderRegistry,
                                 SchedulerCDI scheduler,
                                 ExceptionManager exceptionManager,
                                 Event<DataSetDefModifiedEvent> dataSetDefModifiedEvent,
                                 Event<DataSetDefRegisteredEvent> dataSetDefRegisteredEvent,
                                 Event<DataSetDefRemovedEvent> dataSetDefRemovedEvent,
                                 Event<DataSetStaleEvent> dataSetStaleEvent); @PostConstruct void init(); DataSetDefJSONMarshaller getDataSetDefJsonMarshaller(); org.uberfire.backend.vfs.Path resolveVfsPath(DataSetDef def); @Override void registerDataSetDef(DataSetDef def,
                                   String subjectId,
                                   String message); @Override DataSetDef removeDataSetDef(String uuid,
                                       String subjectId,
                                       String message); void removeDataSetDef(org.uberfire.backend.vfs.Path path,
                                 String subjectId,
                                 String comment); DataSetDef removeDataSetDef(DataSetDef def,
                                       String subjectId,
                                       String message); Collection<DataSetDef> listDataSetDefs(); DataSetDef loadDataSetDef(org.uberfire.backend.vfs.Path path); DataSetDef copyDataSetDef(DataSetDef def,
                                     String newName,
                                     String subjectId,
                                     String message); Path createTempFile(String fileName); void deleteTempFiles(); @Override String getCSVString(CSVDataSetDef def); @Override InputStream getCSVInputStream(CSVDataSetDef def); @Override void deleteCSVFile(CSVDataSetDef def); @Override void saveCSVFile(CSVDataSetDef def); static final String DATASET_EXT; static final String CSV_EXT; }
@Test public void testRegistryDataSetDef() throws Exception { dataSetDefRegistry.registerDataSetDef(dataSetDef); verify(getIOService()).write(any(Path.class), anyString()); verify(dataSetDefRegisteredEvent).fire(any(DataSetDefRegisteredEvent.class)); }