From be60d936d8c05a8f1e11a9d9551aa93bbd1b9272 Mon Sep 17 00:00:00 2001 From: frabacche Date: Tue, 17 Oct 2023 17:45:30 +0200 Subject: [PATCH 1/5] DSC-1304 expose dspace and cris versions in two different attributes --- .../dspace/app/rest/converter/RootConverter.java | 3 ++- .../java/org/dspace/app/rest/model/RootRest.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java index 61f18a5b3c9c..94835b969689 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java @@ -28,7 +28,8 @@ public RootRest convert() { rootRest.setDspaceName(configurationService.getProperty("dspace.name")); rootRest.setDspaceUI(configurationService.getProperty("dspace.ui.url")); rootRest.setDspaceServer(configurationService.getProperty("dspace.server.url")); - rootRest.setDspaceVersion("DSpace " + getSourceVersion()); + rootRest.setDspaceVersion(configurationService.getProperty("dspace.version")); + rootRest.setCrisVersion("DSpace " + getSourceVersion()); return rootRest; } } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java index cef8965601ca..a538a89b9670 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java @@ -21,8 +21,9 @@ public class RootRest extends RestAddressableModel { private String dspaceName; private String dspaceServer; private String dspaceVersion; + private String crisVersion; - public String getCategory() { + public String getCategory() { return CATEGORY; } @@ -67,6 +68,14 @@ public void setDspaceVersion(String dspaceVersion) { this.dspaceVersion = dspaceVersion; } + public String getCrisVersion() { + return crisVersion; + } + + public void setCrisVersion(String crisVersion) { + this.crisVersion = crisVersion; + } + @Override public boolean equals(Object object) { return (object instanceof RootRest && @@ -76,6 +85,7 @@ public boolean equals(Object object) { .append(this.getDspaceUI(), ((RootRest) object).getDspaceUI()) .append(this.getDspaceName(), ((RootRest) object).getDspaceName()) .append(this.getDspaceServer(), ((RootRest) object).getDspaceServer()) + .append(this.getCrisVersion(), ((RootRest)object).getCrisVersion()) .isEquals()); } @@ -88,6 +98,7 @@ public int hashCode() { .append(this.getDspaceName()) .append(this.getDspaceUI()) .append(this.getDspaceServer()) + .append(this.getCrisVersion()) .toHashCode(); } } From b5c979a257cb967077251cbabbf1a63e021507a0 Mon Sep 17 00:00:00 2001 From: frabacche Date: Wed, 18 Oct 2023 08:35:53 +0200 Subject: [PATCH 2/5] DSC-1304 DSpaceVersion stored into a Java constants --- dspace-api/src/main/java/org/dspace/core/CrisConstants.java | 2 +- .../main/java/org/dspace/app/rest/converter/RootConverter.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/core/CrisConstants.java b/dspace-api/src/main/java/org/dspace/core/CrisConstants.java index 18def2d10316..eb503b9aff8e 100644 --- a/dspace-api/src/main/java/org/dspace/core/CrisConstants.java +++ b/dspace-api/src/main/java/org/dspace/core/CrisConstants.java @@ -21,7 +21,7 @@ public class CrisConstants { * same number than the parent leading metadata */ public static final String PLACEHOLDER_PARENT_METADATA_VALUE = "#PLACEHOLDER_PARENT_METADATA_VALUE#"; - + public static final String DSPACE_BASE_VERSION = "7.5"; public static final MetadataFieldName MD_ENTITY_TYPE = new MetadataFieldName("dspace", "entity", "type"); public static final MetadataFieldName MD_SUBMISSION_TYPE = new MetadataFieldName("cris", "submission", "definition"); diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java index 94835b969689..a6aebb0bb9a2 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java @@ -10,6 +10,7 @@ import static org.dspace.app.util.Util.getSourceVersion; import org.dspace.app.rest.model.RootRest; +import org.dspace.core.CrisConstants; import org.dspace.services.ConfigurationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,7 +29,7 @@ public RootRest convert() { rootRest.setDspaceName(configurationService.getProperty("dspace.name")); rootRest.setDspaceUI(configurationService.getProperty("dspace.ui.url")); rootRest.setDspaceServer(configurationService.getProperty("dspace.server.url")); - rootRest.setDspaceVersion(configurationService.getProperty("dspace.version")); + rootRest.setDspaceVersion(CrisConstants.DSPACE_BASE_VERSION); rootRest.setCrisVersion("DSpace " + getSourceVersion()); return rootRest; } From b6598bd5b4924e6be71ddb3f4a2a6d940e5d7450 Mon Sep 17 00:00:00 2001 From: frabacche Date: Wed, 18 Oct 2023 08:44:32 +0200 Subject: [PATCH 3/5] DSC-1304 DSpaceVersion stored into a Java constants --- dspace-api/src/main/java/org/dspace/core/CrisConstants.java | 2 +- .../main/java/org/dspace/app/rest/converter/RootConverter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/core/CrisConstants.java b/dspace-api/src/main/java/org/dspace/core/CrisConstants.java index eb503b9aff8e..5bce199cfd76 100644 --- a/dspace-api/src/main/java/org/dspace/core/CrisConstants.java +++ b/dspace-api/src/main/java/org/dspace/core/CrisConstants.java @@ -21,7 +21,7 @@ public class CrisConstants { * same number than the parent leading metadata */ public static final String PLACEHOLDER_PARENT_METADATA_VALUE = "#PLACEHOLDER_PARENT_METADATA_VALUE#"; - public static final String DSPACE_BASE_VERSION = "7.5"; + public static final String DSPACE_BASE_VERSION = "DSpace 7.5"; public static final MetadataFieldName MD_ENTITY_TYPE = new MetadataFieldName("dspace", "entity", "type"); public static final MetadataFieldName MD_SUBMISSION_TYPE = new MetadataFieldName("cris", "submission", "definition"); diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java index a6aebb0bb9a2..b6d9499d5f77 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java @@ -30,7 +30,7 @@ public RootRest convert() { rootRest.setDspaceUI(configurationService.getProperty("dspace.ui.url")); rootRest.setDspaceServer(configurationService.getProperty("dspace.server.url")); rootRest.setDspaceVersion(CrisConstants.DSPACE_BASE_VERSION); - rootRest.setCrisVersion("DSpace " + getSourceVersion()); + rootRest.setCrisVersion(getSourceVersion()); return rootRest; } } From 051e17e6a1b436f7d793e311acc0f7a1d82a41f7 Mon Sep 17 00:00:00 2001 From: frabacche Date: Wed, 18 Oct 2023 11:55:30 +0200 Subject: [PATCH 4/5] DSC-1304 test fix --- .../java/org/dspace/app/rest/converter/RootConverterTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java b/dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java index acb3b0c263d0..73b12848e790 100644 --- a/dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java +++ b/dspace-server-webapp/src/test/java/org/dspace/app/rest/converter/RootConverterTest.java @@ -13,6 +13,7 @@ import org.dspace.app.rest.model.RootRest; import org.dspace.app.util.Util; +import org.dspace.core.CrisConstants; import org.dspace.services.ConfigurationService; import org.junit.Before; import org.junit.Test; @@ -52,7 +53,8 @@ public void testCorrectPropertiesSetFromConfigurationService() throws Exception assertEquals("dspaceurl", rootRest.getDspaceUI()); assertEquals("dspacename", rootRest.getDspaceName()); assertEquals(restUrl, rootRest.getDspaceServer()); - assertEquals("DSpace " + Util.getSourceVersion(), rootRest.getDspaceVersion()); + assertEquals(CrisConstants.DSPACE_BASE_VERSION, rootRest.getDspaceVersion()); + assertEquals(Util.getSourceVersion(), rootRest.getCrisVersion()); } @Test From a5c859ed9e70b4d04c3303a0b8494f5e174270bc Mon Sep 17 00:00:00 2001 From: frabacche Date: Wed, 18 Oct 2023 14:44:07 +0200 Subject: [PATCH 5/5] DSC-1304 checkstyle! --- .../org/dspace/app/rest/converter/RootConverter.java | 2 +- .../java/org/dspace/app/rest/model/RootRest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java index b6d9499d5f77..1d81e308e39f 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/converter/RootConverter.java @@ -30,7 +30,7 @@ public RootRest convert() { rootRest.setDspaceUI(configurationService.getProperty("dspace.ui.url")); rootRest.setDspaceServer(configurationService.getProperty("dspace.server.url")); rootRest.setDspaceVersion(CrisConstants.DSPACE_BASE_VERSION); - rootRest.setCrisVersion(getSourceVersion()); + rootRest.setCrisVersion(getSourceVersion()); return rootRest; } } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java index a538a89b9670..9fd6a1263423 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/model/RootRest.java @@ -23,7 +23,7 @@ public class RootRest extends RestAddressableModel { private String dspaceVersion; private String crisVersion; - public String getCategory() { + public String getCategory() { return CATEGORY; } @@ -69,12 +69,12 @@ public void setDspaceVersion(String dspaceVersion) { } public String getCrisVersion() { - return crisVersion; - } + return crisVersion; + } - public void setCrisVersion(String crisVersion) { - this.crisVersion = crisVersion; - } + public void setCrisVersion(String crisVersion) { + this.crisVersion = crisVersion; + } @Override public boolean equals(Object object) {