Skip to content

Commit ee71339

Browse files
Merge branch 'url-storage-path' into 'master'
Use correct storagePath by default See merge request ghsc/hazdev/pdl!140
2 parents 36b6a50 + cfffc85 commit ee71339

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

code.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Product Distribution Layer",
44
"organization": "U.S. Geological Survey",
55
"description": "Distribution system used for derived earthquake information",
6-
"version": "v2.7.8",
6+
"version": "v2.7.9",
77
"status": "Production",
88
"permissions": {
99
"usageType": "openSource",

src/main/java/gov/usgs/earthquake/aws/AwsBatchIndexer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import gov.usgs.earthquake.indexer.Indexer;
2323
import gov.usgs.earthquake.product.Product;
2424
import gov.usgs.earthquake.product.ProductId;
25-
import gov.usgs.earthquake.product.io.JsonProduct;
2625
import gov.usgs.earthquake.util.JDBCConnection;
2726
import gov.usgs.util.Config;
2827
import gov.usgs.util.StreamUtils;

src/main/java/gov/usgs/earthquake/distribution/ProductClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class ProductClient extends DefaultConfigurable implements
6464
ProductClientMBean, Bootstrappable {
6565

6666
/** The "release" version number. */
67-
public static final String RELEASE_VERSION = "Version 2.7.8 2021-02-10";
67+
public static final String RELEASE_VERSION = "Version 2.7.9 2021-02-10";
6868

6969
/** Property name used on products for current RELEASE_VERSION. */
7070
public static final String PDL_CLIENT_VERSION_PROPERTY = "pdl-client-version";

src/main/java/gov/usgs/earthquake/distribution/URLProductStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void configure(final Config config) throws Exception {
129129
}
130130
LOGGER.config("[" + getName() + "] using format " + storageFormat);
131131

132-
storagePath = config.getProperty(STORAGE_PATH_PROPERTY, DEFAULT_DIRECTORY);
132+
storagePath = config.getProperty(STORAGE_PATH_PROPERTY, DEFAULT_STORAGE_PATH);
133133
LOGGER.config("[" + getName() + "] using path " + storagePath);
134134
}
135135

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package gov.usgs.earthquake.distribution;
2+
3+
import gov.usgs.earthquake.product.ProductId;
4+
import gov.usgs.util.Config;
5+
6+
import java.net.URL;
7+
import java.util.Date;
8+
9+
import org.junit.Assert;
10+
import org.junit.Test;
11+
12+
13+
public class URLProductStorageTest {
14+
15+
/**
16+
* Test that storage path is configured properly by default
17+
* and includes all product id components (so url is unique per product).
18+
*/
19+
@Test
20+
public void testDefaultStoragePath() throws Exception {
21+
URLProductStorage storage = new URLProductStorage();
22+
Config config = new Config();
23+
config.setProperty(URLProductStorage.URL_PROPERTY_NAME, "http://testserver/product/");
24+
storage.configure(config);
25+
26+
ProductId id = new ProductId("example_source", "example_type", "example_code", new Date());
27+
String path = storage.getProductPath(id);
28+
Assert.assertTrue("contains source", path.contains("example_source"));
29+
Assert.assertTrue("contains type", path.contains("example_type"));
30+
Assert.assertTrue("contains code", path.contains("example_code"));
31+
Assert.assertTrue(
32+
"contains updateTime",
33+
path.contains("" + id.getUpdateTime().getTime()));
34+
}
35+
36+
/**
37+
* Test that url is constructed by combining base url and product path.
38+
*/
39+
@Test
40+
public void testGetProductUrl() throws Exception {
41+
URLProductStorage storage = new URLProductStorage();
42+
Config config = new Config();
43+
config.setProperty(URLProductStorage.URL_PROPERTY_NAME, "http://testserver/product/");
44+
storage.configure(config);
45+
46+
ProductId id = new ProductId("source", "type", "code", new Date());
47+
URL url = storage.getProductURL(id);
48+
Assert.assertEquals("Computes URL",
49+
url.toExternalForm(),
50+
"http://testserver/product/" + storage.getProductPath(id));
51+
}
52+
53+
}

0 commit comments

Comments
 (0)