Skip to content

Commit 4198707

Browse files
authored
Merge pull request #1546 from NCEAS/develop
2.16.1 First Merge from develop to main
2 parents 0b03768 + 7615b62 commit 4198707

File tree

11 files changed

+109
-18
lines changed

11 files changed

+109
-18
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Metacat: Data Preservation and Discovery System
22

3-
Version: 2.16.0 Release
3+
Version: 2.16.1 Release
44

55
Send feedback and bugs to: [email protected]
66
http://github.com/NCEAS/metacat
@@ -67,9 +67,14 @@ for the next release.
6767

6868
## Release Notes
6969

70+
### Release Notes for 2.16.1
71+
Bugs fixed in this release:
72+
* Upgrade some library jar files to fix severe security vulnerabilities
73+
* Metacat cannot create objects without DOI setting enabled
74+
7075
### Release Notes for 2.16.0
7176
New features and bugs fixed in this release:
72-
* Upgrade some library jar files to fix critical security threats
77+
* Upgrade some library jar files to fix critical security vulnerabilities
7378
* Refactor the DOI service to use the plug-in architecture
7479
* CN subjects cannot query private objects
7580
* Users with the write permission cannot update system metadata

build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#Version of this build. This needs to be a dotted numeric version. For
44
#instance 1.9.1 is okay. 1.9.1_rc1 is not.
5-
metacat.version=2.16.0
5+
metacat.version=2.16.1
66

77
#This is for packaging purposes. leave it blank for final production release.
88
metacat.releaseCandidate=

lib/metacat.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ server.internalPort=80
3434
############### Application Values ############
3535

3636
## one of the few places where we use ANT tokens
37-
application.metacatVersion=2.16.0
37+
application.metacatVersion=2.16.1
3838
application.metacatReleaseInfo=-1
3939
application.readOnlyMode=false
4040

@@ -136,6 +136,7 @@ database.upgradeVersion.2.14.1=upgrade-db-to-2.14.1
136136
database.upgradeVersion.2.15.0=upgrade-db-to-2.15.0
137137
database.upgradeVersion.2.15.1=upgrade-db-to-2.15.1
138138
database.upgradeVersion.2.16.0=upgrade-db-to-2.16.0
139+
database.upgradeVersion.2.16.1=upgrade-db-to-2.16.1
139140

140141
## for running java-based utilities
141142
database.upgradeUtility.1.5.0=edu.ucsb.nceas.metacat.admin.upgrade.Upgrade1_5_0

metacat-common/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>edu.ucsb.nceas.metacat.common</groupId>
55
<artifactId>metacat-common</artifactId>
66
<packaging>jar</packaging>
7-
<version>2.16.0</version>
7+
<version>2.16.1</version>
88
<name>metacat-common</name>
99
<url>http://maven.apache.org</url>
1010
<properties>
@@ -219,17 +219,17 @@
219219
<dependency>
220220
<groupId>org.apache.logging.log4j</groupId>
221221
<artifactId>log4j-1.2-api</artifactId>
222-
<version>2.16.0</version>
222+
<version>2.17.0</version>
223223
</dependency>
224224
<dependency>
225225
<groupId>org.apache.logging.log4j</groupId>
226226
<artifactId>log4j-core</artifactId>
227-
<version>2.16.0</version>
227+
<version>2.17.0</version>
228228
</dependency>
229229
<dependency>
230230
<groupId>org.apache.logging.log4j</groupId>
231231
<artifactId>log4j-jcl</artifactId>
232-
<version>2.16.0</version>
232+
<version>2.17.0</version>
233233
</dependency>
234234
<dependency>
235235
<groupId>commons-logging</groupId>

metacat-index/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<groupId>edu.ucsb.nceas.metacat.index</groupId>
55
<artifactId>metacat-index</artifactId>
66
<packaging>war</packaging>
7-
<version>2.16.0</version>
7+
<version>2.16.1</version>
88
<name>metacat-index</name>
99
<url>http://maven.apache.org</url>
1010

1111
<properties>
1212
<d1_cn_index_processor_version>2.3.14</d1_cn_index_processor_version>
13-
<metacat_common_version>2.16.0</metacat_common_version>
13+
<metacat_common_version>2.16.1</metacat_common_version>
1414
</properties>
1515

