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.repository.model.RepositoryTask;
24 import java.io.Serializable;
27 * @author Martin Stockhammer <martin_s@apache.org>
29 @Schema(name="ScanTask", description = "Repository scan task information")
30 public class ScanTask implements Serializable
32 private static final long serialVersionUID = -681163357370848098L;
33 private String repositoryId="";
34 private boolean updateRelatedArtifacts;
35 private boolean fullRepository;
36 private boolean running = false;
37 private String resource = "";
38 private long maxExecutionTimeMs = 0;
40 public static ScanTask of( MetadataScanTask repositoryTask ) {
41 ScanTask scanTask = new ScanTask( );
42 scanTask.setFullRepository( repositoryTask.isFullScan());
43 scanTask.setUpdateRelatedArtifacts( repositoryTask.isUpdateRelatedArtifacts() );
44 scanTask.setResource( repositoryTask.getResource() );
45 scanTask.setMaxExecutionTimeMs( repositoryTask.getMaxExecutionTimeMs() );
46 scanTask.setRepositoryId( repositoryTask.getRepositoryId( ) );
50 @Schema(name="repository_id", description = "Identifier of the repository, this task is running on")
51 public String getRepositoryId( )
56 public void setRepositoryId( String repositoryId )
58 this.repositoryId = repositoryId==null?"":repositoryId;
61 @Schema(name="update_related_artifacts", description = "True, if related artifacts are updated too.")
62 public boolean isUpdateRelatedArtifacts( )
64 return updateRelatedArtifacts;
67 public void setUpdateRelatedArtifacts( boolean updateRelatedArtifacts )
69 this.updateRelatedArtifacts = updateRelatedArtifacts;
72 @Schema(name="full_repository",description = "True, if this is a full repository scan")
73 public boolean isFullRepository( )
75 return fullRepository;
78 public void setFullRepository( boolean fullRepository )
80 this.fullRepository = fullRepository;
83 @Schema(name="running", description = "True, if this task is currently running")
84 public boolean isRunning( )
89 public void setRunning( boolean running )
91 this.running = running;
94 @Schema(name="resource",description = "Name of the resource to update")
95 public String getResource( )
100 public void setResource( String resource )
102 this.resource = resource==null?"":resource;
105 @Schema(name="max_excecution_time_ms",description = "Maximum execution time in ms")
106 public long getMaxExecutionTimeMs( )
108 return maxExecutionTimeMs;
111 public void setMaxExecutionTimeMs( long maxExecutionTimeMs )
113 this.maxExecutionTimeMs = maxExecutionTimeMs;
117 public boolean equals( Object o )
119 if ( this == o ) return true;
120 if ( o == null || getClass( ) != o.getClass( ) ) return false;
122 ScanTask scanTask = (ScanTask) o;
124 if ( updateRelatedArtifacts != scanTask.updateRelatedArtifacts ) return false;
125 if ( fullRepository != scanTask.fullRepository ) return false;
126 if ( running != scanTask.running ) return false;
127 if ( maxExecutionTimeMs != scanTask.maxExecutionTimeMs ) return false;
128 if ( !repositoryId.equals( scanTask.repositoryId ) ) return false;
129 return resource.equals( scanTask.resource );
133 public int hashCode( )
135 int result = repositoryId.hashCode( );
136 result = 31 * result + ( updateRelatedArtifacts ? 1 : 0 );
137 result = 31 * result + ( fullRepository ? 1 : 0 );
138 result = 31 * result + ( running ? 1 : 0 );
139 result = 31 * result + resource.hashCode( );
140 result = 31 * result + (int) ( maxExecutionTimeMs ^ ( maxExecutionTimeMs >>> 32 ) );
145 public String toString( )
147 final StringBuilder sb = new StringBuilder( "ScanTask{" );
148 sb.append( "repositoryId='" ).append( repositoryId ).append( '\'' );
149 sb.append( ", updateRelatedArtifacts=" ).append( updateRelatedArtifacts );
150 sb.append( ", fullRepository=" ).append( fullRepository );
151 sb.append( ", running=" ).append( running );
152 sb.append( ", resource='" ).append( resource ).append( '\'' );
153 sb.append( ", maxExecutionTimeMs=" ).append( maxExecutionTimeMs );
155 return sb.toString( );