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

Commit 84a42f6

Browse files
committed
Merge branch 'v1.3'
2 parents f1a4758 + 0ff10d0 commit 84a42f6

File tree

20 files changed

+658
-182
lines changed

20 files changed

+658
-182
lines changed

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
.settings/
2-
.classpath
1+
.settings/
2+
.classpath
33
nb-configuration.xml
44
nbproject/
5-
/target/
6-
/bin/
7-
.vagrant/
5+
/target/
6+
/bin/
7+
.vagrant/
8+
/nbactions.xml

README.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,62 @@ 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.
77

8-
## Running the back-end
8+
## Notes on building the application
9+
10+
The DOE CODE services API project is built using the maven build system, configured
11+
via the pom.xml in the project base folder. In order to facilitate shared configuration
12+
elements amongst this and other supporting applications, certain environment-specific
13+
options and settings have been migrated into a shared resources folder separate from
14+
each application.
15+
16+
This folder is assumed to be in the developer's "home" folder, under the path "shared-resources/doecode/".
17+
This folder should contain a standard Java properties file containing the desired
18+
configuration elements, customized to your specific environment(s) as needed. One
19+
might have a file for development, testing, and production, or as many other disparate
20+
configurations as dictated by your own systems.
21+
22+
The configuration elements are detailed below, and should be in these properties
23+
files with your personal values. In the maven build process, these properties
24+
are included according to the "environment" defined variable, which defaults to "development".
25+
Therefore, unless overridden, the $HOME/shared-resources/doecode/development.properties file
26+
should contain your default environmental settings.
27+
28+
The "environment" value may be altered by your own private profiles, or through
29+
the use of the command line switch -Denvironment=desired-value of maven at build time.
30+
31+
In order to activate and load "test.properties" from your shared-resources for example:
32+
33+
```bash
34+
mvn -Denvironment=test package
35+
```
36+
37+
38+
## Configuration Elements used
939

1040
The application will run on most back-end Java EE platforms, tested
1141
specifically on Jetty and Tomcat. This assumes one already has a persistence
12-
store up-and-running; define your access information via a local maven
13-
profile, ensure you define:
42+
store up-and-running.
43+
44+
These properties are loaded from the "environment.properties" configuration file
45+
and should correspond to environmental settings per your setup.
1446

1547
Parameter | Definition
1648
--- | ---
17-
${database.driver} | the JDBC database driver to use
18-
${database.url} | the JDBC URL to access
19-
${database.username} | the database user (with create/alter schema permission)
20-
${database.password} | the user's password
21-
${serviceapi.host} | base URL for validation services
22-
${publishing.host} | base URL for submitting final metadata to OSTI (via /submit API)
23-
${datacite.username} | (optional) DataCite user account name for registering DOIs
24-
${datacite.password} | (optional) DataCite account password for DOI registration
25-
${datacite.baseurl} | (optional) DataCite base URL prefix to use for DOI registration
26-
${datacite.prefix} | (optional) DataCite registration DOI prefix value
27-
${index.url} | (optional) URL to indexing service (e.g., SOLR, see below)
28-
${search.url} | (optional) base URL to searching service (SOLR, see below)
29-
${site.url} | base URL of the client front-end services
30-
${email.host} | SMTP host name for sending confirmation emails
31-
${email.from} | The user name to use for sending above emails
49+
database.driver | the JDBC database driver to use
50+
database.url | the JDBC URL to access
51+
database.username | the database user (with create/alter schema permission)
52+
database.password | the user's password
53+
serviceapi.host | base URL for validation services
54+
publishing.host | base URL for submitting final metadata to OSTI (via /submit API)
55+
datacite.username | (optional) DataCite user account name for registering DOIs
56+
datacite.password | (optional) DataCite account password for DOI registration
57+
datacite.baseurl | (optional) DataCite base URL prefix to use for DOI registration
58+
datacite.prefix | (optional) DataCite registration DOI prefix value
59+
index.url | (optional) URL to indexing service (e.g., SOLR, see below)
60+
search.url | (optional) base URL to searching service (SOLR, see below)
61+
site.url | base URL of the client front-end services
62+
email.host | SMTP host name for sending confirmation emails
63+
email.from | The user name to use for sending above emails
3264

3365
If optional parameters, such as the DataCite settings, are left blank, those features
3466
will not apply.
@@ -37,8 +69,11 @@ Execute the back-end via:
3769

3870
```bash
3971
mvn jetty:run
72+
```
73+
74+
or
4075

41-
# or
76+
```bash
4277
mvn tomcat:run
4378
```
4479

@@ -48,12 +83,14 @@ Note that log4j assumes tomcat as a basis for its files; simply include the
4883
command line switch to override:
4984

