001package org.apache.archiva.indexer.merger.base; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.indexer.ArchivaIndexingContext; 023import org.apache.archiva.indexer.merger.IndexMerger; 024import org.apache.archiva.indexer.merger.IndexMergerException; 025import org.slf4j.Logger; 026import org.slf4j.LoggerFactory; 027 028/** 029 * @author Olivier Lamy 030 * @since 2.0.0 031 */ 032public class MergedRemoteIndexesTask 033 implements Runnable 034{ 035 036 private Logger logger = LoggerFactory.getLogger( getClass() ); 037 038 private MergedRemoteIndexesTaskRequest mergedRemoteIndexesTaskRequest; 039 040 public MergedRemoteIndexesTask( MergedRemoteIndexesTaskRequest mergedRemoteIndexesTaskRequest ) 041 { 042 this.mergedRemoteIndexesTaskRequest = mergedRemoteIndexesTaskRequest; 043 } 044 045 @Override 046 public void run() 047 { 048 try 049 { 050 this.execute(); 051 } 052 catch ( IndexMergerException e ) 053 { 054 logger.error( e.getMessage(), e ); 055 } 056 } 057 058 public MergedRemoteIndexesTaskResult execute() 059 throws IndexMergerException 060 { 061 IndexMerger indexMerger = mergedRemoteIndexesTaskRequest.getIndexMerger(); 062 063 ArchivaIndexingContext indexingContext = 064 indexMerger.buildMergedIndex( mergedRemoteIndexesTaskRequest.getIndexMergerRequest() ); 065 066 return new MergedRemoteIndexesTaskResult( indexingContext ); 067 } 068 069 @Override 070 public boolean equals( Object o ) 071 { 072 if ( this == o ) 073 { 074 return true; 075 } 076 if ( !( o instanceof MergedRemoteIndexesTask ) ) 077 { 078 return false; 079 } 080 081 MergedRemoteIndexesTask that = (MergedRemoteIndexesTask) o; 082 083 return mergedRemoteIndexesTaskRequest.equals( that.mergedRemoteIndexesTaskRequest ); 084 } 085 086 @Override 087 public int hashCode() 088 { 089 return mergedRemoteIndexesTaskRequest.hashCode(); 090 } 091}