aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-repository-api
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-06-06 21:36:46 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-06-06 21:36:46 +0200
commitc2bbd80b1b728fb6e7bff05d6fe2123c8b0f6122 (patch)
tree1227739dbb9f7975c825687b4763c97ccd4f1c6c /archiva-modules/archiva-base/archiva-repository-api
parent6c0afa8b8f2210fa32644cf17a8fa004a98719db (diff)
downloadarchiva-c2bbd80b1b728fb6e7bff05d6fe2123c8b0f6122.tar.gz
archiva-c2bbd80b1b728fb6e7bff05d6fe2123c8b0f6122.zip
Adding type for repository group config
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-api')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java42
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java32
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java192
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java43
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java119
5 files changed, 428 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
new file mode 100644
index 000000000..79c7466cc
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java
@@ -0,0 +1,42 @@
+package org.apache.archiva.indexer.merger;
+/*
+ * 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.indexer.ArchivaIndexingContext;
+
+import java.util.Collection;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M2
+ */
+public interface IndexMerger
+{
+ /**
+ * @param indexMergerRequest
+ * @return a temporary directory with a merge index (directory marked deleteOnExit)
+ * @throws IndexMergerException
+ */
+ ArchivaIndexingContext buildMergedIndex(IndexMergerRequest indexMergerRequest )
+ throws IndexMergerException;
+
+ void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex );
+
+ Collection<TemporaryGroupIndex> getTemporaryGroupIndexes();
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java
new file mode 100644
index 000000000..3930831d6
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java
@@ -0,0 +1,32 @@
+package org.apache.archiva.indexer.merger;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M2
+ */
+public class IndexMergerException
+ extends Exception
+{
+ public IndexMergerException( String message, Throwable t )
+ {
+ super( message, t );
+ }
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java
new file mode 100644
index 000000000..0b3803f48
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java
@@ -0,0 +1,192 @@
+package org.apache.archiva.indexer.merger;
+/*
+ * 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 java.nio.file.Path;
+import java.util.Collection;
+
+/**
+ * @author Olivier Lamy
+ */
+public class IndexMergerRequest
+{
+ /**
+ * repositories Ids to merge content
+ */
+ private Collection<String> repositoriesIds;
+
+ /**
+ * will generate a downloadable index
+ */
+ private boolean packIndex;
+
+ /**
+ * original groupId (repositoryGroup id)
+ */
+ private String groupId;
+
+ private String mergedIndexPath = ".indexer";
+
+ private int mergedIndexTtl;
+
+ private Path mergedIndexDirectory;
+
+ private boolean temporary;
+
+ public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId )
+ {
+ this.repositoriesIds = repositoriesIds;
+ this.packIndex = packIndex;
+ this.groupId = groupId;
+ }
+
+ /**
+ * @since 1.4-M4
+ */
+ public IndexMergerRequest( Collection<String> repositoriesIds, boolean packIndex, String groupId,
+ String mergedIndexPath, int mergedIndexTtl )
+ {
+ this.repositoriesIds = repositoriesIds;
+ this.packIndex = packIndex;
+ this.groupId = groupId;
+ this.mergedIndexPath = mergedIndexPath;
+ this.mergedIndexTtl = mergedIndexTtl;
+ }
+
+ public Collection<String> getRepositoriesIds()
+ {
+ return repositoriesIds;
+ }
+
+ public void setRepositoriesIds( Collection<String> repositoriesIds )
+ {
+ this.repositoriesIds = repositoriesIds;
+ }
+
+ public boolean isPackIndex()
+ {
+ return packIndex;
+ }
+
+ public void setPackIndex( boolean packIndex )
+ {
+ this.packIndex = packIndex;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public String getMergedIndexPath()
+ {
+ return mergedIndexPath;
+ }
+
+ public void setMergedIndexPath( String mergedIndexPath )
+ {
+ this.mergedIndexPath = mergedIndexPath;
+ }
+
+ public int getMergedIndexTtl()
+ {
+ return mergedIndexTtl;
+ }
+
+ public void setMergedIndexTtl( int mergedIndexTtl )
+ {
+ this.mergedIndexTtl = mergedIndexTtl;
+ }
+
+ public Path getMergedIndexDirectory()
+ {
+ return mergedIndexDirectory;
+ }
+
+ public void setMergedIndexDirectory( Path mergedIndexDirectory )
+ {
+ this.mergedIndexDirectory = mergedIndexDirectory;
+ }
+
+ public IndexMergerRequest mergedIndexDirectory( Path mergedIndexDirectory )
+ {
+ this.mergedIndexDirectory = mergedIndexDirectory;
+ return this;
+ }
+
+ public boolean isTemporary()
+ {
+ return temporary;
+ }
+
+ public void setTemporary( boolean temporary )
+ {
+ this.temporary = temporary;
+ }
+
+
+ public IndexMergerRequest temporary( boolean temporary )
+ {
+ this.temporary = temporary;
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder( "IndexMergerRequest{" );
+ sb.append( "repositoriesIds=" ).append( repositoriesIds );
+ sb.append( ", packIndex=" ).append( packIndex );
+ sb.append( ", groupId='" ).append( groupId ).append( '\'' );
+ sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
+ sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl );
+ sb.append( ", mergedIndexDirectory=" ).append( mergedIndexDirectory );
+ sb.append( ", temporary=" ).append( temporary );
+ sb.append( '}' );
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+
+ IndexMergerRequest that = (IndexMergerRequest) o;
+
+ return groupId.equals( that.groupId );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return groupId.hashCode();
+ }
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java
new file mode 100644
index 000000000..9ba97e701
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java
@@ -0,0 +1,43 @@
+package org.apache.archiva.scheduler;
+
+/*
+ * 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.repository.RepositoryGroup;
+
+import java.nio.file.Path;
+
+/**
+ * @author Olivier Lamy
+ * @since 2.0.0
+ */
+public interface MergedRemoteIndexesScheduler
+{
+
+ /**
+ * will check if this repository group need to a schedule a cron to download/merge
+ * remote indexes
+ * @param repositoryGroup
+ */
+ void schedule(RepositoryGroup repositoryGroup, Path directory );
+
+ void unschedule( RepositoryGroup repositoryGroup );
+
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java
new file mode 100644
index 000000000..d0b576b74
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java
@@ -0,0 +1,119 @@
+package org.apache.archiva.indexer.merger;
+/*
+ * 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 java.io.Serializable;
+import java.nio.file.Path;
+import java.util.Date;
+
+/**
+ * @author Olivier Lamy
+ */
+public class TemporaryGroupIndex
+ implements Serializable
+{
+ private long creationTime = new Date().getTime();
+
+ private Path directory;
+
+ private String indexId;
+
+ private String groupId;
+
+ private int mergedIndexTtl;
+
+ public TemporaryGroupIndex(Path directory, String indexId, String groupId, int mergedIndexTtl)
+ {
+ this.directory = directory;
+ this.indexId = indexId;
+ this.groupId = groupId;
+ this.mergedIndexTtl = mergedIndexTtl;
+ }
+
+ public long getCreationTime()
+ {
+ return creationTime;
+ }
+
+ public TemporaryGroupIndex setCreationTime( long creationTime )
+ {
+ this.creationTime = creationTime;
+ return this;
+ }
+
+ public Path getDirectory()
+ {
+ return directory;
+ }
+
+ public TemporaryGroupIndex setDirectory( Path directory )
+ {
+ this.directory = directory;
+ return this;
+ }
+
+ public String getIndexId()
+ {
+ return indexId;
+ }
+
+ public TemporaryGroupIndex setIndexId( String indexId )
+ {
+ this.indexId = indexId;
+ return this;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public int getMergedIndexTtl() {
+ return mergedIndexTtl;
+ }
+
+ public void setMergedIndexTtl(int mergedIndexTtl) {
+ this.mergedIndexTtl = mergedIndexTtl;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Long.toString( creationTime ).hashCode();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( !( o instanceof TemporaryGroupIndex ) )
+ {
+ return false;
+ }
+ return this.creationTime == ( (TemporaryGroupIndex) o ).creationTime;
+ }
+}