@Override public ConfigGroup newConfigGroup(final ConfigType type, final String name, final String description) { final ConfigGroup configGroup = new ConfigGroup(); configGroup.setDescription(description); configGroup.setName(name); configGroup.setType(type); configGroup.setEnabled(true); return configGroup; }
@Override public ConfigGroup newConfigGroup(final ConfigType type, final String namespace, final String name, final String description) { if (!type.hasNamespace() && namespace != null && !namespace.isEmpty()) { throw new RuntimeException("The ConfigType " + type.toString() + " does not support namespaces."); } final ConfigGroup configGroup = new ConfigGroup(); configGroup.setDescription(description); configGroup.setName(name); configGroup.setType(type); configGroup.setNamespace(namespace); configGroup.setEnabled(true); return configGroup; }
@Override public ConfigGroup newConfigGroup(final ConfigType type, final String name, final String description) { if (type.hasNamespace()) { throw new RuntimeException("The ConfigType " + type.toString() + " requires a namespace."); } final ConfigGroup configGroup = new ConfigGroup(); configGroup.setDescription(description); configGroup.setName(name); configGroup.setType(type); configGroup.setEnabled(true); return configGroup; }
@Override public ConfigGroup newConfigGroup(ConfigType type, final String name, final String description) { if (ConfigType.SPACE.equals(type)) { type = ConfigType.ORGANIZATIONAL_UNIT; } final ConfigGroup configGroup = new ConfigGroup(); configGroup.setDescription(description); configGroup.setName(name); configGroup.setType(type); configGroup.setEnabled(true); return configGroup; }
@Override public boolean updateConfiguration(final ConfigGroup configGroup) { if (ConfigType.SPACE.equals(configGroup.getType())) { configGroup.setType(ConfigType.ORGANIZATIONAL_UNIT); } String filename = configGroup.getName().replaceAll(INVALID_FILENAME_CHARS, "_"); final Path filePath = ioService.get(systemRepository.getUri()).resolve(filename + configGroup.getType().getExt()); final CommentedOption commentedOption = new CommentedOption(getIdentityName(), "Updated config " + filePath.getFileName()); saveConfiguration(configGroup, filePath, commentedOption); configGroupsByTypeWithoutNamespace.remove(configGroup.getType()); return true; }
@Override public boolean addConfiguration(final ConfigGroup configGroup) { if (ConfigType.SPACE.equals(configGroup.getType())) { configGroup.setType(ConfigType.ORGANIZATIONAL_UNIT); } String filename = configGroup.getName().replaceAll(INVALID_FILENAME_CHARS, "_"); final Path filePath = ioService.get(systemRepository.getUri()).resolve(filename + configGroup.getType().getExt()); // avoid duplicated writes to not cause cyclic cluster sync if (ioService.exists(filePath)) { return true; } final CommentedOption commentedOption = new CommentedOption(getIdentityName(), "Created config " + filePath.getFileName()); saveConfiguration(configGroup, filePath, commentedOption); configGroupsByTypeWithoutNamespace.remove(configGroup.getType()); return true; }
@Override public boolean removeConfiguration(final ConfigGroup configGroup) { if (ConfigType.SPACE.equals(configGroup.getType())) { configGroup.setType(ConfigType.ORGANIZATIONAL_UNIT); } configGroupsByTypeWithoutNamespace.remove(configGroup.getType()); String filename = configGroup.getName().replaceAll(INVALID_FILENAME_CHARS, "_"); final Path filePath = ioService.get(systemRepository.getUri()).resolve(filename + configGroup.getType().getExt()); if (!ioService.exists(filePath)) { return true; } boolean result; try { ioService.startBatch(filePath.getFileSystem()); result = ioService.deleteIfExists(filePath); if (result) { updateLastModified(); } } catch (Exception ex) { throw new RuntimeException(ex); } finally { ioService.endBatch(); } return result; }