@Override public Map<String, String> getArtifactProperties(IInstallableUnit iu, IArtifactDescriptor descriptor) { // workaround Bug 539672 // TODO this is a nasty hack, and it doesn't even work; see org.eclipse.equinox.p2.publisher.AbstractPublisherAction.processArtifactPropertiesAdvice(IInstallableUnit, IArtifactDescriptor, IPublisherInfo) for (Map.Entry<String, String> entry : properties.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ((ArtifactDescriptor) descriptor).setProperty(key, value); } return null; }
private static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk) { IArtifactDescriptor result = artifactRepo != null ? artifactRepo.createArtifactDescriptor(key) : new ArtifactDescriptor(key); if (result instanceof ArtifactDescriptor) { ArtifactDescriptor descriptor = (ArtifactDescriptor) result; if (pathOnDisk != null) { descriptor.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, Long.toString(pathOnDisk.length())); descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); } if (info == null || (info.getArtifactOptions() & IPublisherInfo.A_NO_MD5) == 0) { String md5 = computeMD5(pathOnDisk); if (md5 != null) descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, md5); } } return result; }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; // Other implementations of IArtifactDescriptor must not be considered equal if (!(obj.getClass().equals(getClass()))) return false; ArtifactDescriptor other = (ArtifactDescriptor) obj; if (key == null) { if (other.getArtifactKey() != null) return false; } else if (!key.equals(other.getArtifactKey())) return false; if (!Arrays.equals(processingSteps, other.getProcessingSteps())) return false; String format = getProperty(FORMAT); String otherFormat = other.getProperty(FORMAT); if (format != null ? !format.equals(otherFormat) : otherFormat != null) return false; return true; }
protected IArtifactDescriptor createPack200ArtifactDescriptor(IArtifactKey key, File pathOnDisk, String installSize) { ArtifactDescriptor result = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, key, pathOnDisk); //TODO this size calculation is bogus if (pathOnDisk != null) { result.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, installSize); // TODO - this is wrong but I'm testing a work-around for bug 205842 result.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); } IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$ result.setProcessingSteps(steps); result.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED); return result; }
public synchronized URI createLocation(ArtifactDescriptor descriptor) { if (flatButPackedEnabled(descriptor)) { return getLocationForPackedButFlatArtifacts(descriptor); } // if the descriptor is canonical, clear out any UUID that might be set and use the Mapper if (descriptor.getProcessingSteps().length == 0) { descriptor.setProperty(ARTIFACT_UUID, null); IArtifactKey key = descriptor.getArtifactKey(); URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT)); if (result != null) { if (isFolderBased(descriptor) && URIUtil.lastSegment(result).endsWith(JAR_EXTENSION)) { return URIUtil.removeFileExtension(result); } return result; } } // Otherwise generate a location by creating a UUID, remembering it in the properties // and computing the location byte[] bytes = new UniversalUniqueIdentifier().toBytes(); descriptor.setProperty(ARTIFACT_UUID, bytesToHexString(bytes)); return blobStore.fileFor(bytes); }
throw new Error(); ArtifactDescriptor d = new ArtifactDescriptor(a); d.setProperty(e.getKey(), e.getValue()); break; d.setProcessingSteps(Arrays.stream(ad[0].getProcessingSteps()).filter( e -> !e.getProcessorId().equals("org.eclipse.equinox.p2.processing.Pack200Unpacker")) .toArray(IProcessingStepDescriptor[]::new));
private static void calculateChecksums(File pathOnDisk, ArtifactDescriptor descriptor) { // TODO disable specific algorithms List<String> checksumsToSkip = Collections.emptyList(); Map<String, String> checksums = new HashMap<>(); IStatus status = ChecksumUtilities.calculateChecksums(pathOnDisk, checksums, checksumsToSkip); if (!status.isOK()) { // TODO handle errors in some way LogHelper.log(status); } Map<String, String> checksumProperties = ChecksumUtilities.checksumsToProperties(IArtifactDescriptor.DOWNLOAD_CHECKSUM, checksums); descriptor.addProperties(checksumProperties); }
public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) { return new ArtifactDescriptor(key); }
public String toString() { String format = getProperty(IArtifactDescriptor.FORMAT); if (format == null) return "canonical: " + key.toString(); //$NON-NLS-1$ return format + ": " + key.toString(); //$NON-NLS-1$ }
public int hashCode() { int superHash = super.hashCode(); String ref = getRepositoryProperty(ARTIFACT_REFERENCE); if (ref != null) return 31 * superHash + ref.hashCode(); return superHash; } }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof SimpleArtifactDescriptor)) return false; SimpleArtifactDescriptor other = (SimpleArtifactDescriptor) obj; //Properties affecting SimpleArtifactRepository#getLocation String locationProperty = getRepositoryProperty(ARTIFACT_REFERENCE); String otherProperty = other.getRepositoryProperty(ARTIFACT_REFERENCE); // want not null and the same, or both null if (locationProperty != null ? !locationProperty.equals(otherProperty) : otherProperty != null) return false; return super.equals(obj); }
public synchronized URI createLocation(ArtifactDescriptor descriptor) { if (flatButPackedEnabled(descriptor)) { return getLocationForPackedButFlatArtifacts(descriptor); } // if the descriptor is canonical, clear out any UUID that might be set and use the Mapper if (descriptor.getProcessingSteps().length == 0) { descriptor.setProperty(ARTIFACT_UUID, null); IArtifactKey key = descriptor.getArtifactKey(); URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT)); if (result != null) { if (isFolderBased(descriptor) && URIUtil.lastSegment(result).endsWith(JAR_EXTENSION)) { return URIUtil.removeFileExtension(result); } return result; } } // Otherwise generate a location by creating a UUID, remembering it in the properties // and computing the location byte[] bytes = new UniversalUniqueIdentifier().toBytes(); descriptor.setProperty(ARTIFACT_UUID, bytesToHexString(bytes)); return blobStore.fileFor(bytes); }
protected IArtifactDescriptor createPack200ArtifactDescriptor(IArtifactKey key, File pathOnDisk, String installSize) { ArtifactDescriptor result = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, key, pathOnDisk); //TODO this size calculation is bogus if (pathOnDisk != null) { result.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, installSize); // TODO - this is wrong but I'm testing a work-around for bug 205842 result.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); } IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; //$NON-NLS-1$ result.setProcessingSteps(steps); result.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED); return result; }
private IArtifactDescriptor getDestinationDescriptor(IArtifactDescriptor sourceDescriptor) { // Get the descriptor to use to store the artifact // Since we are mirroring, ensure we clear out data from the original descriptor that may // not apply in the new repo location. // TODO this is brittle. perhaps the repo itself should do this? there are cases where // we really do need to give the repo the actual descriptor to use however... IArtifactDescriptor destinationDescriptor = target.createArtifactDescriptor(sourceDescriptor.getArtifactKey()); // destinationDescriptor.setProcessingSteps(EMPTY_STEPS); // destinationDescriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, null); // destinationDescriptor.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, null); // destinationDescriptor.setProperty(IArtifactDescriptor.FORMAT, null); if (targetDescriptorProperties != null && destinationDescriptor instanceof ArtifactDescriptor) ((ArtifactDescriptor) destinationDescriptor).addProperties(targetDescriptorProperties); if (targetRepositoryProperties != null && destinationDescriptor instanceof SimpleArtifactDescriptor) ((SimpleArtifactDescriptor) destinationDescriptor).addRepositoryProperties(targetRepositoryProperties); return destinationDescriptor; }
public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) { return new ArtifactDescriptor(key); }
public String toString() { String format = getProperty(IArtifactDescriptor.FORMAT); if (format == null) return "canonical: " + key.toString(); //$NON-NLS-1$ return format + ": " + key.toString(); //$NON-NLS-1$ }
public int hashCode() { int superHash = super.hashCode(); String ref = getRepositoryProperty(ARTIFACT_REFERENCE); if (ref != null) return 31 * superHash + ref.hashCode(); return superHash; } }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof SimpleArtifactDescriptor)) return false; SimpleArtifactDescriptor other = (SimpleArtifactDescriptor) obj; //Properties affecting SimpleArtifactRepository#getLocation String locationProperty = getRepositoryProperty(ARTIFACT_REFERENCE); String otherProperty = other.getRepositoryProperty(ARTIFACT_REFERENCE); // want not null and the same, or both null if (locationProperty != null ? !locationProperty.equals(otherProperty) : otherProperty != null) return false; return super.equals(obj); }
public synchronized URI createLocation(ArtifactDescriptor descriptor) { if (flatButPackedEnabled(descriptor)) { return getLocationForPackedButFlatArtifacts(descriptor); } // if the descriptor is canonical, clear out any UUID that might be set and use the Mapper if (descriptor.getProcessingSteps().length == 0) { descriptor.setProperty(ARTIFACT_UUID, null); IArtifactKey key = descriptor.getArtifactKey(); URI result = mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(), descriptor.getProperty(IArtifactDescriptor.FORMAT)); if (result != null) { if (isFolderBased(descriptor) && URIUtil.lastSegment(result).endsWith(JAR_EXTENSION)) { return URIUtil.removeFileExtension(result); } return result; } } // Otherwise generate a location by creating a UUID, remembering it in the properties // and computing the location byte[] bytes = new UniversalUniqueIdentifier().toBytes(); descriptor.setProperty(ARTIFACT_UUID, bytesToHexString(bytes)); return blobStore.fileFor(bytes); }
@Override public Map<String, String> getArtifactProperties(IInstallableUnit iu, IArtifactDescriptor descriptor) { final StringBuilder builder = new StringBuilder(); builder.append(iu.getId()); builder.append('/'); builder.append(iu.getVersion()); // Workaround bug Bug 539672 ((ArtifactDescriptor) descriptor).setProperty(PROPERTY_NAME, builder.toString()); return null; }