Skip to content

Commit cd1d771

Browse files
dfcoffinclaude
andauthored
feat: ESPI 4.0 Schema Compliance - Phase 0.5: OAuth and Common Domain Enums (#109)
* feat: ESPI 4.0 Schema Compliance - Phase 0.5: OAuth and Common Domain Enums Implements OAuth 2.0 and common domain enumerations from espi.xsd with proper JAXB/Jakarta XML binding annotations and comprehensive documentation. OAuth Enums (String values): - GrantType (3 values) - OAuth 2.0 grant types (authorization_code, client_credentials, refresh_token) - TokenType (1 value) - OAuth 2.0 token types (Bearer) - OAuthError (13 values) - OAuth 2.0 error codes per RFC 6749 - ResponseType (1 value) - OAuth 2.0 response types (code) - TokenEndPointMethod (1 value) - Token endpoint authentication methods Common Enums (int values): - Currency (14 values) - ISO 4217 currency codes (USD, EUR, GBP, etc.) - StatusCode (14 values) - HTTP status codes for transaction status Refactoring: - Moved enums from domain/common/ to domain/common/enums/ package - Deleted old enum files (GrantType, TokenType, OAuthError, ResponseType) - Updated all imports in entity and test files - Added wildcard import for domain/common/enums in affected files - Updated tests to use ESPI 4.0 compliant ResponseType.CODE (removed non-standard TOKEN) All enums include: - Apache License 2.0 header (copyright 2025 Green Button Alliance, Inc.) - JAXB/Jakarta XML binding annotations (@XmlType, @XmlEnum, @XmlEnumValue) - getValue() and fromValue() methods with IllegalArgumentException for invalid values - Comprehensive Javadoc from XSD documentation with line numbers - Type-safe enum constants (String for OAuth, int for Currency/StatusCode) Total enum values in batch: 47 Per ESPI 4.0 specification (NAESB REQ.21) All tests: 781/781 passed ✓ - Unit tests: 638/638 passed - Integration tests: 143/143 passed (with Docker/TestContainers) Related to #101 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: Update import in ModernAuthorizationController for relocated enums Updates import statements in openespi-thirdparty ModernAuthorizationController to use new enum package location (domain/common/enums). Fixes compilation error in openespi-thirdparty module. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 44ef6d8 commit cd1d771

18 files changed

Lines changed: 731 additions & 198 deletions

File tree

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/common/GrantType.java

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

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/common/OAuthError.java

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

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/common/ResponseType.java

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

openespi-common/src/main/java/org/greenbuttonalliance/espi/common/domain/common/TokenType.java

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
* Copyright (c) 2025 Green Button Alliance, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.greenbuttonalliance.espi.common.domain.common.enums;
18+
19+
import jakarta.xml.bind.annotation.XmlEnum;
20+
import jakarta.xml.bind.annotation.XmlEnumValue;
21+
import jakarta.xml.bind.annotation.XmlType;
22+
23+
/**
24+
* Enumeration for Currency values.
25+
*
26+
* Code for the currency for costs associated with this ReadingType.
27+
* The valid values per the standard are defined in CurrencyCode.
28+
* Per ESPI 4.0 espi.xsd lines 2101-2195.
29+
*/
30+
@XmlType(name = "Currency", namespace = "http://naesb.org/espi")
31+
@XmlEnum
32+
public enum Currency {
33+
34+
/**
35+
* US dollar.
36+
* XSD value: 840 (line 2108)
37+
*/
38+
@XmlEnumValue("840")
39+
USD(840),
40+
41+
/**
42+
* European euro.
43+
* XSD value: 978 (line 2114)
44+
*/
45+
@XmlEnumValue("978")
46+
EUR(978),
47+
48+
/**
49+
* Australian dollar.
50+
* XSD value: 36 (line 2120)
51+
*/
52+
@XmlEnumValue("36")
53+
AUD(36),
54+
55+
/**
56+
* Canadian dollar.
57+
* XSD value: 124 (line 2126)
58+
*/
59+
@XmlEnumValue("124")
60+
CAD(124),
61+
62+
/**
63+
* Swiss francs.
64+
* XSD value: 756 (line 2132)
65+
*/
66+
@XmlEnumValue("756")
67+
CHF(756),
68+
69+
/**
70+
* Chinese yuan renminbi.
71+
* XSD value: 156 (line 2138)
72+
*/
73+
@XmlEnumValue("156")
74+
CNY(156),
75+
76+
/**
77+
* Danish crown.
78+
* XSD value: 208 (line 2144)
79+
*/
80+
@XmlEnumValue("208")
81+
DKK(208),
82+
83+
/**
84+
* British pound.
85+
* XSD value: 826 (line 2150)
86+
*/
87+
@XmlEnumValue("826")
88+
GBP(826),
89+
90+
/**
91+
* Japanese yen.
92+
* XSD value: 392 (line 2156)
93+
*/
94+
@XmlEnumValue("392")
95+
JPY(392),
96+
97+
/**
98+
* Norwegian crown.
99+
* XSD value: 578 (line 2162)
100+
*/
101+
@XmlEnumValue("578")
102+
NOK(578),
103+
104+
/**
105+
* Russian ruble.
106+
* XSD value: 643 (line 2168)
107+
*/
108+
@XmlEnumValue("643")
109+
RUB(643),
110+
111+
/**
112+
* Swedish crown.
113+
* XSD value: 752 (line 2174)
114+
*/
115+
@XmlEnumValue("752")
116+
SEK(752),
117+
118+
/**
119+
* India rupees.
120+
* XSD value: 356 (line 2180)
121+
*/
122+
@XmlEnumValue("356")
123+
INR(356),
124+
125+
/**
126+
* Another type of currency.
127+
* XSD value: 0 (line 2186)
128+
*/
129+
@XmlEnumValue("0")
130+
OTHER(0);
131+
132+
private final int value;
133+
134+
Currency(int value) {
135+
this.value = value;
136+
}
137+
138+
public int getValue() {
139+
return value;
140+
}
141+
142+
public static Currency fromValue(int value) {
143+
for (Currency kind : Currency.values()) {
144+
if (kind.value == value) {
145+
return kind;
146+
}
147+
}
148+
throw new IllegalArgumentException("Invalid Currency value: " + value);
149+
}
150+
}

0 commit comments

Comments
 (0)