@Override public final PatchingException doesNotApply(final String appliesTo, final String version) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), doesNotApply$str(), appliesTo, version)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToDelete = "WFLYPAT0004: Failed to delete (%s)";
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
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 PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
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()); } }
@Override public final PatchingException cannotCopyFilesToTempDir(final String tempDir, final String reason, final Throwable cause) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), cannotCopyFilesToTempDir$str(), tempDir, reason), cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotCopyFiles = "WFLYPAT0047: Cannot copy files from %s to %s: %s";
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
@Override protected Layer getProvider(final String name, final InstalledIdentity identity) throws OperationFailedException { final Layer target = identity.getLayer(name); if (target == null) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.noSuchLayer(name).getLocalizedMessage()); } return target; } }
@Override public final PatchingException alreadyApplied(final String patchId) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), alreadyApplied$str(), patchId)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String noSuchLayer = "WFLYPAT0013: There is no layer called %s installed";
static PatchingException rethrowException(final Exception e) { if (e instanceof PatchingException) { return (PatchingException) e; } else { return new PatchingException(e); } }
@Override protected PatchableTarget getProvider(final String name, final InstalledIdentity identity) throws OperationFailedException { final AddOn target = identity.getAddOn(name); if (target == null) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.noSuchLayer(name).getLocalizedMessage()); } return target; } }
@Override public final PatchingException noSuchLayer(final String name) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), noSuchLayer$str(), name)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToResolvePatch = "WFLYPAT0014: Failed to resolve a valid patch descriptor for %s %s";
private static void copyFile(File source, File target) throws PatchingException { try { Files.copy(source.toPath(), target.toPath()); } catch (IOException e1) { throw new PatchingException("Failed to copy " + source.getAbsolutePath() + " to " + target.getAbsolutePath()); } }
@Override protected PatchableTarget getProvider(final String name, final InstalledIdentity identity) throws OperationFailedException { final AddOn target = identity.getAddOn(name); if (target == null) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.noSuchLayer(name).getLocalizedMessage()); } return target; } }
@Override public final PatchingException failedToResolvePatch(final String product, final String version) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), failedToResolvePatch$str(), product, version)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String requiresPatch = "WFLYPAT0015: Requires patch '%s'";
private static void copyFile(File source, File target) throws PatchingException { try { Files.copy(source.toPath(), target.toPath()); } catch (IOException e1) { throw new PatchingException("Failed to copy " + source.getAbsolutePath() + " to " + target.getAbsolutePath()); } }
@Override protected Layer getProvider(final String name, final InstalledIdentity identity) throws OperationFailedException { final Layer target = identity.getLayer(name); if (target == null) { throw new OperationFailedException(PatchLogger.ROOT_LOGGER.noSuchLayer(name).getLocalizedMessage()); } return target; } }
@Override public final PatchingException cannotRollbackPatch(final String id) { final PatchingException result = new PatchingException(String.format(getLoggingLocale(), cannotRollbackPatch$str(), id)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String alreadyApplied = "WFLYPAT0012: Patch '%s' already applied";
protected static void copyDir(File src, File trg) throws PatchingException { try { IoUtils.copyFile(src, trg); } catch (IOException e) { throw new PatchingException("Failed to copy modification content from " + src.getAbsolutePath() + " to " + trg.getAbsolutePath(), e); } }
return formatFailedResponse(e); return formatFailedResponse(PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchId).getLocalizedMessage());