我想访问上传到sonaytype nexus2.14.0-01的工件(包含交付的zip文件),将其解压缩到tmp目录中并检查其内容。
我能够挂接到创建操作的句柄请求中,但是,此时工件还没有上载到存储库。
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{this=org.sonatype.nexus.proxy.RequestContext@3476eab3, parent=null}, pathStack=[], processedRepositories=[], appliedMappings={}}(GAVCE=fakepath:configurationmanagement:0.1:c=null:e=zip, for "deliveries" [id=deliveries]) 而是一个呼唤
repository.getLocalStorage().retrieveItem(repository,resourceStoreRequest)(自然地)失败了。
在上传文件并可以处理之后,有没有关于使用什么钩子的建议?
致以最好的问候,爱德华
发布于 2016-10-13 00:28:46
我使用了一个不太好的变通方法来实现所需的功能。
在原始类中,我向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());
}
}我已经创建了另一个类,订阅nexus发送的所有事件。
@Named
@EagerSingleton
public class EventBusListener
{
public void onEvent (RepositoryItemEventStoreCreate e)
{
... the functionality to access the item
e.getItem() // -> that is the Storage Item I was looking for
}
}该解决方案有一些缺点,例如,事件多次触发,您需要确保只执行一次处理,但对于第一个解决方案,它是可以接受的(对我来说)。
致以最好的问候,爱德华
https://stackoverflow.com/questions/39982014
复制相似问题