@Override public Path save(final Path path, final KModuleModel content, final Metadata metadata, final String comment) { try { if (metadata == null) { ioService.write(Paths.convert(path), moduleContentHandler.toString(content)); } else { ioService.write( Paths.convert(path), moduleContentHandler.toString(content), metadataService.setUpAttributes(path, metadata)); } //The pom.xml, kmodule.xml and project.imports are all saved from ModuleScreenPresenter //We only raise InvalidateDMOModuleCacheEvent and ResourceUpdatedEvent(pom.xml) events once //in POMService.save to avoid duplicating events (and re-construction of DMO). return path; } catch (Exception e) { e.printStackTrace(); throw ExceptionUtilities.handleException(e); } } }
@Override public Path setUpKModule(final Path path) { try { final org.uberfire.java.nio.file.Path pathToKModuleXML = Paths.convert(path); if (ioService.exists(pathToKModuleXML)) { throw new FileAlreadyExistsException(pathToKModuleXML.toString()); } else { ioService.write(pathToKModuleXML, moduleContentHandler.toString(new KModuleModel())); //Don't raise a NewResourceAdded event as this is handled at the Module level in ModuleServices return Paths.convert(pathToKModuleXML); } } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Test public void testMarshallingOfDefaultDroolsNameSpace() throws Exception { final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); final String kmodule = kModuleContentHandler.toString( new KModuleModel() ); assertNotNull( kmodule ); assertTrue( kmodule.contains( "xmlns=\"http://www.drools.org/xsd/kmodule\"" ) ); }