Skip to content

Commit

Permalink
Align uprotocol-kotlin with uprotocol-java version 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
neelam-kushwah committed Nov 22, 2023
1 parent 9600dea commit b8d06d9
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 897 deletions.
112 changes: 38 additions & 74 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@
<description>Language specific uProtocol library for building and using UUri, UUID, UAttributes, UTransport, and more
</description>

<version>${revision}</version>
<version>1.5.2-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<!-- <java.version>11</java.version>-->
<kotlin.version>1.9.20</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<revision>1.5.1-SNAPSHOT</revision>

<junit.platform.version>1.9.1</junit.platform.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
Expand Down Expand Up @@ -127,6 +125,7 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
Expand All @@ -140,28 +139,7 @@
</goals>
</execution>
</executions>
<!-- <configuration>-->
<!-- <outputDir>${project.build.directory}/docs/javadoc</outputDir>-->
<!-- <includes>-->
<!-- <include>src\main\kotlin\**\*.kt</include> </includes>-->
<!-- </configuration>-->
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<!-- <version>3.6.0</version>-->
<!-- <configuration>-->
<!-- <doclint>all,-missing,-reference</doclint>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-javadocs</id>-->
<!-- <goals>-->
<!-- <goal>jar</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -176,7 +154,7 @@
<plugin>
<groupId>org.eclipse.dash</groupId>
<artifactId>license-tool-plugin</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.0.2</version>
<executions>
<execution>
<id>license-check</id>
Expand Down Expand Up @@ -356,18 +334,6 @@
<artifactId>protobuf-java</artifactId>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf.version}</version>
</dependency>

<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
<version>2.16.0</version>
</dependency>


<!-- https://search.maven.org/artifact/com.github.f4b6a3/uuid-creator -->
<dependency>
Expand All @@ -386,7 +352,7 @@
<dependency>
<groupId>org.eclipse.uprotocol</groupId>
<artifactId>uprotocol-core-api</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
</dependency>

<!-- JSON library for JUnit test cases -->
Expand All @@ -396,11 +362,7 @@
<version>20230227</version> <!-- Use the latest version -->
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.jetbrains.kotlin</groupId>-->
<!-- <artifactId>kotlin-stdlib-jdk8</artifactId>-->
<!-- <version>${kotlin.version}</version>-->
<!-- </dependency>-->

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
Expand All @@ -410,29 +372,20 @@
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>

<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>jetbrains-public</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>dash-licenses-snapshots</id>
<url>https://repo.eclipse.org/content/repositories/dash-licenses-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://repo.eclipse.org/content/repositories/dash-licenses-releases/</url>
</pluginRepository>

</pluginRepositories>
Expand All @@ -443,17 +396,17 @@
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down Expand Up @@ -481,7 +434,18 @@
</plugins>
</build>


</profile>
</profiles>
<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package org.eclipse.uprotocol.cloudevent.factory

