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

Commit ca15d82

Browse files
author
Tim Sowers
committed
Standardizing "R" on "Repository URL" across Apps.
1 parent d7c5177 commit ca15d82

File tree

3 files changed

+140
-140
lines changed

3 files changed

+140
-140
lines changed
Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
# API Connectors
2-
3-
These are the currently-supported repositories from which the API will attempt
4-
to pre-populate information it can glean given the project URL. Currently the
5-
information obtained is somewhat sparse, as this is intended to provoke
6-
discussion on what elements of metadata we should map to DOE CODE's schema.
7-
8-
If any of these sources should have a "metadata.yml" file checked-in on the
9-
master branch, project root level, the Connector will attempt to read from and
10-
parse its information instead of calling various API methods to fill in the
11-
metadata information.
12-
13-
## GitHub
14-
15-
Given the GitHub repository URL, the following information is obtained (provided
16-
the project has such filled-in):
17-
* Software Title ("Full Name")
18-
* Acronym ("Name")
19-
* Description
20-
* Developers Listing ("Contributors")
21-
* First/Last Name
22-
* Email
23-
* Affiliations ("Company") if provided
24-
25-
## SourceForge
26-
27-
From SourceForge's available API, the following is mapped:
28-
* Software Title ("Name")
29-
* Acronym ("Short Name")
30-
* Description
31-
* License (concatenating multiple SF licenses, if provided)
32-
* Developers (first and last name)
33-
34-
## BitBucket
35-
36-
BitBucket API maps elements:
37-
* Software Title ("Full Name")
38-
* Acronym ("Name")
39-
* Developers
40-
* If a "team" is found, iterate through each team member; if a single user/
41-
Owner, take that as the sole developer
42-
* First/Last Name
43-
44-
# ConnectorFactory instantiation
45-
46-
These connector instances should each implement the ConnectorInterface interface
47-
in order to be added to a ConnectorFactory instantiation. The interface defines
48-
only two methods:
49-
50-
``` java
51-
init() throws IOException
52-
```
53-
54-
Initialize the Connector, if necessary, throwing IOException on errors
55-
56-
``` java
57-
read(String url)
58-
```
59-
60-
Attempt to load Metadata information from the given URL, if recognized. If not,
61-
or unable to do so, return null.
62-
63-
In order to use the Factory, one should acquire an instance, and add each desired Connector to it:
64-
65-
``` java
66-
ConnectorFactory factory = ConnectorFactory.getInstance()
67-
.add(new GitHub())
68-
.add(new SourceForge())
69-
.build();
70-
```
71-
72-
Simply call the `factory.read(String)` method to obtain any JSON metadata if possible.
73-
Note this may return null if not recognized.
1+
# API Connectors
2+
3+
These are the currently-supported repositories from which the API will attempt
4+
to pre-populate information it can glean given the project URL. Currently the
5+
information obtained is somewhat sparse, as this is intended to provoke
6+
discussion on what elements of metadata we should map to DOE CODE's schema.
7+
8+
If any of these sources should have a "metadata.yml" file checked-in on the
9+
master branch, project root level, the Connector will attempt to read from and
10+
parse its information instead of calling various API methods to fill in the
11+
metadata information.
12+
13+
## GitHub
14+
15+
Given the GitHub Repository URL, the following information is obtained (provided
16+
the project has such filled-in):
17+
* Software Title ("Full Name")
18+
* Acronym ("Name")
19+
* Description
20+
* Developers Listing ("Contributors")
21+
* First/Last Name
22+
* Email
23+
* Affiliations ("Company") if provided
24+
25+
## SourceForge
26+
27+
From SourceForge's available API, the following is mapped:
28+
* Software Title ("Name")
29+
* Acronym ("Short Name")
30+
* Description
31+
* License (concatenating multiple SF licenses, if provided)
32+
* Developers (first and last name)
33+
34+
## BitBucket
35+
36+
BitBucket API maps elements:
37+
* Software Title ("Full Name")
38+
* Acronym ("Name")
39+
* Developers
40+
* If a "team" is found, iterate through each team member; if a single user/
41+
Owner, take that as the sole developer
42+
* First/Last Name
43+
44+
# ConnectorFactory instantiation
45+
46+
These connector instances should each implement the ConnectorInterface interface
47+
in order to be added to a ConnectorFactory instantiation. The interface defines
48+
only two methods:
49+
50+
``` java
51+
init() throws IOException
52+
```
53+
54+
Initialize the Connector, if necessary, throwing IOException on errors
55+
56+
``` java
57+
read(String url)
58+
```
59+
60+
Attempt to load Metadata information from the given URL, if recognized. If not,
61+
or unable to do so, return null.
62+
63+
In order to use the Factory, one should acquire an instance, and add each desired Connector to it:
64+
65+
``` java
66+
ConnectorFactory factory = ConnectorFactory.getInstance()
67+
.add(new GitHub())
68+
.add(new SourceForge())
69+
.build();
70+
```
71+
72+
Simply call the `factory.read(String)` method to obtain any JSON metadata if possible.
73+
Note this may return null if not recognized.

