2016-10-11 1 views
1

sonaytype nexus 2.14.0-01에 업로드 된 이슈 (zip 파일이 포함 된)에 액세스하여 tmp 디렉토리에 압축을 풀고 내용을 검사하려고합니다.업로드 후 넥서스 플러그인에서 Sonatype nexus artifact에 액세스하십시오.

생성 작업에 대한 핸들 요청에 연결할 수 있지만 그 시점에 이슈가 아직 리포지토리에 업로드되지 않았습니다.

public void onHandle(Repository repository, ResourceStoreRequest resourceStoreRequest, Action action) throws ItemNotFoundException, IllegalOperationException 
{ 
    log.info("got onHandle Request for " + repository.toString() + " " + action.toString() + " " + resourceStoreRequest.toString()); 
    log.info("that is the file to process: " + resourceStoreRequest.getRequestPath()); 
} 

로그 항목 :

2016-10-11 18:01:23,760+0200 INFO [qtp1685232414-73] admin DeliveryRequestProcessor - got onHandle Request for M2Repository(id=deliveries) create ResourceStoreRequest{requestPath='/fakepath/configurationmanagement/0.1/configurationmanagement-0.1.zip', requestContext=RequestContext{[email protected], parent=null}, pathStack=[], processedRepositories=[], appliedMappings={}}(GAVCE=fakepath:configurationmanagement:0.1:c=null:e=zip, for "deliveries" [id=deliveries]) 

하지만

repository.getLocalStorage().retrieveItem(repository,resourceStoreRequest) 

에 대한 호출이 (자연스럽게) 실패합니다.

파일 업로드 후 처리 할 수있는 훅에 대한 조언이 있습니까?

안부, 에드워드

답변

0

내가 필요한 기능을 구현하기 위해 그리 좋은 해결 방법을 사용했다.

원래 클래스에서는 Listener를 EventBus에 등록합니다.

@Named(DeliveryRequestProcessor.ID) 
public class DeliveryRequestProcessor extends ComponentSupport 
    implements RequestStrategy { 

    @Inject 
    public DeliveryRequestProcessor(final EventBus eventBus) 
    { 
     this.eventBus = Preconditions.checkNotNull(eventBus); 
     eventBus.register(new EventBusListener()); 
    } 
} 

나는 넥서스가 보내는 모든 이벤트에 가입하여 다른 클래스를 만들었습니다. 이 솔루션에는 몇 가지 단점이있다. 예를 들어. 이벤트가 여러 번 발생하고 처리가 하나만 수행되도록해야하지만 첫 번째 솔루션은 수용 할 수 있어야합니다 (나를 위해).

감사합니다. Eduard