import com.google.protobuf.Any
import com.google.protobuf.Empty
import com.google.rpc.Code
import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.eclipse.uprotocol.cloudevent.datamodel.UCloudEventAttributes
Expand Down Expand Up @@ -110,7 +109,7 @@ interface CloudEventFactory {
* @param applicationUriForRPC The destination of the response. The uri for the original application that requested the RPC and this response is for.
* @param serviceMethodUri The uri for the method that was called on the service Ex.: :/body.access/1/rpc.UpdateDoor
* @param requestId The cloud event id from the original request cloud event that this response if for.
* @param communicationStatus A [Code] value that indicates of a platform communication error while delivering this CloudEvent.
* @param communicationStatus A UCode value that indicates of a platform communication error while delivering this CloudEvent.
* @param attributes Additional attributes such as ttl, hash and priority.
* @return Returns a response CloudEvent Response for the use case of RPC Response message that failed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package org.eclipse.uprotocol.cloudevent.factory
import com.google.protobuf.Any
import com.google.protobuf.InvalidProtocolBufferException
import com.google.protobuf.Message
import com.google.rpc.Code
import org.eclipse.uprotocol.v1.UCode;
import io.cloudevents.CloudEvent
import io.cloudevents.CloudEventData
import io.cloudevents.core.builder.CloudEventBuilder
Expand Down Expand Up @@ -119,16 +119,16 @@ interface UCloudEvent {
/**
* Extract the integer value of the communication status attribute from a cloud event. The communication status attribute is optional.
* If there was a platform communication error that occurred while delivering this cloudEvent, it will be indicated in this attribute.
* If the attribute does not exist, it is assumed that everything was Code.OK_VALUE.
* If the attribute does not exist, it is assumed that everything was UCode.OK_VALUE.
* @param cloudEvent CloudEvent with the platformError to be extracted.
* @return Returns a [Code] value that indicates of a platform communication error while delivering this CloudEvent or Code.OK_VALUE.
* @return Returns a UCode value that indicates of a platform communication error while delivering this CloudEvent or UCode.OK_VALUE.
*/
fun getCommunicationStatus(cloudEvent: CloudEvent): Int {
return try {
extractIntegerValueFromExtension("commstatus", cloudEvent)
.orElse(Code.OK_VALUE)
.orElse(UCode.OK_VALUE)
} catch (e: Exception) {
Code.OK_VALUE
UCode.OK_VALUE
}
}

Expand All @@ -138,13 +138,13 @@ interface UCloudEvent {
* @return returns true if the provided CloudEvent is marked with having a platform delivery problem.
*/
fun hasCommunicationStatusProblem(cloudEvent: CloudEvent): Boolean {
return getCommunicationStatus(cloudEvent) != Code.OK_VALUE
return getCommunicationStatus(cloudEvent) != UCode.OK_VALUE
}

/**
* Returns a new CloudEvent from the supplied CloudEvent, with the platform communication added.
* @param cloudEvent CloudEvent that the platform delivery error will be added.
* @param communicationStatus the platform delivery error Code to add to the CloudEvent.
* @param communicationStatus the platform delivery error UCode to add to the CloudEvent.
* @return Returns a new CloudEvent from the supplied CloudEvent, with the platform communication added.
*/
fun addCommunicationStatus(cloudEvent: CloudEvent, communicationStatus: Int?): CloudEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@

package org.eclipse.uprotocol.cloudevent.validate

import com.google.rpc.Code
import com.google.rpc.Status
import io.cloudevents.CloudEvent
import org.eclipse.uprotocol.cloudevent.factory.UCloudEvent
import org.eclipse.uprotocol.v1.UResource
import org.eclipse.uprotocol.v1.UUri
import org.eclipse.uprotocol.validation.ValidationResult
import org.eclipse.uprotocol.uri.serializer.LongUriSerializer
import org.eclipse.uprotocol.uri.validator.UriValidator
import org.eclipse.uprotocol.v1.UMessageType
import org.eclipse.uprotocol.v1.*
import java.util.Optional


Expand All @@ -60,9 +56,9 @@ abstract class CloudEventValidator {
/**
* Validate the CloudEvent. A CloudEventValidator instance is obtained according to the type attribute on the CloudEvent.
* @param cloudEvent The CloudEvent to validate.
* @return Returns a google.rpc.Status with success or a google.rpc.Status with failure containing all the errors that were found.
* @return Returns a UStatus with success or a UUStatuswith failure containing all the errors that were found.
*/
fun validate(cloudEvent: CloudEvent): Status {
fun validate(cloudEvent: CloudEvent): UStatus{
val errorMessage = listOf(
validateVersion(cloudEvent),
validateId(cloudEvent),
Expand All @@ -75,8 +71,8 @@ abstract class CloudEventValidator {
return if (errorMessage.isBlank()) {
ValidationResult.success().toStatus()
} else {
Status.newBuilder()
.setCode(Code.INVALID_ARGUMENT_VALUE)
UStatus.newBuilder()
.setCode(UCode.INVALID_ARGUMENT)
.setMessage(errorMessage)
.build()
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/eclipse/uprotocol/rpc/RpcClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

package org.eclipse.uprotocol.rpc

import java.util.concurrent.CompletableFuture
import org.eclipse.uprotocol.v1.UPayload
import org.eclipse.uprotocol.v1.UAttributes
import org.eclipse.uprotocol.v1.UUri
import java.util.concurrent.CompletionStage

/**
* RpcClient is an interface used by code generators for uProtocol services defined in proto files such as
Expand All @@ -44,5 +44,5 @@ interface RpcClient {
* @param attributes Metadata for the method invocation (i.e. priority, timeout, etc.)
* @return Returns the CompletableFuture with the result or exception.
*/
fun invokeMethod(topic: UUri, payload: UPayload, attributes: UAttributes): CompletableFuture<UPayload>
fun invokeMethod(topic: UUri, payload: UPayload, attributes: UAttributes): CompletionStage<UPayload>
}
Loading

0 comments on commit b8d06d9

Please sign in to comment.