Skip to content
Snippets Groups Projects
Commit 3e332849 authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into Version-2

# Conflicts:
#	kop-common-dependencies/pom.xml
#	kop-common-parent/pom.xml
parents 48bacb52 e9f8694d
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<protoc-gen.version>1.51.1</protoc-gen.version> <protoc-gen.version>1.51.1</protoc-gen.version>
<mapstruct.version>1.5.5.Final</mapstruct.version> <mapstruct.version>1.5.5.Final</mapstruct.version>
<commons-io.version>2.12.0</commons-io.version> <commons-io.version>2.13.0</commons-io.version>
<commons-beanutils.version>1.9.4</commons-beanutils.version> <commons-beanutils.version>1.9.4</commons-beanutils.version>
<commons-lang3.version>3.12.0</commons-lang3.version> <commons-lang3.version>3.12.0</commons-lang3.version>
<commons-collections.version>4.4</commons-collections.version> <commons-collections.version>4.4</commons-collections.version>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
package de.itvsh.kop.common.binaryfile; package de.itvsh.kop.common.binaryfile;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import de.itvsh.kop.common.datatype.StringBasedValue; import de.itvsh.kop.common.datatype.StringBasedValue;
...@@ -42,6 +43,9 @@ public class FileId extends StringBasedValue { ...@@ -42,6 +43,9 @@ public class FileId extends StringBasedValue {
} }
public static FileId from(String fileId) { public static FileId from(String fileId) {
if (Objects.nonNull(fileId)) {
return new FileId(fileId); return new FileId(fileId);
} }
return null;
}
} }
\ No newline at end of file
...@@ -37,6 +37,11 @@ import lombok.NoArgsConstructor; ...@@ -37,6 +37,11 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class GrpcUtil { public class GrpcUtil {
public static final Key<byte[]> HEADER_KEY_USER_ID = createKeyOf("USER_ID-bin");
public static final Key<byte[]> HEADER_KEY_CLIENT_NAME = createKeyOf("CLIENT_NAME-bin");
public static final Key<byte[]> HEADER_KEY_REQUEST_ID = createKeyOf("REQUEST_ID-bin");
public static Key<String> keyOfString(String key) { public static Key<String> keyOfString(String key) {
return Key.of(key, Metadata.ASCII_STRING_MARSHALLER); return Key.of(key, Metadata.ASCII_STRING_MARSHALLER);
} }
...@@ -45,10 +50,12 @@ public class GrpcUtil { ...@@ -45,10 +50,12 @@ public class GrpcUtil {
return Key.of(key, Metadata.BINARY_BYTE_MARSHALLER); return Key.of(key, Metadata.BINARY_BYTE_MARSHALLER);
} }
public static String getFromHeaders(String key, Metadata headers) { public static Optional<String> getFromHeaders(String key, Metadata headers) {
return Optional.ofNullable(headers.get(createKeyOf(key))) return getFromHeaders(createKeyOf(key), headers);
.map(GrpcUtil::byteToString) }
.orElse(null);
public static Optional<String> getFromHeaders(Key<byte[]> key, Metadata headers) {
return Optional.ofNullable(headers.get(key)).map(GrpcUtil::byteToString);
} }
public static Collection<String> getCollection(String key, Metadata headers) { public static Collection<String> getCollection(String key, Metadata headers) {
...@@ -64,4 +71,5 @@ public class GrpcUtil { ...@@ -64,4 +71,5 @@ public class GrpcUtil {
private static String byteToString(byte[] bytes) { private static String byteToString(byte[] bytes) {
return new String(bytes, StandardCharsets.UTF_8); return new String(bytes, StandardCharsets.UTF_8);
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment