fateh288 commented on code in PR #569: URL: https://github.com/apache/ranger/pull/569#discussion_r2193995793
########## liquibase-database-upgrade/src/main/java/org/apache/ranger/db/upgrade/LiquibaseDBUtilsMain.java: ########## @@ -0,0 +1,108 @@ +/* + * 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 com.beust.jcommander.JCommander; +import com.google.gson.Gson; +import liquibase.Scope; +import liquibase.command.CommandResults; +import liquibase.resource.ClassLoaderResourceAccessor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; + +import java.util.HashMap; + +public class LiquibaseDBUtilsMain { + private static final Logger LOG = LoggerFactory.getLogger(LiquibaseDBUtilsMain.class); + + private LiquibaseDBUtilsMain() { + } + + public static void main(String[] argv) { + ArgsParserLiquibaseDBUtilsMain argsParserLiquibaseDBUtilsMain = new ArgsParserLiquibaseDBUtilsMain(); + + JCommander.newBuilder() + .addObject(argsParserLiquibaseDBUtilsMain) + .build() + .parse(argv); + + String op = argsParserLiquibaseDBUtilsMain.opName; + String tagName = argsParserLiquibaseDBUtilsMain.tagName; + String serviceName = argsParserLiquibaseDBUtilsMain.serviceName; + ICommandDriver commandDriver = SpringContext.getBean(ICommandDriver.class); + if (commandDriver == null) { + throw new RuntimeException("commandDriver not found. Exiting!"); + } + HashMap<String, Object> response = new HashMap<>(); + response.put("op_status", Constants.RETURN_CODE_FAILURE); + try { + Scope.child(Scope.Attr.resourceAccessor, new ClassLoaderResourceAccessor(), () -> { + switch (op) { + case "isUpgradeComplete": + final String tagNamePostUpdate = Utils.getPostUpdateTagName(tagName); + CommandResults upgradeCompleteTagExistsResult = commandDriver.tagExists(serviceName, tagNamePostUpdate); + if (LiquibaseCommandResultsUtil.doesTagExist(upgradeCompleteTagExistsResult)) { + LOG.info("isUpgradeComplete={}", Constants.RETURN_CODE_SUCCESS); + response.put("op_status", Constants.RETURN_CODE_SUCCESS); + response.put("isUpgradeComplete", Constants.RETURN_CODE_SUCCESS); + } else { + LOG.info("isUpgradeComplete={}", Constants.RETURN_CODE_FAILURE); + response.put("op_status", Constants.RETURN_CODE_SUCCESS); + response.put("isUpgradeComplete", Constants.RETURN_CODE_FAILURE); + } + break; + case "isFinalizeComplete": + final String tagNameForFinalizeComplete = Utils.getFinalizeTagName(tagName); + CommandResults finalizeCompleteTagExistsResult = commandDriver.tagExists(serviceName, tagNameForFinalizeComplete); + if (LiquibaseCommandResultsUtil.doesTagExist(finalizeCompleteTagExistsResult)) { + LOG.info("isFinalizeComplete={}", Constants.RETURN_CODE_SUCCESS); + response.put("op_status", Constants.RETURN_CODE_SUCCESS); + response.put("isFinalizeComplete", Constants.RETURN_CODE_SUCCESS); + } else { + LOG.info("isFinalizeComplete={}", Constants.RETURN_CODE_FAILURE); + response.put("op_status", Constants.RETURN_CODE_SUCCESS); + response.put("isFinalizeComplete", Constants.RETURN_CODE_FAILURE); + } + break; +// case "releaseLock": Review Comment: Addressed ########## liquibase-database-upgrade/changelogs/kms/db/postgres/create_trigger_kmsencoded_postgres.sql: ########## @@ -0,0 +1,40 @@ +-- 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. + +--liquibase formatted sql + +-- Create a trigger function +CREATE OR REPLACE FUNCTION copy_data_trigger_function() +RETURNS TRIGGER AS +' +BEGIN + -- If column_a is updated and is not null, update column_b + IF NEW.kms_encoded IS NOT NULL THEN Review Comment: Addressed -- 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