@Test public void testSynonymsFileCreation() throws Exception { File synonymsFile = NodeTypeIndexingUtils.createPrimaryTypeSynonymsFile(tempFolder.newFolder().getPath() + "/pt-synonyms.txt", s); assertNotNull(synonymsFile); assertTrue(synonymsFile.exists()); }
public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception { File file = new File(path); StringWriter stringWriter = new StringWriter(); NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes(); while (allNodeTypes.hasNext()) { NodeType nodeType = allNodeTypes.nextNodeType(); NodeType[] superTypes = nodeType.getSupertypes(); if (superTypes != null && superTypes.length > 0) { stringWriter.append(nodeType.getName()).append(" => "); for (int i = 0; i < superTypes.length; i++) { stringWriter.append(superTypes[i].getName()); if (i < superTypes.length - 1) { stringWriter.append(','); } stringWriter.append(' '); } stringWriter.append('\n'); } } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(stringWriter.toString().getBytes("UTF-8")); fileOutputStream.flush(); fileOutputStream.close(); if (file.exists() || file.createNewFile()) { return file; } else { throw new IOException("primary types synonyms file could not be created"); } }
NodeTypeIndexingUtils { public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception { File file = new File(path); StringWriter stringWriter = new StringWriter(); NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes(); while (allNodeTypes.hasNext()) { NodeType nodeType = allNodeTypes.nextNodeType(); NodeType[] superTypes = nodeType.getSupertypes(); if (superTypes != null && superTypes.length > 0) { stringWriter.append(nodeType.getName()).append(" => "); for (int i = 0; i < superTypes.length; i++) { stringWriter.append(superTypes[i].getName()); if (i < superTypes.length - 1) { stringWriter.append(','); } stringWriter.append(' '); } stringWriter.append('\n'); } } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(stringWriter.toString().getBytes("UTF-8")); fileOutputStream.flush(); fileOutputStream.close(); if (file.exists() || file.createNewFile()) { return file; } else { throw new IOException("primary types synonyms file could not be created"); } } }
NodeTypeIndexingUtils { public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception { File file = new File(path); StringWriter stringWriter = new StringWriter(); NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes(); while (allNodeTypes.hasNext()) { NodeType nodeType = allNodeTypes.nextNodeType(); NodeType[] superTypes = nodeType.getSupertypes(); if (superTypes != null && superTypes.length > 0) { stringWriter.append(nodeType.getName()).append(" => "); for (int i = 0; i < superTypes.length; i++) { stringWriter.append(superTypes[i].getName()); if (i < superTypes.length - 1) { stringWriter.append(','); } stringWriter.append(' '); } stringWriter.append('\n'); } } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(stringWriter.toString().getBytes("UTF-8")); fileOutputStream.flush(); fileOutputStream.close(); if (file.exists() || file.createNewFile()) { return file; } else { throw new IOException("primary types synonyms file could not be created"); } }  }
NodeTypeIndexingUtils { public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception { File file = new File(path); StringWriter stringWriter = new StringWriter(); NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes(); while (allNodeTypes.hasNext()) { NodeType nodeType = allNodeTypes.nextNodeType(); NodeType[] superTypes = nodeType.getSupertypes(); if (superTypes != null && superTypes.length > 0) { stringWriter.append(nodeType.getName()).append(" => "); for (int i = 0; i < superTypes.length; i++) { stringWriter.append(superTypes[i].getName()); if (i < superTypes.length - 1) { stringWriter.append(','); } stringWriter.append(' '); } stringWriter.append('\n'); } } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(stringWriter.toString().getBytes("UTF-8")); fileOutputStream.flush(); fileOutputStream.close(); if (file.exists() || file.createNewFile()) { return file; } else { throw new IOException("primary types synonyms file could not be created"); } }  static File createPrimaryTypeSynonymsFile(String path, Session session); }
NodeTypeIndexingUtils { public static File createPrimaryTypeSynonymsFile(String path, Session session) throws Exception { File file = new File(path); StringWriter stringWriter = new StringWriter(); NodeTypeIterator allNodeTypes = session.getWorkspace().getNodeTypeManager().getAllNodeTypes(); while (allNodeTypes.hasNext()) { NodeType nodeType = allNodeTypes.nextNodeType(); NodeType[] superTypes = nodeType.getSupertypes(); if (superTypes != null && superTypes.length > 0) { stringWriter.append(nodeType.getName()).append(" => "); for (int i = 0; i < superTypes.length; i++) { stringWriter.append(superTypes[i].getName()); if (i < superTypes.length - 1) { stringWriter.append(','); } stringWriter.append(' '); } stringWriter.append('\n'); } } FileOutputStream fileOutputStream = new FileOutputStream(file); fileOutputStream.write(stringWriter.toString().getBytes("UTF-8")); fileOutputStream.flush(); fileOutputStream.close(); if (file.exists() || file.createNewFile()) { return file; } else { throw new IOException("primary types synonyms file could not be created"); } }  static File createPrimaryTypeSynonymsFile(String path, Session session);  }