From 508529afe121516e1556bae444e08751c6633f57 Mon Sep 17 00:00:00 2001 From: John Arthorne Date: Fri, 15 Feb 2008 16:48:48 +0000 Subject: Renamed class to avoid confusion with mirror selection support --- .../internal/p2/artifact/mirror/Mirror.java | 64 ------------------- .../p2/artifact/mirror/MirrorApplication.java | 5 +- .../internal/p2/artifact/mirror/Mirroring.java | 71 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 65 deletions(-) delete mode 100644 bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirror.java create mode 100644 bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirroring.java (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror') diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirror.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirror.java deleted file mode 100644 index 4e5eaad94..000000000 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirror.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * compeople AG (Stefan Liebig) - various ongoing maintenance - *******************************************************************************/ -package org.eclipse.equinox.internal.p2.artifact.mirror; - -import java.io.IOException; -import java.io.OutputStream; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; - -public class Mirror { - private IArtifactRepository source; - private IArtifactRepository destination; - private boolean raw; - - public Mirror(IArtifactRepository source, IArtifactRepository destination, boolean raw) { - this.source = source; - this.destination = destination; - this.raw = raw; - } - - public void run() { - if (!destination.isModifiable()) - throw new IllegalStateException("Destination repository must be modifiable: " + destination.getLocation()); - IArtifactKey[] keys = source.getArtifactKeys(); - for (int i = 0; i < keys.length; i++) { - IArtifactKey key = keys[i]; - IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(key); - for (int j = 0; j < descriptors.length; j++) - mirror(descriptors[j]); - } - } - - private void mirror(IArtifactDescriptor descriptor) { - IArtifactDescriptor newDescriptor = raw ? descriptor : new ArtifactDescriptor(descriptor); - try { - OutputStream repositoryStream = null; - try { - System.out.println("Mirroring: " + descriptor.getArtifactKey()); //$NON-NLS-1$ - repositoryStream = destination.getOutputStream(newDescriptor); - if (repositoryStream == null) - return; - // TODO Is that ok to ignore the result? - source.getArtifact(descriptor, repositoryStream, new NullProgressMonitor()); - } finally { - if (repositoryStream != null) - repositoryStream.close(); - } - } catch (IOException e) { - // TODO Is that ok to ignore the exception - e.printStackTrace(); - } - } - -} diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java index c533ce1f6..1e46f03f3 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java @@ -20,6 +20,9 @@ import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifact import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +/** + * An application that performs mirroring of artifacts between repositories. + */ public class MirrorApplication implements IApplication { private URL sourceLocation; @@ -33,7 +36,7 @@ public class MirrorApplication implements IApplication { Map args = context.getArguments(); initializeFromArguments((String[]) args.get("application.args")); setupRepositories(); - new Mirror(source, destination, raw).run(); + new Mirroring(source, destination, raw).run(); return null; } diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirroring.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirroring.java new file mode 100644 index 000000000..ce0c90ffe --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/Mirroring.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * compeople AG (Stefan Liebig) - various ongoing maintenance + *******************************************************************************/ +package org.eclipse.equinox.internal.p2.artifact.mirror; + +import java.io.IOException; +import java.io.OutputStream; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; + +/** + * A utility class that performs mirroring of artifacts between repositories. + */ +public class Mirroring { + private IArtifactRepository source; + private IArtifactRepository destination; + private boolean raw; + + public Mirroring(IArtifactRepository source, IArtifactRepository destination, boolean raw) { + this.source = source; + this.destination = destination; + this.raw = raw; + } + + public void run() { + if (!destination.isModifiable()) + throw new IllegalStateException("Destination repository must be modifiable: " + destination.getLocation()); + IArtifactKey[] keys = source.getArtifactKeys(); + for (int i = 0; i < keys.length; i++) { + IArtifactKey key = keys[i]; + IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(key); + for (int j = 0; j < descriptors.length; j++) + mirror(descriptors[j]); + } + } + + private void mirror(IArtifactDescriptor descriptor) { + IArtifactDescriptor newDescriptor = raw ? descriptor : new ArtifactDescriptor(descriptor); + try { + OutputStream repositoryStream = null; + try { + System.out.println("Mirroring: " + descriptor.getArtifactKey()); //$NON-NLS-1$ + repositoryStream = destination.getOutputStream(newDescriptor); + if (repositoryStream == null) + return; + // TODO Is that ok to ignore the result? + source.getArtifact(descriptor, repositoryStream, new NullProgressMonitor()); + } finally { + if (repositoryStream != null) + repositoryStream.close(); + } + } catch (ProvisionException e) { + // TODO Is that ok to ignore the exception + e.printStackTrace(); + } catch (IOException e) { + // TODO Is that ok to ignore the exception + e.printStackTrace(); + } + } + +} -- cgit v1.2.3