public ContentItem getContentItem() { return modification.getItem(); }
public ContentItem getItem() { return modification.getItem(); }
public <T extends ContentItem> T getContentItem(Class<T> expected) { return modification.getItem(expected); }
public ContentItem getItem() { return modification.getItem(); }
public ContentItem getContentItem() { return modification.getItem(); }
public <T extends ContentItem> T getContentItem(Class<T> expected) { return modification.getItem(expected); }
ContentModifications(Collection<ContentModification> mods) { modifications = new HashMap<Integer, ContentModification>(mods.size()); for (ContentModification mod : mods) { modifications.put(getKey(mod.getItem()), mod); } }
ContentModifications(Collection<ContentModification> mods) { modifications = new HashMap<Integer, ContentModification>(mods.size()); for (ContentModification mod : mods) { modifications.put(getKey(mod.getItem()), mod); } }
public ContentType getContentType() { return modification.getItem().getContentType(); }
public ContentType getContentType() { return modification.getItem().getContentType(); }
protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { final ContentModification original = super.getOriginalModification(targetHash, itemHash); final ModificationType type; if (Arrays.equals(NO_CONTENT, itemHash) && !backup.exists()) { type = ModificationType.ADD; } else { type = ModificationType.MODIFY; } return new ContentModification(original.getItem(), original.getTargetHash(), type, original.getCondition()); } }
protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { final ContentModification original = super.getOriginalModification(targetHash, itemHash); final ModificationType type; if (Arrays.equals(NO_CONTENT, itemHash) && !backup.exists()) { type = ModificationType.ADD; } else { type = ModificationType.MODIFY; } return new ContentModification(original.getItem(), original.getTargetHash(), type, original.getCondition()); } }
/** * Add a content modification. * * @param modification the content modification */ public T addContentModification(final ContentModification modification) { if (itemFilter.accepts(modification.getItem())) { internalAddModification(modification); } return returnThis(); }
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); } }
/** * Add a content modification. * * @param modification the content modification */ public T addContentModification(final ContentModification modification) { if (itemFilter.accepts(modification.getItem())) { internalAddModification(modification); } return returnThis(); }
@Test public void testUpdateModifiedFileWithPRESERVE_ALL() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.PRESERVE_ALL); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileUpdated.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(modifiedFile); assertArrayEquals(expectedModifiedHash, hashFile(modifiedFile)); } } }
@Test public void testUpdateModifiedFileWithSTRICT() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.STRICT); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileUpdated.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(modifiedFile); assertArrayEquals(expectedModifiedHash, hashFile(modifiedFile)); } }
static void addMissingModifications(IdentityPatchContext.PatchEntry target, Collection<ContentModification> modifications, final ContentItemFilter filter) throws IOException { final String cpId = target.getCumulativePatchID(); for (final ContentModification modification : modifications) { final ContentItem item = modification.getItem(); // Check if we accept the item if (!filter.accepts(item)) { continue; } final Location location = new Location(item); final ContentTaskDefinition definition = target.get(location); if (definition == null) { target.put(location, new ContentTaskDefinition(location, new ContentEntry(cpId, modification), false)); } else if(definition.isRollback()) { target.prepareForPortForward(item, cpId); definition.setTarget(new ContentEntry(cpId, modification)); } } }
@Test public void testRemoveModifiedFileWithSTRICT() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.STRICT); fail("Patch shouldn't be applied - ContentVerificationPolicy.STRICT"); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileRemoved.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(removedFile); assertArrayEquals(expectedModifiedHash, hashFile(removedFile)); } }
@Test public void testRemoveModifiedFileWithPRESERVE_ALL() throws Exception { try { runner.applyPatch(zippedPatch, ContentVerificationPolicy.PRESERVE_ALL); fail("Patch shouldn't be applied - ContentVerificationPolicy.PRESERVE_ALL"); } catch (ContentConflictsException e) { assertPatchHasNotBeenApplied(e, patch, fileRemoved.getItem(), env); /// file has not been modified in the AS7 installation assertFileExists(removedFile); assertArrayEquals(expectedModifiedHash, hashFile(removedFile)); } } }