5085
```bash
51-
mvn -P *your-profile* -Dcatalina.base=$HOME jetty:run
86+
mvn -P *your-profile* -Dcatalina.base=$HOME -Denvironment=*your-environment* jetty:run
5287
```
5388

5489
to have logs in $HOME/logs/doecode.log via log4j default configuration.
5590

56-
The value of ${database.driver} is org.apache.derby.jdbc.EmbeddedDriver for Derby.
91+
The value of ${database.driver} is org.apache.derby.jdbc.EmbeddedDriver for Derby. You
92+
may wish to have a specific configuration file in your shared-resources to
93+
facilitate this build and run process.
5794

5895
## API services
5996

pom.xml

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

1111
<properties>
@@ -15,8 +15,10 @@
1515
<jackson.version>2.9.0</jackson.version>
1616
<projectName>doecodeapi</projectName>
1717
<datacite.url>https://mds.test.datacite.org/</datacite.url>
18+
<environment>development</environment>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1820
</properties>
19-
21+
2022
<dependencies>
2123
<dependency>
2224
<groupId>junit</groupId>
@@ -205,39 +207,46 @@
205207
<version>1.3.2</version>
206208
</dependency>
207209

208-
<dependency>
209-
<groupId>org.apache.shiro</groupId>
210-
<artifactId>shiro-web</artifactId>
211-
<version>1.3.2</version>
212-
</dependency>
213-
214-
<dependency>
215-
<groupId>org.secnod.shiro</groupId>
216-
<artifactId>shiro-jersey</artifactId>
217-
<version>0.2.0</version>
218-
</dependency>
219-
220-
<dependency>
221-
<groupId>io.jsonwebtoken</groupId>
222-
<artifactId>jjwt</artifactId>
223-
<version>0.7.0</version>
224-
</dependency>
210+
<dependency>
211+
<groupId>org.apache.shiro</groupId>
212+
<artifactId>shiro-web</artifactId>
213+
<version>1.3.2</version>
214+
</dependency>
225215

226-
227-
<dependency>
228-
<groupId>org.apache.commons</groupId>
229-
<artifactId>commons-email</artifactId>
230-
<version>1.4</version>
231-
</dependency>
232-
<dependency>
233-
<groupId>org.eclipse.jgit</groupId>
234-
<artifactId>org.eclipse.jgit</artifactId>
235-
<version>4.8.0.201706111038-r</version>
236-
<type>jar</type>
237-
</dependency>
238-
239-
</dependencies>
216+
<dependency>
217+
<groupId>org.secnod.shiro</groupId>
218+
<artifactId>shiro-jersey</artifactId>
219+
<version>0.2.0</version>
220+
</dependency>
221+
222+
<dependency>
223+
<groupId>io.jsonwebtoken</groupId>
224+
<artifactId>jjwt</artifactId>
225+
<version>0.7.0</version>
226+
</dependency>
227+
228+
229+
<dependency>
230+
<groupId>org.apache.commons</groupId>
231+
<artifactId>commons-email</artifactId>
232+
<version>1.4</version>
233+
</dependency>
234+
<!-- git support -->
235+
<dependency>
236+
<groupId>org.eclipse.jgit</groupId>
237+
<artifactId>org.eclipse.jgit</artifactId>
238+
<version>4.8.0.201706111038-r</version>
239+
<type>jar</type>
240+
</dependency>
241+
<!-- SVN support -->
242+
<dependency>
243+
<groupId>org.tmatesoft.svnkit</groupId>
244+
<artifactId>svnkit</artifactId>
245+
<version>1.9.0</version>
246+
<type>jar</type>
247+
</dependency>
240248

249+
</dependencies>
241250

242251
<build>
243252
<finalName>${projectName}</finalName>
@@ -254,6 +263,25 @@
254263
</resources>
255264

256265
<plugins>
266+
<!-- support shared resources properties files -->
267+
<plugin>
268+
<groupId>org.codehaus.mojo</groupId>
269+
<artifactId>properties-maven-plugin</artifactId>
270+
<version>1.0.0</version>
271+
<executions>
272+
<execution>
273+
<phase>initialize</phase>
274+
<goals>
275+
<goal>read-project-properties</goal>
276+
</goals>
277+
<configuration>
278+
<files>
279+
<file>${user.home}/shared-resources/doecode/${environment}.properties</file>
280+
</files>
281+
</configuration>
282+
</execution>
283+
</executions>
284+
</plugin>
257285
<plugin>
258286
<groupId>org.apache.maven.plugins</groupId>
259287
<artifactId>maven-surefire-plugin</artifactId>
@@ -283,20 +311,18 @@
283311
</webApp>
284312
</configuration>
285313
</plugin>
286-
287-
288-
<plugin>
289-
<groupId>org.apache.tomcat.maven</groupId>
290-
<artifactId>tomcat7-maven-plugin</artifactId>
291-
<version>2.2</version>
292-
<configuration>
293-
<url>http://${host}:${port}/manager/text</url>
294-
<server>${server}</server>
295-
<path>/${projectName}</path>
296-
<warFile>${project.build.directory}/${projectName}.war</warFile>
297-
<path>/${projectName}</path>
298-
</configuration>
299-
</plugin>
314+
315+
<!-- tomcat deployment -->
316+
<plugin>
317+
<groupId>org.apache.tomcat.maven</groupId>
318+
<artifactId>tomcat7-maven-plugin</artifactId>
319+
<version>2.2</version>
320+
<configuration>
321+
<server>${server}</server>
322+
<url>http://${host}:${port}/manager/text</url>
323+
<path>/${projectName}</path>
324+
</configuration>
325+
</plugin>
300326

