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()); } }
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()); } }
static void assertPatchHasNotBeenApplied(ContentConflictsException result, Patch patch, ContentItem problematicItem, DirectoryStructure structure) { assertFalse("patch should have failed", result.getConflicts().isEmpty()); assertTrue(problematicItem + " is not reported in the problems " + result.getConflicts(), result.getConflicts().contains(problematicItem)); assertDirDoesNotExist(structure.getInstalledImage().getPatchHistoryDir(patch.getPatchId())); }
protected PatchingTestStepBuilder testModuleConflicts(final ContentVerificationPolicy resolvePolicy) throws Exception { final PatchingTestBuilder builder = createDefaultBuilder(); final byte[] moduleHash = new byte[20]; // Create a conflict final File base = builder.getFile("modules", "system", "layers", "base"); createModule0(base, "org.jboss.test", randomString()); final PatchingTestStepBuilder oneOff1 = builder.createStepBuilder(); oneOff1.setPatchId("one-off-1") .oneOffPatchIdentity(PRODUCT_VERSION) .oneOffPatchElement("base-oo1", BASE, false) .updateModuleWithRandomContent("org.jboss.test", NO_CONTENT, moduleHash) ; try { apply(oneOff1); Assert.fail("should have detected conflicts"); } catch (ContentConflictsException expected) { final ModuleItem item = new ModuleItem("org.jboss.test", "main", moduleHash); Assert.assertTrue(expected.getConflicts().contains(item)); } // Apply patch and override all apply(oneOff1, resolvePolicy); return oneOff1; }