Search in sources :

Example 1 with Resource

use of org.sonatype.siesta.Resource in project concord by walmartlabs.

the class ProcessResource method listAttachments.

/**
 * Lists process attachments.
 *
 * @param instanceId
 * @return
 */
@GET
@ApiOperation(value = "List attachments", responseContainer = "list", response = String.class)
@javax.ws.rs.Path("/{id}/attachment")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<String> listAttachments(@ApiParam @PathParam("id") UUID instanceId) {
    ProcessEntry processEntry = processManager.assertProcess(instanceId);
    assertProcessAccess(processEntry, "attachments");
    PartialProcessKey processKey = new ProcessKey(processEntry.instanceId(), processEntry.createdAt());
    String resource = Constants.Files.JOB_ATTACHMENTS_DIR_NAME + "/";
    List<String> l = stateManager.list(processKey, resource);
    return l.stream().map(s -> s.substring(resource.length())).collect(Collectors.toList());
}
Also used : ProcessWaitManager(com.walmartlabs.concord.server.process.waits.ProcessWaitManager) Resource(org.sonatype.siesta.Resource) Size(javax.validation.constraints.Size) ProcessLogAccessManager(com.walmartlabs.concord.server.process.logs.ProcessLogAccessManager) PolicyManager(com.walmartlabs.concord.server.policy.PolicyManager) LoggerFactory(org.slf4j.LoggerFactory) ProcessResult(com.walmartlabs.concord.server.process.ProcessManager.ProcessResult) ApiParam(io.swagger.annotations.ApiParam) MultipartInput(org.jboss.resteasy.plugins.providers.multipart.MultipartInput) ProcessKeyCache(com.walmartlabs.concord.server.process.queue.ProcessKeyCache) ApiOperation(io.swagger.annotations.ApiOperation) ProcessQueueDao(com.walmartlabs.concord.server.process.queue.ProcessQueueDao) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ProcessWaitEntry(com.walmartlabs.concord.server.process.ProcessEntry.ProcessWaitEntry) Path(java.nio.file.Path) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessConfiguration(com.walmartlabs.concord.server.cfg.ProcessConfiguration) ProcessLogManager(com.walmartlabs.concord.server.process.logs.ProcessLogManager) IOUtils(com.walmartlabs.concord.common.IOUtils) EncryptedProjectValueManager(com.walmartlabs.concord.server.org.project.EncryptedProjectValueManager) ProcessStatus(com.walmartlabs.concord.server.sdk.ProcessStatus) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) SecretStoreConfiguration(com.walmartlabs.concord.server.cfg.SecretStoreConfiguration) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) javax.ws.rs(javax.ws.rs) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException) CheckResult(com.walmartlabs.concord.policyengine.CheckResult) HttpUtils(com.walmartlabs.concord.server.HttpUtils) java.util(java.util) AbstractWaitCondition(com.walmartlabs.concord.server.process.waits.AbstractWaitCondition) ProcessQueueManager(com.walmartlabs.concord.server.process.queue.ProcessQueueManager) AttachmentsRule(com.walmartlabs.concord.policyengine.AttachmentsRule) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) Singleton(javax.inject.Singleton) ConfigurationUtils(com.walmartlabs.concord.common.ConfigurationUtils) StandardCopyOption(java.nio.file.StandardCopyOption) MessageFormat(java.text.MessageFormat) ProcessStateManager.zipTo(com.walmartlabs.concord.server.process.state.ProcessStateManager.zipTo) Inject(javax.inject.Inject) MultipartUtils(com.walmartlabs.concord.server.MultipartUtils) ExpressionUtils(com.walmartlabs.concord.server.events.ExpressionUtils) EntryPoint(com.walmartlabs.concord.server.process.PayloadManager.EntryPoint) HttpServletRequest(javax.servlet.http.HttpServletRequest) Constants(com.walmartlabs.concord.sdk.Constants) PolicyEngine(com.walmartlabs.concord.policyengine.PolicyEngine) Imports(com.walmartlabs.concord.imports.Imports) OffsetDateTimeParam(com.walmartlabs.concord.server.OffsetDateTimeParam) Api(io.swagger.annotations.Api) ZipArchiveOutputStream(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream) Named(javax.inject.Named) Status(javax.ws.rs.core.Response.Status) ProcessStatusHistoryEntry(com.walmartlabs.concord.server.process.ProcessEntry.ProcessStatusHistoryEntry) ProcessLog(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog) Roles(com.walmartlabs.concord.server.security.Roles) UserPrincipal(com.walmartlabs.concord.server.security.UserPrincipal) ProcessStateManager(com.walmartlabs.concord.server.process.state.ProcessStateManager) Logger(org.slf4j.Logger) Files(java.nio.file.Files) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Validate(org.sonatype.siesta.Validate) PolicyException(com.walmartlabs.concord.server.policy.PolicyException) ProjectAccessManager(com.walmartlabs.concord.server.org.project.ProjectAccessManager) javax.ws.rs.core(javax.ws.rs.core) ProcessFilter(com.walmartlabs.concord.server.process.queue.ProcessFilter) OrganizationManager(com.walmartlabs.concord.server.org.OrganizationManager) java.io(java.io) ProcessStateManager.path(com.walmartlabs.concord.server.process.state.ProcessStateManager.path) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) ResourceAccessLevel(com.walmartlabs.concord.server.org.ResourceAccessLevel) Authorization(io.swagger.annotations.Authorization) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ConfigurationUtils (com.walmartlabs.concord.common.ConfigurationUtils)1 IOUtils (com.walmartlabs.concord.common.IOUtils)1 Imports (com.walmartlabs.concord.imports.Imports)1 AttachmentsRule (com.walmartlabs.concord.policyengine.AttachmentsRule)1 CheckResult (com.walmartlabs.concord.policyengine.CheckResult)1 PolicyEngine (com.walmartlabs.concord.policyengine.PolicyEngine)1 Constants (com.walmartlabs.concord.sdk.Constants)1 HttpUtils (com.walmartlabs.concord.server.HttpUtils)1 MultipartUtils (com.walmartlabs.concord.server.MultipartUtils)1 OffsetDateTimeParam (com.walmartlabs.concord.server.OffsetDateTimeParam)1 ProcessConfiguration (com.walmartlabs.concord.server.cfg.ProcessConfiguration)1 SecretStoreConfiguration (com.walmartlabs.concord.server.cfg.SecretStoreConfiguration)1 ExpressionUtils (com.walmartlabs.concord.server.events.ExpressionUtils)1 OrganizationManager (com.walmartlabs.concord.server.org.OrganizationManager)1 ResourceAccessLevel (com.walmartlabs.concord.server.org.ResourceAccessLevel)1 EncryptedProjectValueManager (com.walmartlabs.concord.server.org.project.EncryptedProjectValueManager)1 ProjectAccessManager (com.walmartlabs.concord.server.org.project.ProjectAccessManager)1 PolicyException (com.walmartlabs.concord.server.policy.PolicyException)1 PolicyManager (com.walmartlabs.concord.server.policy.PolicyManager)1