/** * Goes back in rollback history adding the patch id and it's application timestamp * to the resulting list. */ private static void fillHistoryIn(InstalledIdentity installedImage, PatchableTarget.TargetInfo info, ModelNode result, boolean excludeAgedOut) throws PatchingException { final Iterator i = iterator(installedImage, info, excludeAgedOut); while(i.hasNext()) { final Entry next = i.next(); fillHistoryIn(result, next); } }
@Override public boolean hasNextCP() { final IteratorState state = new IteratorState(currentInfo, patchIndex); return nextCP(this, state) != null; }
/** * Create a local target. * * @param jbossHome the jboss home * @param moduleRoots the module roots * @param bundlesRoots the bundle roots * @return the local target * @throws IOException */ public static final PatchOperationTarget createLocal(final File jbossHome, List<File> moduleRoots, List<File> bundlesRoots) throws IOException { final PatchTool tool = PatchTool.Factory.createLocalTool(jbossHome, moduleRoots, bundlesRoots); return new LocalPatchOperationTarget(tool); }
@Override protected ModelNode applyPatch(final File file, final ContentPolicyBuilderImpl builder) { final ContentVerificationPolicy policy = builder.createPolicy(); ModelNode result = new ModelNode(); try { PatchingResult apply = tool.applyPatch(file, policy); apply.commit(); result.get(OUTCOME).set(SUCCESS); result.get(RESULT).setEmptyObject(); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
@Override protected ModelNode rollback(final String streamName, final String patchId, final ContentPolicyBuilderImpl builder, boolean rollbackTo, boolean resetConfiguration) { final ContentVerificationPolicy policy = builder.createPolicy(); ModelNode result = new ModelNode(); try { PatchingResult rollback = tool.rollback(streamName, patchId, policy, rollbackTo, resetConfiguration); rollback.commit(); result.get(OUTCOME).set(SUCCESS); result.get(RESULT).setEmptyObject(); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
@Override protected ModelNode rollbackLast(final String streamName, final ContentPolicyBuilderImpl builder, boolean restoreConfiguration) { final ContentVerificationPolicy policy = builder.createPolicy(); ModelNode result = new ModelNode(); try { PatchingResult rollback = tool.rollbackLast(streamName, policy, restoreConfiguration); rollback.commit(); result.get(OUTCOME).set(SUCCESS); result.get(RESULT).setEmptyObject(); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
protected PatchingResult executePatch(final PatchTool tool, final File file) throws IOException, PatchingException { final PatchingResult result = tool.applyPatch(file, ContentVerificationPolicy.STRICT); result.commit(); return result; }
@Override protected ModelNode history(String streamName, boolean excludeAgedOut) { final ModelNode result = new ModelNode(); result.get(OUTCOME).set(SUCCESS); try { result.get(RESULT).set(tool.getPatchingHistory(streamName).getHistory(excludeAgedOut)); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
@Override public ModelNode execute(PatchOperationTarget target) throws PatchingException { return target.rollback(patchStream, patchId, this, rollbackTo, resetConfiguration); } };
/** * Create a builder to rollback the last applied patch. * * @param resetConfiguration whether to reset the configuration to the previous state * @return the operation builder */ public static PatchOperationBuilder rollbackLast(final boolean resetConfiguration) { return rollbackLast(null, resetConfiguration); }
/** * Is equivalent to getHistory(info, false) * * @param info the point from which to load the history * @return returns a list of entries representing basic info * about the patches applied or an empty list if * there is no patching information * @throws PatchingException in case there was an error loading the history */ default ModelNode getHistory(PatchableTarget.TargetInfo info) throws PatchingException { return getHistory(info, false); }
/** * Is equivalent to iterator(info, false). * * @param info the point to start from * @return iterator over the patching history * @throws PatchingException in case there was an error loading the history */ default Iterator iterator(final PatchableTarget.TargetInfo info) throws PatchingException { return iterator(info, false); }
@Override public boolean isAgedOut() { if (agedOut == null) { agedOut = Factory.isAgedOut(i.mgr, getMetadata()); } return agedOut; } };
/** * Whether a content verification can be ignored or not. * * @param item the content item to verify * @return */ public boolean isIgnored(final ContentItem item) { return contentPolicy.ignoreContentValidation(item); }
/** * Goes back in rollback history adding the patch id and it's application timestamp * to the resulting list. */ private static void fillHistoryIn(InstalledIdentity installedImage, PatchableTarget.TargetInfo info, ModelNode result, boolean excludeAgedOut) throws PatchingException { final Iterator i = iterator(installedImage, info, excludeAgedOut); while(i.hasNext()) { final Entry next = i.next(); fillHistoryIn(result, next); } }
@Override protected ModelNode history(String streamName, boolean excludeAgedOut) { final ModelNode result = new ModelNode(); result.get(OUTCOME).set(SUCCESS); try { result.get(RESULT).set(tool.getPatchingHistory(streamName).getHistory(excludeAgedOut)); } catch (PatchingException e) { return formatFailedResponse(e); } return result; }
@Override public boolean hasNextCP() { final IteratorState state = new IteratorState(currentInfo, patchIndex); return nextCP(this, state) != null; }
/** * Create a local target. * * @param jbossHome the jboss home * @param moduleRoots the module roots * @param bundlesRoots the bundle roots * @return the local target * @throws IOException */ public static final PatchOperationTarget createLocal(final File jbossHome, List<File> moduleRoots, List<File> bundlesRoots) throws IOException { final PatchTool tool = PatchTool.Factory.createLocalTool(jbossHome, moduleRoots, bundlesRoots); return new LocalPatchOperationTarget(tool); }