sdedic commented on code in PR #7698: URL: https://github.com/apache/netbeans/pull/7698#discussion_r1740449631
########## enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/ConfigFileProvider.java: ########## @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.cloud.oracle.assets; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import org.netbeans.spi.lsp.CommandProvider; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Dusan Petrovic + */ +@ServiceProvider(service = CommandProvider.class) +public class ConfigFileProvider implements CommandProvider { + private static final String GET_CONFIG_FILE_PATH = "nbls.config.file.path"; //NOI18N + private static final String FILE_DELIMITER = ","; //NOI18N + + private final ConfigFileGenerator applicationPropertiesFileGenerator; + private final ConfigFileGenerator bootstrapPropertiesFileGenerator; + + public ConfigFileProvider() { + this.applicationPropertiesFileGenerator = new ConfigFileGenerator("application-", ".properties", GET_CONFIG_FILE_PATH, false); // NOI18N + this.bootstrapPropertiesFileGenerator = new ConfigFileGenerator("bootstrap-", ".properties", GET_CONFIG_FILE_PATH, false); // NOI18N + } + + @Override + public Set<String> getCommands() { + return Collections.singleton(GET_CONFIG_FILE_PATH); + } + + @Override + public CompletableFuture<Object> runCommand(String command, List<Object> arguments) { + CompletableFuture ret = new CompletableFuture(); + + Properties applicationProps = new Properties(); + Properties bootstrapProps = new Properties(); + PropertiesGenerator propGen = new PropertiesGenerator(false); + + applicationProps.putAll(propGen.getApplication()); + bootstrapProps.putAll(propGen.getBootstrap()); + + StringBuilder sb = new StringBuilder(); + try { + if (!bootstrapProps.isEmpty()) { + Path bootstrapProperties = bootstrapPropertiesFileGenerator.writePropertiesFile(bootstrapProps); + sb.append(bootstrapProperties.toAbsolutePath().toString()); + } + + if (!applicationProps.isEmpty()) { + Path applicationPropertiesPath = applicationPropertiesFileGenerator.writePropertiesFile(applicationProps); + if (sb.length() > 0) { + sb.append(FILE_DELIMITER); + } + sb.append(applicationPropertiesPath.toAbsolutePath().toString()); + } + ret.complete(sb.toString()); Review Comment: Why return a delimited string, instead of String[] ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
