blob: 006a1a3291bf3ad4146e23bd89187f6aa7fc0877 [file] [log] [blame]
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed 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 com.googlesource.gerrit.plugins.verifystatus.server.schema;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
public class Oracle extends CiBaseDataSourceType {
private final PluginConfig config;
@Inject
public Oracle(SitePaths site, @PluginName String pluginName) {
super("oracle.jdbc.driver.OracleDriver");
File file = site.gerrit_config.toFile();
FileBasedConfig cfg = new FileBasedConfig(file, FS.DETECTED);
try {
cfg.load();
} catch (IOException | ConfigInvalidException e) {
throw new ProvisionException(e.getMessage(), e);
}
this.config = PluginConfig.create(pluginName, cfg, null);
}
@Override
public String getUrl() {
final StringBuilder b = new StringBuilder();
b.append("jdbc:oracle:thin:@");
b.append(JdbcUtil.hostname(config.getString("hostname")));
b.append(JdbcUtil.port(config.getString("port")));
b.append(":");
b.append(config.getString("instance"));
return b.toString();
}
}