You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ScanStatus.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package org.apache.archiva.rest.api.model.v2;
  2. /*
  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
  10. *
  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
  17. * under the License.
  18. */
  19. import io.swagger.v3.oas.annotations.media.Schema;
  20. import org.apache.archiva.admin.model.beans.MetadataScanTask;
  21. import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
  22. import org.apache.archiva.scheduler.repository.model.RepositoryTask;
  23. import java.io.Serializable;
  24. import java.util.ArrayList;
  25. import java.util.List;
  26. import java.util.stream.Collectors;
  27. /**
  28. * @author Martin Stockhammer <martin_s@apache.org>
  29. */
  30. @Schema(name="ScanStatus", description = "Status of repository scan tasks")
  31. public class ScanStatus implements Serializable
  32. {
  33. private boolean scanRunning = false;
  34. private int scanQueued = 0;
  35. private boolean indexRunning = false;
  36. private int indexQueued = 0;
  37. private List<IndexingTask> indexingQueue = new ArrayList<>( );
  38. private List<ScanTask> scanQueue = new ArrayList<>( );
  39. public ScanStatus( )
  40. {
  41. }
  42. public static ScanStatus of( org.apache.archiva.admin.model.beans.ScanStatus modelStatus ) {
  43. ScanStatus status = new ScanStatus( );
  44. status.setIndexRunning( modelStatus.isIndexScanRunning() );
  45. status.setScanRunning( modelStatus.isMetadataScanRunning() );
  46. List<org.apache.archiva.admin.model.beans.IndexingTask> indexQueue = modelStatus.getIndexingQueue( );
  47. status.setIndexingQueue( indexQueue.stream().map(IndexingTask::of).collect( Collectors.toList()) );
  48. status.setIndexQueued( indexQueue.size( ) > 0 ? indexQueue.size( ) - 1 : 0 );
  49. List<MetadataScanTask> scanQueue = modelStatus.getScanQueue( );
  50. status.setScanQueue( scanQueue.stream().map( ScanTask::of ).collect( Collectors.toList()) );
  51. status.setScanQueued( scanQueue.size( ) > 0 ? scanQueue.size( ) - 1 : 0 );
  52. return status;
  53. }
  54. @Schema( name = "scan_running", description = "True, if a scan is currently running" )
  55. public boolean isScanRunning( )
  56. {
  57. return scanRunning;
  58. }
  59. public void setScanRunning( boolean scanRunning )
  60. {
  61. this.scanRunning = scanRunning;
  62. }
  63. @Schema(name ="scan_queued", description = "Number of scans in the task queue")
  64. public int getScanQueued( )
  65. {
  66. return scanQueued;
  67. }
  68. public void setScanQueued( int scanQueued )
  69. {
  70. this.scanQueued = scanQueued;
  71. }
  72. @Schema(name="index_running", description = "True, if there is a index task currently running")
  73. public boolean isIndexRunning( )
  74. {
  75. return indexRunning;
  76. }
  77. public void setIndexRunning( boolean indexRunning )
  78. {
  79. this.indexRunning = indexRunning;
  80. }
  81. @Schema(name="index_queued", description = "Number of queued index tasks")
  82. public int getIndexQueued( )
  83. {
  84. return indexQueued;
  85. }
  86. public void setIndexQueued( int indexQueued )
  87. {
  88. this.indexQueued = indexQueued;
  89. }
  90. @Schema( name = "indexing_queue", description = "List of indexing tasks waiting for execution" )
  91. public List<IndexingTask> getIndexingQueue( )
  92. {
  93. return indexingQueue;
  94. }
  95. public void setIndexingQueue( List<IndexingTask> indexingQueue )
  96. {
  97. this.indexingQueue = new ArrayList<>( indexingQueue );
  98. }
  99. @Schema(name="scan_queue", description = "List of scan tasks waiting for execution")
  100. public List<ScanTask> getScanQueue( )
  101. {
  102. return scanQueue;
  103. }
  104. public void setScanQueue( List<ScanTask> scanQueue )
  105. {
  106. this.scanQueue = new ArrayList<>( scanQueue );
  107. }
  108. }