1616
<repositories>

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.ecoinformatics</groupId>
66
<artifactId>metacat</artifactId>
7-
<version>2.16.0</version>
7+
<version>2.16.1</version>
88
<name>metacat</name>
99
<packaging>war</packaging>
1010
<url>http://maven.apache.org</url>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<d1_libclient_version>2.3.1</d1_libclient_version>
1414
<d1_portal_version>2.3.2</d1_portal_version>
15-
<metacat_common_version>2.16.0</metacat_common_version>
15+
<metacat_common_version>2.16.1</metacat_common_version>
1616
</properties>
1717
<repositories>
1818
<repository>

src/edu/ucsb/nceas/metacat/doi/DOIService.java

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.dataone.service.types.v2.SystemMetadata;
2626

2727
import edu.ucsb.nceas.ezid.EZIDException;
28+
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
2829

2930
/**
3031
* An interface for the DOI service
@@ -51,4 +52,10 @@ public boolean registerDOI(SystemMetadata sysMeta) throws InvalidRequest, DOIExc
5152
* @throws InvalidRequest
5253
*/
5354
public Identifier generateDOI() throws DOIException, InvalidRequest;
55+
56+
/**
57+
* Refresh the status (enable or disable) of the DOI service from property file
58+
* @throws PropertyNotFoundException
59+
*/
60+
public void refreshStatus() throws PropertyNotFoundException;
5461
}

src/edu/ucsb/nceas/metacat/doi/ezid/EzidDOIService.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,7 @@ public boolean registerDOI(SystemMetadata sysMeta) throws InvalidRequest, DOIExc
243243
throw new DOIException(e.getMessage());
244244
}
245245
}
246-
} else {
247-
throw new InvalidRequest("2193", "DOI scheme is not enabled at this node.");
248-
}
249-
246+
}
250247
return true;
251248
}
252249

@@ -372,5 +369,14 @@ public Identifier generateDOI() throws DOIException, InvalidRequest {
372369
}
373370
return identifier;
374371
}
372+
373+
374+
/**
375+
* Refresh the status (enable or disable) of the DOI service from property file
376+
* @throws PropertyNotFoundException
377+
*/
378+
public void refreshStatus() throws PropertyNotFoundException {
379+
doiEnabled = new Boolean(PropertyService.getProperty("guid.ezid.enabled")).booleanValue();
380+
}
375381

376382
}

src/loaddtdschema-postgres.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@ INSERT INTO xml_catalog (entry_type, public_id, system_id) SELECT 'Schema', 'htt
217217
INSERT INTO xml_catalog (entry_type, public_id, format_id) SELECT 'NonXML', 'science-on-schema.org/Dataset;ld+json', 'science-on-schema.org/Dataset;ld+json' WHERE NOT EXISTS (SELECT * FROM xml_catalog WHERE public_id='science-on-schema.org/Dataset;ld+json');
218218

219219
INSERT INTO db_version (version, status, date_created)
220-
VALUES ('2.16.0',1,CURRENT_DATE);
220+
VALUES ('2.16.1',1,CURRENT_DATE);

src/upgrade-db-to-2.16.1-postgres.sql

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Ensure xml_catalog sequence is at table max
3+
*/
4+
5+
SELECT setval('xml_catalog_id_seq', (SELECT max(catalog_id) from xml_catalog));
6+
7+
/*
8+
* update the database version
9+
*/
10+
UPDATE db_version SET status=0;
11+
12+
INSERT INTO db_version (version, status, date_created)
13+
VALUES ('2.16.1', 1, CURRENT_DATE);

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java