src/main/java/gov/osti/services/Metadata.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ not used to mint information until submitted or announced with metadata successf
152152
153153
`GET /doecodeapi/services/metadata/autopopulate?repo={url}`
154154
155-
Attempt to read information from the given *repository URL* value. Supports github.com, bitbucket.org, and sourceforge.com.
155+
Attempt to read information from the given *Repository URL* value. Supports github.com, bitbucket.org, and sourceforge.com.
156156
Any relevant information from the repository API will be returned in JSON metadata format.
157157
Mapped repository information varies according to service API-supplied metadata. Optionally, you may specify
158158
a query parameter of "format=yaml" to receive YAML file suitable for download.
@@ -382,7 +382,7 @@ A full JSON example is [provided below](#json_example).
382382
| code_id | The unique value given to a particular DOE CODE Project record once stored. Should be *null* or not provided for new entries, and will be returned once a record is saved or submitted successfully. |
383383
| site_ownership_code | The DOE National Laboratory, DOE Program Office, Field Office, or Major Site/Facility that is submitting the code/software. This value is determined by the system. |
384384
| accessibility | This refers to how the source of the project type is accessed; must be one of "OS" (open source), "ON" (open source, not public), or "CS" (closed source, site hosted) |
385-
| repository_link | If the software project is available via public hosting service, such as github.com, bitbucket.org, etc. the public repository URL should be provided here. DOE CODE does not currently support the submission of individual branch URL paths, so this must be a primary or base URL for the repository. |
385+
| repository_link | If the software project is available via public hosting service, such as github.com, bitbucket.org, etc. the public Repository URL should be provided here. DOE CODE does not currently support the submission of individual branch URL paths, so this must be a primary or base URL for the repository. |
386386
| landing_page | If the project is not available via open source hosting site, provide a URL describing the project and contact information for obtaining binary or source |
387387
| developers | An array of Objects, providing information about a project's developers or creators. Array order determines display order. Fields are [specified below](#persons_fields). |
388388
| contributors | An array of information about project contributors. Array order determines display order. Fields are [specified below](#persons_fields). Contributors must specify a [type of contribution](#contributor_types) made to the project. |
Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
1-
/*
2-
*/
3-
package gov.osti.connectors;
4-
5-
import org.junit.After;
6-
import org.junit.AfterClass;
7-
import org.junit.Before;
8-
import org.junit.BeforeClass;
9-
import org.junit.Test;
10-
import static org.junit.Assert.*;
11-
12-
/**
13-
* Simple value tests for SourceForge API reader.
14-
*
15-
* @author ensornl
16-
*/
17-
public class SourceForgeTest {
18-
19-
public SourceForgeTest() {
20-
}
21-
22-
@BeforeClass
23-
public static void setUpClass() {
24-
}
25-
26-
@AfterClass
27-
public static void tearDownClass() {
28-
}
29-
30-
@Before
31-
public void setUp() {
32-
}
33-
34-
@After
35-
public void tearDown() {
36-
}
37-
38-
/**
39-
* Test extraction of the project name from various SOURCEFORGE repository URLs.
40-
*/
41-
@Test
42-
public void testGetProjectNameFromUrl() {
43-
// these aren't recognized
44-
String[] badvalues = {
45-
"/projects/url",
46-
"sourceforge.com/projects/me",
47-
"https://sourceforge/projects/nope",
48-
"",
49-
null
50-
};
51-
52-
for ( String value : badvalues ) {
53-
assertNull ("Found acceptable: " + value, SourceForge.getProjectNameFromUrl(value));
54-
}
55-
56-
assertEquals("arpa project name wrong", "arpa_project_x", SourceForge.getProjectNameFromUrl("https://svn.code.sf.net/p/arpa_project_x/code/trunk"));
57-
58-
assertEquals("wrong niceproject", "niceproject", SourceForge.getProjectNameFromUrl("http://svn.code.sf.net/p/niceproject/code"));
59-
assertEquals("Not ats", "ats-automatedtestingsystem", SourceForge.getProjectNameFromUrl("https://svn.code.sf.net/p/ats-automatedtestingsystem/code/"));
60-
61-
assertEquals("Matcher failed", "doecode", SourceForge.getProjectNameFromUrl("https://sourceforge.net/projects/doecode"));
62-
assertEquals("Matcher failed", "doecode", SourceForge.getProjectNameFromUrl("http://sourceforge.net/projects/doecode/"));
63-
}
64-
65-
}
1+
/*
2+
*/
3+
package gov.osti.connectors;
4+
5+
import org.junit.After;
6+
import org.junit.AfterClass;
7+
import org.junit.Before;
8+
import org.junit.BeforeClass;
9+
import org.junit.Test;
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Simple value tests for SourceForge API reader.
14+
*
15+
* @author ensornl
16+
*/
17+
public class SourceForgeTest {
18+
19+
public SourceForgeTest() {
20+
}
21+
22+
@BeforeClass
23+
public static void setUpClass() {
24+
}
25+
26+
@AfterClass
27+
public static void tearDownClass() {
28+
}
29+
30+
@Before
31+
public void setUp() {
32+
}
33+
34+
@After
35+
public void tearDown() {
36+
}
37+
38+
/**
39+
* Test extraction of the project name from various SOURCEFORGE Repository URLs.
40+
*/
41+
@Test
42+
public void testGetProjectNameFromUrl() {
43+
// these aren't recognized
44+
String[] badvalues = {
45+
"/projects/url",
46+
"sourceforge.com/projects/me",
47+
"https://sourceforge/projects/nope",
48+
"",
49+
null
50+
};
51+
52+
for ( String value : badvalues ) {
53+
assertNull ("Found acceptable: " + value, SourceForge.getProjectNameFromUrl(value));
54+
}
55+
56+
assertEquals("arpa project name wrong", "arpa_project_x", SourceForge.getProjectNameFromUrl("https://svn.code.sf.net/p/arpa_project_x/code/trunk"));
57+
58+
assertEquals("wrong niceproject", "niceproject", SourceForge.getProjectNameFromUrl("http://svn.code.sf.net/p/niceproject/code"));
59+
assertEquals("Not ats", "ats-automatedtestingsystem", SourceForge.getProjectNameFromUrl("https://svn.code.sf.net/p/ats-automatedtestingsystem/code/"));
60+
61+
assertEquals("Matcher failed", "doecode", SourceForge.getProjectNameFromUrl("https://sourceforge.net/projects/doecode"));
62+
assertEquals("Matcher failed", "doecode", SourceForge.getProjectNameFromUrl("http://sourceforge.net/projects/doecode/"));
63+
}
64+
65+
}

0 commit comments

Comments
 (0)