/** * Get the original modification. Tasks like module remove can override this and fix the hashes based on the created content. * * @param targetHash the new target hash code (current content) * @param itemHash the new content item hash (backup content) * @return the original modification */ protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { return description.getModification(); }
/** * Get the original modification. Tasks like module remove can override this and fix the hashes based on the created content. * * @param targetHash the new target hash code (current content) * @param itemHash the new content item hash (backup content) * @return the original modification */ protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { return description.getModification(); }
@Override public boolean isRelevant(PatchingTaskContext context) throws PatchingException { final ModificationCondition condition = description.getModification().getCondition(); if(condition == null) { return true; } return condition.isSatisfied(context); }
@Override public boolean isRelevant(PatchingTaskContext context) throws PatchingException { final ModificationCondition condition = description.getModification().getCondition(); if(condition == null) { return true; } return condition.isSatisfied(context); }
@Override public boolean isRelevant(PatchingTaskContext context) throws PatchingException { final ModificationCondition condition = description.getModification().getCondition(); if(condition == null) { return true; } return condition.isSatisfied(context); }
@Override public boolean isRelevant(PatchingTaskContext context) throws PatchingException { final ModificationCondition condition = description.getModification().getCondition(); if(condition == null) { return true; } return condition.isSatisfied(context); }
@Override public boolean prepare(PatchingTaskContext context) throws IOException { // we create the backup in any case, since it is possible that the task // will be processed anyhow if the user specified OVERRIDE_ALL policy. // If the task is undone, the patch history will be deleted (including this backup). backup(target, backup, Arrays.asList(item.getPath()), rollback, context); // See if the hash matches the metadata boolean isEmptyDirectory = false; if (target.isDirectory()) { final File[] children = target.listFiles(); if (children == null || children.length == 0) { isEmptyDirectory = true; } } final byte[] expected = description.getModification().getTargetHash(); final byte[] actual = isEmptyDirectory ? NO_CONTENT : HashUtils.hashFile(target); return Arrays.equals(expected, actual); }
@Override public boolean prepare(PatchingTaskContext context) throws IOException { // we create the backup in any case, since it is possible that the task // will be processed anyhow if the user specified OVERRIDE_ALL policy. // If the task is undone, the patch history will be deleted (including this backup). backup(target, backup, Arrays.asList(item.getPath()), rollback, context); // See if the hash matches the metadata boolean isEmptyDirectory = false; if (target.isDirectory()) { final File[] children = target.listFiles(); if (children == null || children.length == 0) { isEmptyDirectory = true; } } final byte[] expected = description.getModification().getTargetHash(); final byte[] actual = isEmptyDirectory ? NO_CONTENT : HashUtils.hashFile(target); return Arrays.equals(expected, actual); }
@Override protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { final ModuleItem original = getContentItem(); final ModuleItem item = new ModuleItem(original.getName(), original.getSlot(), targetHash); return new ContentModification(item, description.getModification().getTargetHash(), ModificationType.MODIFY, description.getModification().getCondition()); }
@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)) { 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(); } // System.out.println("ModuleUpdateTask.prepare " + description.getModificationType() + " backup " + (backupHash == IoUtils.NO_CONTENT)); // the problem here appears for compact CPs when a module at some point was added then removed and then re-added // re-adding will be MODIFY because the removed module will exist on the FS but will be marked as absent in its module.xml // so applying re-add (MODIFY) to the version where the module didn't exist will fail return false; }
@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)) { 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(); } // System.out.println("ModuleUpdateTask.prepare " + description.getModificationType() + " backup " + (backupHash == IoUtils.NO_CONTENT)); // the problem here appears for compact CPs when a module at some point was added then removed and then re-added // re-adding will be MODIFY because the removed module will exist on the FS but will be marked as absent in its module.xml // so applying re-add (MODIFY) to the version where the module didn't exist will fail return false; }
@Override protected ContentModification getOriginalModification(byte[] targetHash, byte[] itemHash) { final ModuleItem original = getContentItem(); final ModuleItem item = new ModuleItem(original.getName(), original.getSlot(), targetHash); return new ContentModification(item, description.getModification().getTargetHash(), ModificationType.MODIFY, description.getModification().getCondition()); }
@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 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; }