301327
<plugin>
302328
<groupId>org.apache.maven.plugins</groupId>
@@ -305,6 +331,7 @@
305331
<configuration>
306332
<source>${jdk.version}</source>
307333
<target>${jdk.version}</target>
334+
<encoding>${project.build.sourceEncoding}</encoding>
308335
</configuration>
309336

310337

@@ -327,6 +354,14 @@
327354
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
328355
</configuration>
329356
</plugin>
357+
<plugin>
358+
<groupId>org.apache.maven.plugins</groupId>
359+
<artifactId>maven-resources-plugin</artifactId>
360+
<version>2.4.3</version>
361+
<configuration>
362+
<encoding>${project.build.sourceEncoding}</encoding>
363+
</configuration>
364+
</plugin>
330365
</plugins>
331366
</build>
332367
</project>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class SourceForge implements ConnectorInterface {
3030
// the logger implementation
3131
private static final Logger log = LoggerFactory.getLogger(SourceForge.class);
3232
// pattern to match for PROJECT NAME
33-
private static final Pattern PROJECT_NAME_PATTERN = Pattern.compile("/projects/(.*)$");
33+
private static final Pattern PROJECT_NAME_PATTERN = Pattern.compile("/(?:p|projects)/([a-zA-Z0-9_-]+).*$");
3434

3535
/**
3636
* initialize this Connector
@@ -46,6 +46,8 @@ public void init() throws IOException {
4646
*
4747
* Assumes it contains "sourceforge.net" and the PATH contains the
4848
* "project/project-name" value.
49+
* SF might also be of the form: sourceforge.net/p/project-name or sf.net/p/project-name
50+
* for example.
4951
*
5052
* @param url the URL to process
5153
* @return the PROJECT NAME if possible, or null if not
@@ -58,7 +60,8 @@ protected static String getProjectNameFromUrl(String url) {
5860

5961
// protection against bad URL input
6062
if (null!=uri.getHost()) {
61-
if (uri.getHost().contains("sourceforge.net")) {
63+
if (uri.getHost().contains("sourceforge.net") ||
64+
uri.getHost().contains("sf.net")) {
6265
// assume SourceForge path is formed by "/projects/project-name"
6366
if (null==uri.getPath())
6467
return null;

src/main/java/gov/osti/entity/Agent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnore;
44
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import gov.osti.services.Validation;
56
import java.io.Serializable;
67
import javax.persistence.Column;
78
import javax.persistence.GeneratedValue;
@@ -85,9 +86,8 @@ public void setEmail(String email) {
8586
public String getOrcid() {
8687
return orcid;
8788
}
88-
8989
public void setOrcid(String orcid) {
90-
this.orcid = orcid;
90+
this.orcid = Validation.formatORCID(orcid, "dashed");
9191
}
9292

9393
/**

src/main/java/gov/osti/entity/DOECodeMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ public void setDevelopers(List<Developer> devlist) {
495495
}
496496

497497
@Size (max = 255, message = "Recipient name is limited to 255 characters.")
498-
@Column (name = "RECIPIENT_NAME")
498+
@Column (name = "RECIPIENT_NAME", length = 255)
499499
public String getRecipientName() {
500500
return recipientName;
501501
}
@@ -613,6 +613,7 @@ public String getOwner() {
613613
}
614614

615615
public void setOwner(String owner) {
616+
owner = owner != null ? owner.toLowerCase() : owner;
616617
this.owner = owner;
617618
}
618619

src/main/java/gov/osti/entity/Site.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@Entity
1616
@Table(name="sites")
1717
@NamedQueries ({
18-
@NamedQuery (name = "Site.findByDomain", query = "SELECT s FROM Site s JOIN s.emailDomains d WHERE d = :domain")
18+
@NamedQuery (name = "Site.findByDomain", query = "SELECT s FROM Site s JOIN s.emailDomains d WHERE d = lower(:domain)")
1919
})
2020
public class Site implements Serializable {
2121

0 commit comments

Comments
 (0)