本文整理了Java中com.linecorp.centraldogma.internal.Jackson.convertValue()
方法的一些代码示例,展示了Jackson.convertValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jackson.convertValue()
方法的具体详情如下:
包路径:com.linecorp.centraldogma.internal.Jackson
类名称:Jackson
方法名:convertValue
暂无
代码示例来源:origin: line/centraldogma
private static CommitMessageDto convertCommitMessage(JsonNode jsonNode) {
final CommitMessageDto commitMessage = Jackson.convertValue(jsonNode, CommitMessageDto.class);
checkArgument(!isNullOrEmpty(commitMessage.summary()), "summary should be non-null");
return commitMessage;
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
private static CommitMessageDto convertCommitMessage(JsonNode jsonNode) {
final CommitMessageDto commitMessage = Jackson.convertValue(jsonNode, CommitMessageDto.class);
checkArgument(!isNullOrEmpty(commitMessage.summary()), "summary should be non-null");
return commitMessage;
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
private static CommitMessageDto convertCommitMessage(JsonNode jsonNode) {
final CommitMessageDto commitMessage = Jackson.convertValue(jsonNode, CommitMessageDto.class);
checkArgument(!isNullOrEmpty(commitMessage.summary()), "summary should be non-null");
return commitMessage;
}
}
代码示例来源:origin: line/centraldogma
private static Entry<CommitMessageDto, Change<?>> commitMessageAndChange(AggregatedHttpMessage message) {
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
final CommitMessageDto commitMessage =
Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
final EntryDto file = Jackson.convertValue(node.get("file"), EntryDto.class);
final Change<?> change;
switch (file.getType()) {
case "JSON":
change = Change.ofJsonUpsert(file.getPath(), file.getContent());
break;
case "TEXT":
change = Change.ofTextUpsert(file.getPath(), file.getContent());
break;
default:
throw new IllegalArgumentException("unsupported file type: " + file.getType());
}
return Maps.immutableEntry(commitMessage, change);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
private static Entry<CommitMessageDto, Change<?>> commitMessageAndChange(AggregatedHttpMessage message) {
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
final CommitMessageDto commitMessage =
Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
final EntryDto file = Jackson.convertValue(node.get("file"), EntryDto.class);
final Change<?> change;
switch (file.getType()) {
case "JSON":
change = Change.ofJsonUpsert(file.getPath(), file.getContent());
break;
case "TEXT":
change = Change.ofTextUpsert(file.getPath(), file.getContent());
break;
default:
throw new IllegalArgumentException("unsupported file type: " + file.getType());
}
return Maps.immutableEntry(commitMessage, change);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
private static Entry<CommitMessageDto, Change<?>> commitMessageAndChange(AggregatedHttpMessage message) {
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
final CommitMessageDto commitMessage =
Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
final EntryDto file = Jackson.convertValue(node.get("file"), EntryDto.class);
final Change<?> change;
switch (file.getType()) {
case "JSON":
change = Change.ofJsonUpsert(file.getPath(), file.getContent());
break;
case "TEXT":
change = Change.ofTextUpsert(file.getPath(), file.getContent());
break;
default:
throw new IllegalArgumentException("unsupported file type: " + file.getType());
}
return Maps.immutableEntry(commitMessage, change);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
}
代码示例来源:origin: line/centraldogma
.thenApply(entry -> {
if (entry != null) {
return Jackson.<Map<String, LegacyToken>>convertValue(
entry.content(), TOKEN_MAP_TYPE_REFERENCE).values();
} else {
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}
*
* <p>Updates {@link Permission}s for the specified {@code appId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}")
@Consumes("application/json-patch+json")
public CompletableFuture<Revision> updateSpecificTokenPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("appId") String appId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
return mds.findTokenByAppId(appId)
.thenCompose(token -> mds.updatePerTokenPermission(
author, projectName, repoName, appId, permissions));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/users/{memberId}
*
* <p>Updates {@link Permission}s for the specified {@code memberId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/users/{memberId}")
@Consumes("application/json-patch+json")
public CompletableFuture<Revision> updateSpecificUserPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("memberId") String memberId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
final User member = new User(loginNameNormalizer.apply(urlDecode(memberId)));
return mds.findPermissions(projectName, repoName, member)
.thenCompose(unused -> mds.updatePerUserPermission(author,
projectName, repoName, member,
permissions));
}
代码示例来源:origin: line/centraldogma
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/users/{memberId}
*
* <p>Updates {@link Permission}s for the specified {@code memberId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/users/{memberId}")
@Consumes("application/json-patch+json")
public CompletableFuture<Revision> updateSpecificUserPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("memberId") String memberId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
final User member = new User(loginNameNormalizer.apply(urlDecode(memberId)));
return mds.findPermissions(projectName, repoName, member)
.thenCompose(unused -> mds.updatePerUserPermission(author,
projectName, repoName, member,
permissions));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
.thenApply(entry -> {
if (entry != null) {
return Jackson.<Map<String, LegacyToken>>convertValue(
entry.content(), TOKEN_MAP_TYPE_REFERENCE).values();
} else {
代码示例来源:origin: line/centraldogma
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}
*
* <p>Updates {@link Permission}s for the specified {@code appId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}")
@Consumes("application/json-patch+json")
public CompletableFuture<Revision> updateSpecificTokenPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("appId") String appId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
return mds.findTokenByAppId(appId)
.thenCompose(token -> mds.updatePerTokenPermission(
author, projectName, repoName, appId, permissions));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
.thenApply(entry -> {
if (entry != null) {
return Jackson.<Map<String, LegacyToken>>convertValue(
entry.content(), TOKEN_MAP_TYPE_REFERENCE).values();
} else {
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}
*
* <p>Updates {@link Permission}s for the specified {@code appId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}")
@Consumes("application/json-patch+json")
@Decorator(ProjectOwnersOnly.class)
public CompletableFuture<Revision> updateSpecificTokenPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("appId") String appId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
return mds.findTokenByAppId(appId)
.thenCompose(token -> mds.updatePerTokenPermission(
author, projectName, repoName, appId, permissions));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
/**
* PATCH /metadata/{projectName}/repos/{repoName}/perm/users/{memberId}
*
* <p>Updates {@link Permission}s for the specified {@code memberId} of the specified {@code repoName}
* in the specified {@code projectName}.
*/
@Patch("/metadata/{projectName}/repos/{repoName}/perm/users/{memberId}")
@Consumes("application/json-patch+json")
@Decorator(ProjectOwnersOnly.class)
public CompletableFuture<Revision> updateSpecificUserPermission(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("memberId") String memberId,
JsonPatch jsonPatch,
Author author) {
final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
final User member = new User(loginNameNormalizer.apply(urlDecode(memberId)));
return mds.findPermissions(projectName, repoName, member)
.thenCompose(unused -> mds.updatePerUserPermission(author,
projectName, repoName, member,
permissions));
}
代码示例来源:origin: line/centraldogma
/**
* POST /projects/{projectName}/repositories/{repoName}/delete/revisions/{revision}{path}
* Deletes a file.
*/
@Post("regex:/projects/(?<projectName>[^/]+)/repositories/(?<repoName>[^/]+)" +
"/delete/revisions/(?<revision>[^/]+)(?<path>/.*$)")
@RequiresWritePermission
public HttpResponse deleteFile(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("revision") String revision,
@Param("path") String path,
AggregatedHttpMessage message,
ServiceRequestContext ctx) {
final CommitMessageDto commitMessage;
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
commitMessage = Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
final CompletableFuture<?> future =
push(projectName, repoName, new Revision(revision), AuthUtil.currentAuthor(ctx),
commitMessage.getSummary(), commitMessage.getDetail().getContent(),
Markup.valueOf(commitMessage.getDetail().getMarkup()), Change.ofRemoval(path));
return HttpResponse.from(future.thenApply(unused -> HttpResponse.of(HttpStatus.OK)));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
/**
* POST /projects/{projectName}/repositories/{repoName}/delete/revisions/{revision}{path}
* Deletes a file.
*/
@Post("regex:/projects/(?<projectName>[^/]+)/repositories/(?<repoName>[^/]+)" +
"/delete/revisions/(?<revision>[^/]+)(?<path>/.*$)")
@RequiresWritePermission
public HttpResponse deleteFile(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("revision") String revision,
@Param("path") String path,
AggregatedHttpMessage message,
ServiceRequestContext ctx) {
final CommitMessageDto commitMessage;
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
commitMessage = Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
final CompletableFuture<?> future =
push(projectName, repoName, new Revision(revision), AuthUtil.currentAuthor(ctx),
commitMessage.getSummary(), commitMessage.getDetail().getContent(),
Markup.valueOf(commitMessage.getDetail().getMarkup()), Change.ofRemoval(path));
return HttpResponse.from(future.thenApply(unused -> HttpResponse.of(HttpStatus.OK)));
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
/**
* POST /projects/{projectName}/repositories/{repoName}/delete/revisions/{revision}{path}
* Deletes a file.
*/
@Post("regex:/projects/(?<projectName>[^/]+)/repositories/(?<repoName>[^/]+)" +
"/delete/revisions/(?<revision>[^/]+)(?<path>/.*$)")
@Decorator(HasWritePermission.class)
public HttpResponse deleteFile(@Param("projectName") String projectName,
@Param("repoName") String repoName,
@Param("revision") String revision,
@Param("path") String path,
AggregatedHttpMessage message,
ServiceRequestContext ctx) {
final CommitMessageDto commitMessage;
try {
final JsonNode node = Jackson.readTree(message.content().toStringUtf8());
commitMessage = Jackson.convertValue(node.get("commitMessage"), CommitMessageDto.class);
} catch (IOException e) {
throw new IllegalArgumentException("invalid data to be parsed", e);
}
final CompletableFuture<?> future =
push(projectName, repoName, new Revision(revision), AuthenticationUtil.currentAuthor(ctx),
commitMessage.getSummary(), commitMessage.getDetail().getContent(),
Markup.valueOf(commitMessage.getDetail().getMarkup()), Change.ofRemoval(path));
return HttpResponse.from(future.thenApply(unused -> HttpResponse.of(HttpStatus.OK)));
}
内容来源于网络,如有侵权,请联系作者删除!