Search in sources :

Example 31 with ProcessException

use of com.walmartlabs.concord.server.process.ProcessException in project concord by walmartlabs.

the class ResumeConfigurationProcessor 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);
    }
}
Also used : Path(java.nio.file.Path) ProcessException(com.walmartlabs.concord.server.process.ProcessException) InputStream(java.io.InputStream) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ProcessException (com.walmartlabs.concord.server.process.ProcessException)31 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)20 Path (java.nio.file.Path)19 IOException (java.io.IOException)18 UUID (java.util.UUID)9 InputStream (java.io.InputStream)4 Map (java.util.Map)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 PolicyEngine (com.walmartlabs.concord.policyengine.PolicyEngine)3 ProjectEntry (com.walmartlabs.concord.server.org.project.ProjectEntry)3 ProcessDefinition (com.walmartlabs.concord.process.loader.model.ProcessDefinition)2 Snapshot (com.walmartlabs.concord.repository.Snapshot)2 Payload (com.walmartlabs.concord.server.process.Payload)2 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)2 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)2 UserInfo (com.walmartlabs.concord.server.user.UserInfoProvider.UserInfo)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ConfigurationUtils (com.walmartlabs.concord.common.ConfigurationUtils)1 CycleChecker (com.walmartlabs.concord.common.CycleChecker)1