private void generateResourcesFile(final File resfile, final String format) throws ResourceModelSourceException { final NodeEntryImpl node = framework.createFrameworkNode(); node.setFrameworkProject(configuration.project); final ResourceFormatGenerator generator; if (null != format) { try { generator = framework.getResourceFormatGeneratorService().getGeneratorForFormat(format); } catch (UnsupportedFormatException e) { throw new ResourceModelSourceException(e); } } else { try { generator = framework.getResourceFormatGeneratorService().getGeneratorForFileExtension(resfile); } catch (UnsupportedFormatException e) { throw new ResourceModelSourceException(e); } } if (configuration.includeServerNode) { NodeSetImpl nodes = new NodeSetImpl(); nodes.putNode(node); if (!resfile.getParentFile().exists()) { if (!resfile.getParentFile().mkdirs()) { throw new ResourceModelSourceException( "Parent dir for resource file does not exists, and could not be created: " + resfile); } } try { final FileOutputStream stream = new FileOutputStream(resfile); try { generator.generateDocument(nodes, stream); } finally { stream.close(); } } catch (IOException e) { throw new ResourceModelSourceException(e); } catch (ResourceFormatGeneratorException e) { throw new ResourceModelSourceException(e); } } }
@Override public INodeSet getNodes() throws ResourceModelSourceException { NodeSetImpl iNodeEntries = new NodeSetImpl(); for (int i = 0; i < count; i++) { NodeEntryImpl nodeEntry = new NodeEntryImpl(); nodeEntry.setNodename( (prefix != null ? prefix : "node") + "-" + i + (suffix != null ? suffix : "")); nodeEntry.setHostname( (prefix != null ? prefix : "") + "host" + (suffix != null ? suffix : "")); nodeEntry.setUsername( (prefix != null ? prefix : "") + "user" + (suffix != null ? suffix : "")); nodeEntry.setAttribute("node-executor", "stub"); nodeEntry.setAttribute("file-copier", "stub"); if (null != tags) { nodeEntry.setTags(new HashSet(Arrays.asList(tags.split("\\s*,\\s*")))); } iNodeEntries.putNode(nodeEntry); } return iNodeEntries; }