Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit dfc896c

Browse files
author
sowerstl
committed
Merge branch 'sync'
2 parents 77ed05a + 5476b13 commit dfc896c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2683
-360
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# DOECode Web Application
1+
# DOE CODE Web Application
22

3-
Consists of the "back-end" services and JAX/RS API calls for DOE Code, to be
3+
Consists of the "back-end" services and JAX/RS API calls for DOE CODE, to be
44
accessed by the front-end or presentation layer. This application is targeted
55
at a non-EE Java container such as Tomcat, using JPA and JAX/RS (Jersey implementation)
66
for persistence layer and web API implementation.
@@ -109,7 +109,7 @@ to obtain the output in YAML format.
109109

110110
`POST /services/metadata`
111111

112-
Store a given metadata JSON to the DOECode persistence layer in an incomplete or
112+
Store a given metadata JSON to the DOE CODE persistence layer in an incomplete or
113113
pending status. The resulting JSON information is returned as the JSON object "metadata",
114114
including the generated unique IDs as appropriate if the operation was successful. Record
115115
is placed in the "Saved" work flow.
@@ -121,16 +121,16 @@ format. Does not persist any data.
121121

122122
`POST /services/metadata/publish`
123123

124-
Store the metadata information to the DOECode persistence layer with a "Published"
124+
Store the metadata information to the DOE CODE persistence layer with a "Published"
125125
work flow. JSON is returned as with the "Saved" service above, and this record
126-
is marked as available to the DOECode search output services. If DataCite information
126+
is marked as available to the DOE CODE search output services. If DataCite information
127127
has been configured, this step will attempt to register any DOI entered and update
128128
metadata information with DataCite.
129129

130130
`POST /services/metadata/submit`
131131

132132
Post the metadata to OSTI, attempt to register a DOI if possible, and persist
133-
the information on DOECode. If workflow validations pass, the JSON will be returned
133+
the information on DOE CODE. If workflow validations pass, the JSON will be returned
134134
with appropriate unique identifier information and DOI values posted in the
135135
JSON object "metadata". Data is placed in "Published" state.
136136

@@ -191,11 +191,11 @@ It is often useful to have a simple database for testing that is not your instit
191191
3) In Eclipse, open the "Database Development" perspective.
192192
4) Follow the [Eclipse Documentation](http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.datatools.common.doc.user%2Fdoc%2Fhtml%2Fasc1229700387729.html) to create a Derby Connector, create a connection profile, and connect to Derby.
193193

194-
In step 4, be sure to select "Derby Client Driver" instead of "Derby Embedded Driver." DOE Code is not currently configured to work with the Embedded driver.
194+
In step 4, be sure to select "Derby Client Driver" instead of "Derby Embedded Driver." DOE CODE is not currently configured to work with the Embedded driver.
195195

196196
## Running on AWS
197197

198-
The DOE Code server works well on AWS. For the default RHEL 7 instance, the server can be executed with a Derby database for storing using the following rough steps:
198+
The DOE CODE server works well on AWS. For the default RHEL 7 instance, the server can be executed with a Derby database for storing using the following rough steps:
199199
1) Create the instance. Make sure your security group is configured to let the necessary ports through (normally 8080).
200200
2) SSH into the instance using your key. Issue the following commands to download and install prerequisites including Java, Git, and Derby.
201201
```bash
@@ -250,7 +250,7 @@ cd ~/server
250250
## SOLR for Searching and Indexing (Dissemination)
251251

252252
If configured in the deployment profile, Apache SOLR may be used for an indexing and
253-
searching service for DOECode. Setting up SOLR distribution package version 6.6.0
253+
searching service for DOE CODE. Setting up SOLR distribution package version 6.6.0
254254
as a stand-alone service as follows:
255255

256256
1) Download the [SOLR package from Apache](http://http://lucene.apache.org/solr/)
@@ -285,7 +285,7 @@ http://localhost:{port}/solr/doecode/query
285285
```
286286
in order to get JSON results back in expected formats for the dissemination/searching service.
287287

