Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ScanTask.java 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.repository.model.RepositoryTask;
  22. import java.io.Serializable;
  23. /**
  24. * @author Martin Stockhammer <martin_s@apache.org>
  25. */
  26. @Schema(name="ScanTask", description = "Repository scan task information")
  27. public class ScanTask implements Serializable
  28. {
  29. private static final long serialVersionUID = -681163357370848098L;
  30. private String repositoryId="";
  31. private boolean updateRelatedArtifacts;
  32. private boolean fullRepository;
  33. private boolean running = false;
  34. private String resource = "";
  35. private long maxExecutionTimeMs = 0;
  36. public static ScanTask of( MetadataScanTask repositoryTask ) {
  37. ScanTask scanTask = new ScanTask( );
  38. scanTask.setFullRepository( repositoryTask.isFullScan());
  39. scanTask.setUpdateRelatedArtifacts( repositoryTask.isUpdateRelatedArtifacts() );
  40. scanTask.setResource( repositoryTask.getResource() );
  41. scanTask.setMaxExecutionTimeMs( repositoryTask.getMaxExecutionTimeMs() );
  42. scanTask.setRepositoryId( repositoryTask.getRepositoryId( ) );
  43. return scanTask;
  44. }
  45. @Schema(name="repository_id", description = "Identifier of the repository, this task is running on")
  46. public String getRepositoryId( )
  47. {
  48. return repositoryId;
  49. }
  50. public void setRepositoryId( String repositoryId )
  51. {
  52. this.repositoryId = repositoryId==null?"":repositoryId;
  53. }
  54. @Schema(name="update_related_artifacts", description = "True, if related artifacts are updated too.")
  55. public boolean isUpdateRelatedArtifacts( )
  56. {
  57. return updateRelatedArtifacts;
  58. }
  59. public void setUpdateRelatedArtifacts( boolean updateRelatedArtifacts )
  60. {
  61. this.updateRelatedArtifacts = updateRelatedArtifacts;
  62. }
  63. @Schema(name="full_repository",description = "True, if this is a full repository scan")
  64. public boolean isFullRepository( )
  65. {
  66. return fullRepository;
  67. }
  68. public void setFullRepository( boolean fullRepository )
  69. {
  70. this.fullRepository = fullRepository;
  71. }
  72. @Schema(name="running", description = "True, if this task is currently running")
  73. public boolean isRunning( )
  74. {
  75. return running;
  76. }
  77. public void setRunning( boolean running )
  78. {
  79. this.running = running;
  80. }
  81. @Schema(name="resource",description = "Name of the resource to update")
  82. public String getResource( )
  83. {
  84. return resource;
  85. }
  86. public void setResource( String resource )
  87. {
  88. this.resource = resource==null?"":resource;
  89. }
  90. @Schema(name="max_excecution_time_ms",description = "Maximum execution time in ms")
  91. public long getMaxExecutionTimeMs( )
  92. {
  93. return maxExecutionTimeMs;
  94. }
  95. public void setMaxExecutionTimeMs( long maxExecutionTimeMs )
  96. {
  97. this.maxExecutionTimeMs = maxExecutionTimeMs;
  98. }
  99. @Override
  100. public boolean equals( Object o )
  101. {
  102. if ( this == o ) return true;
  103. if ( o == null || getClass( ) != o.getClass( ) ) return false;
  104. ScanTask scanTask = (ScanTask) o;
  105. if ( updateRelatedArtifacts != scanTask.updateRelatedArtifacts ) return false;
  106. if ( fullRepository != scanTask.fullRepository ) return false;
  107. if ( running != scanTask.running ) return false;
  108. if ( maxExecutionTimeMs != scanTask.maxExecutionTimeMs ) return false;
  109. if ( !repositoryId.equals( scanTask.repositoryId ) ) return false;
  110. return resource.equals( scanTask.resource );
  111. }
  112. @Override
  113. public int hashCode( )
  114. {
  115. int result = repositoryId.hashCode( );
  116. result = 31 * result + ( updateRelatedArtifacts ? 1 : 0 );
  117. result = 31 * result + ( fullRepository ? 1 : 0 );
  118. result = 31 * result + ( running ? 1 : 0 );
  119. result = 31 * result + resource.hashCode( );
  120. result = 31 * result + (int) ( maxExecutionTimeMs ^ ( maxExecutionTimeMs >>> 32 ) );
  121. return result;
  122. }
  123. @Override
  124. public String toString( )
  125. {
  126. final StringBuilder sb = new StringBuilder( "ScanTask{" );
  127. sb.append( "repositoryId='" ).append( repositoryId ).append( '\'' );
  128. sb.append( ", updateRelatedArtifacts=" ).append( updateRelatedArtifacts );
  129. sb.append( ", fullRepository=" ).append( fullRepository );
  130. sb.append( ", running=" ).append( running );
  131. sb.append( ", resource='" ).append( resource ).append( '\'' );
  132. sb.append( ", maxExecutionTimeMs=" ).append( maxExecutionTimeMs );
  133. sb.append( '}' );
  134. return sb.toString( );
  135. }
  136. }