dhavalshah9131 commented on code in PR #569: URL: https://github.com/apache/ranger/pull/569#discussion_r2097480021
########## liquibase-database-upgrade/src/test/java/org/apache/ranger/db/upgrade/FileDBForTest.java: ########## @@ -0,0 +1,186 @@ +/* + * 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.apache.ranger.db.upgrade; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class FileDBForTest { + private FileDBForTest() { + } + + public static void deleteFileIfExists(String filename) { + File file = new File(filename); + if (file.exists()) { + if (file.delete()) { + System.out.println("File deleted successfully: " + filename); + } else { + System.out.println("Failed to delete the file: " + filename); + } + } else { + System.out.println("File does not exist: " + filename); + } + } + + public static boolean tagExists(String filePath, String tagName) { + createFileIfNotExists(filePath); + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + String line; + while ((line = reader.readLine()) != null) { + String[] changeLogRow = line.split(","); + if (changeLogRow[changeLogRow.length - 1].equals(tagName)) { + return true; // String found + } + } + } catch (IOException e) { + System.err.println("Error reading file: " + e.getMessage()); + } + return false; // String not found + } + + public static void tag(String filePath, String tagName) { + createFileIfNotExists(filePath); + if (isFileEmpty(filePath)) { + List<String> lines = new ArrayList<>(); + lines.add(",,," + tagName); + writeLines(filePath, lines, true); + //writeLineToFile(filePath,",,,"+tagName); Review Comment: Remove dead code -- 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: dev-unsubscr...@ranger.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org