Skip to content

Commit 71b14a3

Browse files
Merge pull request #448 from OneBusAway/api-key-cli
Adds CLI for managing API keys
2 parents 0beb2c1 + e299a4c commit 71b14a3

55 files changed

Lines changed: 1916 additions & 56 deletions

File tree

Some content is hidden

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

.claude/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(bin/build_bundle:*)",
5+
"Bash(docker run:*)",
6+
"Bash(docker compose exec:*)",
7+
"Bash(docker compose:*)",
8+
"Bash(java -jar:*)",
9+
"Bash(tree:*)",
10+
"Bash(git add:*)",
11+
"Bash(git commit:*)",
12+
"Bash(mvn test:*)",
13+
"Bash(mvn package:*)"
14+
]
15+
}
16+
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ build/*
2424
docker_app_server/bundle/*
2525
!docker_app_server/bundle/.gitkeep
2626

27-
dependency-reduced-pom.xml
27+
dependency-reduced-pom.xml
28+
29+
.claude/settings.local.json

CLAUDE.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
OneBusAway Application Modules - a multi-module Maven project providing real-time public transit information. The suite powers REST APIs, web interfaces, and integrations for transit agencies worldwide.
8+
9+
**Version:** 2.7.0
10+
**Java:** 11
11+
**Framework:** Spring 5.2.24 (not Spring Boot), Struts 2.5.33, Hibernate 5.4.24
12+
13+
## Build Commands
14+
15+
```bash
16+
# Full build (skip tests for speed)
17+
mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true
18+
19+
# Build with tests
20+
mvn clean install
21+
22+
# Build single module with dependencies
23+
mvn clean package -pl onebusaway-api-key-cli -am
24+
25+
# Run tests for a single module
26+
mvn test -pl onebusaway-api-webapp
27+
28+
# Run a single test
29+
mvn test -Dtest=ConfigActionTest
30+
31+
# Run a single test method
32+
mvn test -Dtest=ConfigActionTest#testIndex
33+
34+
# Verify build (includes license checks)
35+
mvn verify
36+
```
37+
38+
### Docker Development (Recommended)
39+
40+
```bash
41+
docker compose up builder # Start build container + MySQL
42+
43+
# In another terminal:
44+
bin/make # Full Maven build
45+
bin/make --test # Build with tests
46+
bin/build_bundle # Create GTFS data bundle
47+
bin/copy_and_relaunch # Deploy WARs to Tomcat
48+
bin/shell # Shell into container
49+
```
50+
51+
**Access points when running:**
52+
- API: http://localhost:8080/onebusaway-api-webapp/api/where/config.json?key=test
53+
- Tomcat Manager: http://localhost:8080/manager/html (admin/admin)
54+
- Debug port: 5005
55+
56+
## Module Architecture
57+
58+
### Core Layers (bottom-up)
59+
60+
**Infrastructure:**
61+
- `onebusaway-core` - Base classes, constants
62+
- `onebusaway-util` - General utilities
63+
- `onebusaway-container` - Spring context bootstrap
64+
- `onebusaway-geospatial` - GIS utilities
65+
66+
**Data Layer:**
67+
- `onebusaway-transit-data` - Domain models (stops, routes, trips)
68+
- `onebusaway-gtfs-hibernate-spring` - GTFS database ORM
69+
- `onebusaway-gtfs-realtime-model` - GTFS-realtime parsing
70+
- `onebusaway-transit-data-federation` - Core data aggregation engine
71+
- `onebusaway-transit-data-federation-builder` - Builds data bundles from GTFS
72+
73+
**Service Layer:**
74+
- `onebusaway-api-core` - REST API implementation logic
75+
- `onebusaway-realtime-api` - Real-time data interfaces
76+
- `onebusaway-users` - User management, API keys
77+
- `onebusaway-alerts-persistence` - Service alerts storage
78+
79+
**Web Applications (WAR):**
80+
- `onebusaway-api-webapp` - Main REST API (most commonly modified)
81+
- `onebusaway-transit-data-federation-webapp` - Admin/federation UI
82+
- `onebusaway-gtfs-realtime-archiver` - Archives realtime data
83+
- `onebusaway-watchdog-webapp` - Monitoring endpoints
84+
85+
**CLI Tools:**
86+
- `onebusaway-api-key-cli` - Command-line API key management
87+
88+
### Data Flow
89+
90+
1. GTFS static data → `federation-builder` → MySQL database
91+
2. GTFS-realtime feeds → `gtfs-realtime-model` → merged with static data
92+
3. API requests → `api-webapp` (Struts actions) → `api-core``transit-data-federation` → response
93+
94+
## Key Configuration Files
95+
96+
**GTFS Realtime sources:**
97+
`docker_app_server/config/onebusaway-transit-data-federation-webapp-data-sources.xml`
98+
- Configure `tripUpdatesUrl`, `vehiclePositionsUrl`, `alertsUrl`, `agencyId`
99+
100+
**Docker environment:**
101+
`docker-compose.yml`
102+
- `GTFS_URL` - Static GTFS download URL
103+
- `TZ` - Timezone matching GTFS data
104+
105+
## Testing
106+
107+
- Unit tests: `src/test/java/`
108+
- Integration tests: `org.onebusaway.integration.*` (excluded by default)
109+
- Test database: HSQLDB (in-memory)
110+
- Test ports: 9900 (main), 9901 (AJP), 9902 (RMI)
111+
112+
## Contributing Notes
113+
114+
- Fork the repo and submit Pull Requests
115+
- Reference GitHub issue numbers in commits: `Issue #5: Description`
116+
- Run `mvn verify` before submitting to ensure license headers and tests pass
117+
- Code style: https://github.com/OneBusAway/onebusaway/wiki/Code-Style
118+
- License: Apache 2.0 (ICLA required for contributions)

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ RUN CGO_ENABLED=0 go install github.com/patrickbr/gtfstidy@latest
2424

2525
FROM tomcat:8.5.100-jdk11-temurin-focal AS server
2626

27-
ARG MAVEN_VERSION=3.9.9
27+
ARG MAVEN_VERSION=12
2828

29-
ARG OBA_VERSION=2.6.0
29+
ARG OBA_VERSION=2.7.0
3030
ENV OBA_VERSION=$OBA_VERSION
3131

3232
ENV CATALINA_HOME="/usr/local/tomcat"
@@ -85,12 +85,11 @@ COPY ./docker_app_server/config/host-manager_context.xml $CATALINA_HOME/webapps/
8585

8686
# MySQL Connector
8787
WORKDIR $CATALINA_HOME/lib
88-
RUN wget "https://cdn.mysql.com/Downloads/Connector-J/mysql-connector-j-8.4.0.tar.gz" \
89-
&& tar -zxvf mysql-connector-j-8.4.0.tar.gz \
90-
&& mv mysql-connector-j-8.4.0/mysql-connector-j-8.4.0.jar . \
91-
&& rm mysql-connector-j-8.4.0.tar.gz \
92-
&& rm -rf mysql-connector-j-8.4.0
93-
88+
RUN wget "https://cdn.mysql.com/Downloads/Connector-J/mysql-connector-j-9.4.0.tar.gz" \
89+
&& tar -zxvf mysql-connector-j-9.4.0.tar.gz \
90+
&& mv mysql-connector-j-9.4.0/mysql-connector-j-9.4.0.jar . \
91+
&& rm mysql-connector-j-9.4.0.tar.gz \
92+
&& rm -rf mysql-connector-j-9.4.0
9493
# Put the user in the source code directory when they shell in
9594
WORKDIR /src
9695

api-key-cli-data-source.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans
5+
http://www.springframework.org/schema/beans/spring-beans.xsd">
6+
7+
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
8+
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
9+
<property name="url" value="jdbc:mysql://localhost:3306/oba_database?useSSL=false&amp;allowPublicKeyRetrieval=true"/>
10+
<property name="username" value="oba_user"/>
11+
<property name="password" value="oba_password"/>
12+
</bean>
13+
</beans>

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
context: .
2121
dockerfile: Dockerfile
2222
args:
23-
MAVEN_VERSION: 3.9.9
23+
MAVEN_VERSION: 3.9.12
2424
environment:
2525
- GTFS_URL=https://www.soundtransit.org/GTFS-KCM/google_transit.zip
2626
- TZ=America/Los_Angeles
@@ -44,7 +44,7 @@ services:
4444
tty: true
4545

4646
database:
47-
image: mysql:8.3
47+
image: mysql:8.4
4848
container_name: database
4949
environment:
5050
MYSQL_ROOT_PASSWORD: Ins3cure!

docker_app_server/bundle_builder/build_bundle.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ gtfstidy -OscRCSmeD gtfs_pristine.zip
4343

4444
cd gtfs-out
4545

46+
rm -f ../gtfs_tidied.zip
4647
zip ../gtfs_tidied.zip *
4748

4849
cd ..

onebusaway-admin-webapp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.onebusaway</groupId>
77
<artifactId>onebusaway-application-modules</artifactId>
8-
<version>2.6.0</version>
8+
<version>2.7.0</version>
99
</parent>
1010
<artifactId>onebusaway-admin-webapp</artifactId>
1111
<packaging>war</packaging>

onebusaway-agency-metadata/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.onebusaway</groupId>
77
<artifactId>onebusaway-application-modules</artifactId>
8-
<version>2.6.0</version>
8+
<version>2.7.0</version>
99
</parent>
1010
<artifactId>onebusaway-agency-metadata</artifactId>
1111
<packaging>jar</packaging>

onebusaway-alerts-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>onebusaway-application-modules</artifactId>
77
<groupId>org.onebusaway</groupId>
8-
<version>2.6.0</version>
8+
<version>2.7.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)