@Override public boolean accepts(ContentItem item) { final ContentType type = item.getContentType(); return type == ContentType.MISC; } };
@Override public boolean prepare(final PatchingTaskContext context) throws IOException { // Backup backupHash = backup(context); // If the content is already present just resolve any conflict automatically final byte[] contentHash = contentItem.getContentHash(); if(Arrays.equals(backupHash, contentHash)) { // Skip execute for misc items only skipExecution = contentItem.getContentType() == ContentType.MISC && backupHash != NO_CONTENT; return true; } // See if the content matches our expected target final byte[] expected = description.getModification().getTargetHash(); if(Arrays.equals(backupHash, expected)) { // Don't resolve conflicts from the history return ! description.hasConflicts(); } return false; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; MiscContentItem other = (MiscContentItem) obj; if (affectsRuntime != other.affectsRuntime) return false; if (isDirectory != other.isDirectory) return false; return Arrays.equals(path, other.path); } }
private Integer getKey(ContentItem item) { final int prime = 31; int result = 1; result = prime * result + item.getContentType().hashCode(); result = prime * result + item.getRelativePath().hashCode(); return result; } }
static void contentHash(final ContentModification modification, byte[] resultingHash) { if (resultingHash != null) { final byte[] contentHash = modification.getItem().getContentHash(); System.arraycopy(contentHash, 0, resultingHash, 0, contentHash.length); } }
InstalledIdentity patchedInstalledIdentity = InstalledIdentity.load(env.getInstalledImage().getJbossHome(), productConfig, env.getInstalledImage().getModulesDir()); assertInstallationIsPatched(patch, patchedInstalledIdentity.getIdentity().loadTargetInfo()); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); File modulesPatchDir = layerDirStructure.getModulePatchDirectory(layerPatchId); assertDirExists(modulesPatchDir); assertDefinedModule(modulesPatchDir, moduleName, moduleAdded.getItem().getContentHash());
final ContentType contentType = mod.getItem().getContentType(); if(ContentType.MISC.equals(contentType)) { modSrcDir = new File(modSrcDir, Constants.MISC); for (String name : mod.getItem().getName().split("\\.")) { modSrcDir = new File(modSrcDir, name); modTrgDir = new File(modTrgDir, name);
@Test public void testAddFile() throws Exception { // build a one-off patch for the base installation // with 1 added file String patchID = randomString(); File patchDir = mkdir(tempDir, patchID); ContentModification fileAdded = ContentModificationUtils.addMisc(patchDir, patchID, "new file resource", "bin", "my-new-standalone.sh"); Patch patch = PatchBuilder.create() .setPatchId(patchID) .setDescription(randomString()) .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion()) .getParent() .addContentModification(fileAdded) .build(); assertFileDoesNotExist(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); createPatchXMLFile(patchDir, patch); File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId()); PatchingResult result = executePatch(zippedPatch); assertPatchHasBeenApplied(result, patch); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((slot == null) ? 0 : slot.hashCode()); return result; }
private Integer getKey(ContentItem item) { final int prime = 31; int result = 1; result = prime * result + item.getContentType().hashCode(); result = prime * result + item.getRelativePath().hashCode(); return result; } }
final byte[] hash = previous.getItem().getContentHash(); if (!Arrays.equals(hash, contentEntry.getTargetHash())) { throw new IllegalStateException(); final byte[] originalContent = original.getItem().getContentHash(); } else { final byte[] backupItem = item.getContentHash(); final byte[] originalTarget = original.getTargetHash();
InstalledIdentity patchedInstalledIdentity = loadInstalledIdentity(); assertInstallationIsPatched(patch, patchedInstalledIdentity.getIdentity().loadTargetInfo()); assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); assertDefinedModule(modulesPatchDir, moduleName, moduleAdded.getItem().getContentHash());
final ContentType contentType = mod.getItem().getContentType(); if(ContentType.MISC.equals(contentType)) { modSrcDir = new File(modSrcDir, Constants.MISC); for (String name : mod.getItem().getName().split("\\.")) { modSrcDir = new File(modSrcDir, name); modTrgDir = new File(modTrgDir, name);
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (affectsRuntime ? 1231 : 1237); result = prime * result + (isDirectory ? 1231 : 1237); result = prime * result + Arrays.hashCode(path); return result; }
@Override public boolean accepts(ContentItem item) { final ContentType type = item.getContentType(); return type != ContentType.MISC; } };
@Override public boolean prepare(final PatchingTaskContext context) throws IOException { // Backup backupHash = backup(context); // If the content is already present just resolve any conflict automatically final byte[] contentHash = contentItem.getContentHash(); if(Arrays.equals(backupHash, contentHash)) { // Skip execute for misc items only skipExecution = contentItem.getContentType() == ContentType.MISC && backupHash != NO_CONTENT; return true; } // See if the content matches our expected target final byte[] expected = description.getModification().getTargetHash(); if(Arrays.equals(backupHash, expected)) { // Don't resolve conflicts from the history return ! description.hasConflicts(); } return false; }
public static void formatFailedResponse(final PatchingException e, final ModelNode failureDescription) { if(e instanceof ContentConflictsException) { failureDescription.get(Constants.MESSAGE).set(PatchLogger.ROOT_LOGGER.detectedConflicts()); final ModelNode conflicts = failureDescription.get(Constants.CONFLICTS); for(final ContentItem item : ((ContentConflictsException)e).getConflicts()) { final ContentType type = item.getContentType(); switch (type) { case BUNDLE: conflicts.get(Constants.BUNDLES).add(item.getRelativePath()); break; case MODULE: conflicts.get(Constants.MODULES).add(item.getRelativePath()); break; case MISC: conflicts.get(Constants.MISC).add(item.getRelativePath()); break; } } } else { failureDescription.set(e.getLocalizedMessage()); } }
final byte[] hash = previous.getItem().getContentHash(); if (!Arrays.equals(hash, contentEntry.getTargetHash())) { throw new IllegalStateException(); final byte[] originalContent = original.getItem().getContentHash(); } else { final byte[] backupItem = item.getContentHash(); final byte[] originalTarget = original.getTargetHash();
assertFileExists(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); assertDefinedModule(modulesPatchDir, moduleName, moduleAdded.getItem().getContentHash()); PatchingAssert.assertFileDoesNotExist(env.getInstalledImage().getJbossHome(), "bin", fileAdded.getItem().getName()); if (File.separatorChar != '\\') { assertDirDoesNotExist(rolledBackInstalledIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(layerPatchId));
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((slot == null) ? 0 : slot.hashCode()); return result; }