Search in sources :

Example 16 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ConsoleService method isStorageQueryExists.

@GET
@Path("/org/{orgName}/jsonstore/{storeName}/query/{queryName}/exists")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean isStorageQueryExists(@PathParam("orgName") @ConcordKey String orgName, @PathParam("storeName") String storeName, @PathParam("queryName") String queryName) {
    try {
        OrganizationEntry org = orgManager.assertAccess(orgName, true);
        JsonStoreEntry storage = jsonStoreAccessManager.assertAccess(org.getId(), null, storeName, ResourceAccessLevel.READER, true);
        return storageQueryDao.getId(storage.id(), queryName) != null;
    } catch (UnauthorizedException e) {
        return false;
    }
}
Also used : JsonStoreEntry(com.walmartlabs.concord.server.org.jsonstore.JsonStoreEntry) UnauthorizedException(org.apache.shiro.authz.UnauthorizedException) OrganizationEntry(com.walmartlabs.concord.server.org.OrganizationEntry) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 17 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ConsoleService method isApiTokenExists.

@GET
@Path("/apikey/{name}/exists")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public boolean isApiTokenExists(@PathParam("name") @ConcordKey String tokenName) {
    UserPrincipal currentUser = UserPrincipal.getCurrent();
    if (currentUser == null) {
        return false;
    }
    UUID userId = currentUser.getId();
    return apiKeyDao.getId(userId, tokenName) != null;
}
Also used : UserPrincipal(com.walmartlabs.concord.server.security.UserPrincipal) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 18 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class GithubTriggerV2Processor method process.

@Override
@WithTimer
public void process(String eventName, Payload payload, UriInfo uriInfo, List<Result> result) {
    GithubKey githubKey = GithubKey.getCurrent();
    UUID projectId = githubKey.getProjectId();
    List<TriggerEntry> triggers = listTriggers(projectId, payload.getOrg(), payload.getRepo());
    for (TriggerEntry t : triggers) {
        // skip empty push events if the trigger's configuration says so
        if (GithubUtils.ignoreEmptyPush(t) && GithubUtils.isEmptyPush(eventName, payload)) {
            continue;
        }
        Map<String, Object> event = buildEvent(eventName, payload);
        enrichEventConditions(payload, t, event);
        if (DefaultEventFilter.filter(event, t)) {
            result.add(Result.from(event, t));
        }
    }
}
Also used : GithubKey(com.walmartlabs.concord.server.security.github.GithubKey) TriggerEntry(com.walmartlabs.concord.server.org.triggers.TriggerEntry) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Example 19 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessLogResourceV2 method data.

/**
 * Retrieves a log segment' data.
 */
@GET
@ApiOperation(value = "Retrieve the log")
@Path("/{id}/log/segment/{segmentId}/data")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@WithTimer
public Response data(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("segmentId") long segmentId, @HeaderParam("range") String rangeHeader) {
    ProcessKey processKey = logAccessManager.assertLogAccess(instanceId);
    HttpUtils.Range range = HttpUtils.parseRangeHeaderValue(rangeHeader);
    ProcessLog l = logManager.segmentData(processKey, segmentId, range.start(), range.end());
    return toResponse(instanceId, segmentId, l, range);
}
Also used : HttpUtils(com.walmartlabs.concord.server.HttpUtils) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) ProcessLog(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 20 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessLogResourceV2 method segment.

/**
 * Create a new process log segment.
 */
@POST
@ApiOperation(value = "Create process log segment")
@Path("{id}/log/segment")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public LogSegmentOperationResponse segment(@ApiParam @PathParam("id") UUID instanceId, @ApiParam LogSegmentRequest request) {
    ProcessKey processKey = logAccessManager.assertLogAccess(instanceId);
    long segmentId = logManager.createSegment(processKey, request.correlationId(), request.name(), request.createdAt());
    return new LogSegmentOperationResponse(segmentId, OperationResult.CREATED);
}
Also used : ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)64 ApiOperation (io.swagger.annotations.ApiOperation)32 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)26 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)24 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)22 UserPrincipal (com.walmartlabs.concord.server.security.UserPrincipal)16 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)10 UUID (java.util.UUID)9 ProcessEntry (com.walmartlabs.concord.server.process.ProcessEntry)7 EntryPoint (com.walmartlabs.concord.server.process.PayloadManager.EntryPoint)6 Inject (javax.inject.Inject)5 Named (javax.inject.Named)5 Payload (com.walmartlabs.concord.server.process.Payload)4 Path (java.nio.file.Path)4 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HttpUtils (com.walmartlabs.concord.server.HttpUtils)3 ProcessFilter (com.walmartlabs.concord.server.process.queue.ProcessFilter)3 UserEntry (com.walmartlabs.concord.server.user.UserEntry)3 IOException (java.io.IOException)3