-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from com-pas/develop
New release
- Loading branch information
Showing
48 changed files
with
1,025 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.../java/org/lfenergy/compas/scl/validator/rest/exception/NsdocNotFoundExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.validator.rest.exception; | ||
|
||
import org.lfenergy.compas.core.jaxrs.model.ErrorResponse; | ||
import org.lfenergy.compas.scl.validator.exception.NsdocFileNotFoundException; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
public class NsdocNotFoundExceptionHandler implements ExceptionMapper<NsdocFileNotFoundException> { | ||
@Override | ||
public Response toResponse(NsdocFileNotFoundException exception) { | ||
var response = new ErrorResponse(); | ||
response.addErrorMessage(exception.getErrorCode(), exception.getMessage()); | ||
return Response.status(Response.Status.NOT_FOUND).entity(response).build(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
app/src/main/java/org/lfenergy/compas/scl/validator/rest/v1/NsdocResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-FileCopyrightText: 2022 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.validator.rest.v1; | ||
|
||
import io.quarkus.security.Authenticated; | ||
import org.lfenergy.compas.scl.validator.rest.v1.model.NsdocListResponse; | ||
import org.lfenergy.compas.scl.validator.service.NsdocService; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.MediaType; | ||
import java.util.UUID; | ||
|
||
import static org.lfenergy.compas.scl.validator.rest.SclResourceConstants.ID_PARAM; | ||
|
||
@Authenticated | ||
@RequestScoped | ||
@Path("/nsdoc/v1") | ||
public class NsdocResource { | ||
private final NsdocService nsdocService; | ||
|
||
public NsdocResource(NsdocService nsdocService) { | ||
this.nsdocService = nsdocService; | ||
} | ||
|
||
@GET | ||
@Consumes(MediaType.APPLICATION_XML) | ||
@Produces(MediaType.APPLICATION_XML) | ||
public NsdocListResponse list() { | ||
NsdocListResponse response = new NsdocListResponse(); | ||
response.setNsdocFiles(nsdocService.list()); | ||
return response; | ||
} | ||
|
||
@GET | ||
@Path("{" + ID_PARAM + "}") | ||
@Consumes(MediaType.APPLICATION_XML) | ||
@Produces(MediaType.APPLICATION_XML) | ||
public String get(@PathParam(ID_PARAM) UUID id) { | ||
return nsdocService.get(id); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/lfenergy/compas/scl/validator/rest/v1/model/NsdocListResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-FileCopyrightText: 2022 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.validator.rest.v1.model; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
import org.lfenergy.compas.scl.validator.model.NsdocFile; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.util.Collection; | ||
|
||
import static org.lfenergy.compas.scl.validator.SclValidatorConstants.SCL_VALIDATOR_SERVICE_V1_NS_URI; | ||
|
||
@Schema(description = "The response with the list of known NSDoc Files.") | ||
@XmlRootElement(name = "NsdocListResponse", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI) | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public class NsdocListResponse { | ||
@Schema(description = "The list of known NSDoc Files") | ||
@XmlElement(name = "NsdocFile", namespace = SCL_VALIDATOR_SERVICE_V1_NS_URI) | ||
private Collection<NsdocFile> nsdocFiles; | ||
|
||
public Collection<NsdocFile> getNsdocFiles() { | ||
return nsdocFiles; | ||
} | ||
|
||
public void setNsdocFiles(Collection<NsdocFile> nsdocFiles) { | ||
this.nsdocFiles = nsdocFiles; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- SPDX-FileCopyrightText: 2022 Alliander --> | ||
<!-- --> | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
|
||
<NSDoc> | ||
</NSDoc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- SPDX-FileCopyrightText: 2022 Alliander --> | ||
<!-- --> | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
|
||
<NSDoc id="IEC 61850-7-3" | ||
version="2007" | ||
revision="B" | ||
release="3" | ||
lang="en"> | ||
<Doc id="IEC61850_7_3.CDCControl::ENC.q.desc"><![CDATA[Some DA description]]></Doc> | ||
<Doc id="IEC61850_7_3.AnalogueValue::AnalogueValue.i.desc"><![CDATA[Some i description]]></Doc> | ||
</NSDoc> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- SPDX-FileCopyrightText: 2022 Alliander --> | ||
<!-- --> | ||
<!-- SPDX-License-Identifier: Apache-2.0 --> | ||
|
||
<NSDoc id="IEC 61850-7-4" | ||
version="2007" | ||
revision="B" | ||
release="3" | ||
lang="en"> | ||
<Doc id="IEC61850_7_4.LNGroupL::LLN0.cl.title"><![CDATA[Some LN title]]></Doc> | ||
<Doc id="IEC61850_7_4.LNGroupL::LLN0.Beh.desc"><![CDATA[Some DO description]]></Doc> | ||
<Doc id="IEC61850_7_4.AbstractLNsCommon::DomainLN.Beh.desc"><![CDATA[Some DomainLN Descriptions]]></Doc> | ||
</NSDoc> |
27 changes: 27 additions & 0 deletions
27
...a/org/lfenergy/compas/scl/validator/rest/exception/NsdocNotFoundExceptionHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.validator.rest.exception; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.lfenergy.compas.core.jaxrs.model.ErrorResponse; | ||
import org.lfenergy.compas.scl.validator.exception.NsdocFileNotFoundException; | ||
|
||
import static javax.ws.rs.core.Response.Status.NOT_FOUND; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
class NsdocNotFoundExceptionHandlerTest { | ||
@Test | ||
void toResponse_WhenCalledWithException_ThenNotFoundReturnedWithBody() { | ||
var exception = new NsdocFileNotFoundException("Some message that will only be logged"); | ||
var handler = new NsdocNotFoundExceptionHandler(); | ||
|
||
var result = handler.toResponse(exception); | ||
assertEquals(NOT_FOUND.getStatusCode(), result.getStatus()); | ||
var errorMessage = ((ErrorResponse) result.getEntity()).getErrorMessages().get(0); | ||
assertEquals(exception.getErrorCode(), errorMessage.getCode()); | ||
assertEquals(exception.getMessage(), errorMessage.getMessage()); | ||
assertNull(errorMessage.getProperty()); | ||
} | ||
} |
Oops, something went wrong.