288-
These values assume that the DOECode back-end is deployed on the same server as the SOLR standalone service. If not, alter the
288+
These values assume that the DOE CODE back-end is deployed on the same server as the SOLR standalone service. If not, alter the
289289
URL host names and ports appropriately. In order to terminate the SOLR standalone server, issue the command:
290290
```bash
291291
$ bin/solr stop

SOLR-AWS-NOTES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Once this script runs, SOLR should be up and running on the {port} you specify.
5959
Creation of the search core and customization
6060
---------------------------------------------
6161
Once SOLR is running, we will need to create a search and index core to use,
62-
and customize it according to the DOECode specific schema and configuration,
62+
and customize it according to the DOE CODE specific schema and configuration,
6363
which are available in the root of https://github.com/doecode/server.
6464

6565
Switch to the newly-created "solr" user and issue the SOLR commands:
@@ -82,7 +82,7 @@ Issue the command to reload the SOLR core with the new configuration.
8282
[solr] $ curl http://localhost:{port}/solr/admin/cores?action=RELOAD\&core=doecode
8383
```
8484

85-
The DOECode SOLR search core should be up and ready to use on the indicated
85+
The DOE CODE SOLR search core should be up and ready to use on the indicated
8686
port. All that remains is to configure the EC2 instance TCP access rules
8787
to allow inbound connections on the port to the desired group(s) or application
8888
server IPs for the "server" back-end process, which will allow it to index

pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@
44
<groupId>gov.osti</groupId>
55
<artifactId>doecode</artifactId>
66
<packaging>war</packaging>
7-
<version>1.3</version>
8-
<name>DOE Code Web Application (Server)</name>
7+
<version>1.4.0</version>
8+
<name>DOE CODE Web Application (Server)</name>
99
<url>http://maven.apache.org</url>
1010

1111
<properties>
1212
<jdk.version>1.8</jdk.version>
13-
<jersey.version>2.22.2</jersey.version>
14-
<httpclient.version>4.5.2</httpclient.version>
15-
<jackson.version>2.9.0</jackson.version>
16-
<projectName>doecodeapi</projectName>
17-
<datacite.url>https://mds.test.datacite.org/</datacite.url>
18-
<environment>development</environment>
13+
<jersey.version>2.22.2</jersey.version>
14+
<httpclient.version>4.5.2</httpclient.version>
15+
<jackson.version>2.9.0</jackson.version>
16+
<commons-io.version>2.6</commons-io.version>
17+
<projectName>doecodeapi</projectName>
18+
<datacite.url>https://mds.test.datacite.org/</datacite.url>
19+
<environment>development</environment>
1920
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2021
</properties>
21-
22+
2223
<dependencies>
24+
<dependency>
25+
<groupId>commons-io</groupId>
26+
<artifactId>commons-io</artifactId>
27+
<version>${commons-io.version}</version>
28+
</dependency>
2329
<dependency>
2430
<groupId>junit</groupId>
2531
<artifactId>junit</artifactId>

schema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@
461461
<field name="contributors.orcid" type="text_en" multiValued="true" indexed="true" stored="true"/>
462462
<field name="countryOfOrigin" type="text_en" indexed="true" stored="true"/>
463463
<field name="description" type="text_en" indexed="true" stored="true"/>
464+
<field name="programmingLanguages" type="string" multiValued="true" indexed="true" stored="true"/>
465+
<field name="versionNumber" type="text_en" indexed="true" stored="true"/>
466+
<field name="documentationUrl" type="text_en" indexed="true" stored="true"/>
464467
<field name="developers.name" type="text_en" multiValued="true" indexed="true" stored="true"/>
465468
<field name="developers.orcid" type="text_en" multiValued="true" indexed="true" stored="true"/>
466469
<field name="doi" type="string"/>

