use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.
the class ConfigurationProcessor method getWorkspaceCfg.
@SuppressWarnings("unchecked")
private static Map<String, Object> getWorkspaceCfg(Payload payload) {
Path workspace = payload.getHeader(Payload.WORKSPACE_DIR);
Path src = workspace.resolve(Constants.Files.CONFIGURATION_FILE_NAME);
if (!Files.exists(src)) {
return Collections.emptyMap();
}
try (InputStream in = Files.newInputStream(src)) {
ObjectMapper om = new ObjectMapper();
return om.readValue(in, Map.class);
} catch (IOException e) {
throw new ProcessException(payload.getProcessKey(), "Invalid request data format", e, Status.BAD_REQUEST);
}
}
use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.
the class ConfigurationProcessor method getProject.
private ProjectEntry getProject(Payload payload) {
UUID projectId = payload.getHeader(Payload.PROJECT_ID);
if (projectId == null) {
return null;
}
ProjectEntry e = projectDao.get(projectId);
if (e == null) {
throw new ProcessException(payload.getProcessKey(), "Project not found: " + projectId, Status.BAD_REQUEST);
}
return e;
}
use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.
the class ConfigurationStoringProcessor method process.
@Override
public Payload process(Chain chain, Payload payload) {
ProcessKey processKey = payload.getProcessKey();
Map<String, Object> cfg = payload.getHeader(Payload.CONFIGURATION);
if (cfg == null) {
return chain.process(payload);
}
Path workspace = payload.getHeader(Payload.WORKSPACE_DIR);
Path dst = workspace.resolve(Constants.Files.CONFIGURATION_FILE_NAME);
try (OutputStream out = Files.newOutputStream(dst)) {
ObjectMapper om = new ObjectMapper();
om.writeValue(out, cfg);
} catch (IOException e) {
logManager.error(processKey, "Error while saving a metadata file: " + dst, e);
throw new ProcessException(processKey, "Error while saving a metadata file: " + dst, e);
}
return chain.process(payload);
}
use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.
the class DependenciesProcessor method process.
@Override
public Payload process(Chain chain, Payload payload) {
ProcessKey processKey = payload.getProcessKey();
Map<String, Object> cfg = payload.getHeader(Payload.CONFIGURATION);
// get a list of dependencies from the cfg data
Collection<String> deps = deps(processKey, cfg);
if (deps == null) {
return chain.process(payload);
}
boolean failed = false;
for (String d : deps) {
try {
new URI(d);
} catch (URISyntaxException e) {
logManager.error(processKey, "Invalid dependency URL: " + d);
failed = true;
}
}
if (failed) {
throw new ProcessException(processKey, "Invalid dependency list");
}
cfg.put(Constants.Request.DEPENDENCIES_KEY, deps);
payload = payload.putHeader(Payload.CONFIGURATION, cfg);
return chain.process(payload);
}
use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.
the class ForkRepositoryInfoProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, Payload payload) {
UUID parentInstanceId = payload.getHeader(Payload.PARENT_INSTANCE_ID);
ProcessEntry parent = queueManager.get(PartialProcessKey.from(parentInstanceId));
if (parent == null) {
throw new ProcessException(payload.getProcessKey(), "Parent process '" + parentInstanceId + "' not found");
}
RepositoryProcessor.CommitInfo ci = new RepositoryProcessor.CommitInfo(parent.commitId(), parent.commitBranch(), null, parent.commitMsg());
RepositoryProcessor.RepositoryInfo i = new RepositoryProcessor.RepositoryInfo(parent.repoId(), parent.repoName(), parent.repoUrl(), parent.repoPath(), parent.commitBranch(), parent.commitId(), ci);
payload = payload.putHeader(REPOSITORY_INFO_KEY, i);
return chain.process(payload);
}
Aggregations