1 package org.apache.archiva.rest.api.model.v2;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 import io.swagger.v3.oas.annotations.media.Schema;
21 import org.apache.archiva.admin.model.beans.MetadataScanTask;
22 import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
23 import org.apache.archiva.scheduler.repository.model.RepositoryTask;
25 import java.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.stream.Collectors;
31 * @author Martin Stockhammer <martin_s@apache.org>
33 @Schema(name="ScanStatus", description = "Status of repository scan tasks")
34 public class ScanStatus implements Serializable
36 private boolean scanRunning = false;
37 private int scanQueued = 0;
38 private boolean indexRunning = false;
39 private int indexQueued = 0;
40 private List<IndexingTask> indexingQueue = new ArrayList<>( );
41 private List<ScanTask> scanQueue = new ArrayList<>( );
47 public static ScanStatus of( org.apache.archiva.admin.model.beans.ScanStatus modelStatus ) {
48 ScanStatus status = new ScanStatus( );
49 status.setIndexRunning( modelStatus.isIndexScanRunning() );
50 status.setScanRunning( modelStatus.isMetadataScanRunning() );
51 List<org.apache.archiva.admin.model.beans.IndexingTask> indexQueue = modelStatus.getIndexingQueue( );
52 status.setIndexingQueue( indexQueue.stream().map(IndexingTask::of).collect( Collectors.toList()) );
53 status.setIndexQueued( indexQueue.size( ) > 0 ? indexQueue.size( ) - 1 : 0 );
54 List<MetadataScanTask> scanQueue = modelStatus.getScanQueue( );
55 status.setScanQueue( scanQueue.stream().map( ScanTask::of ).collect( Collectors.toList()) );
56 status.setScanQueued( scanQueue.size( ) > 0 ? scanQueue.size( ) - 1 : 0 );
61 @Schema( name = "scan_running", description = "True, if a scan is currently running" )
62 public boolean isScanRunning( )
67 public void setScanRunning( boolean scanRunning )
69 this.scanRunning = scanRunning;
72 @Schema(name ="scan_queued", description = "Number of scans in the task queue")
73 public int getScanQueued( )
78 public void setScanQueued( int scanQueued )
80 this.scanQueued = scanQueued;
83 @Schema(name="index_running", description = "True, if there is a index task currently running")
84 public boolean isIndexRunning( )
89 public void setIndexRunning( boolean indexRunning )
91 this.indexRunning = indexRunning;
94 @Schema(name="index_queued", description = "Number of queued index tasks")
95 public int getIndexQueued( )
100 public void setIndexQueued( int indexQueued )
102 this.indexQueued = indexQueued;
105 @Schema( name = "indexing_queue", description = "List of indexing tasks waiting for execution" )
106 public List<IndexingTask> getIndexingQueue( )
108 return indexingQueue;
111 public void setIndexingQueue( List<IndexingTask> indexingQueue )
113 this.indexingQueue = new ArrayList<>( indexingQueue );
116 @Schema(name="scan_queue", description = "List of scan tasks waiting for execution")
117 public List<ScanTask> getScanQueue( )
122 public void setScanQueue( List<ScanTask> scanQueue )
124 this.scanQueue = new ArrayList<>( scanQueue );