src/main/java/gov/osti/connectors/BitBucket.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ public JsonNode read(String url) {
9797
try {
9898
// try to get the METADATA YAML first
9999
JsonNode results = HttpUtil.readMetadataYaml(BITBUCKET_RAW_URL + name + "/raw/master/metadata.yml");
100-
101100
if (null!=results)
102101
return results;
103-
// try alternate names
102+
// try alternate metadata name
103+
results = HttpUtil.readMetadataYaml(BITBUCKET_RAW_URL + name + "/raw/master/.metadata.yml");
104+
if (null!=results)
105+
return results;
106+
// try alternate name
104107
results = HttpUtil.readMetadataYaml(BITBUCKET_RAW_URL + name + "/raw/master/doecode.yml");
108+
if (null!=results)
109+
return results;
110+
// try alternate doecode name
111+
results = HttpUtil.readMetadataYaml(BITBUCKET_RAW_URL + name + "/raw/master/.doecode.yml");
105112
if (null!=results)
106113
return results;
107114

src/main/java/gov/osti/connectors/Connector.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/main/java/gov/osti/connectors/GitHub.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,20 @@ public JsonNode read(String url) {
134134
// if it's not empty, use that
135135
if (null!=yaml)
136136
return yaml;
137-
// try alternate names
137+
// try alternate metadata name
138+
yaml = HttpUtil.readMetadataYaml(GITHUB_RAW_BASE_URL + name + "/master/.metadata.yml");
139+
if (null!=yaml)
140+
return yaml;
141+
// try alternate name
138142
yaml = HttpUtil.readMetadataYaml(GITHUB_RAW_BASE_URL + name + "/master/doecode.yml");
143+
if (null!=yaml)
144+
return yaml;
145+
// try alternate doecode name
146+
yaml = HttpUtil.readMetadataYaml(GITHUB_RAW_BASE_URL + name + "/master/.doecode.yml");
139147
if (null!=yaml)
140148
return yaml;
141149

142-
// acquire the SourceForge API response as JSON
150+
// acquire the GitHub API response as JSON
143151
HttpGet get = gitHubAPIGet(GITHUB_BASE_URL + name);
144152

145153
// Convert the JSON into an Object we can handle
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package gov.osti.connectors;
2+
3+
import gov.osti.connectors.gitlab.Project;
4+
import gov.osti.connectors.api.GitLabAPI;
5+
import com.fasterxml.jackson.databind.JsonNode;
6+
import gov.osti.entity.DOECodeMetadata;
7+
import java.io.IOException;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
11+
/**
12+
* The GitLab metadata scraper class, to acquire/write relevant data
13+
* from/to the GitLab public API (or local OSTI API for OSTI Hosted).
14+
*
15+
* @author sowerst
16+
*/
17+
public class GitLab implements ConnectorInterface {
18+
19+
/** a logger implementation * */
20+
private static final Logger log = LoggerFactory.getLogger(GitLab.class);
21+
22+
/** authentication information for accessing GitLab API * */
23+
/**
24+
* Initialize and read the properties for configuration purposes.
25+
*
26+
* Obtains connector authentication information from properties files.
27+
*
28+
* @throws IOException on file IO errors
29+
*/
30+
@Override
31+
public void init() throws IOException {
32+
}
33+
34+
/**
35+
* Obtain the connection-driven metadata elements from GitLab public API
36+
* requests, or OSTI GitLab authenticated requests.
37+
*
38+
* @param url the URL to process
39+
*
40+
* @return a JsonElement of the DOECodeMetadata filled in as possible from
41+
* the API
42+
*/
43+
@Override
44+
public JsonNode read(String url) {
45+
DOECodeMetadata md = new DOECodeMetadata();
46+
47+
try {
48+
GitLabAPI glApi = new GitLabAPI(url);
49+
50+
// try to identify the NAME of the project
51+
if (null == glApi.getProjectName())
52+
return null;
53+
54+
// try to get the metadata YAML file first
55+
JsonNode yaml = HttpUtil.readMetadataYaml(glApi.acquireRawFileGet("metadata.yml"));
56+
// if it's not empty, use that
57+
if (null != yaml)
58+
return yaml;
59+
// try alternate metadata name
60+
yaml = HttpUtil.readMetadataYaml(glApi.acquireRawFileGet(".metadata.yml"));
61+
if (null != yaml)
62+
return yaml;
63+
// try alternate name
64+
yaml = HttpUtil.readMetadataYaml(glApi.acquireRawFileGet("doecode.yml"));
65+
if (null != yaml)
66+
return yaml;
67+
// try alternate doecode name
68+
yaml = HttpUtil.readMetadataYaml(glApi.acquireRawFileGet(".doecode.yml"));
69+
if (null != yaml)
70+
return yaml;
71+
72+
// Convert the JSON into an Object we can handle
73+
Project project = glApi.fetchProject();
74+
75+
// parse the relevant response parts into Metadata
76+
md.setSoftwareTitle(project.getName());
77+
md.setAcronym(project.getFullPath());
78+
md.setDescription(project.getDescription());
79+
80+
/*
81+
* TODO:
82+
* Scrape Contributors/Developers
83+
* name/email/affiliations
84+
*/
85+
return md.toJson();
86+
} catch (IOException e) {
87+
// here's where you'd warn about the IO error
88+
log.warn("IO Error reading GitLab information: " + e.getMessage());
89+
log.warn("Read from " + url);
90+
}
91+
// unable to process this one
92+
return null;
93+
}
94+
95+
}

src/main/java/gov/osti/connectors/HttpUtil.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,43 @@ protected static String fetch(HttpGet get) throws IOException {
7272
hc.close();
7373
}
7474
}
75-
75+
7676
/**
7777
* Attempt to read URL (file) as a YAML metadata reference. Returns null
7878
* if YAML file not found or could not process.
79-
*
79+
*
8080
* @param url the URL to the file to attempt to read
8181
* @return JSON representation of the YAML read, or null if not found/invalid
8282
* @throws IOException on file IO errors
8383
*/
8484
protected static JsonNode readMetadataYaml(String url) throws IOException {
85+
try {
86+
return readMetadataYaml(new HttpGet(url));
87+
} catch ( IOException e ) {
88+
// no YAML or illegal format, skip it
89+
return null;
90+
}
91+
}
92+
93+
/**
94+
* Attempt to read URL (file) as a YAML metadata reference. Returns null
95+
* if YAML file not found or could not process.
96+
*
97+
* @param url the HTTPGET URL to the file to attempt to read
98+
* @return JSON representation of the YAML read, or null if not found/invalid
99+
* @throws IOException on file IO errors
100+
*/
101+
protected static JsonNode readMetadataYaml(HttpGet url) throws IOException {
85102
try {
86103
// read the YAML in as a DOECodeMetadata record
87-
DOECodeMetadata yaml = YAML_MAPPER.readValue(HttpUtil.fetch(new HttpGet(url)), DOECodeMetadata.class);
104+
DOECodeMetadata yaml = YAML_MAPPER.readValue(HttpUtil.fetch(url), DOECodeMetadata.class);
88105
return (null==yaml) ? null : yaml.toJson();
89106
} catch ( IOException e ) {
90107
// no YAML or illegal format, skip it
91108
return null;
92109
}
93110
}
94-
111+
95112
/**
96113
* Write the Metadata in YAML format.
97114
* @param in the DOECodeMetadata to write

src/main/java/gov/osti/connectors/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
These are the currently-supported repositories from which the API will attempt
44
to pre-populate information it can glean given the project URL. Currently the
55
information obtained is somewhat sparse, as this is intended to provoke
6-
discussion on what elements of metadata we should map to DOECode's schema.
6+
discussion on what elements of metadata we should map to DOE CODE's schema.
77

88
If any of these sources should have a "metadata.yml" file checked-in on the
99
master branch, project root level, the Connector will attempt to read from and

0 commit comments

Comments
 (0)