From 7e0b3164f0684ce76f05b011d65115b5cd484f09 Mon Sep 17 00:00:00 2001 From: imedina Date: Tue, 25 Apr 2023 02:16:56 +0100 Subject: [PATCH 1/2] core: rename GitRepositoryState.get() to GitRepositoryState.getInstance() --- .../analysis/clinical/InterpretationAnalysis.java | 8 ++++---- .../exomiser/ExomiserInterpretationAnalysis.java | 4 ++-- .../circos/CircosLocalAnalysisExecutor.java | 2 +- .../GenomePlotLocalAnalysisExecutor.java | 2 +- .../hrdetect/HRDetectLocalAnalysisExecutor.java | 14 +------------- .../MutationalSignatureLocalAnalysisExecutor.java | 5 +++-- .../executors/DockerWrapperAnalysisExecutor.java | 2 +- .../analysis/rga/RgaSolrExtenalResource.java | 6 ++---- .../app/cli/admin/AdminCliOptionsParser.java | 4 ++-- .../opencb/opencga/app/cli/admin/AdminMain.java | 6 +++--- .../admin/executors/MigrationCommandExecutor.java | 2 +- .../app/cli/internal/InternalCliOptionsParser.java | 4 ++-- .../opencga/app/cli/internal/InternalMain.java | 6 +++--- .../app/cli/main/utils/CommandLineUtils.java | 12 ++++++------ .../opencga/app/cli/main/utils/JobsTopManager.java | 2 +- .../opencga/app/cli/session/SessionManager.java | 2 +- .../issue_1849/CompleteStatusDataModelUtils.java | 4 ++-- .../catalog/db/mongodb/MetaMongoDBAdaptor.java | 2 +- .../opencga/catalog/managers/AuditManager.java | 2 +- .../catalog/stats/solr/CatalogSolrManager.java | 2 +- .../opencga/catalog/templates/TemplateManager.java | 2 +- .../opencga/catalog/utils/PedigreeGraphUtils.java | 2 +- .../catalog/stats/solr/SolrExternalResource.java | 2 +- .../opencga/core/common/GitRepositoryState.java | 12 ++++++++++-- .../org/opencb/opencga/core/docs/DocBuilder.java | 2 +- .../org/opencb/opencga/core/models/Metadata.java | 2 +- .../opencga/core/models/common/InternalStatus.java | 4 ++-- .../opencb/opencga/core/tools/result/Status.java | 4 ++-- .../opencga/server/generator/models/RestApi.java | 2 +- .../opencb/opencga/server/rest/MetaWSServer.java | 6 +++--- .../opencga/server/rest/OpenCGAWSServer.java | 8 ++++---- .../main/resources/parserAbstractMethods.template | 4 ++-- .../opencga/storage/app/StorageAdminMain.java | 4 ++-- .../opencb/opencga/storage/app/StorageMain.java | 6 +++--- .../app/cli/client/ClientCliOptionsParser.java | 4 ++-- .../app/cli/server/AdminCliOptionsParser.java | 4 ++-- .../core/metadata/VariantMetadataConverter.java | 2 +- .../variant/solr/VariantSolrExternalResource.java | 2 +- .../hadoop/variant/executors/MRExecutor.java | 2 +- .../org/opencb/opencga/test/cli/OptionsParser.java | 4 ++-- 40 files changed, 82 insertions(+), 87 deletions(-) diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java index 02ab7d9b5d8..4fe57ad701b 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/InterpretationAnalysis.java @@ -79,8 +79,8 @@ protected InterpretationMethod getInterpretationMethod(String name) { .setName(name) .setDependencies(Collections.singletonList(new Software() .setName("OpenCGA") - .setVersion(GitRepositoryState.get().getBuildVersion()) - .setCommit(GitRepositoryState.get().getCommitId()))); + .setVersion(GitRepositoryState.getInstance().getBuildVersion()) + .setCommit(GitRepositoryState.getInstance().getCommitId()))); return method; } @@ -114,8 +114,8 @@ protected void saveInterpretation(String studyId, ClinicalAnalysis clinicalAnaly // Interpretation method InterpretationMethod method = new InterpretationMethod(getId(), null, null, - Collections.singletonList(new Software().setName("OpenCGA").setVersion(GitRepositoryState.get().getBuildVersion()) - .setCommit(GitRepositoryState.get().getCommitId()))); + Collections.singletonList(new Software().setName("OpenCGA").setVersion(GitRepositoryState.getInstance().getBuildVersion()) + .setCommit(GitRepositoryState.getInstance().getCommitId()))); // Analyst ClinicalAnalyst analyst = clinicalInterpretationManager.getAnalyst(token); diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java index 07e35a78504..39fa4fd581c 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/clinical/exomiser/ExomiserInterpretationAnalysis.java @@ -137,8 +137,8 @@ protected void run() throws ToolException { protected void saveInterpretation(String studyId, ClinicalAnalysis clinicalAnalysis) throws ToolException, StorageEngineException, CatalogException, IOException { // Interpretation method - InterpretationMethod method = new InterpretationMethod(getId(), GitRepositoryState.get().getBuildVersion(), - GitRepositoryState.get().getCommitId(), Collections.singletonList( + InterpretationMethod method = new InterpretationMethod(getId(), GitRepositoryState.getInstance().getBuildVersion(), + GitRepositoryState.getInstance().getCommitId(), Collections.singletonList( new Software() .setName("Exomiser") .setRepository("Docker: " + ExomiserWrapperAnalysisExecutor.DOCKER_IMAGE_NAME) diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java index cd2ada565fa..40f829ecd6c 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/circos/CircosLocalAnalysisExecutor.java @@ -58,7 +58,7 @@ public class CircosLocalAnalysisExecutor extends CircosAnalysisExecutor implements StorageToolExecutor { public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" - + GitRepositoryState.get().getBuildVersion(); + + GitRepositoryState.getInstance().getBuildVersion(); private VariantStorageManager storageManager; private File snvsFile; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java index 027bb8dc9a8..4246e142d55 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/genomePlot/GenomePlotLocalAnalysisExecutor.java @@ -61,7 +61,7 @@ public class GenomePlotLocalAnalysisExecutor extends GenomePlotAnalysisExecutor implements StorageToolExecutor { public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" - + GitRepositoryState.get().getBuildVersion(); + + GitRepositoryState.getInstance().getBuildVersion(); private GenomePlotConfig plotConfig; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java index 4c96ad7b3b0..f85e0a1873a 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/hrdetect/HRDetectLocalAnalysisExecutor.java @@ -16,31 +16,21 @@ package org.opencb.opencga.analysis.variant.hrdetect; -import htsjdk.samtools.reference.BlockCompressedIndexedFastaSequenceFile; -import htsjdk.samtools.reference.FastaSequenceIndex; -import htsjdk.samtools.reference.ReferenceSequence; -import htsjdk.samtools.util.GZIIndex; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.opencb.biodata.models.variant.StudyEntry; import org.opencb.biodata.models.variant.Variant; -import org.opencb.biodata.models.variant.avro.VariantType; import org.opencb.commons.datastore.core.Query; import org.opencb.commons.datastore.core.QueryOptions; -import org.opencb.commons.datastore.core.QueryResultWriter; import org.opencb.commons.exec.Command; import org.opencb.commons.utils.DockerUtils; -import org.opencb.opencga.analysis.ResourceUtils; import org.opencb.opencga.analysis.StorageToolExecutor; import org.opencb.opencga.catalog.exceptions.CatalogException; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.exceptions.ToolException; import org.opencb.opencga.core.exceptions.ToolExecutorException; -import org.opencb.opencga.core.response.OpenCGAResult; -import org.opencb.opencga.core.response.VariantQueryResult; import org.opencb.opencga.core.tools.annotations.ToolExecutor; import org.opencb.opencga.core.tools.variant.HRDetectAnalysisExecutor; -import org.opencb.opencga.core.tools.variant.MutationalSignatureAnalysisExecutor; import org.opencb.opencga.storage.core.exceptions.StorageEngineException; import org.opencb.opencga.storage.core.variant.adaptors.VariantQueryParam; import org.opencb.opencga.storage.core.variant.adaptors.iterators.VariantDBIterator; @@ -53,14 +43,12 @@ import java.nio.file.Paths; import java.util.*; -import static org.opencb.opencga.analysis.variant.mutationalSignature.MutationalSignatureAnalysis.CATALOGUES_FILENAME_DEFAULT; - @ToolExecutor(id="opencga-local", tool = HRDetectAnalysis.ID, framework = ToolExecutor.Framework.LOCAL, source = ToolExecutor.Source.STORAGE) public class HRDetectLocalAnalysisExecutor extends HRDetectAnalysisExecutor implements StorageToolExecutor { - public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); + public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.getInstance().getBuildVersion(); private final static String CNV_FILENAME = "cnv.tsv"; private final static String INDEL_FILENAME = "indel.vcf"; diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java index f2bf45cf487..c542521329a 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/variant/mutationalSignature/MutationalSignatureLocalAnalysisExecutor.java @@ -64,11 +64,12 @@ public class MutationalSignatureLocalAnalysisExecutor extends MutationalSignatureAnalysisExecutor implements StorageToolExecutor { - public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); - private static final String SVCLASS = "SVCLASS"; private static final String EXT_SVTYPE = "EXT_SVTYPE"; + public final static String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + + GitRepositoryState.getInstance().getBuildVersion(); + private Path opencgaHome; private Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java index 27d6c54d7b3..21f619cc5a4 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/wrappers/executors/DockerWrapperAnalysisExecutor.java @@ -32,7 +32,7 @@ public String getDockerImageName() { } public String getDockerImageVersion() { - return GitRepositoryState.get().getBuildVersion(); + return GitRepositoryState.getInstance().getBuildVersion(); } private Logger privateLogger = LoggerFactory.getLogger(DockerWrapperAnalysisExecutor.class); diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java index 0884482ef80..f45e8e77ec2 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaSolrExtenalResource.java @@ -5,10 +5,8 @@ import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.NodeConfig; -import org.apache.solr.core.SolrResourceLoader; import org.junit.rules.ExternalResource; import org.opencb.commons.datastore.solr.SolrManager; -import org.opencb.opencga.analysis.variant.manager.VariantStorageManager; import org.opencb.opencga.core.common.GitRepositoryState; import org.opencb.opencga.core.config.storage.StorageConfiguration; @@ -40,8 +38,8 @@ protected void before() throws Throwable { Path rootDir = getTmpRootDir(); - String mainConfigSet = "opencga-rga-configset-" + GitRepositoryState.get().getBuildVersion(); - String auxConfigSet = "opencga-rga-aux-configset-" + GitRepositoryState.get().getBuildVersion(); + String mainConfigSet = "opencga-rga-configset-" + GitRepositoryState.getInstance().getBuildVersion(); + String auxConfigSet = "opencga-rga-aux-configset-" + GitRepositoryState.getInstance().getBuildVersion(); copyConfigSetConfiguration(mainConfigSet, "managed-schema"); copyConfigSetConfiguration(auxConfigSet, "aux-managed-schema"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java index 89832e53260..28787847b65 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminCliOptionsParser.java @@ -800,8 +800,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Admin (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-admin.sh [-h|--help] [--version] [options]"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java index 2bb78fb51c3..2dc1f8d638b 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/AdminMain.java @@ -30,7 +30,7 @@ */ public class AdminMain { - public static final String VERSION = GitRepositoryState.get().getBuildVersion(); + public static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public static void main(String[] args) { @@ -71,8 +71,8 @@ public static void main(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); System.exit(0); } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java index ceaab6ea98d..a360eaa2f1e 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/admin/executors/MigrationCommandExecutor.java @@ -167,7 +167,7 @@ private String parseVersion(String version) { public static String getDefaultVersion() { String version; - version = GitRepositoryState.get().getBuildVersion(); + version = GitRepositoryState.getInstance().getBuildVersion(); // Remove extra information version = version.split("-")[0]; return version; diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java index f11d519c846..132ad854c82 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalCliOptionsParser.java @@ -468,8 +468,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Analysis (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-internal.sh [-h|--help] [--version] [options]"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java index a1aaf7466f3..98d8b965357 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/internal/InternalMain.java @@ -28,7 +28,7 @@ */ public class InternalMain { - public static final String VERSION = GitRepositoryState.get().getBuildVersion(); + public static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public static void main(String[] args) { System.exit(privateMain(args)); @@ -48,8 +48,8 @@ public static int privateMain(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); return 0; } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java index 46af3e8eeb9..4454887584b 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/CommandLineUtils.java @@ -18,16 +18,16 @@ public class CommandLineUtils { private static final Logger logger = LoggerFactory.getLogger(CommandLineUtils.class); public static String getVersionString() { - String res = PrintUtils.getKeyValueAsFormattedString("\tOpenCGA CLI version: ", "\t" + GitRepositoryState.get().getBuildVersion() + "\n"); - res += PrintUtils.getKeyValueAsFormattedString("\tGit version:", "\t\t" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId() + "\n"); + String res = PrintUtils.getKeyValueAsFormattedString("\tOpenCGA CLI version: ", "\t" + GitRepositoryState.getInstance().getBuildVersion() + "\n"); + res += PrintUtils.getKeyValueAsFormattedString("\tGit version:", "\t\t" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId() + "\n"); res += PrintUtils.getKeyValueAsFormattedString("\tProgram:", "\t\tOpenCGA (OpenCB)" + "\n"); res += PrintUtils.getKeyValueAsFormattedString("\tDescription: ", "\t\tBig Data platform for processing and analysing NGS data" + "\n"); return res; } public static String getHelpVersionString() { - String res = PrintUtils.getHelpVersionFormattedString("OpenCGA CLI version: ", "\t" + GitRepositoryState.get().getBuildVersion() + "\n"); - res += PrintUtils.getHelpVersionFormattedString("Git version:", "\t\t" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId() + "\n"); + String res = PrintUtils.getHelpVersionFormattedString("OpenCGA CLI version: ", "\t" + GitRepositoryState.getInstance().getBuildVersion() + "\n"); + res += PrintUtils.getHelpVersionFormattedString("Git version:", "\t\t" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId() + "\n"); res += PrintUtils.getHelpVersionFormattedString("Program:", "\t\tOpenCGA (OpenCB)" + "\n"); res += PrintUtils.getHelpVersionFormattedString("Description: ", "\t\tBig Data platform for processing and analysing NGS data" + "\n"); return res; @@ -90,7 +90,7 @@ public static String[] processShortCuts(String[] args) { break; case "--build-version": case "build-version": - println(GitRepositoryState.get().getBuildVersion()); + println(GitRepositoryState.getInstance().getBuildVersion()); break; case "logout": return ArrayUtils.addAll(new String[]{"users"}, args); @@ -99,7 +99,7 @@ public static String[] processShortCuts(String[] args) { if (args.length > 1 && args[1].equals("studies")) { println(String.join(", ", OpencgaMain.getShell().getSessionManager().getSession().getStudies()), Color.GREEN); } else { - printWarn("Opencga version " + GitRepositoryState.get().getBuildVersion() + " can only list studies"); + printWarn("Opencga version " + GitRepositoryState.getInstance().getBuildVersion() + " can only list studies"); } } else { printWarn("List studies is only available in Shell mode"); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java index 1c2099ec471..15d7b63e6ec 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/main/utils/JobsTopManager.java @@ -150,7 +150,7 @@ public void print(JobTop top) { jobTable.restoreCursorPosition(); jobTable.println("OpenCGA jobs TOP"); - jobTable.println(" Version " + GitRepositoryState.get().getBuildVersion()); + jobTable.println(" Version " + GitRepositoryState.getInstance().getBuildVersion()); jobTable.println(" " + TextOutputWriter.SIMPLE_DATE_FORMAT.format(Date.from(Instant.now()))); jobTable.println(); jobTable.print(Enums.ExecutionStatus.RUNNING + ": " + top.getStats().getRunning() + ", "); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java b/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java index 640a687f7c3..f822716041e 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/cli/session/SessionManager.java @@ -111,7 +111,7 @@ private void init() { private Session createEmptySession() { Session session = new Session(); session.setHost(host); - session.setVersion(GitRepositoryState.get().getBuildVersion()); + session.setVersion(GitRepositoryState.getInstance().getBuildVersion()); session.setTimestamp(System.currentTimeMillis()); session.setStudies(new ArrayList()); session.setCurrentStudy(NO_STUDY); diff --git a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java index d23d2345681..d9e270c3d9f 100644 --- a/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java +++ b/opencga-app/src/main/java/org/opencb/opencga/app/migrations/v2_2_0/catalog/issue_1849/CompleteStatusDataModelUtils.java @@ -35,8 +35,8 @@ public static void completeInternalStatus(Document document) { completeStatus(internal); Document status = internal.get("status", Document.class); - status.put("version", GitRepositoryState.get().getBuildVersion()); - status.put("commit", GitRepositoryState.get().getCommitId()); + status.put("version", GitRepositoryState.getInstance().getBuildVersion()); + status.put("commit", GitRepositoryState.getInstance().getCommitId()); String id = status.getString("id"); if (StringUtils.isEmpty(id)) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java index bb542490cdc..295a84f2093 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/db/mongodb/MetaMongoDBAdaptor.java @@ -55,7 +55,7 @@ public class MetaMongoDBAdaptor extends MongoDBAdaptor implements MetaDBAdaptor Filters.eq(ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID), Filters.eq(OLD_ID, MongoDBAdaptorFactory.METADATA_OBJECT_ID)); private final MongoDBCollection metaCollection; - private static final String VERSION = GitRepositoryState.get().getBuildVersion(); + private static final String VERSION = GitRepositoryState.getInstance().getBuildVersion(); public MetaMongoDBAdaptor(MongoDBCollection metaMongoDBCollection, Configuration configuration, MongoDBAdaptorFactory dbAdaptorFactory) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java index 1f0a9ae40c6..b95d3b0ff0e 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/managers/AuditManager.java @@ -184,7 +184,7 @@ public void audit(String operationId, String userId, Enums.Action action, Enums. public void audit(String operationId, String userId, Enums.Action action, Enums.Resource resource, String resourceId, String resourceUuid, String studyId, String studyUuid, ObjectMap params, AuditRecord.Status status, ObjectMap attributes) { - String apiVersion = GitRepositoryState.get().getBuildVersion(); + String apiVersion = GitRepositoryState.getInstance().getBuildVersion(); Date date = TimeUtils.getDate(); String auditId = UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.AUDIT); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java index 6be7ad1be28..b1c2df87d1f 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/stats/solr/CatalogSolrManager.java @@ -268,7 +268,7 @@ public DataResult facetedQuery(Study study, String collection, Query //***************** PRIVATE ****************/ private void populateConfigCollectionMap() { - String version = GitRepositoryState.get().getBuildVersion(); + String version = GitRepositoryState.getInstance().getBuildVersion(); CONFIGS_COLLECTION.put(DATABASE_PREFIX + COHORT_SOLR_COLLECTION, COHORT_CONF_SET + "-" + version); CONFIGS_COLLECTION.put(DATABASE_PREFIX + FILE_SOLR_COLLECTION, FILE_CONF_SET + "-" + version); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java index 16a638e0e2d..bb59584363b 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/templates/TemplateManager.java @@ -125,7 +125,7 @@ public void validate(TemplateManifest manifest) throws CatalogException { } // Check version - GitRepositoryState gitRepositoryState = GitRepositoryState.get(); + GitRepositoryState gitRepositoryState = GitRepositoryState.getInstance(); String version = gitRepositoryState.getBuildVersion(); String versionShort; if (version.contains("-")) { diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java index 6459083abab..b56966a44e8 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java @@ -25,7 +25,7 @@ public class PedigreeGraphUtils { public static final String PEDIGREE_JSON_FILENAME = "ped_coords.json"; public static final String PEDIGREE_TSV_FILENAME = "ped_coords.tsv"; - public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.get().getBuildVersion(); + public static final String R_DOCKER_IMAGE = "opencb/opencga-ext-tools:" + GitRepositoryState.getInstance().getBuildVersion(); public static PedigreeGraph getPedigreeGraph(Family family, Path openCgaHome, Path scratchDir) throws IOException { PedigreeGraph pedigreeGraph = new PedigreeGraph(); diff --git a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java index cc0a758e602..677262d5cf8 100644 --- a/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java +++ b/opencga-catalog/src/test/java/org/opencb/opencga/catalog/stats/solr/SolrExternalResource.java @@ -41,7 +41,7 @@ public void before() throws Exception { Path rootDir = getOpencgaHome(); - String version = GitRepositoryState.get().getBuildVersion(); + String version = GitRepositoryState.getInstance().getBuildVersion(); // Copy configuration copyConfiguration("cohort-managed-schema", CatalogSolrManager.COHORT_CONF_SET + "-" + version); diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java index 80f1563dec6..790d8adcbe0 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java @@ -32,6 +32,7 @@ public class GitRepositoryState { public static final String DEFAULT_RESOURCE_NAME = "git.properties"; private static GitRepositoryState gitRepositoryState; + private static Properties properties; private static final Logger logger = LoggerFactory.getLogger(GitRepositoryState.class); private String tags; // =${git.tags} // comma separated tag names @@ -57,9 +58,16 @@ public class GitRepositoryState { private String buildHost; // =${git.build.host} private String buildVersion; // =${git.build.version} - public static GitRepositoryState get() { + public static String get(String key) { + if (properties == null) { + getInstance(); + } + return properties.getProperty(key); + } + + public static GitRepositoryState getInstance() { if (gitRepositoryState == null) { - Properties properties = new Properties(); + properties = new Properties(); InputStream stream = null; try { stream = GitRepositoryState.class.getClassLoader().getResourceAsStream(DEFAULT_RESOURCE_NAME); diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java b/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java index 53f0014dd27..a647bbd8b43 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/docs/DocBuilder.java @@ -44,7 +44,7 @@ public static void main(String[] args) { config.setType(DocFactory.DocFactoryType.MARKDOWN); config.setOutputDir("/workspace/opencga/docs/data-models/"); config.setGithubServerURL("https://github.com/opencb/opencga/tree/" - + GitRepositoryState.get().getBranch() + "/opencga-core"); + + GitRepositoryState.getInstance().getBranch() + "/opencga-core"); config.setJsondir("/workspace/opencga/opencga-core/src/main/resources/doc/json"); config.setGitbookServerURL("https://docs.opencga.opencb.org/data-models"); try { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java index a0a67ee823a..99fb1bedeaa 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/Metadata.java @@ -31,7 +31,7 @@ public class Metadata { public Metadata() { - this(GitRepositoryState.get().getBuildVersion(), TimeUtils.getTime()); + this(GitRepositoryState.getInstance().getBuildVersion(), TimeUtils.getTime()); } public Metadata(String version, String creationDate) { diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java b/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java index 732cb04adaf..a934efdc3ee 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/models/common/InternalStatus.java @@ -120,8 +120,8 @@ protected void init(String statusId, String statusName, String description) { super.name = statusName; super.description = description; super.date = TimeUtils.getTime(); - this.version = GitRepositoryState.get().getBuildVersion(); - this.commit = GitRepositoryState.get().getCommitId(); + this.version = GitRepositoryState.getInstance().getBuildVersion(); + this.commit = GitRepositoryState.getInstance().getCommitId(); } @Override diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java b/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java index da1778bf650..dc811356a1a 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/tools/result/Status.java @@ -61,8 +61,8 @@ public Status(Type name, String step, Date date) { public static Status initStatus() { Status status = new Status(); - status.version = GitRepositoryState.get().getBuildVersion(); - status.commit = GitRepositoryState.get().getCommitId(); + status.version = GitRepositoryState.getInstance().getBuildVersion(); + status.commit = GitRepositoryState.getInstance().getCommitId(); return status; } diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java b/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java index 84ae7f75aae..cff66f13e62 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/generator/models/RestApi.java @@ -28,7 +28,7 @@ public class RestApi { private List categories; public RestApi() { - this(GitRepositoryState.get().getBuildVersion(), GitRepositoryState.get().getCommitId(), new ArrayList<>()); + this(GitRepositoryState.getInstance().getBuildVersion(), GitRepositoryState.getInstance().getCommitId(), new ArrayList<>()); } public RestApi(String version, String commit, List categories) { diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java index e075e938983..528853faeb6 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/MetaWSServer.java @@ -80,9 +80,9 @@ public MetaWSServer(@Context UriInfo uriInfo, @Context HttpServletRequest httpSe public Response getAbout() { Map info = new HashMap<>(5); info.put("Program", "OpenCGA (OpenCB)"); - info.put("Version", GitRepositoryState.get().getBuildVersion()); - info.put("Git branch", GitRepositoryState.get().getBranch()); - info.put("Git commit", GitRepositoryState.get().getCommitId()); + info.put("Version", GitRepositoryState.getInstance().getBuildVersion()); + info.put("Git branch", GitRepositoryState.getInstance().getBranch()); + info.put("Git commit", GitRepositoryState.getInstance().getCommitId()); info.put("Description", "Big Data platform for processing and analysing NGS data"); OpenCGAResult queryResult = new OpenCGAResult(); queryResult.setTime(0); diff --git a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java index d152cf17277..03a39102d9e 100644 --- a/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java +++ b/opencga-server/src/main/java/org/opencb/opencga/server/rest/OpenCGAWSServer.java @@ -260,8 +260,8 @@ static void init(String opencgaHomeStr) { } logger.info("| OpenCGA REST successfully started!"); - logger.info("| - Version " + GitRepositoryState.get().getBuildVersion()); - logger.info("| - Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + logger.info("| - Version " + GitRepositoryState.getInstance().getBuildVersion()); + logger.info("| - Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); logger.info("========================================================================\n"); } @@ -428,8 +428,8 @@ private static void addErrorEvent(RestResponse response, Throwable e) { } public static void setFederationServer(OpenCGAResult result, String baseuri) { - result.setFederationNode(new FederationNode(baseuri, GitRepositoryState.get().getCommitId(), - GitRepositoryState.get().getBuildVersion())); + result.setFederationNode(new FederationNode(baseuri, GitRepositoryState.getInstance().getCommitId(), + GitRepositoryState.getInstance().getBuildVersion())); } public static void logResponse(Response.StatusType statusInfo, RestResponse queryResponse, long startTime, diff --git a/opencga-server/src/main/resources/parserAbstractMethods.template b/opencga-server/src/main/resources/parserAbstractMethods.template index a06cc76c2f1..4d25b76e871 100644 --- a/opencga-server/src/main/resources/parserAbstractMethods.template +++ b/opencga-server/src/main/resources/parserAbstractMethods.template @@ -18,8 +18,8 @@ if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java index 85313d4e4c3..0825354d734 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageAdminMain.java @@ -48,8 +48,8 @@ public static int privateMain(String[] args) { String parsedCommand = adminCliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (adminCliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); return 0; } else if (adminCliOptionsParser.getGeneralOptions().help) { adminCliOptionsParser.printUsage(); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java index 05da1e97637..9f7ec6fd321 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/StorageMain.java @@ -48,9 +48,9 @@ public static int privateMain(String[] args) { String parsedCommand = cliOptionsParser.getCommand(); if (parsedCommand == null || parsedCommand.isEmpty()) { if (cliOptionsParser.getGeneralOptions().version) { - System.out.println("Version " + GitRepositoryState.get().getBuildVersion()); - System.out.println("Git version: " + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); -// System.out.println(GitRepositoryState.get()); + System.out.println("Version " + GitRepositoryState.getInstance().getBuildVersion()); + System.out.println("Git version: " + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); +// System.out.println(GitRepositoryState.getInstance()); return 0; } else if (cliOptionsParser.getGeneralOptions().help) { cliOptionsParser.printUsage(); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java index 9c430b284c1..fb567276992 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/client/ClientCliOptionsParser.java @@ -82,8 +82,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Storage (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-storage.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java index 7aedfbd4e85..86a4bcca419 100644 --- a/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java +++ b/opencga-storage/opencga-storage-app/src/main/java/org/opencb/opencga/storage/app/cli/server/AdminCliOptionsParser.java @@ -76,8 +76,8 @@ public void printUsage() { if (parsedCommand.isEmpty()) { System.err.println(""); System.err.println("Program: OpenCGA Storage Admin (OpenCB)"); - System.err.println("Version: " + GitRepositoryState.get().getBuildVersion()); - System.err.println("Git commit: " + GitRepositoryState.get().getCommitId()); + System.err.println("Version: " + GitRepositoryState.getInstance().getBuildVersion()); + System.err.println("Git commit: " + GitRepositoryState.getInstance().getCommitId()); System.err.println("Description: Big Data platform for processing and analysing NGS data"); System.err.println(""); System.err.println("Usage: opencga-storage-admin.sh [-h|--help] [--version] [options]"); diff --git a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java index 1ec92d91ea9..d2114731bc1 100644 --- a/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java +++ b/opencga-storage/opencga-storage-core/src/main/java/org/opencb/opencga/storage/core/metadata/VariantMetadataConverter.java @@ -48,7 +48,7 @@ public VariantMetadata toVariantMetadata(VariantQueryProjection variantQueryProj // .setDate(Date.from(Instant.now()).toString()) .setCreationDate(TimeUtils.getTime()) .setStudies(studies) - .setVersion(GitRepositoryState.get().getDescribeShort()) + .setVersion(GitRepositoryState.getInstance().getDescribeShort()) .setSpecies(species) .build(); diff --git a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java index 122ef2da4af..031360d3298 100644 --- a/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java +++ b/opencga-storage/opencga-storage-core/src/test/java/org/opencb/opencga/storage/core/variant/solr/VariantSolrExternalResource.java @@ -63,7 +63,7 @@ protected void before() throws Throwable { Path rootDir = getTmpRootDir(); - String configSet = "opencga-variant-configset-" + GitRepositoryState.get().getBuildVersion(); + String configSet = "opencga-variant-configset-" + GitRepositoryState.getInstance().getBuildVersion(); // Copy configuration getResourceUri("configsets/variantsCollection/solrconfig.xml", "configsets/" + configSet + "/solrconfig.xml"); diff --git a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java index 7ba0a4faf85..ef8f97152ad 100644 --- a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java +++ b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/main/java/org/opencb/opencga/storage/hadoop/variant/executors/MRExecutor.java @@ -51,7 +51,7 @@ public MRExecutor init(ObjectMap options) { public static String getJarWithDependencies(ObjectMap options) throws StorageEngineException { String jar = options.getString(MR_JAR_WITH_DEPENDENCIES.key(), null); if (jar == null) { - jar = "opencga-storage-hadoop-core-" + GitRepositoryState.get().getBuildVersion() + "-jar-with-dependencies.jar"; + jar = "opencga-storage-hadoop-core-" + GitRepositoryState.getInstance().getBuildVersion() + "-jar-with-dependencies.jar"; // throw new StorageEngineException("Missing option " + MR_JAR_WITH_DEPENDENCIES); } if (!Paths.get(jar).isAbsolute()) { diff --git a/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java b/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java index efd41c2b319..256df4315ee 100644 --- a/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java +++ b/opencga-test/src/main/java/org/opencb/opencga/test/cli/OptionsParser.java @@ -76,8 +76,8 @@ public static void printVersion() { private static Map getVersionMap() { Map versionMap = new HashMap<>(); - versionMap.put("OpenCGA Test version:", GitRepositoryState.get().getBuildVersion()); - versionMap.put("Git version:", "" + GitRepositoryState.get().getBranch() + " " + GitRepositoryState.get().getCommitId()); + versionMap.put("OpenCGA Test version:", GitRepositoryState.getInstance().getBuildVersion()); + versionMap.put("Git version:", "" + GitRepositoryState.getInstance().getBranch() + " " + GitRepositoryState.getInstance().getCommitId()); versionMap.put("Program:", "OpenCGA-test (OpenCB)"); versionMap.put("Description:", "Data generation application for the openCGA platform"); return versionMap; From 9f49693aef0aaf890ed6ed148f11ee3121ddf7e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Coll=20Morag=C3=B3n?= Date: Fri, 15 Sep 2023 09:14:30 +0100 Subject: [PATCH 2/2] core: Relocate git.properties file to avoid classpath collisions. #TASK-4688 --- opencga-app/pom.xml | 2 +- opencga-core/pom.xml | 2 +- .../core/common/GitRepositoryState.java | 51 ++++++++++--------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/opencga-app/pom.xml b/opencga-app/pom.xml index 4d18a6476ca..536a11e7893 100644 --- a/opencga-app/pom.xml +++ b/opencga-app/pom.xml @@ -306,7 +306,7 @@ - + diff --git a/opencga-core/pom.xml b/opencga-core/pom.xml index 508d50cede8..8c00825f541 100644 --- a/opencga-core/pom.xml +++ b/opencga-core/pom.xml @@ -139,7 +139,7 @@ true - target/generated-resources/git.properties + target/generated-resources/org/opencb/opencga/core/git.properties false diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java index 790d8adcbe0..36b942d381a 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/common/GitRepositoryState.java @@ -30,11 +30,11 @@ */ public class GitRepositoryState { - public static final String DEFAULT_RESOURCE_NAME = "git.properties"; + public static final String DEFAULT_RESOURCE_NAME = "org/opencb/opencga/core/git.properties"; private static GitRepositoryState gitRepositoryState; - private static Properties properties; private static final Logger logger = LoggerFactory.getLogger(GitRepositoryState.class); + private Properties properties; private String tags; // =${git.tags} // comma separated tag names private String branch; // =${git.branch} private String dirty; // =${git.dirty} @@ -59,42 +59,43 @@ public class GitRepositoryState { private String buildVersion; // =${git.build.version} public static String get(String key) { - if (properties == null) { - getInstance(); - } - return properties.getProperty(key); + return getInstance().properties.getProperty(key); } public static GitRepositoryState getInstance() { if (gitRepositoryState == null) { - properties = new Properties(); - InputStream stream = null; - try { - stream = GitRepositoryState.class.getClassLoader().getResourceAsStream(DEFAULT_RESOURCE_NAME); - if (stream != null) { - properties.load(stream); - } - } catch (IOException e) { - logger.warn("Error reading " + DEFAULT_RESOURCE_NAME, e); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - logger.warn("Error closing stream from " + DEFAULT_RESOURCE_NAME, e); - } + gitRepositoryState = load(DEFAULT_RESOURCE_NAME); + } + return gitRepositoryState; + } + + public static GitRepositoryState load(String resourceName) { + Properties properties = new Properties(); + InputStream stream = null; + try { + stream = GitRepositoryState.class.getClassLoader().getResourceAsStream(resourceName); + if (stream != null) { + properties.load(stream); + } + } catch (IOException e) { + logger.warn("Error reading " + resourceName, e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + logger.warn("Error closing stream from " + resourceName, e); } } - - gitRepositoryState = new GitRepositoryState(properties); } - return gitRepositoryState; + return new GitRepositoryState(properties); } GitRepositoryState() { } private GitRepositoryState(Properties properties) { + this.properties = properties; this.tags = properties.getProperty("git.tags"); this.branch = properties.getProperty("git.branch"); this.dirty = properties.getProperty("git.dirty");