Skip to content
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

feat(commands) #26: Implement Commands module #82

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

atschabu
Copy link
Contributor

Implementor is responsible for async handling of calling callback via the client

Example implementation of postStartSession

    override suspend fun postStartSession(
        partnerUrl: String,
        startSession: StartSession,
    ): OcpiResponseBody<CommandResponse> {
        validate {
            validateLength("response_url", startSession.responseUrl, 255)
            validateLength("token.country_code", startSession.token.countryCode, 2)
            validateLength("token.partyId", startSession.token.partyId, 3)
            validateLength("token.uid", startSession.token.uid, 36)
            validateLength("token.issuer", startSession.token.issuer, 64)
            validateLength("location_id", startSession.locationId, 36)
        }

        val responseType = if (startSession.evseUid == null) {
            // we don't allow remote start on a location. This is an implementation detail on our side
            log.warn("remote start session without evse_id from {}", partnerUrl)
            CommandResponseType.REJECTED
        } else {
            // you either need to store or forward the remote start reference, as we will need it in the session object. 
           async {
                val resultType = ocppClient.remoteStart(startSession.evseUid!!, startSession.token.uid)
                val result = CommandResult(resultType, emptyList())
                commandCpoClient.postCommandCallback(
                    result,
                    partnerUrl,
                    startSession.responseUrl
                )
            }

            CommandResponseType.ACCEPTED
        }

        return OcpiResponseBody.success(CommandResponse(responseType, 30, emptyList()))
    }

@atschabu atschabu changed the title feat(commands) #26: Implment Commands module feat(commands) #26: Implement Commands module Feb 21, 2024
@atschabu
Copy link
Contributor Author

Quality Gate Failed Quality Gate failed

Failed conditions C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

unfortunately I can't see the complaint :/

Copy link

sonarqubecloud bot commented Feb 21, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@lilgallon
Copy link
Member

lilgallon commented Feb 21, 2024

The quality gate complains about parts of the code like: req.pathParams["authRef"]!!,. There are 7 occurrences.

Map values should be accessed safely. Using the non-null assertion operator here can throw a NullPointerException.

They are all false positive in their context, I fixed them in SonarCloud

Copy link
Member

@lilgallon lilgallon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for your contribution

@lilgallon lilgallon merged commit 257bb47 into IZIVIA:main Feb 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants