@Test public void writeDataObject2YamlFileTest() throws IOException { String targetFileName = "src/test/resources/conf/plain_write_acl.yml"; File transport = new File(targetFileName); transport.delete(); transport.createNewFile(); Map<String, Object> aclYamlMap = new HashMap<String, Object>(); List<String> globalWhiteRemoteAddrs = new ArrayList<String>(); globalWhiteRemoteAddrs.add("10.10.103.*"); globalWhiteRemoteAddrs.add("192.168.0.*"); aclYamlMap.put("globalWhiteRemoteAddrs", globalWhiteRemoteAddrs); List<Map<String, Object>> accounts = new ArrayList<Map<String, Object>>(); Map<String, Object> accountsMap = new LinkedHashMap<String, Object>() { { put("accessKey", "RocketMQ"); put("secretKey", "12345678"); put("whiteRemoteAddress", "whiteRemoteAddress"); put("admin", "true"); } }; accounts.add(accountsMap); aclYamlMap.put("accounts", accounts); Assert.assertTrue(AclUtils.writeDataObject(targetFileName, aclYamlMap)); transport.delete(); }
public static boolean writeDataObject(String path, Map<String, Object> dataMap) { Yaml yaml = new Yaml(); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(path)); String dumpAsMap = yaml.dumpAsMap(dataMap); pw.print(dumpAsMap); pw.flush(); } catch (Exception e) { throw new AclException(e.getMessage()); } finally { if (pw != null) { pw.close(); } } return true; }
AclUtils { public static boolean writeDataObject(String path, Map<String, Object> dataMap) { Yaml yaml = new Yaml(); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(path)); String dumpAsMap = yaml.dumpAsMap(dataMap); pw.print(dumpAsMap); pw.flush(); } catch (Exception e) { throw new AclException(e.getMessage()); } finally { if (pw != null) { pw.close(); } } return true; } }
AclUtils { public static boolean writeDataObject(String path, Map<String, Object> dataMap) { Yaml yaml = new Yaml(); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(path)); String dumpAsMap = yaml.dumpAsMap(dataMap); pw.print(dumpAsMap); pw.flush(); } catch (Exception e) { throw new AclException(e.getMessage()); } finally { if (pw != null) { pw.close(); } } return true; }  }
AclUtils { public static boolean writeDataObject(String path, Map<String, Object> dataMap) { Yaml yaml = new Yaml(); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(path)); String dumpAsMap = yaml.dumpAsMap(dataMap); pw.print(dumpAsMap); pw.flush(); } catch (Exception e) { throw new AclException(e.getMessage()); } finally { if (pw != null) { pw.close(); } } return true; }  static byte[] combineRequestContent(RemotingCommand request, SortedMap<String, String> fieldsMap); static byte[] combineBytes(byte[] b1, byte[] b2); static String calSignature(byte[] data, String secretKey); static void IPv6AddressCheck(String netaddress); static String v6ipProcess(String netaddress, String[] strArray, int index); static void verify(String netaddress, int index); static String[] getAddreeStrArray(String netaddress, String partialAddress); static boolean isScope(String netaddress, int index); static boolean isScope(String[] num, int index); static boolean isColon(String netaddress); static boolean isScope(String num); static boolean isScope(int num); static boolean isAsterisk(String asterisk); static boolean isComma(String colon); static boolean isMinus(String minus); static boolean isIPv6Scope(String[] num, int index); static boolean isIPv6Scope(int num); static String expandIP(String netaddress, int part); static T getYamlDataObject(String path, Class<T> clazz); static boolean writeDataObject(String path, Map<String, Object> dataMap); static RPCHook getAclRPCHook(String fileName); }
AclUtils { public static boolean writeDataObject(String path, Map<String, Object> dataMap) { Yaml yaml = new Yaml(); PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(path)); String dumpAsMap = yaml.dumpAsMap(dataMap); pw.print(dumpAsMap); pw.flush(); } catch (Exception e) { throw new AclException(e.getMessage()); } finally { if (pw != null) { pw.close(); } } return true; }  static byte[] combineRequestContent(RemotingCommand request, SortedMap<String, String> fieldsMap); static byte[] combineBytes(byte[] b1, byte[] b2); static String calSignature(byte[] data, String secretKey); static void IPv6AddressCheck(String netaddress); static String v6ipProcess(String netaddress, String[] strArray, int index); static void verify(String netaddress, int index); static String[] getAddreeStrArray(String netaddress, String partialAddress); static boolean isScope(String netaddress, int index); static boolean isScope(String[] num, int index); static boolean isColon(String netaddress); static boolean isScope(String num); static boolean isScope(int num); static boolean isAsterisk(String asterisk); static boolean isComma(String colon); static boolean isMinus(String minus); static boolean isIPv6Scope(String[] num, int index); static boolean isIPv6Scope(int num); static String expandIP(String netaddress, int part); static T getYamlDataObject(String path, Class<T> clazz); static boolean writeDataObject(String path, Map<String, Object> dataMap); static RPCHook getAclRPCHook(String fileName);  }