use of com.walmartlabs.concord.server.process.Payload in project concord by walmartlabs.
the class FormServiceV2 method resume.
private void resume(ProcessKey processKey, String eventName, String formName, Map<String, Object> req) {
Payload payload;
try {
payload = payloadManager.createResumePayload(processKey, eventName, req);
} catch (IOException e) {
throw new RuntimeException("Error while creating a payload for: " + processKey, e);
}
// remove the form when the process resumes
Path workDir = payload.getHeader(Payload.WORKSPACE_DIR);
payload = payload.putHeader(Payload.RESUME_HOOKS, Collections.singletonList(() -> formManager.delete(workDir, formName)));
processManager.resume(payload);
}
use of com.walmartlabs.concord.server.process.Payload in project concord by walmartlabs.
the class PayloadStoreProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, Payload payload) {
ProcessKey processKey = payload.getProcessKey();
// remove things that shouldn't be in the serialized payload
Map<String, Object> headers = payload.getHeaders().entrySet().stream().filter(e -> !(e.getValue() instanceof Path)).filter(e -> !EXCLUDED_HEADERS.contains(e.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
String serializedHeaders = serialize(headers);
stateManager.tx(tx -> {
stateManager.insert(tx, processKey, "_initial/payload.json", serializedHeaders.getBytes());
stateManager.importPath(tx, processKey, "_initial/attachments/", payload.getHeader(Payload.BASE_DIR), (path, basicFileAttributes) -> payload.getAttachments().containsValue(path));
});
return chain.process(payload);
}
use of com.walmartlabs.concord.server.process.Payload in project concord by walmartlabs.
the class RepositoryProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, final Payload payload) {
ProcessKey processKey = payload.getProcessKey();
UUID projectId = payload.getHeader(Payload.PROJECT_ID);
RepositoryEntry repo = getRepositoryEntry(payload);
if (projectId == null || repo == null) {
return chain.process(payload);
}
logManager.info(processKey, "Copying the repository's data: {} @ {}:{}, path: {}", repo.getUrl(), repo.getBranch() != null ? repo.getBranch() : "*", repo.getCommitId() != null ? repo.getCommitId() : "head", repo.getPath() != null ? repo.getPath() : "/");
Path dst = payload.getHeader(Payload.WORKSPACE_DIR);
Payload newPayload = repositoryManager.withLock(repo.getUrl(), () -> {
try {
Repository repository = payload.getHeader(Payload.REPOSITORY);
if (repository == null) {
repository = repositoryManager.fetch(projectId, repo, true);
}
Snapshot snapshot = repository.export(dst);
CommitInfo ci = null;
if (repository.fetchResult() != null) {
FetchResult r = Objects.requireNonNull(repository.fetchResult());
ci = new CommitInfo(r.head(), r.branchOrTag(), r.author(), r.message());
}
RepositoryInfo i = new RepositoryInfo(repo.getId(), repo.getName(), repo.getUrl(), repo.getPath(), repo.getBranch(), repo.getCommitId(), ci);
return payload.putHeader(REPOSITORY_INFO_KEY, i).putHeader(Payload.REPOSITORY, repository).putHeader(Payload.REPOSITORY_SNAPSHOT, Collections.singletonList(snapshot));
} catch (Exception e) {
log.error("process -> repository error", e);
logManager.error(processKey, "Error while processing a repository: " + repo.getUrl(), e);
throw new ProcessException(processKey, "Error while processing a repository: " + repo.getUrl(), e);
}
});
return chain.process(newPayload);
}
Aggregations