diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2')
69 files changed, 1860 insertions, 263 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java index 5dbb891bc..7d2b7de43 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/JarComparator.java @@ -10,13 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.internal.repository.comparator; +import org.eclipse.equinox.p2.internal.repository.comparator.java.*; + +import org.eclipse.equinox.p2.repository.tools.comparator.IArtifactComparator; + import java.io.*; import java.util.*; +import java.util.Map.Entry; import java.util.jar.*; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.osgi.util.NLS; public class JarComparator implements IArtifactComparator { @@ -80,8 +86,8 @@ public class JarComparator implements IArtifactComparator { if (firstFileSize != secondFileSize) { return newErrorStatus(NLS.bind(Messages.differentNumberOfEntries, new String[] {descriptorString, sourceLocation, Integer.toString(firstFileSize), destinationLocation, Integer.toString(secondFileSize)})); } - for (Enumeration enumeration = firstFile.entries(); enumeration.hasMoreElements();) { - ZipEntry entry = (ZipEntry) enumeration.nextElement(); + for (Enumeration<? extends ZipEntry> enumeration = firstFile.entries(); enumeration.hasMoreElements();) { + ZipEntry entry = enumeration.nextElement(); String entryName = entry.getName(); final ZipEntry entry2 = secondFile.getEntry(entryName); if (!entry.isDirectory() && entry2 != null) { @@ -145,8 +151,7 @@ public class JarComparator implements IArtifactComparator { Attributes attributes2 = manifest2.getMainAttributes(); if (attributes.size() != attributes2.size()) return false; - for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); + for (Entry<Object, Object> entry : attributes.entrySet()) { Object value2 = attributes2.get(entry.getKey()); if (value2 == null) { return false; @@ -192,7 +197,7 @@ public class JarComparator implements IArtifactComparator { return false; props1.keys(); - for (Iterator iterator = props1.keySet().iterator(); iterator.hasNext();) { + for (Iterator<Object> iterator = props1.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); if (!props2.containsKey(key)) return false; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/MD5ArtifactComparator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/MD5ArtifactComparator.java new file mode 100644 index 000000000..754aeb22e --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/MD5ArtifactComparator.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 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 + *******************************************************************************/ + +package org.eclipse.equinox.p2.internal.repository.comparator; + +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.artifact.repository.Activator; +import org.eclipse.equinox.p2.internal.repository.tools.Messages; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.tools.comparator.IArtifactComparator; +import org.eclipse.osgi.util.NLS; + +public class MD5ArtifactComparator implements IArtifactComparator { + + public static String MD5_COMPARATOR_ID = "org.eclipse.equinox.artifact.md5.comparator"; //$NON-NLS-1$ + + public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destDescriptor) { + String sourceMD5 = sourceDescriptor.getProperty(IArtifactDescriptor.DOWNLOAD_MD5); + String destMD5 = destDescriptor.getProperty(IArtifactDescriptor.DOWNLOAD_MD5); + + if (sourceMD5 == null && destMD5 == null) + return new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.info_noMD5Infomation, sourceDescriptor)); + + if (sourceMD5 == null) + return new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.info_noMD5InRepository, source, sourceDescriptor)); + + if (destMD5 == null) + return new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.info_noMD5InRepository, destination, destDescriptor)); + + if (sourceMD5.equals(destMD5)) + return Status.OK_STATUS; + + return new Status(IStatus.WARNING, Activator.ID, NLS.bind(Messages.warning_differentMD5, new Object[] {URIUtil.toUnencodedString(sourceDescriptor.getRepository().getLocation()), URIUtil.toUnencodedString(destDescriptor.getRepository().getLocation()), sourceDescriptor})); + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Annotation.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Annotation.java index 2771ea6f1..db3fea4ce 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Annotation.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Annotation.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class Annotation extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationComponent.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationComponent.java index ac8374398..7a1922d3b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationComponent.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationComponent.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class AnnotationComponent extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationComponentValue.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationComponentValue.java index 386643914..74a26447c 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationComponentValue.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationComponentValue.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class AnnotationComponentValue extends ClassFileStruct { /** diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationDefaultAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationDefaultAttribute.java index a52692c20..638adb12d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AnnotationDefaultAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AnnotationDefaultAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class AnnotationDefaultAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AttributeNamesConstants.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AttributeNamesConstants.java index 3f55bfce0..f4d03fcc7 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/AttributeNamesConstants.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/AttributeNamesConstants.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public interface AttributeNamesConstants { /* diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/CharOperation.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/CharOperation.java index 2f1ae4d9b..246c66dbc 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/CharOperation.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/CharOperation.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public final class CharOperation { public static final char[] This = "this".toCharArray(); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileAttribute.java index 05225801f..bcc92e718 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ClassFileAttribute extends ClassFileStruct { public static final ClassFileAttribute[] NO_ATTRIBUTES = new ClassFileAttribute[0]; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileReader.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileReader.java index 61765ef09..dea13cc34 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileReader.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileReader.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.util.Arrays; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileStruct.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileStruct.java index a8c6038e3..24e4f6493 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFileStruct.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFileStruct.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public abstract class ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFormatException.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFormatException.java index acff39c2c..32d05426f 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ClassFormatException.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ClassFormatException.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ClassFormatException extends Exception { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/CodeAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/CodeAttribute.java index 97884685a..70f5f3dc2 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/CodeAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/CodeAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class CodeAttribute extends ClassFileAttribute { private static final ExceptionTableEntry[] NO_EXCEPTION_TABLE = new ExceptionTableEntry[0]; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPool.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPool.java index 380108600..a6c585ab2 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPool.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPool.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ConstantPool extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPoolConstant.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPoolConstant.java index 7cebf66e1..abc13b255 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPoolConstant.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPoolConstant.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public interface ConstantPoolConstant { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPoolEntry.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPoolEntry.java index cdee2fd49..881356fce 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantPoolEntry.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantPoolEntry.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ConstantPoolEntry { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantValueAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantValueAttribute.java index 75e961e77..cfc20ec56 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ConstantValueAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ConstantValueAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ConstantValueAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/DefaultBytecodeVisitor.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/DefaultBytecodeVisitor.java index aaeaf264b..90b8599a3 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/DefaultBytecodeVisitor.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/DefaultBytecodeVisitor.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import org.eclipse.osgi.util.NLS; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Disassembler.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Disassembler.java index f96d48823..69a9bfb3c 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Disassembler.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Disassembler.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.util.Arrays; import java.util.Comparator; @@ -1040,10 +1040,8 @@ public class Disassembler { private void disassembleTypeMembers(ClassFileReader classFileReader, char[] className, StringBuffer buffer, String lineSeparator, int tabNumber, int mode, boolean isEnum) { FieldInfo[] fields = classFileReader.getFieldInfos(); // sort fields - Arrays.sort(fields, new Comparator() { - public int compare(Object o1, Object o2) { - FieldInfo fieldInfo1 = (FieldInfo) o1; - FieldInfo fieldInfo2 = (FieldInfo) o2; + Arrays.sort(fields, new Comparator<FieldInfo>() { + public int compare(FieldInfo fieldInfo1, FieldInfo fieldInfo2) { int compare = new String(fieldInfo1.getName()).compareTo(new String(fieldInfo2.getName())); if (compare == 0) { return new String(fieldInfo1.getDescriptor()).compareTo(new String(fieldInfo2.getDescriptor())); @@ -1057,10 +1055,8 @@ public class Disassembler { } MethodInfo[] methods = classFileReader.getMethodInfos(); // sort methods - Arrays.sort(methods, new Comparator() { - public int compare(Object o1, Object o2) { - MethodInfo methodInfo1 = (MethodInfo) o1; - MethodInfo methodInfo2 = (MethodInfo) o2; + Arrays.sort(methods, new Comparator<MethodInfo>() { + public int compare(MethodInfo methodInfo1, MethodInfo methodInfo2) { int compare = new String(methodInfo1.getName()).compareTo(new String(methodInfo2.getName())); if (compare == 0) { return new String(methodInfo1.getDescriptor()).compareTo(new String(methodInfo2.getDescriptor())); diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/EnclosingMethodAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/EnclosingMethodAttribute.java index f764778fb..a7daac77d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/EnclosingMethodAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/EnclosingMethodAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class EnclosingMethodAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ExceptionAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ExceptionAttribute.java index 336aae015..7883c093a 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ExceptionAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ExceptionAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ExceptionAttribute extends ClassFileAttribute { private int exceptionsNumber; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ExceptionTableEntry.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ExceptionTableEntry.java index 6d889cd27..0598acf2a 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ExceptionTableEntry.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ExceptionTableEntry.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ExceptionTableEntry extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/FieldInfo.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/FieldInfo.java index 9ebd6a86d..46b79c64d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/FieldInfo.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/FieldInfo.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.util.Arrays; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/IModifierConstants.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/IModifierConstants.java index 17607b11e..b869fdbc1 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/IModifierConstants.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/IModifierConstants.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public interface IModifierConstants { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/IOpcodeMnemonics.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/IOpcodeMnemonics.java index 720591ed6..a6de65d6b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/IOpcodeMnemonics.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/IOpcodeMnemonics.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public interface IOpcodeMnemonics { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/InnerClassesAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/InnerClassesAttribute.java index 4a316098b..a9202fe72 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/InnerClassesAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/InnerClassesAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class InnerClassesAttribute extends ClassFileAttribute { private static final InnerClassesAttributeEntry[] NO_ENTRIES = new InnerClassesAttributeEntry[0]; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/InnerClassesAttributeEntry.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/InnerClassesAttributeEntry.java index 34b267fb2..2c63c8a44 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/InnerClassesAttributeEntry.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/InnerClassesAttributeEntry.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class InnerClassesAttributeEntry extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Messages.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Messages.java index 3edd78f26..8c2076f23 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Messages.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Messages.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import org.eclipse.osgi.util.NLS; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/MethodInfo.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/MethodInfo.java index c7789475a..14d57c21b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/MethodInfo.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/MethodInfo.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.util.Arrays; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/OpcodeStringValues.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/OpcodeStringValues.java index 76f80e9b6..dbc879e9b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/OpcodeStringValues.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/OpcodeStringValues.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class OpcodeStringValues implements IOpcodeMnemonics { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ParameterAnnotation.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ParameterAnnotation.java index ad7c6dcac..8f08991c1 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/ParameterAnnotation.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/ParameterAnnotation.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class ParameterAnnotation extends ClassFileStruct { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeInvisibleAnnotationsAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeInvisibleAnnotationsAttribute.java index f2e164c79..ef3244b5d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeInvisibleAnnotationsAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeInvisibleAnnotationsAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class RuntimeInvisibleAnnotationsAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeInvisibleParameterAnnotationsAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeInvisibleParameterAnnotationsAttribute.java index 3c724dd08..b9f489153 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeInvisibleParameterAnnotationsAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeInvisibleParameterAnnotationsAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class RuntimeInvisibleParameterAnnotationsAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeVisibleAnnotationsAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeVisibleAnnotationsAttribute.java index ff738fa3c..00306e271 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeVisibleAnnotationsAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeVisibleAnnotationsAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class RuntimeVisibleAnnotationsAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeVisibleParameterAnnotationsAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeVisibleParameterAnnotationsAttribute.java index 71700e217..1f2b84011 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/RuntimeVisibleParameterAnnotationsAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/RuntimeVisibleParameterAnnotationsAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class RuntimeVisibleParameterAnnotationsAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Signature.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Signature.java index e530f1e40..7b855bb25 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Signature.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Signature.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.util.ArrayList; @@ -577,7 +577,7 @@ public final class Signature { if (methodOrTypeSignature[0] != C_GENERIC_START) return CharOperation.NO_CHAR_CHAR; - ArrayList paramList = new ArrayList(1); + ArrayList<char[]> paramList = new ArrayList<char[]>(1); int paramStart = 1, i = 1; // start after leading '<' while (i < length) { if (methodOrTypeSignature[i] == C_GENERIC_END) { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/SignatureAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/SignatureAttribute.java index e6024103a..f186ca661 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/SignatureAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/SignatureAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class SignatureAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/SourceFileAttribute.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/SourceFileAttribute.java index f468e8433..1d51be982 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/SourceFileAttribute.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/SourceFileAttribute.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public class SourceFileAttribute extends ClassFileAttribute { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/TypeConstants.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/TypeConstants.java index 1e000fbd9..99e3e7841 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/TypeConstants.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/TypeConstants.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; public interface TypeConstants { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Utility.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java index 888ce1654..4a982deb4 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/Utility.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.internal.repository.comparator; +package org.eclipse.equinox.p2.internal.repository.comparator.java; import java.io.*; import java.util.Arrays; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/messages.properties index e8c395639..e8c395639 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/messages.properties +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/messages.properties diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java new file mode 100644 index 000000000..8ea5bfa04 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/FileMirrorLog.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2009 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 + *******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.mirroring; + +import java.io.*; +import java.util.Date; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.artifact.repository.Messages; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; + +public class FileMirrorLog implements IArtifactMirrorLog { + + private static final String INDENT = "\t"; //$NON-NLS-1$ + private static final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ + private BufferedWriter out; + private boolean consoleMessage = false; + private int minSeverity = IStatus.OK; + private boolean hasRoot = false; + + public FileMirrorLog(String location, int minSeverity, String root) { + this.minSeverity = minSeverity; + try { + File log = new File(location); + if (log.getParentFile().exists() || log.getParentFile().mkdirs()) { + out = new BufferedWriter(new FileWriter(log, true)); + if (root != null) { + log(root + " - " + new Date()); //$NON-NLS-1$ + hasRoot = true; + } + } else + throw new IOException(Messages.exception_unableToCreateParentDir); + } catch (IOException e) { + exceptionOccurred(null, e); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#log(org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor, org.eclipse.core.runtime.IStatus) + */ + public void log(IArtifactDescriptor descriptor, IStatus status) { + if (status.getSeverity() >= minSeverity) { + log(descriptor.toString()); + log(status, INDENT); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#log(org.eclipse.core.runtime.IStatus) + */ + public void log(IStatus status) { + log(status, ""); //$NON-NLS-1$ + } + + /* + * Write a status to the log, indenting it based on status depth. + * @param status the status to log + * @param depth the depth of the status + */ + private void log(IStatus status, String prefix) { + if (status.getSeverity() >= minSeverity) { + // Write status to log + log(prefix + status.getMessage()); + + // Write exception to log if applicable + String exceptionMessage = status.getException() != null ? status.getException().getMessage() : null; + if (exceptionMessage != null) + log(prefix + exceptionMessage); + + // Write the children of the status to the log + IStatus[] nestedStatus = status.getChildren(); + if (nestedStatus != null) + for (int i = 0; i < nestedStatus.length; i++) + log(nestedStatus[i], prefix + INDENT); + } + } + + /* + * Write a message to the log + * @param message the message to write + */ + private void log(String message) { + try { + out.write((hasRoot ? INDENT : "") + message + SEPARATOR); //$NON-NLS-1$ + } catch (IOException e) { + exceptionOccurred((hasRoot ? INDENT : "") + message, e); //$NON-NLS-1$ + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#close() + */ + public void close() { + try { + if (out != null) + out.close(); + } catch (IOException e) { + exceptionOccurred(null, e); + } + } + + /* + * Show an error message if this the first time, and print status messages. + */ + private void exceptionOccurred(String message, Exception e) { + if (!consoleMessage) { + System.err.println(Messages.MirrorLog_Exception_Occurred); + e.printStackTrace(System.err); + System.err.println(Messages.MirrorLog_Console_Log); + consoleMessage = true; + } + if (message != null) + System.out.println(message); + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/IArtifactMirrorLog.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/IArtifactMirrorLog.java new file mode 100644 index 000000000..727929df5 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/IArtifactMirrorLog.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2009 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 + *******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.mirroring; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; + +public interface IArtifactMirrorLog { + + // Log a status associated with a descriptor + public void log(IArtifactDescriptor descriptor, IStatus status); + + // Log a status + public void log(IStatus status); + + // Notify that logging is completed & cleanup resources + public void close(); +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/Mirroring.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/Mirroring.java new file mode 100644 index 000000000..8d2b993ad --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/Mirroring.java @@ -0,0 +1,291 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 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.p2.internal.repository.mirroring; + +import org.eclipse.equinox.p2.repository.tools.comparator.ArtifactComparatorFactory; +import org.eclipse.equinox.p2.repository.tools.comparator.IArtifactComparator; + +import java.util.*; +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.artifact.repository.RawMirrorRequest; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.internal.repository.tools.Activator; +import org.eclipse.equinox.p2.internal.repository.tools.Messages; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; +import org.eclipse.osgi.util.NLS; + +/** + * A utility class that performs mirroring of artifacts between repositories. + */ +public class Mirroring { + private IArtifactRepository source; + private IArtifactRepository destination; + private IArtifactRepository baseline; + private boolean raw; + private boolean compare = false; + private boolean validate = false; + private IArtifactComparator comparator; + private String comparatorID; + private List<IArtifactKey> keysToMirror; + private IArtifactMirrorLog comparatorLog; + + private IArtifactComparator getComparator() { + if (comparator == null) + comparator = ArtifactComparatorFactory.getArtifactComparator(comparatorID); + return comparator; + } + + public Mirroring(IArtifactRepository source, IArtifactRepository destination, boolean raw) { + this.source = source; + this.destination = destination; + this.raw = raw; + } + + public void setCompare(boolean compare) { + this.compare = compare; + } + + public void setComparatorId(String id) { + this.comparatorID = id; + } + + public void setComparatorLog(IArtifactMirrorLog comparatorLog) { + this.comparatorLog = comparatorLog; + } + + public void setBaseline(IArtifactRepository baseline) { + this.baseline = baseline; + } + + public void setValidate(boolean validate) { + this.validate = validate; + } + + public MultiStatus run(boolean failOnError, boolean verbose) { + if (!destination.isModifiable()) + throw new IllegalStateException(NLS.bind(Messages.exception_destinationNotModifiable, destination.getLocation())); + if (compare) + getComparator(); //initialize the comparator. Only needed if we're comparing. Used to force error if comparatorID is invalid. + MultiStatus multiStatus = new MultiStatus(Activator.ID, IStatus.OK, Messages.message_mirroringStatus, null); + Iterator<IArtifactKey> keys = null; + if (keysToMirror != null) + keys = keysToMirror.iterator(); + else { + IQueryResult<IArtifactKey> result = source.query(ArtifactKeyQuery.ALL_KEYS, null); + keys = result.iterator(); + } + while (keys.hasNext()) { + IArtifactKey key = keys.next(); + IArtifactDescriptor[] descriptors = source.getArtifactDescriptors(key); + for (int j = 0; j < descriptors.length; j++) { + IStatus result = mirror(descriptors[j], verbose); + //Only log INFO and WARNING if we want verbose logging. Always log ERRORs + if (!result.isOK() && (verbose || result.getSeverity() == IStatus.ERROR)) + multiStatus.add(result); + //stop mirroring as soon as we have an error + if (failOnError && multiStatus.getSeverity() == IStatus.ERROR) + return multiStatus; + } + } + if (validate) { + // Simple validation of the mirror + IStatus validation = validateMirror(verbose); + if (!validation.isOK() && (verbose || validation.getSeverity() == IStatus.ERROR)) + multiStatus.add(validation); + } + return multiStatus; + } + + private IStatus mirror(IArtifactDescriptor descriptor, boolean verbose) { + IArtifactDescriptor newDescriptor = raw ? descriptor : new ArtifactDescriptor(descriptor); + + if (verbose) + System.out.println("Mirroring: " + descriptor.getArtifactKey() + " (Descriptor: " + descriptor + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + if (compare && baseline != null) + if (baseline.contains(descriptor)) { + // we have to create an output stream based on the descriptor found in the baseline otherwise all + // the properties will be copied over from the wrong descriptor and our repository will be inconsistent. + IArtifactDescriptor baselineDescriptor = getBaselineDescriptor(descriptor); + + // if we found a descriptor in the baseline then we'll use it to copy the artifact + if (baselineDescriptor != null) { + MultiStatus status = new MultiStatus(Activator.ID, IStatus.OK, NLS.bind(Messages.Mirroring_compareAndDownload, descriptor), null); + //Compare source against baseline + IStatus comparison = getComparator().compare(baseline, baselineDescriptor, source, descriptor); + if (comparatorLog != null) + comparatorLog.log(baselineDescriptor, comparison); + status.add(comparison); + if (destination.contains(baselineDescriptor)) + return compareToDestination(baselineDescriptor); + + //download artifact from baseline + status.add(downloadArtifact(baseline, baselineDescriptor, baselineDescriptor)); + return status; + } + } + + // Check if the destination already contains the file. + if (destination.contains(newDescriptor)) { + if (compare) + return compareToDestination(descriptor); + String message = NLS.bind(Messages.mirror_alreadyExists, descriptor, destination); + return new Status(IStatus.INFO, Activator.ID, ProvisionException.ARTIFACT_EXISTS, message, null); + } + + return downloadArtifact(source, newDescriptor, descriptor); + } + + /** + * Takes an IArtifactDescriptor descriptor and the ProvisionException that was thrown when destination.getOutputStream(descriptor) + * and compares descriptor to the duplicate descriptor in the destination. + * + * Callers should verify the ProvisionException was thrown due to the artifact existing in the destination before invoking this method. + * @param descriptor + * @return the status of the compare + */ + private IStatus compareToDestination(IArtifactDescriptor descriptor) { + IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(descriptor.getArtifactKey()); + IArtifactDescriptor destDescriptor = null; + for (int i = 0; destDescriptor == null && i < destDescriptors.length; i++) { + if (destDescriptors[i].equals(descriptor)) + destDescriptor = destDescriptors[i]; + } + if (destDescriptor == null) + return new Status(IStatus.INFO, Activator.ID, ProvisionException.ARTIFACT_EXISTS, Messages.Mirroring_noMatchingDescriptor, null); + return compare(source, descriptor, destination, destDescriptor); + } + + private IStatus compare(IArtifactRepository sourceRepository, IArtifactDescriptor sourceDescriptor, IArtifactRepository destRepository, IArtifactDescriptor destDescriptor) { + IStatus comparison = getComparator().compare(sourceRepository, sourceDescriptor, destRepository, destDescriptor); + if (comparatorLog != null) + comparatorLog.log(sourceDescriptor, comparison); + return comparison; + } + + /* + * Create, and execute a MirrorRequest for a given descriptor. + */ + private IStatus downloadArtifact(IArtifactRepository sourceRepo, IArtifactDescriptor destDescriptor, IArtifactDescriptor srcDescriptor) { + RawMirrorRequest request = new RawMirrorRequest(srcDescriptor, destDescriptor, destination); + request.setSourceRepository(sourceRepo); + + request.perform(new NullProgressMonitor()); + + return request.getResult(); + } + + public void setArtifactKeys(IArtifactKey[] keys) { + this.keysToMirror = Arrays.asList(keys); + } + + /* + * Get the equivalent descriptor from the baseline repository + */ + private IArtifactDescriptor getBaselineDescriptor(IArtifactDescriptor descriptor) { + IArtifactDescriptor[] baselineDescriptors = baseline.getArtifactDescriptors(descriptor.getArtifactKey()); + for (int i = 0; i < baselineDescriptors.length; i++) { + if (baselineDescriptors[i].equals(descriptor)) + return baselineDescriptors[i]; + } + return null; + } + + /* + * Simple validation of a mirror to see if all source descriptors are present in the destination + */ + private IStatus validateMirror(boolean verbose) { + MultiStatus status = new MultiStatus(Activator.ID, 0, Messages.Mirroring_ValidationError, null); + + // The keys that were mirrored in this session + Iterator<IArtifactKey> keys = null; + if (keysToMirror != null) { + keys = keysToMirror.iterator(); + } else { + IQueryResult<IArtifactKey> result = source.query(ArtifactKeyQuery.ALL_KEYS, null); + keys = result.iterator(); + } + while (keys.hasNext()) { + IArtifactKey artifactKey = keys.next(); + IArtifactDescriptor[] srcDescriptors = source.getArtifactDescriptors(artifactKey); + IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(artifactKey); + + Arrays.sort(srcDescriptors, new ArtifactDescriptorComparator()); + Arrays.sort(destDescriptors, new ArtifactDescriptorComparator()); + + int src = 0; + int dest = 0; + while (src < srcDescriptors.length && dest < destDescriptors.length) { + if (!destDescriptors[dest].equals(srcDescriptors[src])) { + if (destDescriptors[dest].toString().compareTo((srcDescriptors[src].toString())) > 0) { + // Missing an artifact + if (verbose) + System.out.println(NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src])); + status.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src++]))); + } else { + // Its okay if there are extra descriptors in the destination + dest++; + } + } else { + // check properties for differences + Map<String, String> destMap = destDescriptors[dest].getProperties(); + Map<String, String> srcProperties = null; + if (baseline != null) { + IArtifactDescriptor baselineDescriptor = getBaselineDescriptor(destDescriptors[dest]); + if (baselineDescriptor != null) + srcProperties = baselineDescriptor.getProperties(); + } + // Baseline not set, or could not find descriptor so we'll use the source descriptor + if (srcProperties == null) + srcProperties = srcDescriptors[src].getProperties(); + + // Cycle through properties of the originating descriptor & compare + for (String key : srcProperties.keySet()) { + if (!srcProperties.get(key).equals(destMap.get(key))) { + if (verbose) + System.out.println(NLS.bind(Messages.Mirroring_differentDescriptorProperty, new Object[] {destDescriptors[dest], key, srcProperties.get(key), destMap.get(key)})); + status.add(new Status(IStatus.WARNING, Activator.ID, NLS.bind(Messages.Mirroring_differentDescriptorProperty, new Object[] {destDescriptors[dest], key, srcProperties.get(key), destMap.get(key)}))); + } + } + src++; + dest++; + } + } + + // If there are still source descriptors they're missing from the destination repository + while (src < srcDescriptors.length) { + if (verbose) + System.out.println(NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src])); + status.add(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Mirroring_missingDescriptor, srcDescriptors[src++]))); + } + } + + return status; + } + + // Simple comparator for ArtifactDescriptors + protected class ArtifactDescriptorComparator implements Comparator<IArtifactDescriptor> { + + public int compare(IArtifactDescriptor arg0, IArtifactDescriptor arg1) { + if (arg0 != null && arg1 != null) + return arg0.toString().compareTo(arg1.toString()); + else if (arg1 == null && arg0 == null) + return 0; + else if (arg1 == null) + return 1; + return -1; + } + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/XMLMirrorLog.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/XMLMirrorLog.java new file mode 100644 index 000000000..0b488f73a --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/mirroring/XMLMirrorLog.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2009 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 + *******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.mirroring; + +import java.io.*; +import java.util.Date; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.artifact.repository.Messages; +import org.eclipse.equinox.internal.p2.persistence.XMLWriter; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; + +public class XMLMirrorLog implements IArtifactMirrorLog { + private static final String DEFAULT_FORMAT = "canonical"; //$NON-NLS-1$ + // Constants used in XML tags + private static final String LOG = "log"; //$NON-NLS-1$ + private static final String TIME_ATTRIBUTE = "time"; //$NON-NLS-1$ + private static final String DESCRIPTOR_ELEMENT = "descriptor"; //$NON-NLS-1$ + private static final String DESCRIPTOR_CLASSIFIER_ATTRIBUTE = "classifier"; //$NON-NLS-1$ + private static final String DESCRIPTOR_FORMAT_ATTRIBUTE = "format"; //$NON-NLS-1$ + private static final String DESCRIPTOR_ID_ATTRIBUTE = "id"; //$NON-NLS-1$ + private static final String DESCRIPTOR_VERSION_ATTRIBUTE = "version"; //$NON-NLS-1$ + private static final String STATUS_ELEMENT = "status"; //$NON-NLS-1$ + private static final String STATUS_SEVERITY_ATTRIBUTE = "severity"; //$NON-NLS-1$ + private static final String STATUS_MESSAGE_ATTRIBUTE = "message"; //$NON-NLS-1$ + + private int minStatus = IStatus.OK; + private XMLWriter writer; + private OutputStream outputStream; + private boolean consoleMessage = false; + + public XMLMirrorLog(String location, int minStatus, String root) { + this.minStatus = minStatus; + + try { + outputStream = new FileOutputStream(location); + writer = new XMLWriter(outputStream, null); + if (root != null) + writer.start(root.toLowerCase()); + else + writer.start(LOG); + writer.attribute(TIME_ATTRIBUTE, new Date()); + } catch (UnsupportedEncodingException e) { + exceptionOccurred(e); + } catch (FileNotFoundException e) { + exceptionOccurred(e); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#log(org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor, org.eclipse.core.runtime.IStatus) + */ + public void log(IArtifactDescriptor descriptor, IStatus status) { + if (status.getSeverity() < minStatus) + return; + // Start descriptor tag + if (writer != null) { + writer.start(DESCRIPTOR_ELEMENT); + writer.attribute(DESCRIPTOR_ID_ATTRIBUTE, descriptor.getArtifactKey().getId()); + writer.attribute(DESCRIPTOR_CLASSIFIER_ATTRIBUTE, descriptor.getArtifactKey().getClassifier()); + writer.attribute(DESCRIPTOR_VERSION_ATTRIBUTE, descriptor.getArtifactKey().getVersion()); + if (descriptor.getProperties().get(IArtifactDescriptor.FORMAT) != null) + writer.attribute(DESCRIPTOR_FORMAT_ATTRIBUTE, descriptor.getProperties().get(IArtifactDescriptor.FORMAT)); + else + writer.attribute(DESCRIPTOR_FORMAT_ATTRIBUTE, DEFAULT_FORMAT); + } else + // Creation of the XML writer failed, dump results to the console + System.out.println(descriptor); + + log(status); + + // Close descriptor tag + if (writer != null) + writer.end(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#log(org.eclipse.core.runtime.IStatus) + */ + public void log(IStatus status) { + if (status.getSeverity() < minStatus) + return; + + if (writer != null) { + // Start status tag + writer.start(STATUS_ELEMENT); + // Set severity attribute + switch (status.getSeverity()) { + case IStatus.OK : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, "OK"); //$NON-NLS-1$ + break; + case IStatus.INFO : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, "INFO"); //$NON-NLS-1$ + break; + case IStatus.WARNING : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, "WARNING"); //$NON-NLS-1$ + break; + case IStatus.ERROR : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, "ERROR"); //$NON-NLS-1$ + break; + case IStatus.CANCEL : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, "CANCEL"); //$NON-NLS-1$ + break; + default : + writer.attribute(STATUS_SEVERITY_ATTRIBUTE, status.getSeverity()); + } + // Set message attribute + writer.attribute(STATUS_MESSAGE_ATTRIBUTE, status.getMessage()); + } else + // Creation of the XML writer failed, dump results to the console + System.out.println(status); + + // Log children statuses + IStatus[] nestedStatus = status.getChildren(); + if (nestedStatus != null) + for (int i = 0; i < nestedStatus.length; i++) + log(nestedStatus[i]); + + // Close status tag + if (writer != null) + writer.end(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog#close() + */ + public void close() { + try { + if (writer != null) { + // Close opening tag & flush results + writer.end(); + writer.flush(); + } + } finally { + if (outputStream != null) + try { + // Close output stream + outputStream.close(); + } catch (IOException e) { + exceptionOccurred(e); + } + } + } + + /* + * Show an error message if this the first time + */ + private void exceptionOccurred(Exception e) { + if (!consoleMessage) { + System.err.println(Messages.MirrorLog_Exception_Occurred); + e.printStackTrace(System.err); + System.err.println(Messages.MirrorLog_Console_Log); + consoleMessage = true; + } + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java index 0181e06d1..c1d1bb18c 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. + * Copyright (c) 2009, 2010 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 @@ -15,24 +15,29 @@ import java.util.*; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; +import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepositoryFactory; +import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; +import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory; import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.repository.*; +import org.eclipse.equinox.p2.core.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.*; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.util.NLS; +import org.osgi.framework.ServiceReference; public abstract class AbstractApplication { protected boolean removeAddedRepositories = true; - protected List sourceRepositories = new ArrayList(); //List of repository descriptors - protected List artifactReposToRemove = new ArrayList(); - protected List metadataReposToRemove = new ArrayList(); - protected List sourceIUs = new ArrayList(); - private List destinationRepos = new ArrayList(); + protected List<RepositoryDescriptor> sourceRepositories = new ArrayList<RepositoryDescriptor>(); //List of repository descriptors + protected List<URI> artifactReposToRemove = new ArrayList<URI>(); + protected List<URI> metadataReposToRemove = new ArrayList<URI>(); + protected List<IInstallableUnit> sourceIUs = new ArrayList<IInstallableUnit>(); + private List<RepositoryDescriptor> destinationRepos = new ArrayList<RepositoryDescriptor>(); protected IArtifactRepository destinationArtifactRepository = null; protected IMetadataRepository destinationMetadataRepository = null; @@ -40,18 +45,50 @@ public abstract class AbstractApplication { private CompositeMetadataRepository compositeMetadataRepository = null; private CompositeArtifactRepository compositeArtifactRepository = null; - public void setSourceIUs(List ius) { + protected IProvisioningAgent agent; + + public AbstractApplication() { + super(); + try { + setupAgent(); + } catch (ProvisionException e) { + LogHelper.log(e); + } + } + + private void setupAgent() throws ProvisionException { + //note if we ever wanted these applications to act on a different agent than + //the currently running system we would need to set it here + ServiceReference agentRef = Activator.getBundleContext().getServiceReference(IProvisioningAgent.SERVICE_NAME); + if (agentRef != null) { + agent = (IProvisioningAgent) Activator.getBundleContext().getService(agentRef); + if (agent != null) + return; + } + //there is no agent around so we need to create one + ServiceReference providerRef = Activator.getBundleContext().getServiceReference(IProvisioningAgentProvider.SERVICE_NAME); + if (providerRef == null) + throw new RuntimeException("No provisioning agent provider is available"); //$NON-NLS-1$ + IProvisioningAgentProvider provider = (IProvisioningAgentProvider) Activator.getBundleContext().getService(providerRef); + if (provider == null) + throw new RuntimeException("No provisioning agent provider is available"); //$NON-NLS-1$ + //obtain agent for currently running system + agent = provider.createAgent(null); + Activator.getBundleContext().ungetService(providerRef); + } + + public void setSourceIUs(List<IInstallableUnit> ius) { sourceIUs = ius; } - protected void finalizeRepositories() throws ProvisionException { + protected void finalizeRepositories() { if (removeAddedRepositories) { - IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); - for (Iterator iter = artifactReposToRemove.iterator(); iter.hasNext();) - artifactRepositoryManager.removeRepository((URI) iter.next()); - IMetadataRepositoryManager metadataRepositoryManager = Activator.getMetadataRepositoryManager(); - for (Iterator iter = metadataReposToRemove.iterator(); iter.hasNext();) - metadataRepositoryManager.removeRepository((URI) iter.next()); + IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); + for (URI uri : artifactReposToRemove) + artifactRepositoryManager.removeRepository(uri); + IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); + for (URI uri : metadataReposToRemove) + metadataRepositoryManager.removeRepository(uri); } metadataReposToRemove = null; artifactReposToRemove = null; @@ -61,13 +98,20 @@ public abstract class AbstractApplication { destinationMetadataRepository = null; } + protected IMetadataRepositoryManager getMetadataRepositoryManager() { + return (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); + } + + protected IArtifactRepositoryManager getArtifactRepositoryManager() { + return (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); + } + public void initializeRepos(IProgressMonitor progress) throws ProvisionException { - IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); - IMetadataRepositoryManager metadataRepositoryManager = Activator.getMetadataRepositoryManager(); + IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); + IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); URI curLocation = null; try { - for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { - RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); + for (RepositoryDescriptor repo : sourceRepositories) { curLocation = repo.getRepoLocation(); if (repo.isBoth()) { addRepository(artifactRepositoryManager, curLocation, 0, progress); @@ -106,9 +150,9 @@ public abstract class AbstractApplication { RepositoryDescriptor artifactRepoDescriptor = null; RepositoryDescriptor metadataRepoDescriptor = null; - Iterator iter = destinationRepos.iterator(); + Iterator<RepositoryDescriptor> iter = destinationRepos.iterator(); while (iter.hasNext() && (artifactRepoDescriptor == null || metadataRepoDescriptor == null)) { - RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); + RepositoryDescriptor repo = iter.next(); if (repo.isArtifact() && artifactRepoDescriptor == null) artifactRepoDescriptor = repo; if (repo.isMetadata() && metadataRepoDescriptor == null) @@ -188,12 +232,12 @@ public abstract class AbstractApplication { } } - protected boolean initDestinationRepository(IRepository repository, RepositoryDescriptor descriptor) { + protected boolean initDestinationRepository(IRepository<?> repository, RepositoryDescriptor descriptor) { if (repository != null && repository.isModifiable()) { if (descriptor.getName() != null) repository.setName(descriptor.getName()); - if (repository instanceof ICompositeRepository && !descriptor.isAppend()) - ((ICompositeRepository) repository).removeAllChildren(); + if (repository instanceof ICompositeRepository<?> && !descriptor.isAppend()) + ((ICompositeRepository<?>) repository).removeAllChildren(); else if (repository instanceof IMetadataRepository && !descriptor.isAppend()) ((IMetadataRepository) repository).removeAll(); else if (repository instanceof IArtifactRepository && !descriptor.isAppend()) @@ -206,12 +250,13 @@ public abstract class AbstractApplication { public IMetadataRepository getCompositeMetadataRepository() { if (compositeMetadataRepository == null) { try { - compositeMetadataRepository = new CompositeMetadataRepository(new URI("memory:/composite"), "parent metadata repo", null);//$NON-NLS-1$ //$NON-NLS-2$ + CompositeMetadataRepositoryFactory factory = new CompositeMetadataRepositoryFactory(); + factory.setAgent(agent); + compositeMetadataRepository = (CompositeMetadataRepository) factory.create(new URI("memory:/composite"), "parent metadata repo", CompositeMetadataRepository.REPOSITORY_TYPE, null);//$NON-NLS-1$ //$NON-NLS-2$ } catch (URISyntaxException e) { //Can't happen } - for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { - RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); + for (RepositoryDescriptor repo : sourceRepositories) { if (repo.isMetadata()) compositeMetadataRepository.addChild(repo.getRepoLocation()); } @@ -222,12 +267,13 @@ public abstract class AbstractApplication { public IArtifactRepository getCompositeArtifactRepository() { if (compositeArtifactRepository == null) { try { - compositeArtifactRepository = new CompositeArtifactRepository(new URI("memory:/composite"), "parent artifact repo", null);//$NON-NLS-1$ //$NON-NLS-2$ + CompositeArtifactRepositoryFactory factory = new CompositeArtifactRepositoryFactory(); + factory.setAgent(agent); + compositeArtifactRepository = (CompositeArtifactRepository) factory.create(new URI("memory:/composite"), "parent artifact repo", CompositeArtifactRepository.REPOSITORY_TYPE, null);//$NON-NLS-1$ //$NON-NLS-2$ } catch (URISyntaxException e) { //Can't happen } - for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { - RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); + for (RepositoryDescriptor repo : sourceRepositories) { if (repo.isArtifact()) compositeArtifactRepository.addChild(repo.getRepoLocation()); } diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java index 5c101ea89..b79dc8ce4 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java @@ -10,15 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.internal.repository.tools; +import org.eclipse.equinox.p2.core.ProvisionException; + import java.net.URI; import java.net.URISyntaxException; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.engine.IProfileRegistry; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.service.packageadmin.PackageAdmin; @@ -74,7 +75,7 @@ public class Activator implements BundleActivator { * Return the artifact repository manager. Throw an exception if it cannot be obtained. */ public static IArtifactRepositoryManager getArtifactRepositoryManager() throws ProvisionException { - IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(getBundleContext(), IArtifactRepositoryManager.class.getName()); + IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(getBundleContext(), IArtifactRepositoryManager.SERVICE_NAME); if (manager == null) throw new ProvisionException(Messages.no_artifactRepo_manager); return manager; @@ -84,7 +85,7 @@ public class Activator implements BundleActivator { * Return the profile registry. Throw an exception if it cannot be found. */ static IProfileRegistry getProfileRegistry() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(getBundleContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(getBundleContext(), IProfileRegistry.SERVICE_NAME); if (registry == null) throw new ProvisionException(Messages.no_profile_registry); return registry; @@ -112,7 +113,7 @@ public class Activator implements BundleActivator { * Return the metadata repository manager. Throw an exception if it cannot be obtained. */ public static IMetadataRepositoryManager getMetadataRepositoryManager() throws ProvisionException { - IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(getBundleContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(getBundleContext(), IMetadataRepositoryManager.SERVICE_NAME); if (manager == null) throw new ProvisionException(Messages.no_metadataRepo_manager); return manager; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/ArtifactRepositoryValidator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/ArtifactRepositoryValidator.java new file mode 100644 index 000000000..3748fc12f --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/ArtifactRepositoryValidator.java @@ -0,0 +1,85 @@ +package org.eclipse.equinox.p2.internal.repository.tools; + +import org.eclipse.equinox.p2.repository.tools.comparator.ArtifactComparatorFactory; +import org.eclipse.equinox.p2.repository.tools.comparator.IArtifactComparator; + +import java.util.Iterator; +import java.util.List; +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.*; + +public class ArtifactRepositoryValidator { + + private IArtifactComparator comparator; + + public ArtifactRepositoryValidator(String comparatorId) throws ProvisionException { + comparator = ArtifactComparatorFactory.getArtifactComparator(comparatorId); + if (comparatorId == null) + throw new ProvisionException(Messages.invalidComparatorId); + + } + + public IStatus validateRepository(IArtifactRepository repository) { + if (repository instanceof CompositeArtifactRepository) + return validateComposite((CompositeArtifactRepository) repository); + + IQueryResult<IArtifactKey> queryResult = repository.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()); + for (Iterator<IArtifactKey> iterator = queryResult.iterator(); iterator.hasNext();) { + IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(iterator.next()); + for (int i = 0; i < descriptors.length - 2; i++) { + IStatus compareResult = comparator.compare(repository, descriptors[i], repository, descriptors[i + 1]); + if (!compareResult.isOK()) { + return compareResult; + } + } + } + return Status.OK_STATUS; + } + + public IStatus validateComposite(CompositeArtifactRepository repository) { + List<IArtifactRepository> repos = repository.getLoadedChildren(); + IQueryResult<IArtifactKey> queryResult = repository.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()); + for (Iterator<IArtifactKey> iterator = queryResult.iterator(); iterator.hasNext();) { + IArtifactKey key = iterator.next(); + IArtifactRepository firstRepo = null; + for (IArtifactRepository child : repos) { + if (child.contains(key)) { + if (firstRepo == null) { + firstRepo = child; + continue; + } + + IArtifactDescriptor[] d1 = firstRepo.getArtifactDescriptors(key); + IArtifactDescriptor[] d2 = child.getArtifactDescriptors(key); + //If we assume each repo is internally consistant, we only need to compare one descriptor from each repo + IStatus compareResult = comparator.compare(firstRepo, d1[0], child, d2[0]); + if (!compareResult.isOK()) { + //LogHelper.log(compareResult); + return compareResult; + } + } + } + } + return Status.OK_STATUS; + } + + public IStatus validateComposite(CompositeArtifactRepository composite, IArtifactRepository repository) { + IQueryResult<IArtifactKey> queryResult = repository.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()); + for (Iterator<IArtifactKey> iterator = queryResult.iterator(); iterator.hasNext();) { + IArtifactKey key = iterator.next(); + if (composite.contains(key)) { + IArtifactDescriptor[] d1 = composite.getArtifactDescriptors(key); + IArtifactDescriptor[] d2 = repository.getArtifactDescriptors(key); + //If we assume each repo is internally consistant, we only need to compare one descriptor from each repo + IStatus compareResult = comparator.compare(composite, d1[0], repository, d2[0]); + if (!compareResult.isOK()) + return compareResult; + } + } + return Status.OK_STATUS; + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java index 11f73dee6..96de1e39d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java @@ -11,22 +11,25 @@ package org.eclipse.equinox.p2.internal.repository.tools; import java.net.MalformedURLException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.ICompositeRepository; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.util.NLS; public class CompositeRepositoryApplication extends AbstractApplication { - private List childrenToAdd = new ArrayList(); - private List childrenToRemove = new ArrayList(); + private List<RepositoryDescriptor> childrenToAdd = new ArrayList<RepositoryDescriptor>(); + private List<RepositoryDescriptor> childrenToRemove = new ArrayList<RepositoryDescriptor>(); + private boolean removeAllChildren = false; private boolean failOnExists = false; private String comparatorID = null; @@ -34,30 +37,36 @@ public class CompositeRepositoryApplication extends AbstractApplication { try { initializeRepos(new NullProgressMonitor()); // load repository - ICompositeRepository metadataRepo = (ICompositeRepository) destinationMetadataRepository; + ICompositeRepository<IInstallableUnit> metadataRepo = (ICompositeRepository<IInstallableUnit>) destinationMetadataRepository; CompositeArtifactRepository artifactRepo = (CompositeArtifactRepository) destinationArtifactRepository; - // Remove children from the Composite Repositories - for (Iterator iterator = childrenToRemove.iterator(); iterator.hasNext();) { - RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); - if (child.isArtifact() && artifactRepo != null) - artifactRepo.removeChild(child.getOriginalRepoLocation()); - if (child.isMetadata() && metadataRepo != null) - metadataRepo.removeChild(child.getOriginalRepoLocation()); + if (removeAllChildren) { + if (artifactRepo != null) + artifactRepo.removeAllChildren(); + if (metadataRepo != null) + metadataRepo.removeAllChildren(); + } else { + // Remove children from the Composite Repositories + for (RepositoryDescriptor child : childrenToRemove) { + if (child.isArtifact() && artifactRepo != null) + artifactRepo.removeChild(child.getOriginalRepoLocation()); + if (child.isMetadata() && metadataRepo != null) + metadataRepo.removeChild(child.getOriginalRepoLocation()); + } } // Add children to the Composite Repositories - for (Iterator iterator = childrenToAdd.iterator(); iterator.hasNext();) { - RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); + for (RepositoryDescriptor child : childrenToAdd) { if (child.isArtifact() && artifactRepo != null) artifactRepo.addChild(child.getOriginalRepoLocation()); if (child.isMetadata() && metadataRepo != null) metadataRepo.addChild(child.getOriginalRepoLocation()); } - if (comparatorID != null) - if (!artifactRepo.validate(comparatorID)) - return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.CompositeRepositoryApplication_failedComparator, comparatorID)); + if (comparatorID != null) { + ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(comparatorID); + return validator.validateComposite(artifactRepo); + } return Status.OK_STATUS; } finally { finalizeRepositories(); @@ -72,6 +81,10 @@ public class CompositeRepositoryApplication extends AbstractApplication { childrenToRemove.add(child); } + public void setRemoveAll(boolean all) { + removeAllChildren = all; + } + public void setFailOnExists(boolean value) { failOnExists = value; } @@ -155,8 +168,8 @@ public class CompositeRepositoryApplication extends AbstractApplication { /* * Determine if the repository is valid for this operation */ - private boolean validRepositoryLocation(IRepository repository) throws ProvisionException { - if (repository instanceof ICompositeRepository) { + private boolean validRepositoryLocation(IRepository<?> repository) throws ProvisionException { + if (repository instanceof ICompositeRepository<?>) { // if we have an already existing repository at that location, then throw an error // if the user told us to if (failOnExists) @@ -171,7 +184,7 @@ public class CompositeRepositoryApplication extends AbstractApplication { /* * Initialize a new repository */ - private void initRepository(IRepository repository, RepositoryDescriptor desc) { + private void initRepository(IRepository<?> repository, RepositoryDescriptor desc) { RepositoryHelper.validDestinationRepository(repository); if (desc.isCompressed() && !repository.getProperties().containsKey(IRepository.PROP_COMPRESSED)) repository.setProperty(IRepository.PROP_COMPRESSED, String.valueOf(true)); diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java index 1f4b3c69c..37a7c5d12 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java @@ -18,9 +18,11 @@ public class Messages extends NLS { public static String exception_unableToRemoveRepo; public static String exception_notLocalFileRepo; public static String exception_noEngineService; + public static String exception_noPlannerService; public static String exception_needIUsOrNonEmptyRepo; public static String exception_needDestinationRepo; public static String exception_onlyOneComparator; + public static String exception_loadingRepository; public static String AbstractApplication_no_valid_destinations; @@ -40,11 +42,8 @@ public class Messages extends NLS { public static String MirrorApplication_artifactDestinationNoSource; public static String MirrorApplication_metadataDestinationNoSource; - public static String MirrorApplication_missingIU; - public static String MirrorApplication_missingSourceForIUs; public static String MirrorApplication_no_IUs; public static String MirrorApplication_set_source_repositories; - public static String MirrorApplication_validateAndMirrorProblems; public static String ProcessRepo_location_not_url; public static String ProcessRepo_must_be_local; @@ -58,6 +57,19 @@ public class Messages extends NLS { public static String skippingInvalidFilter; + public static String message_mirroringStatus; + public static String Mirroring_compareAndDownload; + public static String mirror_alreadyExists; + public static String Mirroring_noMatchingDescriptor; + public static String Mirroring_ValidationError; + public static String Mirroring_missingDescriptor; + public static String Mirroring_differentDescriptorProperty; + + public static String invalidComparatorId; + public static String info_noMD5Infomation; + public static String info_noMD5InRepository; + public static String warning_differentMD5; + static { // initialize resource bundles NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java index e73283eed..574abd9bc 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java @@ -10,30 +10,33 @@ *******************************************************************************/ package org.eclipse.equinox.p2.internal.repository.tools; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; - -import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.File; import java.net.URI; -import java.util.ArrayList; -import java.util.Iterator; +import java.net.URISyntaxException; +import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.artifact.mirror.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.director.PermissiveSlicer; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.LatestIUVersionQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; - -public class MirrorApplication extends AbstractApplication { +import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery; +import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.internal.repository.mirroring.*; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.osgi.util.NLS; + +public class MirrorApplication extends AbstractApplication implements IApplication, IExecutableExtension { private static final String LOG_ROOT = "p2.mirror"; //$NON-NLS-1$ + private static final String MIRROR_MODE = "metadataOrArtifacts"; //$NON-NLS-1$ protected SlicingOptions slicingOptions = new SlicingOptions(); @@ -44,17 +47,132 @@ public class MirrorApplication extends AbstractApplication { private boolean raw = true; private boolean verbose = false; private boolean validate = false; + private String metadataOrArtifacts = null; + private String[] rootIUs = null; private File mirrorLogFile; // file to log mirror output to (optional) private File comparatorLogFile; // file to comparator output to (optional) private IArtifactMirrorLog mirrorLog; private IArtifactMirrorLog comparatorLog; + /** + * Convert a list of tokens into an array. The list separator has to be + * specified. + */ + public static String[] getArrayArgsFromString(String list, String separator) { + if (list == null || list.trim().equals("")) //$NON-NLS-1$ + return new String[0]; + List<String> result = new ArrayList<String>(); + for (StringTokenizer tokens = new StringTokenizer(list, separator); tokens.hasMoreTokens();) { + String token = tokens.nextToken().trim(); + if (!token.equals("")) { //$NON-NLS-1$ + if ((token.indexOf('[') >= 0 || token.indexOf('(') >= 0) && tokens.hasMoreTokens()) + result.add(token + separator + tokens.nextToken()); + else + result.add(token); + } + } + return result.toArray(new String[result.size()]); + } + public Object start(IApplicationContext context) throws Exception { + Map<?, ?> args = context.getArguments(); + initializeFromArguments((String[]) args.get(IApplicationContext.APPLICATION_ARGS)); run(null); return IApplication.EXIT_OK; } + public void stop() { + // TODO Auto-generated method stub + + } + + /* + * The old "org.eclipse.equinox.p2.artifact.repository.mirrorApplication" application only does artifacts + * Similary, "org.eclipse.equinox.p2.metadata.repository.mirrorApplication" only does metadata + */ + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) { + if (data instanceof Map<?, ?> && ((Map<?, ?>) data).containsKey(MIRROR_MODE)) { + metadataOrArtifacts = (String) ((Map<?, ?>) data).get(MIRROR_MODE); + } + } + + public void initializeFromArguments(String[] args) throws Exception { + if (args == null) + return; + + File comparatorLogLocation = null; + File mirrorLogLocation = null; + + RepositoryDescriptor destination = new RepositoryDescriptor(); + RepositoryDescriptor sourceRepo = new RepositoryDescriptor(); + if (metadataOrArtifacts != null) { + destination.setKind(metadataOrArtifacts); + sourceRepo.setKind(metadataOrArtifacts); + } + + addDestination(destination); + addSource(sourceRepo); + + for (int i = 0; i < args.length; i++) { + // check for args without parameters (i.e., a flag arg) + if (args[i].equalsIgnoreCase("-raw")) //$NON-NLS-1$ + raw = true; + else if (args[i].equalsIgnoreCase("-ignoreErrors")) //$NON-NLS-1$ + failOnError = false; + else if (args[i].equalsIgnoreCase("-verbose")) //$NON-NLS-1$ + verbose = true; + else if (args[i].equalsIgnoreCase("-compare")) //$NON-NLS-1$ + compare = true; + else if (args[i].equalsIgnoreCase("-validate")) //$NON-NLS-1$ + validate = true; + + // check for args with parameters. If we are at the last argument or + // if the next one has a '-' as the first character, then we can't have + // an arg with a param so continue. + if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$ + continue; + + String arg = args[++i]; + + if (args[i - 1].equalsIgnoreCase("-comparator")) //$NON-NLS-1$ + comparatorID = arg; + else if (args[i - 1].equalsIgnoreCase("-comparatorLog")) //$NON-NLS-1$ + comparatorLogLocation = new File(arg); + else if (args[i - 1].equalsIgnoreCase("-destinationName")) //$NON-NLS-1$ + destination.setName(arg); + else if (args[i - 1].equalsIgnoreCase("-writeMode")) { //$NON-NLS-1$ + if (args[i].equalsIgnoreCase("clean")) //$NON-NLS-1$ + destination.setAppend(false); + } else if (args[i - 1].equalsIgnoreCase("-log")) { //$NON-NLS-1$ + mirrorLogLocation = new File(arg); + } else if (args[i - 1].equalsIgnoreCase("-roots")) { //$NON-NLS-1$ + rootIUs = getArrayArgsFromString(arg, ","); //$NON-NLS-1$ + } else { + try { + if (args[i - 1].equalsIgnoreCase("-source")) { //$NON-NLS-1$ + URI uri = RepositoryHelper.localRepoURIHelper(URIUtil.fromString(arg)); + sourceRepo.setLocation(uri); + destination.setFormat(uri); + } else if (args[i - 1].equalsIgnoreCase("-destination")) //$NON-NLS-1$ + destination.setLocation(RepositoryHelper.localRepoURIHelper(URIUtil.fromString(arg))); + else if (args[i - 1].equalsIgnoreCase("-compareAgainst")) { //$NON-NLS-1$ + baseline = RepositoryHelper.localRepoURIHelper(URIUtil.fromString(arg)); + compare = true; + } + } catch (URISyntaxException e) { + throw new IllegalArgumentException(NLS.bind(Messages.ProcessRepo_location_not_url, arg)); + } + } + } + + // Create logs + if (mirrorLogLocation != null) + mirrorLog = getLog(mirrorLogLocation, "p2.artifact.mirror"); //$NON-NLS-1$ + if (comparatorLogLocation != null && comparatorID != null) + comparatorLog = getLog(comparatorLogLocation, comparatorID); + } + public IStatus run(IProgressMonitor monitor) throws ProvisionException { IStatus mirrorStatus = Status.OK_STATUS; try { @@ -62,7 +180,7 @@ public class MirrorApplication extends AbstractApplication { initializeLogs(); validate(); initializeIUs(); - IQueryable slice = slice(new NullProgressMonitor()); + IQueryable<IInstallableUnit> slice = slice(new NullProgressMonitor()); if (destinationArtifactRepository != null) { mirrorStatus = mirrorArtifacts(slice, new NullProgressMonitor()); if (mirrorStatus.getSeverity() == IStatus.ERROR) @@ -79,19 +197,16 @@ public class MirrorApplication extends AbstractApplication { return mirrorStatus; } - private IStatus mirrorArtifacts(IQueryable slice, IProgressMonitor monitor) throws ProvisionException { + private IStatus mirrorArtifacts(IQueryable<IInstallableUnit> slice, IProgressMonitor monitor) throws ProvisionException { // Obtain ArtifactKeys from IUs - Collector ius = slice.query(InstallableUnitQuery.ANY, new Collector(), monitor); - ArrayList keys = new ArrayList(ius.size()); - for (Iterator iterator = ius.iterator(); iterator.hasNext();) { - IInstallableUnit iu = (IInstallableUnit) iterator.next(); - IArtifactKey[] iuKeys = iu.getArtifacts(); - for (int i = 0; i < iuKeys.length; i++) { - keys.add(iuKeys[i]); - } + IQueryResult<IInstallableUnit> ius = slice.query(InstallableUnitQuery.ANY, monitor); + ArrayList<IArtifactKey> keys = new ArrayList<IArtifactKey>(); + for (Iterator<IInstallableUnit> iterator = ius.iterator(); iterator.hasNext();) { + IInstallableUnit iu = iterator.next(); + keys.addAll(iu.getArtifacts()); } - Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, raw); + Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, raw); mirror.setCompare(compare); mirror.setComparatorId(comparatorID); mirror.setBaseline(initializeBaseline()); @@ -99,7 +214,7 @@ public class MirrorApplication extends AbstractApplication { // If IUs have been specified then only they should be mirrored, otherwise mirror everything. if (keys.size() > 0) - mirror.setArtifactKeys((IArtifactKey[]) keys.toArray(new IArtifactKey[keys.size()])); + mirror.setArtifactKeys(keys.toArray(new IArtifactKey[keys.size()])); if (comparatorLog != null) mirror.setComparatorLog(comparatorLog); @@ -116,12 +231,12 @@ public class MirrorApplication extends AbstractApplication { private IArtifactRepository initializeBaseline() throws ProvisionException { if (baseline == null) return null; - return addRepository(Activator.getArtifactRepositoryManager(), baseline, 0, null); + return addRepository(getArtifactRepositoryManager(), baseline, 0, null); } - private void mirrorMetadata(IQueryable slice, IProgressMonitor monitor) { - Collector allIUs = slice.query(InstallableUnitQuery.ANY, new Collector(), monitor); - destinationMetadataRepository.addInstallableUnits((IInstallableUnit[]) allIUs.toArray(IInstallableUnit.class)); + private void mirrorMetadata(IQueryable<IInstallableUnit> slice, IProgressMonitor monitor) { + IQueryResult<IInstallableUnit> allIUs = slice.query(InstallableUnitQuery.ANY, monitor); + destinationMetadataRepository.addInstallableUnits(allIUs.toArray(IInstallableUnit.class)); } /* @@ -143,17 +258,24 @@ public class MirrorApplication extends AbstractApplication { * If no IUs have been specified we want to mirror them all */ private void initializeIUs() throws ProvisionException { - if (sourceIUs == null || sourceIUs.isEmpty()) { - sourceIUs = new ArrayList(); - IMetadataRepository metadataRepo = getCompositeMetadataRepository(); - Collector collector = metadataRepo.query(InstallableUnitQuery.ANY, new Collector(), null); - - for (Iterator iter = collector.iterator(); iter.hasNext();) { - IInstallableUnit iu = (IInstallableUnit) iter.next(); - sourceIUs.add(iu); + IMetadataRepository metadataRepo = getCompositeMetadataRepository(); + + if (rootIUs != null) { + sourceIUs = new ArrayList<IInstallableUnit>(); + for (int i = 0; i < rootIUs.length; i++) { + String[] segments = getArrayArgsFromString(rootIUs[i], "/"); //$NON-NLS-1$ + VersionRange range = segments.length > 1 ? new VersionRange(segments[i]) : null; + Iterator<IInstallableUnit> queryResult = metadataRepo.query(new InstallableUnitQuery(segments[i], range), null).iterator(); + while (queryResult.hasNext()) + sourceIUs.add(queryResult.next()); } - - if (collector.size() == 0 && destinationMetadataRepository != null) + } else if (sourceIUs == null || sourceIUs.isEmpty()) { + sourceIUs = new ArrayList<IInstallableUnit>(); + Iterator<IInstallableUnit> queryResult = metadataRepo.query(InstallableUnitQuery.ANY, null).iterator(); + while (queryResult.hasNext()) + sourceIUs.add(queryResult.next()); + /* old metadata mirroring app did not throw an exception here */ + if (sourceIUs.size() == 0 && destinationMetadataRepository != null && metadataOrArtifacts == null) throw new ProvisionException(Messages.MirrorApplication_no_IUs); } } @@ -188,16 +310,15 @@ public class MirrorApplication extends AbstractApplication { return new FileMirrorLog(absolutePath, 0, root); } - private IQueryable slice(IProgressMonitor monitor) throws ProvisionException { + private IQueryable<IInstallableUnit> slice(IProgressMonitor monitor) throws ProvisionException { if (slicingOptions == null) slicingOptions = new SlicingOptions(); PermissiveSlicer slicer = new PermissiveSlicer(getCompositeMetadataRepository(), slicingOptions.getFilter(), slicingOptions.includeOptionalDependencies(), slicingOptions.isEverythingGreedy(), slicingOptions.forceFilterTo(), slicingOptions.considerStrictDependencyOnly(), slicingOptions.followOnlyFilteredRequirements()); - IQueryable slice = slicer.slice((IInstallableUnit[]) sourceIUs.toArray(new IInstallableUnit[sourceIUs.size()]), monitor); + IQueryable<IInstallableUnit> slice = slicer.slice(sourceIUs.toArray(new IInstallableUnit[sourceIUs.size()]), monitor); if (slice != null && slicingOptions.latestVersionOnly()) { - Collector collector = new Collector(); - collector = slice.query(new LatestIUVersionQuery(), collector, monitor); - slice = collector; + IQueryResult<IInstallableUnit> queryResult = slice.query(new LatestIUVersionQuery<IInstallableUnit>(), monitor); + slice = queryResult; } if (slicer.getStatus().getSeverity() != IStatus.OK && mirrorLog != null) { mirrorLog.log(slicer.getStatus()); diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RecreateRepositoryApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RecreateRepositoryApplication.java index adb7535d3..adaa79af6 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RecreateRepositoryApplication.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RecreateRepositoryApplication.java @@ -17,31 +17,32 @@ import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor; import org.eclipse.osgi.util.NLS; -public class RecreateRepositoryApplication { +public class RecreateRepositoryApplication extends AbstractApplication { static final private String PUBLISH_PACK_FILES_AS_SIBLINGS = "publishPackFilesAsSiblings"; //$NON-NLS-1$ private RepositoryDescriptor descriptor; private String repoName = null; boolean removeArtifactRepo = true; - private Map repoProperties = null; - private Map repoMap = null; - - public IStatus run(IProgressMonitor monitor) throws ProvisionException, IOException { + private Map<String, String> repoProperties = null; + private Map<IArtifactKey, IArtifactDescriptor[]> repoMap = null; + public IStatus run(IProgressMonitor monitor) throws ProvisionException { try { IArtifactRepository repository = initialize(monitor); removeRepository(repository, monitor); recreateRepository(monitor); } finally { if (removeArtifactRepo) { - IArtifactRepositoryManager repositoryManager = Activator.getArtifactRepositoryManager(); + IArtifactRepositoryManager repositoryManager = getArtifactRepositoryManager(); repositoryManager.removeRepository(descriptor.getRepoLocation()); } } @@ -54,7 +55,7 @@ public class RecreateRepositoryApplication { } private IArtifactRepository initialize(IProgressMonitor monitor) throws ProvisionException { - IArtifactRepositoryManager repositoryManager = Activator.getArtifactRepositoryManager(); + IArtifactRepositoryManager repositoryManager = getArtifactRepositoryManager(); removeArtifactRepo = !repositoryManager.contains(descriptor.getRepoLocation()); IArtifactRepository repository = repositoryManager.loadRepository(descriptor.getRepoLocation(), IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, monitor); @@ -67,46 +68,49 @@ public class RecreateRepositoryApplication { repoName = repository.getName(); repoProperties = repository.getProperties(); - repoMap = new HashMap(); - IArtifactKey[] keys = repository.getArtifactKeys(); - for (int i = 0; i < keys.length; i++) { - IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(keys[i]); - repoMap.put(keys[i], descriptors); + repoMap = new HashMap<IArtifactKey, IArtifactDescriptor[]>(); + IQueryResult<IArtifactKey> keys = repository.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator<IArtifactKey> iterator = keys.iterator(); iterator.hasNext();) { + IArtifactKey key = iterator.next(); + IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key); + repoMap.put(key, descriptors); } return repository; } - private void removeRepository(IArtifactRepository repository, IProgressMonitor monitor) throws ProvisionException, IOException { - IArtifactRepositoryManager manager = Activator.getArtifactRepositoryManager(); + private void removeRepository(IArtifactRepository repository, IProgressMonitor monitor) throws ProvisionException { + IArtifactRepositoryManager manager = getArtifactRepositoryManager(); manager.removeRepository(repository.getLocation()); - boolean compressed = Boolean.valueOf((String) repoProperties.get(IRepository.PROP_COMPRESSED)).booleanValue(); - URI realLocation = SimpleArtifactRepository.getActualLocation(repository.getLocation(), compressed); - File realFile = URIUtil.toFile(realLocation); - - if (!realFile.exists() || !realFile.delete()) - throw new ProvisionException(NLS.bind(Messages.exception_unableToRemoveRepo, realFile.toString())); + boolean compressed = Boolean.valueOf(repoProperties.get(IRepository.PROP_COMPRESSED)).booleanValue(); + try { + URI realLocation = SimpleArtifactRepository.getActualLocation(repository.getLocation(), compressed); + File realFile = URIUtil.toFile(realLocation); + if (!realFile.exists() || !realFile.delete()) + throw new ProvisionException(NLS.bind(Messages.exception_unableToRemoveRepo, realFile.toString())); + } catch (IOException e) { + throw new ProvisionException(NLS.bind(Messages.exception_unableToRemoveRepo, repository.getLocation().toString())); + } } private void recreateRepository(IProgressMonitor monitor) throws ProvisionException { - IArtifactRepositoryManager manager = Activator.getArtifactRepositoryManager(); + IArtifactRepositoryManager manager = getArtifactRepositoryManager(); //add pack200 mappings, the existing repoProperties is not modifiable - Map newProperties = new HashMap(repoProperties); + Map<String, String> newProperties = new HashMap<String, String>(repoProperties); newProperties.put(PUBLISH_PACK_FILES_AS_SIBLINGS, "true"); //$NON-NLS-1$ IArtifactRepository repository = manager.createRepository(descriptor.getRepoLocation(), repoName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, newProperties); if (!(repository instanceof IFileArtifactRepository)) throw new ProvisionException(NLS.bind(Messages.exception_notLocalFileRepo, repository.getLocation())); IFileArtifactRepository simple = (IFileArtifactRepository) repository; - for (Iterator iterator = repoMap.keySet().iterator(); iterator.hasNext();) { - IArtifactKey key = (IArtifactKey) iterator.next(); - IArtifactDescriptor[] descriptors = (IArtifactDescriptor[]) repoMap.get(key); + for (IArtifactKey key : repoMap.keySet()) { + IArtifactDescriptor[] descriptors = repoMap.get(key); String unpackedSize = null; File packFile = null; - Set files = new HashSet(); + Set<File> files = new HashSet<File>(); for (int i = 0; i < descriptors.length; i++) { File artifactFile = simple.getArtifactFile(descriptors[i]); files.add(artifactFile); @@ -137,15 +141,14 @@ public class RecreateRepositoryApplication { } private ArtifactDescriptor createPack200ArtifactDescriptor(IArtifactKey key, File packFile, String installSize) { - final String PACKED_FORMAT = "packed"; //$NON-NLS-1$ if (packFile != null && packFile.exists()) { ArtifactDescriptor result = new ArtifactDescriptor(key); result.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, installSize); result.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(packFile.length())); - ProcessingStepDescriptor[] steps = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$ + IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$ result.setProcessingSteps(steps); - result.setProperty(IArtifactDescriptor.FORMAT, PACKED_FORMAT); + result.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED); return result; } return null; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java index 07815f15f..067dc367b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java @@ -16,17 +16,21 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.p2.engine.DownloadManager; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRequest; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.internal.p2.engine.*; +import org.eclipse.equinox.internal.p2.engine.phases.Collect; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; /** * The transformer takes an existing p2 repository (local or remote), iterates over @@ -42,31 +46,26 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { private static final String PARM_OPERAND = "operand"; //$NON-NLS-1$ protected class CollectNativesAction extends ProvisioningAction { - public IStatus execute(Map parameters) { + public IStatus execute(Map<String, Object> parameters) { InstallableUnitOperand operand = (InstallableUnitOperand) parameters.get(PARM_OPERAND); IInstallableUnit installableUnit = operand.second(); - IArtifactRepositoryManager manager = null; - try { - manager = Activator.getArtifactRepositoryManager(); - } catch (ProvisionException e) { - return e.getStatus(); - } - - IArtifactKey[] toDownload = installableUnit.getArtifacts(); + IArtifactRepositoryManager manager = getArtifactRepositoryManager(); + Collection<IArtifactKey> toDownload = installableUnit.getArtifacts(); if (toDownload == null) return Status.OK_STATUS; - List artifactRequests = (List) parameters.get(NATIVE_ARTIFACTS); + @SuppressWarnings("unchecked") + List<IArtifactRequest> artifactRequests = (List<IArtifactRequest>) parameters.get(NATIVE_ARTIFACTS); - for (int i = 0; i < toDownload.length; i++) { - IArtifactRequest request = manager.createMirrorRequest(toDownload[i], destinationArtifactRepository, null, null); + for (IArtifactKey keyToDownload : toDownload) { + IArtifactRequest request = manager.createMirrorRequest(keyToDownload, destinationArtifactRepository, null, null); artifactRequests.add(request); } return Status.OK_STATUS; } - public IStatus undo(Map parameters) { + public IStatus undo(Map<String, Object> parameters) { // nothing to do for now return Status.OK_STATUS; } @@ -77,26 +76,28 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { super(NATIVE_ARTIFACTS, weight); } - protected ProvisioningAction[] getActions(InstallableUnitOperand operand) { + protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { IInstallableUnit unit = operand.second(); if (unit.getTouchpointType().getId().equals(NATIVE_TYPE)) { - return new ProvisioningAction[] {new CollectNativesAction()}; + return Collections.<ProvisioningAction> singletonList(new CollectNativesAction()); } return null; } - protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { + protected IStatus initializePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) { parameters.put(NATIVE_ARTIFACTS, new ArrayList()); return null; } - protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map parameters) { - List artifactRequests = (List) parameters.get(NATIVE_ARTIFACTS); + protected IStatus completePhase(IProgressMonitor monitor, IProfile profile, Map<String, Object> parameters) { + @SuppressWarnings("unchecked") + List<IArtifactRequest> artifactRequests = (List<IArtifactRequest>) parameters.get(NATIVE_ARTIFACTS); ProvisioningContext context = (ProvisioningContext) parameters.get(PARM_CONTEXT); - - DownloadManager dm = new DownloadManager(context); - for (Iterator it = artifactRequests.iterator(); it.hasNext();) { - dm.add((IArtifactRequest) it.next()); + IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT); + IArtifactRepositoryManager repositoryManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); + DownloadManager dm = new DownloadManager(context, repositoryManager); + for (IArtifactRequest request : artifactRequests) { + dm.add(request); } return dm.start(monitor); } @@ -104,7 +105,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { // the list of IUs that we actually transformed... could have come from the repo // or have been user-specified. - private Collection processedIUs = new ArrayList(); + private Collection<IInstallableUnit> processedIUs = new ArrayList<IInstallableUnit>(); /* * Perform the transformation. @@ -120,24 +121,25 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { // figure out which IUs we need to process collectIUs(progress.newChild(1)); - // create the operands from the list of IUs - InstallableUnitOperand[] operands = new InstallableUnitOperand[processedIUs.size()]; - int i = 0; - for (Iterator iter = processedIUs.iterator(); iter.hasNext();) - operands[i++] = new InstallableUnitOperand(null, (IInstallableUnit) iter.next()); - // call the engine with only the "collect" phase so all we do is download IProfile profile = createProfile(); try { + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits(processedIUs.toArray(new IInstallableUnit[processedIUs.size()])); ProvisioningContext context = new ProvisioningContext(); IEngine engine = (IEngine) ServiceHelper.getService(Activator.getBundleContext(), IEngine.SERVICE_NAME); if (engine == null) throw new ProvisionException(Messages.exception_noEngineService); + IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getBundleContext(), IPlanner.SERVICE_NAME); + if (planner == null) + throw new ProvisionException(Messages.exception_noPlannerService); - IStatus result = engine.perform(profile, getPhaseSet(), operands, context, progress.newChild(1)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, monitor); + IStatus result = engine.perform(plan, getPhaseSet(), progress.newChild(1)); PhaseSet nativeSet = getNativePhase(); if (nativeSet != null) - engine.perform(profile, nativeSet, operands, context, progress.newChild(1)); + engine.perform(plan, nativeSet, progress.newChild(1)); // publish the metadata to a destination - if requested publishMetadata(progress.newChild(1)); @@ -172,7 +174,9 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { if (!hasMetadataSources()) throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo); - processedIUs.addAll(getAllIUs(getCompositeMetadataRepository(), monitor).toCollection()); + Iterator<IInstallableUnit> itor = getAllIUs(getCompositeMetadataRepository(), monitor).iterator(); + while (itor.hasNext()) + processedIUs.add(itor.next()); if (processedIUs.isEmpty()) throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo); @@ -186,16 +190,16 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { // publishing the metadata is optional if (destinationMetadataRepository == null) return; - destinationMetadataRepository.addInstallableUnits((IInstallableUnit[]) processedIUs.toArray(new IInstallableUnit[processedIUs.size()])); + destinationMetadataRepository.addInstallableUnits(processedIUs.toArray(new IInstallableUnit[processedIUs.size()])); } /* * Return a collector over all the IUs contained in the given repository. */ - private Collector getAllIUs(IMetadataRepository repository, IProgressMonitor monitor) { + private IQueryResult<IInstallableUnit> getAllIUs(IMetadataRepository repository, IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, 2); try { - return repository.query(InstallableUnitQuery.ANY, new Collector(), progress.newChild(1)); + return repository.query(InstallableUnitQuery.ANY, progress.newChild(1)); } finally { progress.done(); } @@ -213,7 +217,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication { * Create and return a new profile. */ private IProfile createProfile() throws ProvisionException { - Map properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put(IProfile.PROP_CACHE, URIUtil.toFile(destinationArtifactRepository.getLocation()).getAbsolutePath()); properties.put(IProfile.PROP_INSTALL_FOLDER, URIUtil.toFile(destinationArtifactRepository.getLocation()).getAbsolutePath()); IProfileRegistry registry = Activator.getProfileRegistry(); diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryAnalyzerApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryAnalyzerApplication.java new file mode 100644 index 000000000..8a8503cca --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryAnalyzerApplication.java @@ -0,0 +1,68 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools; + +import java.net.URI; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.repository.tools.analyzer.RepositoryAnalyzer; + +/** + * + */ +public class RepositoryAnalyzerApplication implements IApplication { + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) throws Exception { + + long start = System.currentTimeMillis(); + URI uri = new URI("http://download.eclipse.org/releases/galileo"); + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getBundleContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepository repository = manager.loadRepository(uri, new NullProgressMonitor()); + RepositoryAnalyzer repositoryAnalyzer = new RepositoryAnalyzer(new IMetadataRepository[] {repository}); + IStatus status = repositoryAnalyzer.analyze(new NullProgressMonitor()); + IStatus[] children = status.getChildren(); + long time = (System.currentTimeMillis()) - start; + if (status.isOK()) + System.out.println("Repository Analyzer Finished succesfuly in " + time + " ms."); + else + System.out.println("Repository Analyzer Finished in " + time + " ms with status with errors."); + for (int i = 0; i < children.length; i++) { + if (children[i].isOK()) + System.out.print("[OK] "); + else + System.out.print("[Error] "); + System.out.println(children[i].getMessage()); + if (children[i].isMultiStatus() && children[i].getChildren() != null && children[i].getChildren().length > 0) { + IStatus[] subChildren = children[i].getChildren(); + for (int j = 0; j < subChildren.length; j++) { + System.out.println(" " + subChildren[j].getMessage()); + } + } + } + return IApplication.EXIT_OK; + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + // TODO Auto-generated method stub + + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java index 478f7fe10..f8c2ae76d 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java @@ -12,7 +12,7 @@ package org.eclipse.equinox.p2.internal.repository.tools; import java.net.URI; import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepository; import org.eclipse.osgi.util.NLS; public class RepositoryDescriptor { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/SlicingOptions.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/SlicingOptions.java index 6531d3696..639279ba6 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/SlicingOptions.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/SlicingOptions.java @@ -11,7 +11,7 @@ package org.eclipse.equinox.p2.internal.repository.tools; import java.util.Dictionary; -import java.util.Properties; +import java.util.Hashtable; public class SlicingOptions { private boolean includeOptionalDependencies = true; @@ -20,7 +20,7 @@ public class SlicingOptions { private boolean considerStrictDependencyOnly = false; private boolean followOnlyFilteredRequirements = false; private boolean latestVersion = false; - private Dictionary filter = null; + private Dictionary<String, Object> filter = null; public boolean includeOptionalDependencies() { return includeOptionalDependencies; @@ -54,13 +54,13 @@ public class SlicingOptions { this.considerStrictDependencyOnly = strict; } - public Dictionary getFilter() { + public Dictionary<String, Object> getFilter() { if (filter == null) - filter = new Properties(); + filter = new Hashtable<String, Object>(); return filter; } - public void setFilter(Dictionary filter) { + public void setFilter(Dictionary<String, Object> filter) { this.filter = filter; } diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/CopyrightAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/CopyrightAnalyzer.java new file mode 100644 index 000000000..ea1c42bcc --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/CopyrightAnalyzer.java @@ -0,0 +1,43 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that all Group IUs have a copyright. + */ +public class CopyrightAnalyzer extends IUAnalyzer { + + public void analyzeIU(IInstallableUnit iu) { + if (Boolean.valueOf(iu.getProperty(InstallableUnitDescription.PROP_TYPE_GROUP)).booleanValue()) { + if (iu.getCopyright() == null || iu.getCopyright().getBody().length() == 0) { + // If there is no copyright at all, this is an error + error(iu, "[ERROR] " + iu.getId() + " has no copyright"); + return; + } + if (iu.getCopyright() != null && iu.getCopyright().getBody().startsWith("%")) { + // If there is a copyright, but it starts with %, then check the default + // language for a copyright + String copyrightProperty = iu.getCopyright().getBody().substring(1); + if (iu.getProperty("df_LT." + copyrightProperty) == null) + error(iu, "[ERROR] " + iu.getId() + " has no copyright"); + } + } + } + + public void preAnalysis(IMetadataRepository repository) { + // do nothing + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java new file mode 100644 index 000000000..ed9125b23 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java @@ -0,0 +1,54 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.IMatchExpression; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that for each fragment the host can be resolved. + * Currently this service only checks requirements with the namespace "osgi.bundle" + */ +public class HostCheckAnalyzer extends IUAnalyzer { + + private IMetadataRepository repository; + + public void analyzeIU(IInstallableUnit iu) { + if (iu instanceof IInstallableUnitFragment) { + IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu; + IRequirement[] hosts = fragment.getHost(); + for (int i = 0; i < hosts.length; i++) { + IMatchExpression<IInstallableUnit> hostMatch = hosts[i].getMatches(); + String namespace = RequiredCapability.extractNamespace(hostMatch); + if ("osgi.bundle".equals(namespace)) { + String name = RequiredCapability.extractName(hostMatch); + VersionRange range = RequiredCapability.extractRange(hostMatch); + IQueryResult<IInstallableUnit> results = repository.query(new InstallableUnitQuery(name, range), new NullProgressMonitor()); + if (results.isEmpty()) { + error(iu, "IU Fragment: " + iu.getId() + " cannot find host" + name + " : " + range); + return; + } + } + } + } + + } + + public void preAnalysis(IMetadataRepository repository) { + this.repository = repository; + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/IUCounting.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/IUCounting.java new file mode 100644 index 000000000..4f1589c48 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/IUCounting.java @@ -0,0 +1,57 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IIUAnalyzer; + +/** + * This service just counts the total number of IUs + */ +public class IUCounting implements IIUAnalyzer { + + int totalIUs = 0; + int totalGroups = 0; + int totalFragments = 0; + int totalCategories = 0; + + private boolean hasProperty(IInstallableUnit iu, String property) { + return Boolean.valueOf(iu.getProperty(property)).booleanValue(); + } + + public void analyzeIU(IInstallableUnit iu) { + totalIUs++; + if (hasProperty(iu, InstallableUnitDescription.PROP_TYPE_FRAGMENT)) + totalFragments++; + if (hasProperty(iu, InstallableUnitDescription.PROP_TYPE_GROUP)) + totalGroups++; + if (hasProperty(iu, InstallableUnitDescription.PROP_TYPE_CATEGORY)) + totalCategories++; + } + + public IStatus postAnalysis() { + System.out.println("Total IUs: " + totalIUs); + System.out.println(" Total Groups: " + totalGroups); + System.out.println(" Total Fragments: " + totalFragments); + System.out.println(" Total Categories: " + totalCategories); + return null; + } + + public void preAnalysis(IMetadataRepository repo) { + totalIUs = 0; + totalGroups = 0; + totalFragments = 0; + totalCategories = 0; + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java new file mode 100644 index 000000000..452e12427 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/LicenseAnalyzer.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2009 EclipseSource 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: + * EclipseSource - initial API and implementation + ******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.equinox.p2.metadata.ILicense; + +import java.util.Collection; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that each IU has a license. + */ +public class LicenseAnalyzer extends IUAnalyzer { + + public void analyzeIU(IInstallableUnit iu) { + if (Boolean.valueOf(iu.getProperty(InstallableUnitDescription.PROP_TYPE_GROUP)).booleanValue()) { + Collection<ILicense> licenses = iu.getLicenses(); + if (iu.getLicenses() == null || licenses.size() == 0) { + // If there is no license then this is an error + error(iu, "[ERROR] " + iu.getId() + " has no license"); + return; + } else if (licenses.iterator().next().getBody().length() == 0) { + error(iu, "[ERROR] " + iu.getId() + " has no license"); + return; + } + for (ILicense license : licenses) { + if (license.getBody().startsWith("%")) { + String licenseProperty = license.getBody().substring(1); + if (iu.getProperty("df_LT." + licenseProperty) == null) { + error(iu, "[ERROR] " + iu.getId() + " has no license"); + } + } + } + } + } + + public void preAnalysis(IMetadataRepository repository) { + // Do nothing + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UniqueIUAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UniqueIUAnalyzer.java new file mode 100644 index 000000000..8e589bf05 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UniqueIUAnalyzer.java @@ -0,0 +1,38 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import java.util.HashSet; +import java.util.Set; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that each IU is unique in a given repository. + */ +public class UniqueIUAnalyzer extends IUAnalyzer { + + Set<String> versionedNames = null; + + public void analyzeIU(IInstallableUnit iu) { + // Create a unique name / version pair and cache it + String uniqueID = iu.getId() + ":" + iu.getVersion().toString(); + if (versionedNames.contains(uniqueID)) { + error(iu, "[ERROR]" + iu.getId() + " with version: " + iu.getVersion() + " already exists in the repository"); + return; + } + versionedNames.add(uniqueID); + } + + public void preAnalysis(IMetadataRepository repo) { + versionedNames = new HashSet<String>(); + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UnzipFeatureJarAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UnzipFeatureJarAnalyzer.java new file mode 100644 index 000000000..bb0d2193a --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/UnzipFeatureJarAnalyzer.java @@ -0,0 +1,49 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.equinox.p2.metadata.ITouchpointData; +import org.eclipse.equinox.p2.metadata.ITouchpointInstruction; + +import java.util.List; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that each Feature Jar IU has the unzip touchpoint + */ +public class UnzipFeatureJarAnalyzer extends IUAnalyzer { + + public void analyzeIU(IInstallableUnit iu) { + if (iu.getId().indexOf("feature.jar") > -1) { + List<ITouchpointData> touchpointData = iu.getTouchpointData(); + if (touchpointData.size() == 0) { + error(iu, "[ERROR] No unzip touchpoint for: " + iu.getId()); + } else { + boolean found = false; + for (int i = 0; i < touchpointData.size(); i++) { + ITouchpointInstruction instruction = touchpointData.get(i).getInstruction("zipped"); + if (instruction.getBody().equals("true")) + found = true; + } + if (!found) { + error(iu, "[ERROR] No unzip touchpoint for: " + iu.getId()); + } + } + } + + } + + public void preAnalysis(IMetadataRepository repository) { + // Do nothing + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/VersionAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/VersionAnalyzer.java new file mode 100644 index 000000000..81a90bdc7 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/VersionAnalyzer.java @@ -0,0 +1,43 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.internal.repository.tools.analyzer; + +import org.eclipse.equinox.p2.metadata.Version; + +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.tools.analyzer.IUAnalyzer; + +/** + * This service checks that each IU has a proper version number + * 1. No 0.0.0 + * 2. No x.y.z.qualifier (each qualifier has been replaced) + */ +public class VersionAnalyzer extends IUAnalyzer { + + public void analyzeIU(IInstallableUnit iu) { + if (iu.getVersion().equals(Version.emptyVersion)) { + error(iu, "[ERROR] IU: " + iu.getId() + " has not replaced its qualifiier"); + return; + } + if (iu.getVersion().isOSGiCompatible()) { + String qualifier = Version.toOSGiVersion(iu.getVersion()).getQualifier(); + if (qualifier != null && qualifier.equals("qualifier")) { + error(iu, "[ERROR] IU: " + iu.getId() + " has not replaced its qualifiier"); + return; + } + } + } + + public void preAnalysis(IMetadataRepository repo) { + // Do nothing + } + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties index 6b07d7fc7..708aacfd7 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties @@ -16,6 +16,10 @@ CompositeRepository_default_artifactRepo_name=Composite Artifact Repository CompositeRepository_default_metadataRepo_name=Composite Artifact Repository CompositeRepositoryApplication_failedComparator=Artifact repository failed test with comparator: {0} +info_noMD5Infomation=No MD5 information available for the artifact [{0}]. +info_noMD5InRepository=The repository {0} does not contain MD5 information for artifact [{1}]. +warning_differentMD5=The repositories {0} and {1} have different MD5 sums for the artifact [{2}]. + no_artifactRepo_manager=Unable to acquire artifact repository manager service. no_metadataRepo_manager=Unable to acquire metadata repository manager service. no_package_admin=Unable to acquire package admin service. @@ -27,12 +31,9 @@ skippingInvalidFilter=Invalid filter format, skipping {0}. MirrorApplication_artifactDestinationNoSource=Destination artifact repository specified without a corresponding source artifact repository. MirrorApplication_metadataDestinationNoSource=Destination metadata repository specified without a corresponding source metadata repository. -MirrorApplication_missingIU=Missing: {0} -MirrorApplication_missingSourceForIUs=Unable to locate source repository for IUs MirrorApplication_no_IUs=No IUs specified and no IUs obtained from metadata repositories. MirrorApplication_set_source_repositories=Need to set the source repository location(s). -MirrorApplication_validateAndMirrorProblems=Problems occurred during validation and mirroring -ProcessRepo_location_not_url=Repository location {0} must be a URL. +ProcessRepo_location_not_url=Repository location {0} must be a URI. ProcessRepo_must_be_local=Repository must be local: {0} @@ -44,7 +45,19 @@ exception_invalidSource=Invalid source repository location: {0}. exception_unableToRemoveRepo=Unable to remove artifact repository file: {0}. exception_notLocalFileRepo= {0} is not a local file based repository. exception_noEngineService=Unable to acquire engine service. +exception_noPlannerService=Unable to acquire planner service. +exception_loadingRepository=Exception while loading repository. exception_needIUsOrNonEmptyRepo=Need to specify either a non-empty source metadata repository or a valid list of IUs. exception_needDestinationRepo=Need to set the destination artifact repository location. exception_onlyOneComparator=Only one comparator should be defined. -Repo2RunnableTask_errorTransforming=Error occurred while transforming repository.
\ No newline at end of file +Repo2RunnableTask_errorTransforming=Error occurred while transforming repository: {0}. + +message_mirroringStatus = Messages while mirroring artifact descriptors. +Mirroring_compareAndDownload=Compare and download of {0} from baseline. +mirror_alreadyExists=Artifact: {0} already exists in repository: {1}. +Mirroring_noMatchingDescriptor=Could not match descriptor for compare +Mirroring_ValidationError=Error occurred while validating mirror. +Mirroring_missingDescriptor=Missing descriptor: {0}. +Mirroring_differentDescriptorProperty=Descriptor {0} has different properties for {1}, source: {2}, destination: {3}. + +invalidComparatorId={0} is not a valid comparator id.
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IIUAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IIUAnalyzer.java new file mode 100644 index 000000000..f1dae6c8d --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IIUAnalyzer.java @@ -0,0 +1,38 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.repository.tools.analyzer; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; + +/** + * The IUAnalaysis Interface. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * + * Clients are encouraged to extend IUAnalysis, an abstract class that implements + * this interface. + * + * @since 2.0 + * + */ +public interface IIUAnalyzer { + + public static final String ID = "org.eclipse.equinox.p2.repository.tools.verifier"; //$NON-NLS-1$ + + public void preAnalysis(IMetadataRepository repository); + + public IStatus postAnalysis(); + + public void analyzeIU(IInstallableUnit iu); + +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IUAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IUAnalyzer.java new file mode 100644 index 000000000..4d5bc0ca3 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/IUAnalyzer.java @@ -0,0 +1,46 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.repository.tools.analyzer; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.p2.internal.repository.tools.Activator; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; + +/** + * An abstract base class for the Analyzer. Clients are encouraged to extends this + * class when defining IU Analysis extension points. + * + */ +public abstract class IUAnalyzer implements IIUAnalyzer { + + private List<IStatus> errors = null; + private String analyzerName; + + public void setName(String name) { + this.analyzerName = name; + } + + protected void error(IInstallableUnit iu, String error) { + if (errors == null) + errors = new ArrayList<IStatus>(); + errors.add(new Status(IStatus.ERROR, Activator.ID, error)); + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.p2.repository.tools.verifier.IIUAnalysis#postAnalysis() + */ + public IStatus postAnalysis() { + if (errors == null || errors.size() == 0) + return Status.OK_STATUS; + return new MultiStatus(Activator.ID, IStatus.ERROR, errors.toArray(new IStatus[errors.size()]), analyzerName, null); + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java new file mode 100644 index 000000000..f3e208ec1 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java @@ -0,0 +1,72 @@ +/******************************************************************************* +* Copyright (c) 2009 EclipseSource 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: +* EclipseSource - initial API and implementation +******************************************************************************/ +package org.eclipse.equinox.p2.repository.tools.analyzer; + +import java.util.Iterator; +import org.eclipse.core.runtime.*; +import org.eclipse.equinox.p2.internal.repository.tools.Activator; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; + +/** + * + */ +public class RepositoryAnalyzer { + + private final IMetadataRepository[] repositories; + + public RepositoryAnalyzer(IMetadataRepository[] repositories) { + this.repositories = repositories; + } + + public IStatus analyze(IProgressMonitor monitor) { + MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, null, null); + + SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 2); + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(IIUAnalyzer.ID); + + for (int i = 0; i < repositories.length; i++) { + IQueryResult<IInstallableUnit> queryResult = repositories[i].query(InstallableUnitQuery.ANY, sub); + + SubMonitor repositoryMonitor = SubMonitor.convert(sub, IProgressMonitor.UNKNOWN); + for (int j = 0; j < config.length; j++) { + try { + IIUAnalyzer verifier = (IIUAnalyzer) config[j].createExecutableExtension("class"); //$NON-NLS-1$ + String analyizerName = config[j].getAttribute("name"); //$NON-NLS-1$ + if (verifier instanceof IUAnalyzer) { + ((IUAnalyzer) verifier).setName(analyizerName); + } + verifier.preAnalysis(repositories[i]); + Iterator<IInstallableUnit> iter = queryResult.iterator(); + while (iter.hasNext()) { + IInstallableUnit iu = iter.next(); + verifier.analyzeIU(iu); + } + IStatus postAnalysisResult = verifier.postAnalysis(); + if (postAnalysisResult == null) + postAnalysisResult = new Status(IStatus.OK, Activator.ID, analyizerName); + if (postAnalysisResult.isOK() && !postAnalysisResult.isMultiStatus()) + postAnalysisResult = new Status(IStatus.OK, Activator.ID, analyizerName); + result.add(postAnalysisResult); + } catch (CoreException e) { + if (e.getCause() instanceof ClassNotFoundException) { + result.add(new Status(IStatus.ERROR, Activator.ID, "Cannot find: " + config[j].getAttribute("class"))); + } else + e.printStackTrace(); + } + } + repositoryMonitor.done(); + } + sub.done(); + return result; + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/ArtifactComparatorFactory.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/ArtifactComparatorFactory.java new file mode 100644 index 000000000..522fc9ac3 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/ArtifactComparatorFactory.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 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.p2.repository.tools.comparator; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.RegistryFactory; +import org.eclipse.equinox.internal.p2.artifact.repository.Messages; +import org.eclipse.osgi.util.NLS; + +public class ArtifactComparatorFactory { + private static final String comparatorPoint = "org.eclipse.equinox.p2.artifact.repository.artifactComparators"; //$NON-NLS-1$ + private static final String ATTR_ID = "id"; //$NON-NLS-1$ + private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ + + public static IArtifactComparator getArtifactComparator(String comparatorID) { + IConfigurationElement[] extensions = RegistryFactory.getRegistry().getConfigurationElementsFor(comparatorPoint); + + IConfigurationElement element = null; + if (comparatorID == null && extensions.length > 0) { + element = extensions[0]; //just take the first one + } else { + for (int i = 0; i < extensions.length; i++) { + if (extensions[i].getAttribute(ATTR_ID).equals(comparatorID)) { + element = extensions[i]; + break; + } + } + } + if (element != null) { + try { + Object execExt = element.createExecutableExtension(ATTR_CLASS); + if (execExt instanceof IArtifactComparator) + return (IArtifactComparator) execExt; + } catch (Exception e) { + //fall through + } + } + + if (comparatorID != null) + throw new IllegalArgumentException(NLS.bind(Messages.exception_comparatorNotFound, comparatorID)); + throw new IllegalArgumentException(Messages.exception_noComparators); + } +} diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/IArtifactComparator.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/IArtifactComparator.java new file mode 100644 index 000000000..5197395ae --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/comparator/IArtifactComparator.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 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 + *******************************************************************************/ + +package org.eclipse.equinox.p2.repository.tools.comparator; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; + +public interface IArtifactComparator { + + /** + * Compare 2 equivalent IArtifactDescriptors from different repositories. + * + * IArtifactDescriptors with the same id and version should represent the same + * set of bytes. The comparator should ensure this is true and return an error + * or warning otherwise. + * + * @param source - The source IArtifactRepository + * @param sourceDescriptor - The IArtifactDescriptor from the source repository + * @param destination - The target IArtifactRepository + * @param destDescriptor - The IArtifactDescriptor from the target repository + * + * @return IStatus + */ + public IStatus compare(IArtifactRepository source, IArtifactDescriptor sourceDescriptor, IArtifactRepository destination, IArtifactDescriptor destDescriptor); +} |