+60-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
3434
import edu.ucsb.nceas.metacat.dataone.CNodeService;
3535
import edu.ucsb.nceas.metacat.dataone.MNodeService;
36+
import edu.ucsb.nceas.metacat.doi.DOIServiceFactory;
3637
import edu.ucsb.nceas.metacat.object.handler.JsonLDHandlerTest;
3738
import edu.ucsb.nceas.metacat.object.handler.NonXMLMetadataHandlers;
3839
import edu.ucsb.nceas.metacat.properties.PropertyService;
@@ -215,6 +216,7 @@ public static Test suite() {
215216
suite.addTest(new MNodeServiceTest("testInsertJson_LD"));
216217
suite.addTest(new MNodeServiceTest("testCreateAndUpdateEventLog"));
217218
suite.addTest(new MNodeServiceTest("testUpdateSystemMetadataPermission"));
219+
suite.addTest(new MNodeServiceTest("testCreateAndUpdateWithDoiDisabled"));
218220
return suite;
219221

220222
}
@@ -1977,7 +1979,7 @@ else if (entry.getName().contains("data.2")) {
19771979
// clean up
19781980
bagFile.delete();
19791981
Identifier doi = MNodeService.getInstance(request).publish(session, metadataId);
1980-
Thread.sleep(60000);
1982+
Thread.sleep(80000);
19811983
System.out.println("+++++++++++++++++++ the metadataId on the ore package is "+metadataId.getValue());
19821984
List<Identifier> oreIds = MNodeService.getInstance(request).lookupOreFor(session, doi, true);
19831985
assertTrue(oreIds.size() == 1);
@@ -4068,5 +4070,62 @@ private ResultSet getEventLogs(Identifier guid) throws Exception {
40684070
}
40694071
return result;
40704072
}
4073+
4074+
4075+
/**
4076+
* Test to create and update object when DOI setting is disabled
4077+
*/
4078+
public void testCreateAndUpdateWithDoiDisabled() throws Exception {
4079+
printTestHeader("testCreateAndUpdateWithDoiDisabled");
4080+
String originDOIstatusStr = PropertyService.getInstance().getProperty("guid.ezid.enabled");
4081+
System.out.println("the dois status is ++++++++++++++ " + originDOIstatusStr);
4082+
try {
4083+
Session session = getTestSession();
4084+
PropertyService.getInstance().setPropertyNoPersist("guid.ezid.enabled", "false");//disable doi
4085+
DOIServiceFactory.getDOIService().refreshStatus();
4086+
try {
4087+
//make sure the service of doi is disabled
4088+
MNodeService.getInstance(request).generateIdentifier(session, "doi", null);
4089+
fail("we shouldn't get here since generating doi should fail when the feature is disabled");
4090+
} catch (Exception e) {
4091+
assertTrue(e instanceof ServiceFailure);
4092+
assertTrue(e.getMessage().contains("DOI scheme is not enabled at this node"));
4093+
}
4094+
Identifier guid = new Identifier();
4095+
guid.setValue("testCreateAndUpdateWithDoiDisabled." + System.currentTimeMillis());
4096+
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8"));
4097+
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
4098+
Identifier newPid = new Identifier();
4099+
newPid.setValue("testCreateAndUpdateWithDoiDisabled-2." + (System.currentTimeMillis() + 1)); // ensure it is different from original
4100+
Identifier pid =
4101+
MNodeService.getInstance(request).create(session, guid, object, sysmeta);
4102+
SystemMetadata getSysMeta =
4103+
MNodeService.getInstance(request).getSystemMetadata(session, pid);
4104+
assertEquals(pid.getValue(), getSysMeta.getIdentifier().getValue());
4105+
4106+
object = new ByteArrayInputStream("test".getBytes("UTF-8"));
4107+
SystemMetadata newSysMeta = createSystemMetadata(newPid, session.getSubject(), object);
4108+
// do the update
4109+
Identifier updatedPid =
4110+
MNodeService.getInstance(request).update(session, pid, object, newPid, newSysMeta);
4111+
4112+
// get the updated system metadata
4113+
SystemMetadata updatedSysMeta =
4114+
MNodeService.getInstance(request).getSystemMetadata(session, updatedPid);
4115+
assertEquals(updatedPid.getValue(), updatedSysMeta.getIdentifier().getValue());
4116+
4117+
try {
4118+
//publish will fail too
4119+
MNodeService.getInstance(request).publish(session, updatedPid);
4120+
fail("we shouldn't get here since publishing should fail when the feature is disabled");
4121+
} catch (Exception e) {
4122+
assertTrue(e instanceof ServiceFailure);
4123+
assertTrue(e.getMessage().contains("DOI scheme is not enabled at this node"));
4124+
}
4125+
} finally {
4126+
PropertyService.getInstance().setPropertyNoPersist("guid.ezid.enabled", originDOIstatusStr);
4127+
DOIServiceFactory.getDOIService().refreshStatus();
4128+
}
4129+
}
40714130
}
40724131

0 commit comments

Comments
 (0)