Search in sources :

Example 46 with TrackingKey

use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.

the class EventAuditListener method transformFileGroupingEvent.

private void transformFileGroupingEvent(PromoteCompleteEvent event, FileGroupingEvent fileGroupingEvent) {
    PathsPromoteCompleteEvent pathsPromoteCompleteEvent = (PathsPromoteCompleteEvent) event;
    PathsPromoteResult promoteResult = pathsPromoteCompleteEvent.getPromoteResult();
    String error = promoteResult.getError();
    if (error != null) {
        logger.trace("Error in promoteResult, skip audit.");
        return;
    }
    Set<String> paths = promoteResult.getCompletedPaths();
    if (paths.isEmpty()) {
        logger.trace("No completedPaths, skip audit.");
        return;
    }
    PathsPromoteRequest req = promoteResult.getRequest();
    StoreKey source = req.getSource();
    StoreKey target = req.getTarget();
    // TODO How about generating the key if it does not exist.
    TrackingKey trackingKey = getTrackingKey(source);
    if (trackingKey == null) {
        logger.trace("No tracking key found to: {}", source);
        return;
    }
    Map<String, String> extra = new HashMap<>();
    extra.put(EventConstants.SOURCE, source.toString());
    extra.put(EventConstants.TARGET, target.toString());
    fileGroupingEvent.setExtra(extra);
    fileGroupingEvent.setTimestamp(new Date());
    fileGroupingEvent.setSessionId(trackingKey.getId());
}
Also used : PathsPromoteCompleteEvent(org.commonjava.indy.promote.change.event.PathsPromoteCompleteEvent) HashMap(java.util.HashMap) PathsPromoteResult(org.commonjava.indy.promote.model.PathsPromoteResult) PathsPromoteRequest(org.commonjava.indy.promote.model.PathsPromoteRequest) StoreKey(org.commonjava.indy.model.core.StoreKey) Date(java.util.Date) TrackingKey(org.commonjava.indy.folo.model.TrackingKey)

Aggregations

TrackingKey (org.commonjava.indy.folo.model.TrackingKey)46 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)18 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Path (javax.ws.rs.Path)12 StoreKey (org.commonjava.indy.model.core.StoreKey)11 Test (org.junit.Test)11 TrackedContent (org.commonjava.indy.folo.model.TrackedContent)10 TrackedContentEntry (org.commonjava.indy.folo.model.TrackedContentEntry)10 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)8 GET (javax.ws.rs.GET)6 HEAD (javax.ws.rs.HEAD)6 PUT (javax.ws.rs.PUT)6 AccessChannel (org.commonjava.indy.model.core.AccessChannel)6 Inject (javax.inject.Inject)4 Context (javax.ws.rs.core.Context)4 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)4 Location (org.commonjava.maven.galley.model.Location)4 Transfer (org.commonjava.maven.galley.model.Transfer)4 Logger (org.slf4j.Logger)4