From: Olivier Lamy Date: Mon, 29 Oct 2012 20:59:42 +0000 (+0000) Subject: [MRM-1704] Refactor to remove maven specific part from various repository/metadata... X-Git-Tag: archiva-1.4-M4~689 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7b2d0af209c5515125571b715a7ca1190425e11;p=archiva.git [MRM-1704] Refactor to remove maven specific part from various repository/metadata apis git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1403505 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/MockRepositoryArchivaTaskScheduler.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/MockRepositoryArchivaTaskScheduler.java new file mode 100644 index 000000000..db4cd1c8f --- /dev/null +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/MockRepositoryArchivaTaskScheduler.java @@ -0,0 +1,54 @@ +package org.apache.archiva.metadata.repository; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.redback.components.taskqueue.TaskQueueException; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; +import org.springframework.stereotype.Service; + +/** + * @author Olivier Lamy + */ +@Service ("archivaTaskScheduler#repository") +public class MockRepositoryArchivaTaskScheduler + implements RepositoryArchivaTaskScheduler +{ + public boolean isProcessingRepositoryTask( String repositoryId ) + { + return false; + } + + public boolean isProcessingRepositoryTask( RepositoryTask task ) + { + return false; + } + + public void queueTask( RepositoryTask task ) + throws TaskQueueException + { + // no op + } + + public boolean unQueueTask( RepositoryTask task ) + throws TaskQueueException + { + return false; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositoryArchivaTaskScheduler.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositoryArchivaTaskScheduler.java new file mode 100644 index 000000000..9c6271bdf --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/mock/MockRepositoryArchivaTaskScheduler.java @@ -0,0 +1,54 @@ +package org.apache.archiva.admin.mock; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.redback.components.taskqueue.TaskQueueException; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.archiva.scheduler.repository.RepositoryTask; +import org.springframework.stereotype.Service; + +/** + * @author Olivier Lamy + */ +@Service("archivaTaskScheduler#repository") +public class MockRepositoryArchivaTaskScheduler + implements RepositoryArchivaTaskScheduler +{ + public boolean isProcessingRepositoryTask( String repositoryId ) + { + return false; + } + + public boolean isProcessingRepositoryTask( RepositoryTask task ) + { + return false; + } + + public void queueTask( RepositoryTask task ) + throws TaskQueueException + { + // no op + } + + public boolean unQueueTask( RepositoryTask task ) + throws TaskQueueException + { + return false; + } +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml new file mode 100644 index 000000000..989c4d180 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + archiva-scheduler + org.apache.archiva + 1.4-M4-SNAPSHOT + + archiva-scheduler-repository-api + bundle + Archiva Scheduler :: Repository Scanning Api + + + org.apache.archiva + archiva-scheduler-api + + + commons-io + commons-io + + + org.apache.archiva.redback.components + spring-quartz + + + org.quartz-scheduler + quartz + + + c3p0 + c3p0 + + + javax.transaction + jta + + + + + org.apache.archiva + repository-statistics + + + org.apache.archiva + archiva-configuration + + + + org.slf4j + slf4j-api + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.archiva.scheduler.repository + ${project.version} + + org.apache.archiva.scheduler.repository;version=${project.version} + + + javax.annotation, + javax.inject, + org.apache.archiva.admin.model;version=${project.version}, + org.apache.archiva.admin.model.beans;version=${project.version}, + org.apache.archiva.admin.model.managed;version=${project.version}, + org.apache.archiva.common;version=${project.version}, + org.apache.archiva.configuration;version=${project.version}, + org.apache.archiva.metadata.repository*;version=${project.version}, + org.apache.archiva.repository.scanner;version=${project.version}, + org.apache.archiva.scheduler;version=${project.version}, + org.apache.commons.lang;version="[2.4,3)", + org.codehaus.plexus.personality.plexus.lifecycle.phase, + org.apache.archiva.redback.components.taskqueue*, + org.apache.archiva.redback.components.scheduler, + org.quartz*;version="[2,3)", + org.springframework*;version="[3,4)", + org.slf4j;resolution:=optional + + + + + + + + + org.apache.rat + apache-rat-plugin + + + src/test/resources/test-repo/** + src/test/repositories/** + + + + + + + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java new file mode 100644 index 000000000..b83835a0c --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryArchivaTaskScheduler.java @@ -0,0 +1,45 @@ +package org.apache.archiva.scheduler.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.redback.components.taskqueue.TaskQueueException; +import org.apache.archiva.scheduler.ArchivaTaskScheduler; + +/** + * Scheduling component for archiva repositories + */ +public interface RepositoryArchivaTaskScheduler + extends ArchivaTaskScheduler +{ + + + boolean isProcessingRepositoryTask( String repositoryId ); + + + boolean isProcessingRepositoryTask( RepositoryTask task ); + + void queueTask( RepositoryTask task ) + throws TaskQueueException; + + boolean unQueueTask( RepositoryTask task ) + throws TaskQueueException; + + +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java new file mode 100644 index 000000000..b023cdd2f --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository-api/src/main/java/org/apache/archiva/scheduler/repository/RepositoryTask.java @@ -0,0 +1,145 @@ +package org.apache.archiva.scheduler.repository; + +import org.apache.archiva.redback.components.taskqueue.Task; + +import java.io.File; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * DataRefreshTask - task for discovering changes in the repository + * and updating all associated data. + * + * + */ +public class RepositoryTask + implements Task +{ + private String repositoryId; + + private File resourceFile; + + private boolean updateRelatedArtifacts; + + private boolean scanAll; + + public boolean isScanAll() + { + return scanAll; + } + + public void setScanAll( boolean scanAll ) + { + this.scanAll = scanAll; + } + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public long getMaxExecutionTime() + { + return 0; + } + + public File getResourceFile() + { + return resourceFile; + } + + public void setResourceFile( File resourceFile ) + { + this.resourceFile = resourceFile; + } + + public boolean isUpdateRelatedArtifacts() + { + return updateRelatedArtifacts; + } + + public void setUpdateRelatedArtifacts( boolean updateRelatedArtifacts ) + { + this.updateRelatedArtifacts = updateRelatedArtifacts; + } + + @Override + public String toString() + { + return "RepositoryTask [repositoryId=" + repositoryId + ", resourceFile=" + resourceFile + ", scanAll=" + + scanAll + ", updateRelatedArtifacts=" + updateRelatedArtifacts + "]"; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ( ( repositoryId == null ) ? 0 : repositoryId.hashCode() ); + result = prime * result + ( ( resourceFile == null ) ? 0 : resourceFile.hashCode() ); + return result; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( obj == null ) + { + return false; + } + if ( getClass() != obj.getClass() ) + { + return false; + } + RepositoryTask other = (RepositoryTask) obj; + if ( repositoryId == null ) + { + if ( other.repositoryId != null ) + { + return false; + } + } + else if ( !repositoryId.equals( other.repositoryId ) ) + { + return false; + } + if ( resourceFile == null ) + { + if ( other.resourceFile != null ) + { + return false; + } + } + else if ( !resourceFile.equals( other.resourceFile ) ) + { + return false; + } + return true; + } +}