-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Issue 98 controller functionality #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4e340a9
2c63a16
3a420e9
67d5e30
c955a4d
e638594
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2025 Green Button Alliance, Inc. | ||
| * | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * | ||
| */ | ||
|
|
||
| package org.greenbuttonalliance.espi.common.service.impl; | ||
|
|
||
| import jakarta.xml.bind.JAXBContext; | ||
| import jakarta.xml.bind.JAXBException; | ||
| import org.greenbuttonalliance.espi.common.service.BaseExportService; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Export service for ESPI ApplicationInformation resource. | ||
| * <p> | ||
| * This service handles XML marshalling for the ApplicationInformation resource defined in espi.xsd. | ||
| * <p> | ||
| * Namespace configuration: | ||
| * - Atom namespace (http://www.w3.org/2005/Atom) - default namespace | ||
| * - ESPI namespace (http://naesb.org/espi) - with "espi:" prefix | ||
| */ | ||
| @Service("applicationInformationExportService") | ||
| public class ApplicationInformationExportService extends BaseExportService { | ||
|
|
||
| private static final String ATOM_NAMESPACE = "http://www.w3.org/2005/Atom"; | ||
| private static final String ESPI_NAMESPACE = "http://naesb.org/espi"; | ||
|
|
||
| /** | ||
| * Creates JAXBContext with Atom + ApplicationInformation domain classes. | ||
| * | ||
| * @return JAXBContext configured for ApplicationInformation resource | ||
| * @throws JAXBException if context creation fails | ||
| */ | ||
| @Override | ||
| protected JAXBContext createJAXBContext() throws JAXBException { | ||
| return JAXBContext.newInstance( | ||
| // Atom protocol classes | ||
| org.greenbuttonalliance.espi.common.dto.atom.AtomFeedDto.class, | ||
| org.greenbuttonalliance.espi.common.dto.atom.LinkDto.class, | ||
| org.greenbuttonalliance.espi.common.dto.atom.UsageAtomEntryDto.class, | ||
|
|
||
| // ApplicationInformation resource class (http://naesb.org/espi) | ||
| org.greenbuttonalliance.espi.common.dto.usage.ApplicationInformationDto.class | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the 2 namespaces for ApplicationInformation domain. | ||
| * | ||
| * @return set containing Atom and ESPI namespaces | ||
| */ | ||
| @Override | ||
| protected Set<String> getDomainNamespaces() { | ||
| return Set.of(ATOM_NAMESPACE, ESPI_NAMESPACE); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,10 @@ | |
| import org.springframework.util.Assert; | ||
|
|
||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| @Slf4j | ||
| @Service | ||
|
|
@@ -44,6 +47,7 @@ public class ApplicationInformationServiceImpl implements | |
|
|
||
| private final ApplicationInformationRepository applicationInformationRepository; | ||
| private final ApplicationInformationMapper applicationInformationMapper; | ||
| private final ApplicationInformationExportService applicationInformationExportService; | ||
|
|
||
| @Override | ||
| public ApplicationInformationEntity findByClientId(String clientId) { | ||
|
|
@@ -66,10 +70,8 @@ public ApplicationInformationEntity findByDataCustodianClientId( | |
| String dataCustodianClientId) { | ||
| Assert.notNull(dataCustodianClientId, "dataCustodianClientId is required"); | ||
|
|
||
| // TODO: Add repository method findByDataCustodianClientId if needed | ||
| log.info("Finding ApplicationInformation by dataCustodianClientId: " + dataCustodianClientId); | ||
|
|
||
| return null; | ||
| return applicationInformationRepository.findByDataCustodianId(dataCustodianClientId).orElse(null); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -91,4 +93,44 @@ public ApplicationInformationEntity importResource(InputStream stream) { | |
| return null; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public List<ApplicationInformationEntity> findAll() { | ||
| return applicationInformationRepository.findAll(); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public ApplicationInformationEntity findById(UUID id) { | ||
| return applicationInformationRepository.findById(id).orElse(null); | ||
| } | ||
|
|
||
| @Override | ||
| public ApplicationInformationEntity save(ApplicationInformationEntity entity) { | ||
| return applicationInformationRepository.save(entity); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteById(UUID id) { | ||
| applicationInformationRepository.deleteById(id); | ||
| } | ||
|
|
||
| @Override | ||
| public void export(List<ApplicationInformationEntity> entities, OutputStream outputStream) { | ||
| List<ApplicationInformationDto> dtos = entities.stream() | ||
| .map(applicationInformationMapper::toDto) | ||
| .toList(); | ||
| applicationInformationExportService.exportDto(dtos, outputStream); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: Batch Export Will Throw JAXBException at Runtime This passes a raw Suggested fix — either wrap in an AtomFeedDto feed = new AtomFeedDto();
// populate feed with entries from dtos
applicationInformationExportService.exportDto(feed, outputStream);Or export entities individually: for (ApplicationInformationEntity entity : entities) {
export(entity, outputStream);
} |
||
| } | ||
|
|
||
| @Override | ||
| public void export(ApplicationInformationEntity entity, OutputStream outputStream) { | ||
| applicationInformationExportService.exportDto(applicationInformationMapper.toDto(entity), outputStream); | ||
| } | ||
|
|
||
| @Override | ||
| public ApplicationInformationEntity fromDto(ApplicationInformationDto dto) { | ||
| return applicationInformationMapper.toEntity(dto); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking: Opaque Token Fallback Will Fail at Runtime
When JWT properties are not set, this falls back to
opaqueToken(Customizer.withDefaults()), but noOpaqueTokenIntrospectorbean is defined. TheintrospectionUri,clientId, andclientSecretfields are injected via@Valuebut never wired into any bean. This will cause a startup failure.Suggested fix — wire the introspector: