本文整理了Java中org.eclipse.ditto.json.JsonPointer.append()
方法的一些代码示例,展示了JsonPointer.append()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonPointer.append()
方法的具体详情如下:
包路径:org.eclipse.ditto.json.JsonPointer
类名称:JsonPointer
方法名:append
[英]Creates a new JSON pointer by appending the given pointer to this pointer.
[中]通过将给定指针附加到此指针来创建新的JSON指针。
代码示例来源:origin: org.eclipse.ditto/ditto-protocol-adapter
@Override
public JsonPointer append(final JsonPointer pointer) {
return jsonPointer.append(pointer);
}
代码示例来源:origin: eclipse/ditto
@Override
public JsonPointer append(final JsonPointer pointer) {
return jsonPointer.append(pointer);
}
代码示例来源:origin: eclipse/ditto
private static JsonPointer transformerPointer(@Nullable final String serviceName,
@Nullable final Integer instance) {
JsonPointer newPointer = JsonPointer.empty();
if (serviceName != null) {
newPointer = newPointer.append(JsonPointer.of(serviceName));
}
if (instance != null) {
newPointer = newPointer.append(JsonPointer.of(instance.toString()));
}
return newPointer;
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-connectivity-messaging
private Certificate getClientCertificate(final String certificatePem) {
final byte[] asciiBytes = certificatePem.getBytes(StandardCharsets.US_ASCII);
try {
return X509_CERTIFICATE_FACTORY.generateCertificate(new ByteArrayInputStream(asciiBytes));
} catch (final CertificateException e) {
final JsonPointer errorLocation = Connection.JsonFields.CREDENTIALS.getPointer()
.append(ClientCertificateCredentials.JsonFields.CLIENT_CERTIFICATE.getPointer());
throw badFormat(errorLocation, "CERTIFICATE", "DER")
.build();
}
}
代码示例来源:origin: eclipse/ditto
private Certificate getClientCertificate(final String certificatePem) {
final byte[] asciiBytes = certificatePem.getBytes(StandardCharsets.US_ASCII);
try {
return X509_CERTIFICATE_FACTORY.generateCertificate(new ByteArrayInputStream(asciiBytes));
} catch (final CertificateException e) {
final JsonPointer errorLocation = Connection.JsonFields.CREDENTIALS.getPointer()
.append(ClientCertificateCredentials.JsonFields.CLIENT_CERTIFICATE.getPointer());
throw badFormat(errorLocation, "CERTIFICATE", "DER")
.build();
}
}
代码示例来源:origin: org.eclipse.ditto/ditto-services-connectivity-messaging
private PrivateKey getClientPrivateKey(final String privateKeyPem) {
final Matcher matcher = PRIVATE_KEY_REGEX.matcher(privateKeyPem);
final Supplier<DittoRuntimeExceptionBuilder> errorSupplier = () -> {
final JsonPointer errorLocation = Connection.JsonFields.CREDENTIALS.getPointer()
.append(ClientCertificateCredentials.JsonFields.CLIENT_KEY.getPointer());
return badFormat(errorLocation, PRIVATE_KEY_LABEL, "PKCS #8")
.description("Please format your client key as PEM-encoded unencrypted PKCS #8.");
};
if (!matcher.matches()) {
throw errorSupplier.get().build();
} else {
final String content = matcher.group(1).replaceAll("\\s", "");
final byte[] bytes = decodeBase64(content);
final KeySpec keySpec = new PKCS8EncodedKeySpec(bytes);
try {
return RSA_KEY_FACTORY.generatePrivate(keySpec);
} catch (final InvalidKeySpecException e) {
throw errorSupplier.get().cause(e).build();
}
}
}
代码示例来源:origin: eclipse/ditto
private static JsonPointer createAbsoluteResourcePointer(final ResourceKey resourceKey) {
return JsonFactory.newPointer(resourceKey.getResourceType()).append(resourceKey.getResourcePath());
}
代码示例来源:origin: eclipse/ditto
private PrivateKey getClientPrivateKey(final String privateKeyPem) {
final Matcher matcher = PRIVATE_KEY_REGEX.matcher(privateKeyPem);
final Supplier<DittoRuntimeExceptionBuilder> errorSupplier = () -> {
final JsonPointer errorLocation = Connection.JsonFields.CREDENTIALS.getPointer()
.append(ClientCertificateCredentials.JsonFields.CLIENT_KEY.getPointer());
return badFormat(errorLocation, PRIVATE_KEY_LABEL, "PKCS #8")
.description("Please format your client key as PEM-encoded unencrypted PKCS #8.");
};
if (!matcher.matches()) {
throw errorSupplier.get().build();
} else {
final String content = matcher.group(1).replaceAll("\\s", "");
final byte[] bytes = decodeBase64(content);
final KeySpec keySpec = new PKCS8EncodedKeySpec(bytes);
try {
return RSA_KEY_FACTORY.generatePrivate(keySpec);
} catch (final InvalidKeySpecException e) {
throw errorSupplier.get().cause(e).build();
}
}
}
代码示例来源:origin: eclipse/ditto
return new NullPointerException(MessageFormat.format(msgPattern, levelCount));
});
builder.set(resourcePath.append(subPointer), pointerAndValue.value);
});
代码示例来源:origin: eclipse/ditto
/**
* Converts a {@link ResourceKey} to an iterator of JSON keys by prepending the resource type to the resource path.
*
* @param resourceKey The resource key to convert.
* @return The converted JSON key iterator.
* @throws NullPointerException if {@code resourceKey} is {@code null}.
*/
static Iterator<JsonKey> getJsonKeyIterator(final ResourceKey resourceKey) {
checkNotNull(resourceKey, "resource key to convert");
return JsonFactory.newPointer(resourceKey.getResourceType()).append(resourceKey.getResourcePath()).iterator();
}
代码示例来源:origin: eclipse/ditto
public ThingQueryCommandResponseAssert withResourcePath(final CharSequence resourcePath,
final JsonPointer furtherResourcePathSegments) {
isNotNull();
final JsonPointer expectedResourcePath = JsonFactory.newPointer(resourcePath)
.append(furtherResourcePathSegments);
final JsonPointer actualResourcePath = actual.getResourcePath();
Assertions.assertThat((Object) actualResourcePath)
.overridingErrorMessage("Expected ThingQueryCommandResponse to have resource path \n<%s> but it" +
" had\n<%s>", expectedResourcePath, actualResourcePath)
.isEqualTo(expectedResourcePath);
return myself;
}
代码示例来源:origin: eclipse/ditto
public ThingModifyCommandResponseAssert withResourcePath(final CharSequence resourcePath,
final JsonPointer furtherResourcePathSegments) {
isNotNull();
final JsonPointer expectedResourcePath = JsonFactory.newPointer(resourcePath)
.append(furtherResourcePathSegments);
final JsonPointer actualResourcePath = actual.getResourcePath();
Assertions.assertThat((Object) actualResourcePath)
.overridingErrorMessage("Expected ThingModifyCommandResponse to have resource path \n<%s> but it" +
" had\n<%s>", expectedResourcePath, actualResourcePath)
.isEqualTo(expectedResourcePath);
return myself;
}
代码示例来源:origin: org.eclipse.ditto/ditto-signals-commands-messages
@Override
default JsonPointer getResourcePath() {
final Message<?> message = getMessage();
final String box = message.getDirection() == MessageDirection.TO
? MessageCommand.INBOX_PREFIX
: MessageCommand.OUTBOX_PREFIX;
final JsonPointer pathSuffix =
JsonFactory.newPointer(JsonKey.of(box), JsonKey.of(MessageCommand.MESSAGES_PREFIX),
JsonKey.of(message.getSubject()));
final JsonPointer path = message.getFeatureId()
.map(fId -> JsonFactory.newPointer(JsonKey.of(MessageCommand.FEATURES_PREFIX), JsonKey.of(fId)))
.orElse(JsonPointer.empty());
return path.append(pathSuffix);
}
代码示例来源:origin: eclipse/ditto
@Override
default JsonPointer getResourcePath() {
final Message<?> message = getMessage();
final String box = message.getDirection() == MessageDirection.TO
? MessageCommand.INBOX_PREFIX
: MessageCommand.OUTBOX_PREFIX;
final JsonPointer pathSuffix =
JsonFactory.newPointer(JsonKey.of(box), JsonKey.of(MessageCommand.MESSAGES_PREFIX),
JsonKey.of(message.getSubject()));
final JsonPointer path = message.getFeatureId()
.map(fId -> JsonFactory.newPointer(JsonKey.of(MessageCommand.FEATURES_PREFIX), JsonKey.of(fId)))
.orElse(JsonPointer.empty());
return path.append(pathSuffix);
}
代码示例来源:origin: eclipse/ditto
public ThingModifiedEventAssert withResourcePath(final CharSequence resourcePath,
final JsonPointer furtherResourcePathSegments) {
isNotNull();
final JsonPointer expectedResourcePath;
if (null != furtherResourcePathSegments) {
expectedResourcePath = JsonFactory.newPointer(resourcePath).append(furtherResourcePathSegments);
} else {
expectedResourcePath = JsonFactory.newPointer(resourcePath);
}
final JsonPointer actualResourcePath = actual.getResourcePath();
Assertions.assertThat((CharSequence) actualResourcePath)
.overridingErrorMessage("Expected ThingModifiedEvent to have resource path \n<%s> but it had\n<%s>",
expectedResourcePath, actualResourcePath)
.isEqualTo(expectedResourcePath);
return myself;
}
代码示例来源:origin: eclipse/ditto
@Override
public JsonObject buildJsonView(
final ResourceKey resourceKey,
final Iterable<JsonField> jsonFields,
final AuthorizationContext authorizationContext,
final Permissions permissions) {
checkResourceKey(resourceKey);
checkNotNull(jsonFields, "JSON fields");
checkPermissions(permissions);
final Collection<String> authorizationSubjectIds = getAuthorizationSubjectIds(authorizationContext);
final EffectedResources effectedResources = getGrantedAndRevokedSubResource(
JsonFactory.newPointer(ROOT_RESOURCE), resourceKey.getResourceType(), authorizationSubjectIds,
permissions);
if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) {
return JsonFactory.nullObject();
}
final List<PointerAndValue> flatPointers = new ArrayList<>();
jsonFields.forEach(jsonField -> collectFlatPointers(jsonField.getKey().asPointer(), jsonField, flatPointers));
final Set<JsonPointer> grantedResources = extractJsonPointers(effectedResources.getGrantedResources());
final Set<JsonPointer> revokedResources = extractJsonPointers(effectedResources.getRevokedResources());
final JsonPointer resourcePath = resourceKey.getResourcePath();
final List<PointerAndValue> prefixedPointers = flatPointers.stream()
.map(pv -> new PointerAndValue(resourcePath.append(pv.pointer), pv.value))
.collect(Collectors.toList());
return filterEntries(prefixedPointers, grantedResources, revokedResources, resourcePath);
}
代码示例来源:origin: org.eclipse.ditto/ditto-signals-commands-messages
@Override
default JsonPointer getResourcePath() {
final Message<?> message = getMessage();
final String box = message.getDirection() == MessageDirection.TO ? INBOX_PREFIX : OUTBOX_PREFIX;
final JsonPointer pathSuffix = JsonPointer.empty()
.addLeaf(JsonKey.of(box))
.addLeaf(JsonKey.of(MESSAGES_PREFIX))
.addLeaf(JsonKey.of(message.getSubject()));
final JsonPointer path = message.getFeatureId().map(fId -> JsonPointer.empty()
.addLeaf(JsonKey.of(FEATURES_PREFIX))
.addLeaf(JsonKey.of(fId)))
.orElse(JsonPointer.empty());
return path.append(pathSuffix);
}
代码示例来源:origin: eclipse/ditto
@Override
default JsonPointer getResourcePath() {
final Message<?> message = getMessage();
final String box = message.getDirection() == MessageDirection.TO ? INBOX_PREFIX : OUTBOX_PREFIX;
final JsonPointer pathSuffix = JsonPointer.empty()
.addLeaf(JsonKey.of(box))
.addLeaf(JsonKey.of(MESSAGES_PREFIX))
.addLeaf(JsonKey.of(message.getSubject()));
final JsonPointer path = message.getFeatureId().map(fId -> JsonPointer.empty()
.addLeaf(JsonKey.of(FEATURES_PREFIX))
.addLeaf(JsonKey.of(fId)))
.orElse(JsonPointer.empty());
return path.append(pathSuffix);
}
代码示例来源:origin: org.eclipse.ditto/ditto-protocol-adapter
messageCommandJson.getValue(messagePointer.append(MessageCommand.JsonFields.JSON_MESSAGE_PAYLOAD.getPointer()))
.ifPresent(payloadBuilder::withValue);
代码示例来源:origin: eclipse/ditto
messageCommandJson.getValue(messagePointer.append(MessageCommand.JsonFields.JSON_MESSAGE_PAYLOAD.getPointer()))
.ifPresent(payloadBuilder::withValue);
内容来源于网络,如有侵权,请联系作者删除!